/bin/sh: wildcard expansion fails

Lowell Gilbert freebsd-questions-local at be-well.ilk.org
Wed May 17 07:29:27 PDT 2006


"No at SPAM@mgEDV.net" <nospam at mgedv.net> writes:

> i know things like "cat *lst|wc", but i don't want to type them.
> when i try to use wildcards with "<" or ">" in /bin/sh, it fails:
>
> my input (only one file with this name exists in the current dir):
> wc <*lst

Which is equivalent to "wc *lst", so I'm not sure why you'd want to do
that... 

> /bin/sh's output:
> cannot open *lst: No such file or directory
>
> is there a way to configure /bin/sh for "more/better" expansion?

No.

Incidentally, it is operating as documented (pathname expansion isn't
listed as performed on redirection targets), and explicitly allowed by
the POSIX standard.

> btw, with csh it works fine ;-)

And some other shells too, I'm sure.  

Feel free to fix this yourself; if it still meets the POSIX standards
(i.e., still errors out if the expansion returns multiple files), the
change would probably be accepted...


More information about the freebsd-questions mailing list