2017-05-25 16:33:40 +0000, Austin Group Bug Tracker:
[...]
>  (0003749) geoffclare (manager) - 2017-05-25 16:33
>  http://austingroupbugs.net/view.php?id=1045#c3749 
> ---------------------------------------------------------------------- 
> Interpretation response

Thanks Geoff for that.

[...]
> On page 2562 line 82990-82993 section cd,
> change:<blockquote>−<blockquote>When a <hyphen-minus> is used as the
> operand, this shall be equivalent to the command:<pre>
[...]

Note that that "−" above is a "minus sign" (U+2212), not a "-"
"hyphen minus" (U+002D).

> On page 2564 line 83048 section cd, add a new paragraph to APPLICATION
> USAGE:<blockquote>Since <i>cd</i> treats the operand '−' as a special
> case, applications should not pass arbitrary values as the operand.  For
> example, instead of:<pre>
>     CDPATH= cd -P -- "$dir"
> </pre>applications should use the following:<pre>
>     case $dir in
>     (/*) CDPATH= cd -P "$dir";;
>     ("") CDPATH= cd -P "";;
>     (*) CDPATH= cd -P "./$dir";;
>     esac
> </pre>(The special treatment of "" is to avoid prefixing it with "./"; an
> alternative would be to report empty "$dir" as an error to avoid
> unspecified behavior.)</blockquote> 
[...]

If we add that, we may want to add similar text for the special
handling of "-" in other utilities (like most text utilities and
more).

Don't use:

grep -e "$pattern" -- "$file"

but:

grep -e "$pattern" < "$file"

or

case $file in
 (-) grep -e "$pattern" ./-;;
 (*) grep -e "$pattern" -- "$file";;
esac

And don't use:

grep -e "$pattern" -- *

but

grep -e "$pattern" ./*

And while we're at working around the violations of namespaces
by POSIX utilities, we could mention the problem of awk and
filenames containing "=" characters (where again a work around
is to prefix with "./").

Same for "find" and the confusion with predicates (files called
"!", "-print"...). Specifying BSD's -f would be great for that.

IIRC, "expr"'s problems are already mention though IIRC, there's
already an austin bug about some issues with the examples.

-- 
Stephane

Reply via email to