zsh-users
 help / color / mirror / code / Atom feed
From: Amm <ammdispose-zsh@yahoo.com>
To: zsh-users@zsh.org
Subject: Re: noglob does not call alias?
Date: Thu, 13 Mar 2014 20:18:13 +0530	[thread overview]
Message-ID: <5321C52D.7030104@yahoo.com> (raw)
In-Reply-To: <20140313123811.GH26446@localhost.mi.fu-berlin.de>


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


      parent reply	other threads:[~2014-03-13 14:54 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
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 [this message]

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=5321C52D.7030104@yahoo.com \
    --to=ammdispose-zsh@yahoo.com \
    --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).