The spec
(http://pubs.opengroup.org/onlinepubs/9699919799.2016edition/utilities/V3_chap02.html#tag_18_07)
says:

> the word that follows the redirection operator shall be
> subjected to tilde expansion, parameter expansion, command
> substitution, arithmetic expansion, and quote removal. Pathname
> expansion shall not be performed on the word by a
> non-interactive shell; an interactive shell may perform it, but
> shall do so only when the expansion would result in one word.

That would imply that with shells that implement that
(mis-)feature,

echo text > *

Would replace the content of the file matching that glob if
there was one and only one file matching the glob, but that
otherwise, that command should open (and create) a new file
called "*"

While that's what I observe with /bin/ksh on Solaris 10 (which
by the way is not compliant as it also does it when
non-interactive, same for /usr/xpg4/bin/sh), that's not
particularly useful and that's not how bash or ksh93 do it.
Those instead give an error when the glob doesn't expand to one
file.

I'd suggest the spec be reworded so the behaviour is unspecified
if the glob wouldn't expand to a single file (see also the zsh
(when not in sh emulation) behaviour for another more useful and
different behaviour)

What do you think?
-- 
Stephane

Reply via email to