>> = Brian Foster <blf at utvinternet.ie>
> = Colm Buckley <colm at tuatha.org>
>>>Just a note on the above; the "ls" is completely superfluous. The shell is
>> already expanding "*.mp3" to the list of all mp3 files in the current
>> directory; ls would only be necessary if you wanted to extract file
>> information other than the name [...]
> whilst I also detest the practice of using ls *.bar
> I also also realize it's not the same as *.bar
Yeah; I'm aware of the minutiae. For this problem, though, using the shell
glob expansion without invoking ls is much more correct, both in the
expected and pathological cases.
2. order may differ?
They should both be sorting according to the current locale rules.
3(most significant?) if nothing matches, *.bar _is_ *.bar
> whilst ls *.bar results in an error from ls, and in
> the case shown, the for-loop does not execute.
This depends on how the shell nullglob options are set. You can either get
a null expansion (which I always prefer; I think it's far more correct), or
a maintenance of the literal glob pattern as you suggest. I hate that
nullglob is not set by default; I can't think of any realistic cases where
keeping the literal glob is the more expected / less surprising behaviour.
Colm Buckley / colm at tuatha.org / +353 87 2469146
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!