From: ZyX <kp-pav@yandex.ru>
To: "Christoph (Stucki) von Stuckrad" <stucki@math.fu-berlin.de>
Cc: zsh-users@zsh.org
Subject: Re: noglob does not call alias?
Date: Thu, 13 Mar 2014 17:36:18 +0400 [thread overview]
Message-ID: <4058361394717778@web15g.yandex.ru> (raw)
In-Reply-To: <20140313123811.GH26446@localhost.mi.fu-berlin.de>
13.03.14, 16:50, "Christoph (Stucki) von Stuckrad" <stucki@math.fu-berlin.de>":
>
> 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@mi.fu-berlin.de> \
> 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/
next prev parent reply other threads:[~2014-03-13 13:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-13 8:52 Amm
2014-03-13 11:24 ` ZyX
2014-03-13 12:38 ` Christoph (Stucki) von Stuckrad
2014-03-13 13:36 ` ZyX [this message]
2014-03-13 14:36 ` Bart Schaefer
2014-03-13 15:17 ` Amm
2014-03-13 17:02 ` Bart Schaefer
2014-03-13 14:48 ` Amm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4058361394717778@web15g.yandex.ru \
--to=kp-pav@yandex.ru \
--cc=stucki@math.fu-berlin.de \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).