diff options
-rw-r--r-- | bfs.1 | 616 | ||||
-rw-r--r-- | parse.c | 289 |
2 files changed, 402 insertions, 503 deletions
@@ -80,8 +80,69 @@ and .I +N means "greater than .IR N ." -.SH POSIX find FEATURES -Operators: +.SH FLAGS +.TP +.B \-H +Follow symbolic links on the command line, but not while searching. +.TP +.B \-L +Follow all symbolic links. +.TP +.B \-P +Never follow symbolic links (the default). +.TP +.B \-E +Use extended regular expressions (same as \fB\-regextype posix-extended\fR). +.TP +.B \-X +Filter out files with +.RB non- xargs (1)-safe +names. +.TP +.B \-d +Search in post-order (same as +.BR \-depth ). +.TP +.B \-x +Don't descend into other mount points (same as \fB\-xdev\fR). +.TP +\fB\-f \fIPATH\fR +Treat +.I PATH +as a path to search (useful if it begins with a dash). +.PP +.TP +\fB\-D \fIFLAG\fR +Turn on a debugging flag (see +.B \-D +.IR help ). +.PP +\fB\-O\fIN\fR +.RS +Enable optimization level +.I N +(default: 3) +.TP +\fB\-O\fI0\fR +Disable all optimizations. +.TP +\fB\-O\fI1\fR +Basic logical simplifications. +.TP +\fB\-O\fI2\fR +All +.BI \-O 1 +optimizations, plus dead code elimination and data flow analysis. +.TP +\fB\-O\fI3\fR +All +.BI \-O 2 +optimizations, plus re-order expressions to reduce expected cost. +.TP +\fB\-O\fI4\fR/\fB\-O\fIfast\fR +All optimizations, including aggressive optimizations that may alter the observed behavior in corner cases. +.RE +.SH OPERATORS .TP \fB( \fIexpression \fB)\fR Parentheses are used for grouping expressions together. @@ -90,13 +151,22 @@ You'll probably have to write .I expression .B \\\\) to avoid the parentheses being interpreted by the shell. -.TP +.PP \fB! \fIexpression\fR +.br +\fB\-not \fIexpression\fR +.RS The "not" operator: returns the negation of the truth value of the .IR expression . You may have to write \fB\\! \fIexpression\fR to avoid \fB!\fR being interpreted by the shell. -.TP -\fIexpression\fR [\fB\-a\fR] \fIexpression\fR +.RE +.PP +\fIexpression\fR \fIexpression\fR +.br +\fIexpression \fB\-a \fIexpression\fR +.br +\fIexpression \fB\-and \fIexpression\fR +.RS Short-circuiting "and" operator: if the left-hand .I expression is @@ -105,8 +175,12 @@ returns the right-hand .IR expression ; otherwise, returns .BR false . -.TP +.RE +.PP \fIexpression \fB\-o \fIexpression\fR +.br +\fIexpression \fB\-or \fIexpression\fR +.RS Short-circuiting "or" operator: if the left-hand .I expression is @@ -115,160 +189,39 @@ returns the right-hand .IR expression ; otherwise, returns .BR true . -.LP -Flags: -.TP -.B \-H -Follow symbolic links on the command line, but not while searching. -.TP -.B \-L -Follow all symbolic links. -.LP -Options: -.TP -.B \-depth -Search in post-order (descendents first). -.TP -.B \-xdev -Don't descend into other mount points. -.LP -Tests: -.PP -\fB\-atime\fR [\fI\-+\fR]\fIN\fR -.br -\fB\-ctime\fR [\fI\-+\fR]\fIN\fR -.br -\fB\-mtime\fR [\fI\-+\fR]\fIN\fR -.RS -Find files -.BR a ccessed/ c hanged/ m odified -.I N -days ago. -.RE -.PP -.B \-group NAME -.br -.B \-user NAME -.RS -Find files owned by the group/user -.BR NAME . .RE .TP -\fB\-links\fR [\fI\-+\fR]\fIN\fR -Find files with -.I N -hard links. -.TP -\fB\-name \fIGLOB\fR -Find files whose name matches the -.IR GLOB . -.TP -\fB\-path \fIGLOB\fR -Find files whose entire path matches the -.IR GLOB . -.TP -\fB\-newer \fIFILE\fR -Find files newer than -.IR FILE . -.TP -\fB\-perm\fR [\fI\-\fR]\fIMODE\fR -Find files with a matching mode. -.TP -\fB\-type\fR [\fIbcdlpfs\fR] -Find files of the given type. -Possible types are -.IR b lock -device, -.IR c haracter -device, -.IR d irectory, -symbolic -.IR l ink, -.IR p ipe, -regular -.IR f ile, -and -.IR s ocket. -.TP -\fB\-size\fR [\fI\-+\fR]\fIN\fR[\fIc\fR] -Find files with the given size. -The default unit is 512-byte blocks; -.I c -counts -.IR c haracters/bytes -instead. -.LP -Actions: -.TP -.B \-prune -Don't descend into this directory. -.TP -\fB\-exec \fIcommand ... {} ;\fR -Execute a command. -.TP -\fB\-exec \fIcommand ... {} +\fR -Execute a command with multiple files at once. -.TP -\fB\-ok \fIcommand ... {} ;\fR -Prompt the user whether to execute a command. -.TP -.B \-print -Print the path to the found file. -.SH GNU find FEATURES -Operators: -.TP -\fB\-not \fIexpression\fR -Same as \fB! \fIexpression\fR. -.TP -\fIexpression \fB\-and \fIexpression\fR -Same as -.I expression -.B \-a -.IR expression . -.TP -\fIexpression \fB\-or \fIexpression\fR -Same as -.I expression -.B \-o -.IR expression . -.TP \fIexpression \fB, \fIexpression\fR The "comma" operator: evaluates the left-hand .I expression but discards the result, returning the right-hand .IR expression . -.LP -Flags: -.TP -.B \-P -Never follow symbolic links (the default). -.TP -\fB\-D \fIFLAG\fR -Turn on a debugging flag (see -.B \-D -.IR help ). -.TP -\fB\-O\fIN\fR -Enable optimization level -.I N -(default: 3; interpreted differently than GNU find -- see below). -.LP -Options: -.TP -.B \-d -Search in post-order (same as -.BR \-depth ). +.SH OPTIONS +.PP +.B \-color +.br +.B \-nocolor +.RS +Turn colors on or off (default: +.B \-color +if outputting to a terminal, +.B \-nocolor +otherwise). +.RE .TP .B \-daystart Measure time relative to the start of today. .TP +.B \-depth +Search in post-order (descendents first). +.TP .B \-follow Follow all symbolic links (same as .BR \-L ). -.LP -.B \-ignore_readdir_race +.PP +\fB\-ignore_readdir_race\fR .br -.B \-noignore_readdir_race +\fB\-noignore_readdir_race\fR .RS Whether to report an error if .B bfs @@ -283,10 +236,13 @@ detects that the file tree is modified during the search (default: Ignore files deeper/shallower than .IR N . .RE -.TP +.PP .B \-mount -Don't descend into other mount points (same as -.BR \-xdev ). +.br +.B \-xdev +.RS +Don't descend into other mount points. +.RE .TP .B \-noleaf Ignored; for compatibility with GNU find. @@ -299,44 +255,75 @@ regexes (default: see .B \-regextype .IR help ). -.LP +.PP .B \-warn .br .B \-nowarn .RS Turn on or off warnings about the command line. .RE -.PP -Tests: +.SH TESTS +.TP +.B \-acl +Find files with non-trivial +.BR acl (5) +(Access Control Lists). .PP \fB\-amin\fR [\fI\-+\fR]\fIN\fR .br +\fB\-Bmin\fR [\fI\-+\fR]\fIN\fR +.br \fB\-cmin\fR [\fI\-+\fR]\fIN\fR .br \fB\-mmin\fR [\fI\-+\fR]\fIN\fR .RS Find files -.BR a ccessed/ c hanged/ m odified +.BR a ccessed/ B irthed/ c hanged/ m odified .I N minutes ago. .RE .PP \fB\-anewer \fIFILE\fR .br +\fB\-Bnewer \fIFILE\fR +.br \fB\-cnewer \fIFILE\fR .br \fB\-mnewer \fIFILE\fR .RS Find files -.BR a ccessed/ c hanged/ m odified +.BR a ccessed/ B irthed/ c hanged/ m odified more recently than .I FILE was modified. .RE +.PP +\fB\-atime\fR [\fI\-+\fR]\fIN\fR +.br +\fB\-Btime\fR [\fI\-+\fR]\fIN\fR +.br +\fB\-ctime\fR [\fI\-+\fR]\fIN\fR +.br +\fB\-mtime\fR [\fI\-+\fR]\fIN\fR +.RS +Find files +.BR a ccessed/ B irthed/ c hanged/ m odified +.I N +days ago. +.RE +.TP +.B \-capable +Match files with POSIX.1e +.BR capabilities (7) +set. +.TP +\fB\-depth\fR [\fI\-+\fR]\fIN\fR +Find files with depth +.IR N . .TP .B \-empty Find empty files/directories. -.LP +.PP .B \-executable .br .B \-readable @@ -356,7 +343,7 @@ Always false/true. .B \-fstype TYPE Find files on file systems with the given .BR TYPE . -.LP +.PP \fB\-gid\fR [\fI\-+\fR]\fIN\fR .br \fB\-uid\fR [\fI\-+\fR]\fIN\fR @@ -364,15 +351,54 @@ Find files on file systems with the given Find files owned by group/user ID .IR N . .RE +.PP +\fB\-group \fINAME\fR +.br +\fB\-user \fINAME\fR +.RS +Find files owned by the group/user +.IR NAME . +.RE +.TP +.B \-hidden +Match hidden files (those beginning with +.IR . ). +.PP +\fB\-ilname \fIGLOB\fR +.br +\fB\-iname \fIGLOB\fR +.br +\fB\-ipath \fIGLOB\fR +.br +\fB\-iregex \fIREGEX\fR +.br +\fB\-iwholename \fIGLOB\fR +.RS +Case-insensitive versions of +.BR \-lname / \-name / \-path / \-regex / \-wholename . +.RE .TP \fB\-inum\fR [\fI\-+\fR]\fIN\fR Find files with inode number .IR N . .TP +\fB\-links\fR [\fI\-+\fR]\fIN\fR +Find files with +.I N +hard links. +.TP \fB\-lname \fIGLOB\fR Find symbolic links whose target matches the .IR GLOB . .TP +\fB\-name \fIGLOB\fR +Find files whose name matches the +.IR GLOB . +.TP +\fB\-newer \fIFILE\fR +Find files newer than +.IR FILE . +.TP \fB\-newer\fIXY \fIREFERENCE\fR Find files whose .I X @@ -386,6 +412,24 @@ and can be any of .RI [ aBcm ] .RI ( a ccess/ B irth/ c hange/ m odification). +.PP +.B \-nogroup +.br +.B \-nouser +.RS +Find files owned by nonexistent groups/users. +.RE +.PP +\fB\-path \fIGLOB\fR +.br +\fB\-wholename \fIGLOB\fR +.RS +Find files whose entire path matches the +.IR GLOB . +.RE +.TP +\fB\-perm\fR [\fI\-\fR]\fIMODE\fR +Find files with a matching mode. .TP \fB\-regex \fIREGEX\fR Find files whose entire path matches the regular expression @@ -395,56 +439,64 @@ Find files whose entire path matches the regular expression Find hard links to .IR FILE . .TP -\fB\-size\fR [\fI\-+\fR]\fIN\fR[\fIcwbkMG\fR] -1-byte +\fB\-size\fR [\fI\-+\fR]\fIN\fR[\fIcwbkMGTP\fR] +Find files with the given size, in 1-byte .IR c haracters, 2-byte .IR w ords, 512-byte .IR b locks, -and -.IR k iB/ M iB/ G iB. +(default) or +.IR k iB/ M iB/ G iB/ T iB/ P iB. .TP -\fB\-type\fR [\fIbcdlpfsD\fR] -The -.IR D oor -file type is also supported on platforms that have it (Solaris). +.B \-sparse +Find files that occupy fewer disk blocks than expected. +.TP +\fB\-type\fR [\fIbcdlpfswD\fR] +Find files of the given type. +Possible types are +.IR b lock +device, +.IR c haracter +device, +.IR d irectory, +symbolic +.IR l ink, +.IR p ipe, +regular +.IR f ile, +.IR s ocket, +.IR w hiteout, +and +.IR D oor. .TP \fB\-used\fR [\fI\-+\fR]\fIN\fR Find files last accessed .I N days after they were changed. .TP -\fB\-wholename \fIGLOB\fR -Find files whose entire path matches the -.I GLOB -(same as -.BR \-path ). -.LP -\fB\-ilname \fIGLOB\fR -.br -\fB\-iname \fIGLOB\fR -.br -\fB\-ipath \fIGLOB\fR -.br -\fB\-iregex \fIREGEX\fR -.br -\fB\-iwholename \fIGLOB\fR -.RS -Case-insensitive versions of -.BR \-lname / \-name / \-path / \-regex / \-wholename . -.RE -.TP -\fB\-xtype\fR [\fIbcdlpfsD\fR] +\fB\-xtype\fR [\fIbcdlpfswD\fR] Find files of the given type, following links when .B \-type would not, and vice versa. -.LP -Actions: -.TP +.SH ACTIONS +.PP .B \-delete +.br +.B \-rm +.RS Delete any found files (implies \fB-depth\fR). -.LP +.RE +.TP +\fB\-exec \fIcommand ... {} ;\fR +Execute a command. +.TP +\fB\-exec \fIcommand ... {} +\fR +Execute a command with multiple files at once. +.TP +\fB\-ok \fIcommand ... {} ;\fR +Prompt the user whether to execute a command. +.PP \fB\-execdir \fIcommand ... {} ;\fR .br \fB\-execdir \fIcommand ... {} +\fR @@ -456,23 +508,9 @@ Like but run the command in the same directory as the found file(s). .RE .TP -.B \-ls -List files like -.B ls -.IR \-dils . -.TP -.B \-print0 -Like -.BR \-print , -but use the null character ('\\0') as a separator rather than newlines. -Useful in conjunction with -.B xargs -.IR -0 . -.TP -\fB\-printf \fIFORMAT\fR -Print according to a format string (see -.BR find (1)). -.LP +\fB\-exit\fR [\fISTATUS\fR] +Exit immediately with the given status (0 if unspecified). +.PP \fB\-fls \fIFILE\fR .br \fB\-fprint \fIFILE\fR @@ -488,81 +526,41 @@ but write to instead of standard output. .RE .TP -.B \-quit -Quit immediately. -.TP -.B \-version -Print version information. -.TP -.B \-help -Print usage information. -.SH BSD find FEATURES -Flags: -.TP -.B \-E -Use extended regular expressions (same as \fB\-regextype posix-extended\fR). +.B \-ls +List files like +.B ls +.IR \-dils . .TP -.B \-X -Filter out files with -.RB non- xargs (1)-safe -names. +.B \-nohidden +Filter out hidden files and directories. .TP -.B \-x -Don't descend into other mount points (same as \fB\-xdev\fR). +.B \-print +Print the path to the found file. .TP -\fB\-f \fIPATH\fR -Treat -.I PATH -as a path to search (useful if it begins with a dash). -.LP -Tests: +.B \-print0 +Like +.BR \-print , +but use the null character ('\\0') as a separator rather than newlines. +Useful in conjunction with +.B xargs +.IR -0 . .TP -.B \-acl -Find files with non-trivial -.BR acl (5) -(Access Control Lists). -.PP -\fB\-Bmin\fR [\fI\-+\fR]\fIN\fR -.br -\fB\-Btime\fR [\fI\-+\fR]\fIN\fR +\fB\-printf \fIFORMAT\fR +Print according to a format string (see +.BR find (1)). +These additional format directives are supported: .RS -Find files -.BR B irthed -.I N -minutes/days ago. -.RE .TP -\fB\-Bnewer \fIFILE\fR -Find files -.BR B irthed -more recently than -.I FILE -was modified. +%w +The file's birth time, in the same format as %a/%c/%t. .TP -\fB\-depth\fR [\fI\-+\fR]\fIN\fR -Find files with depth -.IR N . -.LP -.B \-gid NAME -.br -.B \-uid NAME -.RS -Group/user names are supported in addition to numeric IDs. +.RI %W k +Field +.I k +of the file's birth time, in the same format as +.RI %A k /%C k /%T k . .RE .TP -\fB\-size\fR [\fI\-+\fR]\fIN\fR[\fIcwbkMGTP\fR] -Units of -.IR T iB/ P iB -are additionally supported. -.TP -.B \-sparse -Find files that occupy fewer disk blocks than expected. -.LP -Actions: -.TP -\fB\-exit\fR [\fISTATUS\fR] -Exit immediately with the given status (0 if unspecified). -.TP .B \-printx Like .BR \-print , @@ -575,77 +573,17 @@ and .I \-0 instead. .TP -.B \-rm -Delete any found files (same as -.BR \-delete ; -implies -.BR \-depth ). -.SH bfs-SPECIFIC FEATURES -Flags: -.TP -\fB\-O\fI0\fR -Disable all optimizations. -.TP -\fB\-O\fI1\fR -Basic logical simplifications. -.TP -\fB\-O\fI2\fR -All -.BI \-O 1 -optimizations, plus dead code elimination and data flow analysis. -.TP -\fB\-O\fI3\fR -All -.BI \-O 2 -optimizations, plus re-order expressions to reduce expected cost. -.TP -\fB\-O\fI4\fR/\fB\-O\fIfast\fR -All optimizations, including aggressive optimizations that may alter the observed behavior in corner cases. -.LP -Options: -.PP -.B \-color -.br -.B \-nocolor -.RS -Turn colors on or off (default: -.B \-color -if outputting to a terminal, -.B \-nocolor -otherwise). -.RE -.PP -Tests: -.TP -.B \-capable -Match files with POSIX.1e -.BR capabilities (7) -set. -.TP -.B \-hidden -Match hidden files (those beginning with -.IR . ). -.LP -Actions: +.B \-prune +Don't descend into this directory. .TP -.B \-nohidden -Filter out hidden files and directories. -.LP -\fB\-printf \fIFORMAT\fR -.br -\fB\-fprintf \fIFORMAT FILE\fR -.RS -These additional format directives are supported: +.B \-quit +Quit immediately. .TP -%w -The file's birth time, in the same format as %a/%c/%t. +.B \-version +Print version information. .TP -.RI %W k -Field -.I k -of the file's birth time, in the same format as -.RI %A k /%C k /%T k . -.RE +.B \-help +Print usage information. .SH EXAMPLES .TP .B bfs @@ -2333,75 +2333,57 @@ static struct expr *parse_help(struct parser_state *state, int arg1, int arg2) { "${cyn}Flags${rs} (${cyn}-H${rs}/${cyn}-L${rs}/${cyn}-P${rs} etc.), ${mag}paths${rs},\n" "and ${blu}expressions${rs} may be freely mixed in any order.\n\n"); - cfprintf(cout, "${bld}POSIX find features:${rs}\n\n"); - - cfprintf(cout, " ${red}(${rs} ${blu}expression${rs} ${red})${rs}\n"); - cfprintf(cout, " ${red}!${rs} ${blu}expression${rs}\n"); - cfprintf(cout, " ${blu}expression${rs} [${red}-a${rs}] ${blu}expression${rs}\n"); - cfprintf(cout, " ${blu}expression${rs} ${red}-o${rs} ${blu}expression${rs}\n\n"); + cfprintf(cout, "${bld}Flags:${rs}\n\n"); cfprintf(cout, " ${cyn}-H${rs}\n"); cfprintf(cout, " Follow symbolic links on the command line, but not while searching\n"); cfprintf(cout, " ${cyn}-L${rs}\n"); - cfprintf(cout, " Follow all symbolic links\n\n"); + cfprintf(cout, " Follow all symbolic links\n"); + cfprintf(cout, " ${cyn}-P${rs}\n"); + cfprintf(cout, " Never follow symbolic links (the default)\n"); - cfprintf(cout, " ${blu}-depth${rs}\n"); - cfprintf(cout, " Search in post-order (descendents first)\n"); - cfprintf(cout, " ${blu}-xdev${rs}\n"); - cfprintf(cout, " Don't descend into other mount points\n\n"); + cfprintf(cout, " ${cyn}-E${rs}\n"); + cfprintf(cout, " Use extended regular expressions (same as ${blu}-regextype${rs} ${bld}posix-extended${rs})\n"); + cfprintf(cout, " ${cyn}-X${rs}\n"); + cfprintf(cout, " Filter out files with non-${ex}xargs${rs}-safe names\n"); + cfprintf(cout, " ${cyn}-d${rs}\n"); + cfprintf(cout, " Search in post-order (same as ${blu}-depth${rs})\n"); + cfprintf(cout, " ${cyn}-x${rs}\n"); + cfprintf(cout, " Don't descend into other mount points (same as ${blu}-xdev${rs})\n"); - cfprintf(cout, " ${blu}-atime${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " ${blu}-ctime${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " ${blu}-mtime${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " Find files accessed/changed/modified ${bld}N${rs} days ago\n"); - cfprintf(cout, " ${blu}-group${rs} ${bld}NAME${rs}\n"); - cfprintf(cout, " ${blu}-user${rs} ${bld}NAME${rs}\n"); - cfprintf(cout, " Find files owned by the group/user ${bld}NAME${rs}\n"); - cfprintf(cout, " ${blu}-links${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " Find files with ${bld}N${rs} hard links\n"); - cfprintf(cout, " ${blu}-name${rs} ${bld}GLOB${rs}\n"); - cfprintf(cout, " Find files whose name matches the ${bld}GLOB${rs}\n"); - cfprintf(cout, " ${blu}-path${rs} ${bld}GLOB${rs}\n"); - cfprintf(cout, " Find files whose entire path matches the ${bld}GLOB${rs}\n"); - cfprintf(cout, " ${blu}-newer${rs} ${bld}FILE${rs}\n"); - cfprintf(cout, " Find files newer than ${bld}FILE${rs}\n"); - cfprintf(cout, " ${blu}-perm${rs} ${bld}[-]MODE${rs}\n"); - cfprintf(cout, " Find files with a matching mode\n"); - cfprintf(cout, " ${blu}-type${rs} ${bld}[bcdlpfs]${rs}\n"); - cfprintf(cout, " Find files of the given type\n"); - cfprintf(cout, " ${blu}-size${rs} ${bld}[-+]N[c]${rs}\n"); - cfprintf(cout, " Find files with the given size\n\n"); + cfprintf(cout, " ${cyn}-f${rs} ${mag}PATH${rs}\n"); + cfprintf(cout, " Treat ${mag}PATH${rs} as a path to search (useful if begins with a dash)\n"); + cfprintf(cout, " ${cyn}-D${rs} ${bld}FLAG${rs}\n"); + cfprintf(cout, " Turn on a debugging flag (see ${cyn}-D${rs} ${bld}help${rs})\n"); + cfprintf(cout, " ${cyn}-O${rs}${bld}N${rs}\n"); + cfprintf(cout, " Enable optimization level ${bld}N${rs} (default: 3)\n\n"); - cfprintf(cout, " ${blu}-prune${rs}\n"); - cfprintf(cout, " Don't descend into this directory\n"); - cfprintf(cout, " ${blu}-exec${rs} ${bld}command ... {} ;${rs}\n"); - cfprintf(cout, " Execute a command\n"); - cfprintf(cout, " ${blu}-exec${rs} ${bld}command ... {} +${rs}\n"); - cfprintf(cout, " Execute a command with multiple files at once\n"); - cfprintf(cout, " ${blu}-ok${rs} ${bld}command ... {} ;${rs}\n"); - cfprintf(cout, " Prompt the user whether to execute a command\n"); - cfprintf(cout, " ${blu}-print${rs}\n"); - cfprintf(cout, " Print the path to the found file\n\n"); + cfprintf(cout, "${bld}Operators:${rs}\n\n"); + + cfprintf(cout, " ${red}(${rs} ${blu}expression${rs} ${red})${rs}\n\n"); + + cfprintf(cout, " ${red}!${rs} ${blu}expression${rs}\n"); + cfprintf(cout, " ${red}-not${rs} ${blu}expression${rs}\n\n"); + + cfprintf(cout, " ${blu}expression${rs} ${blu}expression${rs}\n"); + cfprintf(cout, " ${blu}expression${rs} ${red}-a${rs} ${blu}expression${rs}\n"); + cfprintf(cout, " ${blu}expression${rs} ${red}-and${rs} ${blu}expression${rs}\n\n"); - cfprintf(cout, "${bld}GNU find features:${rs}\n\n"); + cfprintf(cout, " ${blu}expression${rs} ${red}-o${rs} ${blu}expression${rs}\n"); + cfprintf(cout, " ${blu}expression${rs} ${red}-or${rs} ${blu}expression${rs}\n\n"); - cfprintf(cout, " ${red}-not${rs} ${blu}expression${rs}\n"); - cfprintf(cout, " ${blu}expression${rs} ${red}-and${rs} ${blu}expression${rs}\n"); - cfprintf(cout, " ${blu}expression${rs} ${red}-or${rs} ${blu}expression${rs}\n"); cfprintf(cout, " ${blu}expression${rs} ${red},${rs} ${blu}expression${rs}\n\n"); - cfprintf(cout, " ${cyn}-P${rs}\n"); - cfprintf(cout, " Never follow symbolic links (the default)\n"); - cfprintf(cout, " ${cyn}-D${rs} ${bld}FLAG${rs}\n"); - cfprintf(cout, " Turn on a debugging flag (see ${cyn}-D${rs} ${bld}help${rs})\n"); - cfprintf(cout, " ${cyn}-O${rs}${bld}N${rs}\n"); - cfprintf(cout, " Enable optimization level ${bld}N${rs} (default: 3; interpreted differently than GNU\n"); - cfprintf(cout, " find -- see below)\n\n"); + cfprintf(cout, "${bld}Options:${rs}\n\n"); - cfprintf(cout, " ${blu}-d${rs}\n"); - cfprintf(cout, " Search in post-order (same as ${blu}-depth${rs})\n"); + cfprintf(cout, " ${blu}-color${rs}\n"); + cfprintf(cout, " ${blu}-nocolor${rs}\n"); + cfprintf(cout, " Turn colors on or off (default: ${blu}-color${rs} if outputting to a terminal,\n"); + cfprintf(cout, " ${blu}-nocolor${rs} otherwise)\n"); cfprintf(cout, " ${blu}-daystart${rs}\n"); cfprintf(cout, " Measure times relative to the start of today\n"); + cfprintf(cout, " ${blu}-depth${rs}\n"); + cfprintf(cout, " Search in post-order (descendents first)\n"); cfprintf(cout, " ${blu}-follow${rs}\n"); cfprintf(cout, " Follow all symbolic links (same as ${cyn}-L${rs})\n"); cfprintf(cout, " ${blu}-ignore_readdir_race${rs}\n"); @@ -2412,7 +2394,8 @@ static struct expr *parse_help(struct parser_state *state, int arg1, int arg2) { cfprintf(cout, " ${blu}-mindepth${rs} ${bld}N${rs}\n"); cfprintf(cout, " Ignore files deeper/shallower than ${bld}N${rs}\n"); cfprintf(cout, " ${blu}-mount${rs}\n"); - cfprintf(cout, " Don't descend into other mount points (same as ${blu}-xdev${rs})\n"); + cfprintf(cout, " ${blu}-xdev${rs}\n"); + cfprintf(cout, " Don't descend into other mount points\n"); cfprintf(cout, " ${blu}-noleaf${rs}\n"); cfprintf(cout, " Ignored; for compatibility with GNU find\n"); cfprintf(cout, " ${blu}-regextype${rs} ${bld}TYPE${rs}\n"); @@ -2422,14 +2405,24 @@ static struct expr *parse_help(struct parser_state *state, int arg1, int arg2) { cfprintf(cout, " ${blu}-nowarn${rs}\n"); cfprintf(cout, " Turn on or off warnings about the command line\n\n"); - cfprintf(cout, " ${blu}-amin${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " ${blu}-cmin${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " ${blu}-mmin${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " Find files accessed/changed/modified ${bld}N${rs} minutes ago\n"); - cfprintf(cout, " ${blu}-anewer${rs} ${bld}FILE${rs}\n"); - cfprintf(cout, " ${blu}-cnewer${rs} ${bld}FILE${rs}\n"); - cfprintf(cout, " ${blu}-mnewer${rs} ${bld}FILE${rs}\n"); - cfprintf(cout, " Find files accessed/changed/modified more recently than ${bld}FILE${rs} was modified\n"); + cfprintf(cout, "${bld}Tests:${rs}\n\n"); + +#if BFS_HAS_SYS_ACL + cfprintf(cout, " ${blu}-acl${rs}\n"); + cfprintf(cout, " Find files with non-trivial Access Control Lists\n"); +#endif + cfprintf(cout, " ${blu}-${rs}[${blu}aBcm${rs}]${blu}min${rs} ${bld}[-+]N${rs}\n"); + cfprintf(cout, " Find files ${blu}a${rs}ccessed/${blu}B${rs}irthed/${blu}c${rs}hanged/${blu}m${rs}odified ${bld}N${rs} minutes ago\n"); + cfprintf(cout, " ${blu}-${rs}[${blu}aBcm${rs}]${blu}newer${rs} ${bld}FILE${rs}\n"); + cfprintf(cout, " Find files ${blu}a${rs}ccessed/${blu}B${rs}irthed/${blu}c${rs}hanged/${blu}m${rs}odified more recently than ${bld}FILE${rs} was modified\n"); + cfprintf(cout, " ${blu}-${rs}[${blu}aBcm${rs}]${blu}time${rs} ${bld}[-+]N${rs}\n"); + cfprintf(cout, " Find files ${blu}a${rs}ccessed/${blu}B${rs}irthed/${blu}c${rs}hanged/${blu}m${rs}odified ${bld}N${rs} days ago\n"); +#if BFS_HAS_POSIX1E_CAPABILITIES + cfprintf(cout, " ${blu}-capable${rs}\n"); + cfprintf(cout, " Match files with POSIX.1e capabilities set\n"); +#endif + cfprintf(cout, " ${blu}-depth${rs} ${bld}[-+]N${rs}\n"); + cfprintf(cout, " Find files with depth ${bld}N${rs}\n"); cfprintf(cout, " ${blu}-empty${rs}\n"); cfprintf(cout, " Find empty files/directories\n"); cfprintf(cout, " ${blu}-executable${rs}\n"); @@ -2444,140 +2437,108 @@ static struct expr *parse_help(struct parser_state *state, int arg1, int arg2) { cfprintf(cout, " ${blu}-gid${rs} ${bld}[-+]N${rs}\n"); cfprintf(cout, " ${blu}-uid${rs} ${bld}[-+]N${rs}\n"); cfprintf(cout, " Find files owned by group/user ID ${bld}N${rs}\n"); + cfprintf(cout, " ${blu}-group${rs} ${bld}NAME${rs}\n"); + cfprintf(cout, " ${blu}-user${rs} ${bld}NAME${rs}\n"); + cfprintf(cout, " Find files owned by the group/user ${bld}NAME${rs}\n"); + cfprintf(cout, " ${blu}-hidden${rs}\n"); + cfprintf(cout, " ${blu}-nohidden${rs}\n"); + cfprintf(cout, " Match hidden files, or filter them out\n"); +#ifdef FNM_CASEFOLD + cfprintf(cout, " ${blu}-ilname${rs} ${bld}GLOB${rs}\n"); + cfprintf(cout, " ${blu}-iname${rs} ${bld}GLOB${rs}\n"); + cfprintf(cout, " ${blu}-ipath${rs} ${bld}GLOB${rs}\n"); + cfprintf(cout, " ${blu}-iregex${rs} ${bld}REGEX${rs}\n"); + cfprintf(cout, " ${blu}-iwholename${rs} ${bld}GLOB${rs}\n"); + cfprintf(cout, " Case-insensitive versions of ${blu}-lname${rs}/${blu}-name${rs}/${blu}-path${rs}" + "/${blu}-regex${rs}/${blu}-wholename${rs}\n"); +#endif cfprintf(cout, " ${blu}-inum${rs} ${bld}[-+]N${rs}\n"); cfprintf(cout, " Find files with inode number ${bld}N${rs}\n"); + cfprintf(cout, " ${blu}-links${rs} ${bld}[-+]N${rs}\n"); + cfprintf(cout, " Find files with ${bld}N${rs} hard links\n"); cfprintf(cout, " ${blu}-lname${rs} ${bld}GLOB${rs}\n"); cfprintf(cout, " Find symbolic links whose target matches the ${bld}GLOB${rs}\n"); + cfprintf(cout, " ${blu}-name${rs} ${bld}GLOB${rs}\n"); + cfprintf(cout, " Find files whose name matches the ${bld}GLOB${rs}\n"); + cfprintf(cout, " ${blu}-newer${rs} ${bld}FILE${rs}\n"); + cfprintf(cout, " Find files newer than ${bld}FILE${rs}\n"); cfprintf(cout, " ${blu}-newer${rs}${bld}XY${rs} ${bld}REFERENCE${rs}\n"); cfprintf(cout, " Find files whose ${bld}X${rs} time is newer than the ${bld}Y${rs} time of" " ${bld}REFERENCE${rs}. ${bld}X${rs} and ${bld}Y${rs}\n"); - cfprintf(cout, " can be any of [aBcm].\n"); + cfprintf(cout, " can be any of [${bld}aBcm${rs}].\n"); + cfprintf(cout, " ${blu}-nogroup${rs}\n"); + cfprintf(cout, " ${blu}-nouser${rs}\n"); + cfprintf(cout, " Find files owned by nonexistent groups/users\n"); + cfprintf(cout, " ${blu}-path${rs} ${bld}GLOB${rs}\n"); + cfprintf(cout, " ${blu}-wholename{rs} ${bld}GLOB${rs}\n"); + cfprintf(cout, " Find files whose entire path matches the ${bld}GLOB${rs}\n"); + cfprintf(cout, " ${blu}-perm${rs} ${bld}[-]MODE${rs}\n"); + cfprintf(cout, " Find files with a matching mode\n"); cfprintf(cout, " ${blu}-regex${rs} ${bld}REGEX${rs}\n"); cfprintf(cout, " Find files whose entire path matches the regular expression ${bld}REGEX${rs}\n"); cfprintf(cout, " ${blu}-samefile${rs} ${bld}FILE${rs}\n"); cfprintf(cout, " Find hard links to ${bld}FILE${rs}\n"); - cfprintf(cout, " ${blu}-size${rs} ${bld}[-+]N[cwbkMG]${rs}\n"); - cfprintf(cout, " 1-byte ${bld}c${rs}haracters, 2-byte ${bld}w${rs}ords, 512-byte ${bld}b${rs}locks, and" - " ${bld}k${rs}iB/${bld}M${rs}iB/${bld}G${rs}iB\n"); - cfprintf(cout, " ${blu}-type${rs} ${bld}[bcdlpfsD]${rs}\n"); - cfprintf(cout, " The ${bld}D${rs}oor file type is also supported on platforms that have it (Solaris)\n"); + cfprintf(cout, " ${blu}-size${rs} ${bld}[-+]N[cwbkMGTP]${rs}\n"); + cfprintf(cout, " Find files with the given size, in 1-byte ${bld}c${rs}haracters, 2-byte ${bld}w${rs}ords,\n"); + cfprintf(cout, " 512-byte ${bld}b${rs}locks (default), or ${bld}k${rs}iB/${bld}M${rs}iB/${bld}G${rs}iB/${bld}T${rs}iB/${bld}P${rs}iB\n"); + cfprintf(cout, " ${blu}-sparse${rs}\n"); + cfprintf(cout, " Find files that occupy fewer disk blocks than expected\n"); + cfprintf(cout, " ${blu}-type${rs} ${bld}[bcdlpfswD]${rs}\n"); + cfprintf(cout, " Find files of the given type\n"); cfprintf(cout, " ${blu}-used${rs} ${bld}[-+]N${rs}\n"); cfprintf(cout, " Find files last accessed ${bld}N${rs} days after they were changed\n"); - cfprintf(cout, " ${blu}-wholename${rs} ${bld}GLOB${rs}\n"); - cfprintf(cout, " Find files whose entire path matches the ${bld}GLOB${rs} (same as ${blu}-path${rs})\n"); -#ifdef FNM_CASEFOLD - cfprintf(cout, " ${blu}-ilname${rs} ${bld}GLOB${rs}\n"); - cfprintf(cout, " ${blu}-iname${rs} ${bld}GLOB${rs}\n"); - cfprintf(cout, " ${blu}-ipath${rs} ${bld}GLOB${rs}\n"); - cfprintf(cout, " ${blu}-iregex${rs} ${bld}REGEX${rs}\n"); - cfprintf(cout, " ${blu}-iwholename${rs} ${bld}GLOB${rs}\n"); - cfprintf(cout, " Case-insensitive versions of ${blu}-lname${rs}/${blu}-name${rs}/${blu}-path${rs}" - "/${blu}-regex${rs}/${blu}-wholename${rs}\n"); -#endif - cfprintf(cout, " ${blu}-xtype${rs} ${bld}[bcdlpfsD]${rs}\n"); + cfprintf(cout, " ${blu}-xtype${rs} ${bld}[bcdlpfswD]${rs}\n"); cfprintf(cout, " Find files of the given type, following links when ${blu}-type${rs} would not, and\n"); cfprintf(cout, " vice versa\n\n"); + cfprintf(cout, "${bld}Actions:${rs}\n\n"); + cfprintf(cout, " ${blu}-delete${rs}\n"); + cfprintf(cout, " ${blu}-rm${rs}\n"); cfprintf(cout, " Delete any found files (implies ${blu}-depth${rs})\n"); + cfprintf(cout, " ${blu}-exec${rs} ${bld}command ... {} ;${rs}\n"); + cfprintf(cout, " Execute a command\n"); + cfprintf(cout, " ${blu}-exec${rs} ${bld}command ... {} +${rs}\n"); + cfprintf(cout, " Execute a command with multiple files at once\n"); + cfprintf(cout, " ${blu}-ok${rs} ${bld}command ... {} ;${rs}\n"); + cfprintf(cout, " Prompt the user whether to execute a command\n"); cfprintf(cout, " ${blu}-execdir${rs} ${bld}command ... {} ;${rs}\n"); cfprintf(cout, " ${blu}-execdir${rs} ${bld}command ... {} +${rs}\n"); - cfprintf(cout, " ${blu}-okdir${rs} ${bld}command ... {} ;${rs}\n"); + cfprintf(cout, " ${blu}-okdir${rs} ${bld}command ... {} ;${rs}\n"); cfprintf(cout, " Like ${blu}-exec${rs}/${blu}-ok${rs}, but run the command in the same directory as the found\n"); cfprintf(cout, " file(s)\n"); - cfprintf(cout, " ${blu}-ls${rs}\n"); - cfprintf(cout, " List files like ${ex}ls${rs} ${bld}-dils${rs}\n"); - cfprintf(cout, " ${blu}-print0${rs}\n"); - cfprintf(cout, " Like ${blu}-print${rs}, but use the null character ('\\0') as a separator rather than\n"); - cfprintf(cout, " newlines\n"); - cfprintf(cout, " ${blu}-printf${rs} ${bld}FORMAT${rs}\n"); - cfprintf(cout, " Print according to a format string (see ${ex}man${rs} ${bld}find${rs})\n"); + cfprintf(cout, " ${blu}-exit${rs} [${bld}STATUS${rs}]\n"); + cfprintf(cout, " Exit immediately with the given status (%d if unspecified)\n", EXIT_SUCCESS); cfprintf(cout, " ${blu}-fls${rs} ${bld}FILE${rs}\n"); cfprintf(cout, " ${blu}-fprint${rs} ${bld}FILE${rs}\n"); cfprintf(cout, " ${blu}-fprint0${rs} ${bld}FILE${rs}\n"); cfprintf(cout, " ${blu}-fprintf${rs} ${bld}FORMAT${rs} ${bld}FILE${rs}\n"); cfprintf(cout, " Like ${blu}-ls${rs}/${blu}-print${rs}/${blu}-print0${rs}/${blu}-printf${rs}, but write to" " ${bld}FILE${rs} instead of standard output\n"); + cfprintf(cout, " ${blu}-ls${rs}\n"); + cfprintf(cout, " List files like ${ex}ls${rs} ${bld}-dils${rs}\n"); + cfprintf(cout, " ${blu}-nohidden${rs}\n"); + cfprintf(cout, " Filter out hidden files and directories\n"); + cfprintf(cout, " ${blu}-print${rs}\n"); + cfprintf(cout, " Print the path to the found file\n"); + cfprintf(cout, " ${blu}-print0${rs}\n"); + cfprintf(cout, " Like ${blu}-print${rs}, but use the null character ('\\0') as a separator rather than\n"); + cfprintf(cout, " newlines\n"); + cfprintf(cout, " ${blu}-printf${rs} ${bld}FORMAT${rs}\n"); + cfprintf(cout, " Print according to a format string (see ${ex}man${rs} ${bld}find${rs}). The additional format\n"); + cfprintf(cout, " directives %%w and %%W${bld}k${rs} for printing file birth times are supported.\n"); + cfprintf(cout, " ${blu}-printx${rs}\n"); + cfprintf(cout, " Like ${blu}-print${rs}, but escape whitespace and quotation characters, to make the\n"); + cfprintf(cout, " output safe for ${ex}xargs${rs}. Consider using ${blu}-print0${rs} and ${ex}xargs${rs} ${bld}-0${rs} instead.\n"); + cfprintf(cout, " ${blu}-prune${rs}\n"); + cfprintf(cout, " Don't descend into this directory\n"); cfprintf(cout, " ${blu}-quit${rs}\n"); - cfprintf(cout, " Quit immediately\n\n"); - + cfprintf(cout, " Quit immediately\n"); cfprintf(cout, " ${blu}-version${rs}\n"); cfprintf(cout, " Print version information\n"); cfprintf(cout, " ${blu}-help${rs}\n"); cfprintf(cout, " Print this help message\n\n"); - cfprintf(cout, "${bld}BSD find features:${rs}\n\n"); - - cfprintf(cout, " ${cyn}-E${rs}\n"); - cfprintf(cout, " Use extended regular expressions (same as ${blu}-regextype${rs} ${bld}posix-extended${rs})\n"); - cfprintf(cout, " ${cyn}-X${rs}\n"); - cfprintf(cout, " Filter out files with non-${ex}xargs${rs}-safe names\n"); - cfprintf(cout, " ${cyn}-x${rs}\n"); - cfprintf(cout, " Don't descend into other mount points (same as ${blu}-xdev${rs})\n\n"); - - cfprintf(cout, " ${cyn}-f${rs} ${mag}PATH${rs}\n"); - cfprintf(cout, " Treat ${mag}PATH${rs} as a path to search (useful if begins with a dash)\n\n"); - -#if BFS_HAS_SYS_ACL - cfprintf(cout, " ${blu}-acl${rs}\n"); - cfprintf(cout, " Find files with non-trivial Access Control Lists\n"); -#endif - cfprintf(cout, " ${blu}-Bmin${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " ${blu}-Btime${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " Find files Birthed ${bld}N${rs} minutes/days ago\n"); - cfprintf(cout, " ${blu}-Bnewer${rs} ${bld}FILE${rs}\n"); - cfprintf(cout, " Find files Birthed more recently than ${bld}FILE${rs} was modified\n"); - cfprintf(cout, " ${blu}-depth${rs} ${bld}[-+]N${rs}\n"); - cfprintf(cout, " Find files with depth ${bld}N${rs}\n"); - cfprintf(cout, " ${blu}-gid${rs} ${bld}NAME${rs}\n"); - cfprintf(cout, " ${blu}-uid${rs} ${bld}NAME${rs}\n"); - cfprintf(cout, " Group/user names are supported in addition to numeric IDs\n"); - cfprintf(cout, " ${blu}-size${rs} ${bld}[-+]N[cwbkMGTP]${rs}\n"); - cfprintf(cout, " Units of ${bld}T${rs}iB/${bld}P${rs}iB are additionally supported\n"); - cfprintf(cout, " ${blu}-sparse${rs}\n"); - cfprintf(cout, " Find files that occupy fewer disk blocks than expected\n\n"); - - cfprintf(cout, " ${blu}-exit${rs} ${bld}[STATUS]${rs}\n"); - cfprintf(cout, " Exit immediately with the given status (%d if unspecified)\n", EXIT_SUCCESS); - cfprintf(cout, " ${blu}-printx${rs}\n"); - cfprintf(cout, " Like ${blu}-print${rs}, but escape whitespace and quotation characters, to make the\n"); - cfprintf(cout, " output safe for ${ex}xargs${rs}. Consider using ${blu}-print0${rs} and ${ex}xargs${rs} ${bld}-0${rs} instead.\n"); - cfprintf(cout, " ${blu}-rm${rs}\n"); - cfprintf(cout, " Delete any found files (same as ${blu}-delete${rs}; implies ${blu}-depth${rs})\n\n"); - - cfprintf(cout, "${ex}bfs${rs}${bld}-specific features:${rs}\n\n"); - - cfprintf(cout, " ${cyn}-O${rs}${bld}0${rs}\n"); - cfprintf(cout, " Disable all optimizations\n"); - cfprintf(cout, " ${cyn}-O${rs}${bld}1${rs}\n"); - cfprintf(cout, " Basic logical simplification\n"); - cfprintf(cout, " ${cyn}-O${rs}${bld}2${rs}\n"); - cfprintf(cout, " All ${cyn}-O${rs}${bld}1${rs} optimizations, plus dead code elimination and data flow analysis\n"); - cfprintf(cout, " ${cyn}-O${rs}${bld}3${rs} (default)\n"); - cfprintf(cout, " All ${cyn}-O${rs}${bld}2${rs} optimizations, plus re-order expressions to reduce expected cost\n"); - cfprintf(cout, " ${cyn}-O${rs}${bld}4${rs}/${cyn}-O${rs}${bld}fast${rs}\n"); - cfprintf(cout, " All optimizations, including aggressive optimizations that may alter the\n"); - cfprintf(cout, " observed behavior in corner cases\n\n"); - - cfprintf(cout, " ${blu}-color${rs}\n"); - cfprintf(cout, " ${blu}-nocolor${rs}\n"); - cfprintf(cout, " Turn colors on or off (default: ${blu}-color${rs} if outputting to a terminal,\n"); - cfprintf(cout, " ${blu}-nocolor${rs} otherwise)\n\n"); - -#if BFS_HAS_POSIX1E_CAPABILITIES - cfprintf(cout, " ${blu}-capable${rs}\n"); - cfprintf(cout, " Match files with POSIX.1e capabilities set\n\n"); -#endif - - cfprintf(cout, " ${blu}-hidden${rs}\n"); - cfprintf(cout, " ${blu}-nohidden${rs}\n"); - cfprintf(cout, " Match hidden files, or filter them out\n\n"); - - cfprintf(cout, " ${blu}-printf${rs} ${bld}FORMAT${rs}\n"); - cfprintf(cout, " ${blu}-fprintf${rs} ${bld}FORMAT${rs} ${bld}FILE${rs}\n"); - cfprintf(cout, " The additional format directives %%w and %%W${bld}k${rs} for printing file birth times\n"); - cfprintf(cout, " are supported.\n\n"); - cfprintf(cout, "%s\n", BFS_HOMEPAGE); state->just_info = true; |