Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: noglob does not call alias?
- X-seq: zsh-users 18602
- From: ZyX <kp-pav@xxxxxxxxx>
- To: "Christoph (Stucki) von Stuckrad" <stucki@xxxxxxxxxxxxxxxxx>
- Subject: Re: noglob does not call alias?
- Date: Thu, 13 Mar 2014 17:36:18 +0400
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1394717779; bh=ZSYQk7dxd40IvnC6FZnuR3YbC8mhubjwATgW9X35ZGU=; h=From:To:Cc:In-Reply-To:Subject:Date; b=AKxummattyNgz9uYujpwD79AqC9Hy8oI04te8eJ6Xck+igxQ+3VXEozWcg+smLjG1 7/HuWG0h+Hw6VUmwSqlbuMQqpKFBpL8DvsYvWkqW2a1VmMIRfoMOKwAlI03c1LgmBw Yqw9J3RdPmILmDG/uZGiH8pMmyu0HyxIF2N6VrlA=
- In-reply-to: <20140313123811.GH26446@localhost.mi.fu-berlin.de>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
13.03.14, 16:50, "Christoph (Stucki) von Stuckrad" <stucki@xxxxxxxxxxxxxxxxx>":
>
> Hi!
>
> This looked like a mix of cases and
> I try to sort some out:
>
> On Thu, 13 Mar 2014, ZyX wrote:
>
> > > $ alias rm='nocorrect rm -i'
> ...
> > > rm: remove regular empty file `1'? n
>
> The question is asked because of alias
>
> > > $ 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.
>
> > > $ ls
> > > 2
>
> So here's no question.
>
> > > I think this is not what (new zsh) user expects.
> > >
> > > 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.
>
> > > 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
>
> Well, it DID ask!
>
> > > rm: missing operand
> > > Try `rm --help' for more information.
>
> BUT you still had your alias defined, so you really called
>
> noglob rm -i *
>
> > > 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?
>
> > > But, anyway, continuing with my e-mail:
> > >
> > >
> > > $ 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.
>
>
>
> So I think, the only possibly strange case
> is the 'dangling -i without filename' created
> by the alias.
>
> Such 'strange' effects made me switch completely
> from using 'aliases' to 'functions' instead!
>
> For example defining this:
>
> function rm {
> nocorrect command rm -i "$@"
Corrections happen before function execution. Same for glob expansion. Putting nocorrect modifier here is a no-op, they have to be used from an alias. But putting -i in a function is correct and is the solution to the problem.
>
> }
>
> might be the 'secured rm' which you tried
> to create by aliases and which reacts as
> assumed on 'rm *', because the options
> are 'inside the function only' and do
> not interfere with your typed command.
>
> Stucki
>
> --
> Christoph von Stuckrad * * |nickname |Mail <stucki@xxxxxxxxxxxxxxx> \
> Freie Universitaet Berlin |/_*|'stucki' |Tel(Mo.,Mi.):+49 30 838-75 459|
> Mathematik & Informatik EDV |\ *|if online| (Di,Do,Fr):+49 30 77 39 6600|
> Takustr. 9 / 14195 Berlin * * |on IRCnet|Fax(home): +49 30 77 39 6601/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author