bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Minor documentation issue: escaping {}


From: Bernhard Voelker
Subject: Re: Minor documentation issue: escaping {}
Date: Sat, 14 Oct 2023 20:49:33 +0200
User-agent: Mozilla Thunderbird

On 10/7/23 00:11, Keith Thompson wrote:
As of the latest version of findutils (commit e6e2d10a, Mon 2023-10-02),
the man and info documentation both incorrectly state that {} needs
to be escaped.

In the info documentation, section 3.3.1:
It replaces the string '{}' by the current file name being processed
everywhere it occurs in the command.  Both of these constructions need
to be escaped (with a '\') or quoted to protect them from expansion
by the shell.

("Both" refers to ';' and '{}'.)

In the man page, under "-exec command ;":
The string `{}' is replaced by the current file name being processed
everywhere it occurs in the arguments to the command, not just in
arguments where it is alone, as in some versions of find.  Both of
these constructions might need to be escaped (with a `\') or quoted
to protect them from expansion by the shell.

In the man page, under "-exec command {} +":
Only one instance of `{}' is allowed within the command, and it must
appear at the end, immediately before the `+'; it needs to be escaped
(with a `\') or quoted to protect it from interpretation by the shell.

In the man page, under "-execdir command {} +":
As with -exec, the {} should be quoted if find is being invoked from
a shell.

In all the shells I've tried, {} does *not* need to be escaped.
For example, in bash { is treated as a keyword, and is treated
specially only in a context where it's expected.  In other contexts,
it's just an ordinary string.

I've confirmed that `/bin/echo {}` prints `{}` with no diagnostic in
csh, tcsh, bash, ksh, dash, zsh, busybox sh, and fish.

(Escaping it unnecessarily is harmless, so this doesn't cause any
real problems other than encouraging a little extra typing.)

Thanks for the report.

I agree and see 2 different cases which the documentation should adhere
to more consistently:

a) code examples:
Here, '{}' and '+' do not have to be quoted or escaped -> remove it.
Still, ';' always has to be quoted/escaped (which was okay already.

b) mentioning of the strings '{}', ';' and '+' in the descriptions.
There, they always should get some markup (@samp{} in texi, .B in man).

The attached patch attempts to fix this.
Okay to push?

Thanks & have a nice day,
Berny

Attachment: 0001-doc-change-escaping-quoting-of-and-more-consistently.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]