From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22268 invoked by alias); 13 Mar 2014 13:42:14 -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: 18602 Received: (qmail 9424 invoked from network); 13 Mar 2014 13:42:08 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 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= From: ZyX To: "Christoph (Stucki) von Stuckrad" Cc: zsh-users@zsh.org In-Reply-To: <20140313123811.GH26446@localhost.mi.fu-berlin.de> Subject: Re: noglob does not call alias? MIME-Version: 1.0 Message-Id: <4058361394717778@web15g.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 X-Yandex-Client: =?utf-8?B?WWFPbmxpbmUtYW5kcm9pZC0xLjgxLjM2OQ==?= Date: Thu, 13 Mar 2014 17:36:18 +0400 Content-Transfer-Encoding: 7bit Content-Type: text/plain 13.03.14, 16:50, "Christoph (Stucki) von Stuckrad" ": > > 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 \ > 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/