From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16190 invoked by alias); 13 Mar 2014 12:46:42 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18601 Received: (qmail 26157 invoked from network); 13 Mar 2014 12:46:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Date: Thu, 13 Mar 2014 13:38:11 +0100 From: "Christoph (Stucki) von Stuckrad" To: zsh-users@zsh.org Subject: Re: noglob does not call alias? Message-ID: <20140313123811.GH26446@localhost.mi.fu-berlin.de> Mail-Followup-To: zsh-users@zsh.org References: <1394700750.34719.YahooMailNeo@web194603.mail.sg3.yahoo.com> <197551394709878@web5h.yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <197551394709878@web5h.yandex.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: "Chr. von Stuckrad" X-Originating-IP: 160.45.113.41 X-ZEDAT-Hint: R 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 "$@" } 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 \ 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/