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

Re: 'whence' question

On Tue, Nov 11, 2014 at 8:52 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> Got that patch.  It works as advertised

If you haven't already, you might want to get minimally familiar with
"git" so you can pull from the development repository rather than
applying individual patches.

> but I noticed this:
>    $ whence -vam zsh*                        << UNQUOTED

What's happening here is that zsh* is being expanded as a file glob in
the local directory, and then "whence" is being called with the
resulting file names as arguments and looking up each of them in turn.

$ echo whence -vam zsh*

and see what you get.  I think this will explain all your confusion.

> For now the moral of the story is to always quote, but why would
> one ever *not* quote?

For "whence" one probably would always quote patterns.  For most other
commands that operate on file names, one probably wants them unquoted,
so that is the default behavior.  Command line input semantics
including globbing are entirely separate in *nix from the semantics
internal to the command itself -- very unlike DOS where it is up to
the command to invoke globbing on its arguments.

> I mean is there some valid use of it unquoted, or is that
> just always wrong?  If always wrong, they can we 'autoquote' some how?

You could use

alias whence='noglob whence '

(the trailing space is important, see the description of the "alias" command).

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