Add a -0 option for interoperability with xargs -0.

PR:		bin/56558
Submitted by:	Eugene Grosbein <eugen@grosbein.pp.ru>
MFC after:	2 weeks
This commit is contained in:
Dag-Erling Smørgrav 2005-12-07 12:22:46 +00:00
parent 2d14e0e547
commit 1c6859f833
3 changed files with 14 additions and 4 deletions

View File

@ -103,6 +103,7 @@ statistic (fp, path_fcodes)
}
#endif /* _LOCATE_STATISTIC_ */
extern char separator;
void
#ifdef FF_MMAP
@ -315,11 +316,11 @@ fastfind
else if (f_limit) {
counter++;
if (f_limit >= counter)
(void)puts(path);
(void)printf("%s%c",path,separator);
else
errx(0, "[show only %d lines]", counter - 1);
} else
(void)puts(path);
(void)printf("%s%c",path,separator);
}
break;
}

View File

@ -41,7 +41,7 @@
.Nd find filenames quickly
.Sh SYNOPSIS
.Nm
.Op Fl Scims
.Op Fl 0Scims
.Op Fl l Ar limit
.Op Fl d Ar database
.Ar pattern ...
@ -90,6 +90,11 @@ are stored in 2 bytes.
.Pp
The following options are available:
.Bl -tag -width 10n
.It Fl 0
Print pathnames separated by an
.Tn ASCII NUL
character (character code 0) instead of default NL
(newline, character code 10).
.It Fl S
Print some statistic about the database and exit.
.It Fl c

View File

@ -112,6 +112,7 @@ int f_statistic; /* print statistic */
int f_silent; /* suppress output, show only count of matches */
int f_limit; /* limit number of output lines, 0 == infinite */
u_int counter; /* counter for matches [-c] */
char separator='\n'; /* line separator */
void usage(void);
@ -145,8 +146,11 @@ main(argc, argv)
#endif
(void) setlocale(LC_ALL, "");
while ((ch = getopt(argc, argv, "Scd:il:ms")) != -1)
while ((ch = getopt(argc, argv, "0Scd:il:ms")) != -1)
switch(ch) {
case '0': /* 'find -print0' style */
separator = '\0';
break;
case 'S': /* statistic lines */
f_statistic = 1;
break;