[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: examples in find's man page
From: |
James Youngman |
Subject: |
Re: examples in find's man page |
Date: |
Sat, 16 Jul 2016 21:01:15 +0100 |
On Tue, Apr 26, 2016 at 9:47 AM, Isabella Parakiss <address@hidden> wrote:
>
> find's man page has some god-awful examples:
>
> > find . -type f -exec file '{}' \;
> >
> > Runs `file' on every file in or below the current directory. Notice
> > that the braces are enclosed in single quote marks to protect them
> > from interpretation as shell script punctuation. The semicolon is
> > similarly protected by the use of a backslash, though single quotes
> > could have been used in that case also.
>
> {} needs to be quoted
It _is_quoted here.
> > find repo/ -exec test -d {}/.svn \; -or \
> > -exec test -d {}/.git \; -or -exec test -d {}/CVS \; \
> > -print -prune
>
> but {}/.svn doesn't
I've updated the code to quote it.
> > find /sbin /usr/sbin -executable \! -readable -print
>
> let's escape ! here for no reason
The interpretation of and quoting rules for ! have changed
substantially over the years (for example, it is a reserved word in
only some sh variants, and who knows how its precise interpretation
varied over the lifetime of csh's parser), and I have developed the
habit of quoting in more or less all circumstances.
> > find . -perm -444 -perm /222 ! -perm /111
> > find . -perm -a+r -perm /a+w ! -perm /a+x
>
> but not here because logic
Changed, for consistency even if perhaps not logic.
> > find . -name .snapshot -prune -o \( \! -name *~ -print0 \)|
> > cpio -pmd0 /dest-dir
>
> surely *~ doesn't need to be quoted
It does and it is ... in the source. I hadn't noticed that troff
eats the double-quotes. I introduced the bug in commit
d7d18c0fe1d467d2c49bbf97aa24fd0af1d0be00.
>
> > NON-BUGS
> > $ find . -name *.c -print
> > find: paths must precede expression
> > Usage: find [-H] [-L] [-P] [-Olevel] [-D
> > help|tree|search|stat|rates|opt|exec] [path...] [expression]
> >
> > This happens because *.c has been expanded by the shell
> > resulting in find actually receiving a command line like this:
> >
> > find . -name bigram.c code.c frcode.c locate.c -print
> >
> > That command is of course not going to work. Instead of doing
> > things this way, you should enclose the pattern in quotes or
> > escape the wildcard:
> > $ find . -name '*.c' -print
> > $ find . -name \*.c -print
>
> oh wait apparently wildcards should be quoted or escaped
I've submitted a patch which addresses, I think, most of the above
points (if there's something I missed, please let me know). It
causes this difference in the formatted version of the manual page:
$ ( COLUMNS=1000 export COLUMNS ; cat ./find/find.1 | man -l - >|
/tmp/man-find-after.txt && git show
89580859c021e276ab2c518632883a74e6794ae5 | man -l - >|
/tmp/man-find-before.txt && wdiff -3 /tmp/man-find-{before,after}.txt
)
======================================================================
[-"Security Considerations"-] {+`Security Considerations'+}
======================================================================
[-command.-] {+command, and (when find is being invoked from a shell)
it should be quoted (for example, '{}') to protect it from
interpretation by shells.+}
======================================================================
{+As with -exec, the {} should be quoted if find is being invoked
from a shell.+}
======================================================================
[-".".-] {+`.'.+}
======================================================================
[-"and";-] {+-a;+}
======================================================================
[-"yes"-] {+`yes'+}
======================================================================
[-"no"-] {+`no'+}
======================================================================
[-!-] {+\!+}
======================================================================
[-!-] {+\!+}
======================================================================
[-*~-] {+'*~'+}
======================================================================
[-{}/.svn-] {+'{}'/.svn+}
======================================================================
Thanks for noticing these problems, and thanks for the bug report.
But, your tone is abrasive. That's not helpful. Please adopt a more
moderate tone in the future.
> please fix these, they're embarassing.
>
> --
> xoxo iza
>
0001-find-manpage-quoting-fixes-including-fixing-missing-.patch
Description: Text Data
- Re: examples in find's man page,
James Youngman <=