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

Re: problem with zmv



On Dec 3,  7:44am, Ray Andrews wrote:
}
} On 12/02/2016 07:51 PM, Bart Schaefer wrote:
} > It occurs to me that it might be slightly better to use
} >
} >      alias zmv='function { . zmv }'
} >
} Gotcha ... ok, thanks Bart, I'll not try to understand why, that's taken 
} on faith.

I was having trouble coming up with an example last night, but:

You may have noticed that "noglob" acts a bit like "command" in that
aliases are not expanded:

% alias foo='echo you typed'
% noglob foo *
zsh: command not found: foo

So suppose you want aliases expanded after noglob.  To do that, you
need:

% alias noglob='noglob '

(with the trailing space in the quotes).  Now:

% noglob foo *
you typed *
% 

However, if you have

% alias zmv='() { . zmv }'
% noglob zmv
% functions
noglob () {
        . zmv
}
% 

It's very unlikely this would happen because you'd probably put some
arguments after zmv and get a parse error, but if you replace () with
"function" then you get the parse error every time and no accidents.

If you want noglob with zmv you have to autoload the real function, as
there's no way to use precommand modifiers with an anonymous function.



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