Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: spaces in filenames should be a crime.

Op 27-03-17 om 00:41 schreef Ray Andrews:
> On 26/03/17 02:18 PM, Daniel Shahaf wrote:
>> You could replace the whole function with:
>>      mostrecent() { ls -l -- **/*(.om[1]) }
> Yeah, my original was just something I found on the net and didn't
> bother to improve upon until it crashed and burned on a space in the
> directory name.  I'm not surprised that our 'ls' can do it all by itself.

Note that 'ls' is an external command that doesn't do anything but list
files given to it as arguments. It cannot expand any glob patterns (with
*, etc.); that's the shell's job. The shell resolves the glob pattern
and hands 'ls' the expanded list of arguments. This applies to every
other command as well, and even to shell functions.

(This is a fundamental difference with DOS/Windows batch files, where
every command is expected to resolve patterns by itself.)

Shell globbing can also be dangerous if any file names start with '-';
the command may interpret these as options. Most commands support a
standard method of neutralising that: the special option '--' to disable
option parsing for any subsequent command. A common alternative idiom is
to prepend './' to the glob pattern so that every argument expanded from
it also starts with './' (and hence never '-').


FYI: http://www.acronymfinder.com/

HTH. HAND. ;-)

- M.

Messages sorted by: Reverse Date, Date, Thread, Author