MFC: add a -0 option for interoperability with xargs -0
This commit is contained in:
parent
9004f411a5
commit
3afb234d50
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user