Re: man find -exec -- a little bit more hand-holding

2020-08-14 Thread Jason McIntyre
On Fri, Aug 14, 2020 at 09:24:35AM -0600, Theo de Raadt wrote:
> Christian Weisgerber  wrote:
> 
> > On 2020-08-14, Jason McIntyre  wrote:
> > 
> > > - i cannot work out what is with the \! examples. i know we try to make
> > >   entries work for both csh and sh style shells, but stuff like this
> > >   works without escaping:
> > >
> > >   $ find . ! -type f
> > 
> > Going through the CVS and SCCS history, I see that the examples
> > came with a rewrite of find(1) at Berkeley 30 years ago.
> > 
> > csh's behavior that "for convenience, a `!' is passed unchanged
> > when it is followed by a blank, tab, newline, `=' or `('" has been
> > documented as such at least since the start of the CSRG repository
> > in 1985.
> > 
> > bash, whose history substitution was modeled on csh, also shares
> > this behavior.
> > 
> > I think it was never necessary to escape the '!' and the man page
> > examples were written with an abundance of caution and a lack of
> > understanding of csh's exact replacement mechanism.
> 
> Yep, so I think that particular escape should be deleted.
> 

done.
jmc



Re: man find -exec -- a little bit more hand-holding

2020-08-14 Thread Theo de Raadt
Christian Weisgerber  wrote:

> On 2020-08-14, Jason McIntyre  wrote:
> 
> > - i cannot work out what is with the \! examples. i know we try to make
> >   entries work for both csh and sh style shells, but stuff like this
> >   works without escaping:
> >
> > $ find . ! -type f
> 
> Going through the CVS and SCCS history, I see that the examples
> came with a rewrite of find(1) at Berkeley 30 years ago.
> 
> csh's behavior that "for convenience, a `!' is passed unchanged
> when it is followed by a blank, tab, newline, `=' or `('" has been
> documented as such at least since the start of the CSRG repository
> in 1985.
> 
> bash, whose history substitution was modeled on csh, also shares
> this behavior.
> 
> I think it was never necessary to escape the '!' and the man page
> examples were written with an abundance of caution and a lack of
> understanding of csh's exact replacement mechanism.

Yep, so I think that particular escape should be deleted.



Re: man find -exec -- a little bit more hand-holding

2020-08-14 Thread Christian Weisgerber
On 2020-08-14, Jason McIntyre  wrote:

> - i cannot work out what is with the \! examples. i know we try to make
>   entries work for both csh and sh style shells, but stuff like this
>   works without escaping:
>
>   $ find . ! -type f

Going through the CVS and SCCS history, I see that the examples
came with a rewrite of find(1) at Berkeley 30 years ago.

csh's behavior that "for convenience, a `!' is passed unchanged
when it is followed by a blank, tab, newline, `=' or `('" has been
documented as such at least since the start of the CSRG repository
in 1985.

bash, whose history substitution was modeled on csh, also shares
this behavior.

I think it was never necessary to escape the '!' and the man page
examples were written with an abundance of caution and a lack of
understanding of csh's exact replacement mechanism.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: man find -exec -- a little bit more hand-holding

2020-08-14 Thread Jason McIntyre
On Fri, Aug 14, 2020 at 04:30:13AM +0100, ropers wrote:
> The find man page might benefit from adding a little bit more
> user-friendly hand-holding here:
> 
> Index: find.1
> ===
> RCS file: /cvs/src/usr.bin/find/find.1,v
> retrieving revision 1.98
> diff -u -r1.98 find.1
> --- find.12 Sep 2019 21:18:41 -   1.98
> +++ find.114 Aug 2020 02:59:48 -
> @@ -231,6 +231,10 @@
>  .Qq {}
>  appears anywhere in the utility name or the
>  arguments it is replaced by the pathname of the current file.
> +The semicolon will likely have to be escaped, depending on the shell.
> +See
> +.Sx CAVEATS
> +below.
>  .Pp
>  If terminated by a plus sign,
>  the pathnames for which the
> 
> 
> EXAMPLE:
> 
> $ find ~ -iname ".*" -exec echo {} \;
> works, but
> $ find ~ -iname ".*" -exec echo {} ;
> does not.
> 
> (Yes, this is a contrived example.  I wouldn't want to make people
> copy things all over the place.)
> 

hi.

first off, i do sympathise ;) shell escaping always hurts my head too.

regarding your diff: i don;t think this is the way to go. really, we
would have to add such a text every time we encounter a character that
may need escaping. so the whole point of the text in CAVEATS in to avoid
such a large text addition, and just remind people to watch out
(caveat!) the text in CAVEATS pretty much makes your diff redundant.

the EXAMPLES section additionally shows escaping.

i think there's enough there for people.

havng said that:

- i had hoped we'd have a specific \; example. that format is so
  commonly seen that it might make sense. so i'd not be against either
  adding such an example (currently EXAMPLES is fairly small) or
  altering another.

- i cannot work out what is with the \! examples. i know we try to make
  entries work for both csh and sh style shells, but stuff like this
  works without escaping:

$ find . ! -type f

jmc