Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: noglob does not call alias?
On 03/13/2014 06:08 PM, Christoph (Stucki) von Stuckrad wrote:
$ noglob rm 1
aliases are expanded from the beginning of the LINE,
not from the command itself, so anything in front
of 'rm' seems to suppress the alias, like e.g.
FOO=bar rm 1
also does.
This I think is wrong. noglob and nocorrect should be treated
as special case and word following should be checked for
existence of alias. (not just command)
How do I prevent this?
To prevent 'this', you need to make the
Option '-i' permanent for all 'rm' calls,
which is easier in functions, see at end.
Hmm, then I think functions should be recommended instead of
alias atleast for risky commands like 'rm;
Also 'noglob' does not respect RM_STAR_SILENT=off.
$ unsetopt RM_STAR_SILENT
$ rm *
zsh: sure you want to delete all the files in ... [yn]? n
>>> rm: missing operand
>>> Try `rm --help' for more information.
Well, it DID ask!
Umm, this was not a question. This was part of example.
I was just showing what happens without noglob.
BUT you still had your alias defined, so you really called
noglob rm -i *
As already pointed above noglob does not call rm with -i
Probably you mean nocorrect instead of noglob.
>>> First I think when I said 'n'(no), it should not call
>>> 'rm' at all instead of calling it without any filename.
THIS is an interesting question!
Why did 'rm *', resulting in 'noglob rm -i *' still execute ???
I assume, the handling of 'denied' case of 'rm *' ends with
a still existing parameter to 'rm', and thus runs the command
instead of ignoring it completely?
This actually was side question unrelated to this thread.
But, anyway, continuing with my e-mail:
Here comes the question.
$ noglob rm *
rm: cannot remove `*': No such file or directory
This is, as it should be, and must not reply
differently, lest being incompatible to the
reaction of the other shell variants.
I know, I already stated that this does not cause any harm.
But what I meant that I would still prefer zsh to trigger
a warning whether I used noglob OR not.
I NEVER do 'rm *'. So if there is rm * on command line that surely
means, its by mistake, so I would prefer to see a warning, even if
there is 'noglob'.
Such 'strange' effects made me switch completely
from using 'aliases' to 'functions' instead!
Yep, even I think I should switch to 'functions'!
But I would again propose that 'noglob' and 'nocorrect' should
not treat next word as command, it should also check for alias.
Thanks for your replies
Amm
Messages sorted by:
Reverse Date,
Date,
Thread,
Author