From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27749 invoked from network); 10 Aug 2005 19:58:43 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Aug 2005 19:58:43 -0000 Received: (qmail 1904 invoked from network); 10 Aug 2005 19:58:35 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Aug 2005 19:58:35 -0000 Received: (qmail 21178 invoked by alias); 10 Aug 2005 19:58:29 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9283 Received: (qmail 21168 invoked from network); 10 Aug 2005 19:58:28 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Aug 2005 19:58:28 -0000 Received: (qmail 905 invoked from network); 10 Aug 2005 19:58:28 -0000 Received: from cmailg2.svr.pol.co.uk (195.92.195.172) by a.mx.sunsite.dk with SMTP; 10 Aug 2005 19:58:25 -0000 Received: from modem-3129.marahu.dialup.pol.co.uk ([81.78.220.57] helo=pwstephenson.fsnet.co.uk) by cmailg2.svr.pol.co.uk with esmtp (Exim 4.41) id 1E2wiW-0000I7-1m for zsh-users@sunsite.dk; Wed, 10 Aug 2005 20:58:24 +0100 Received: by pwstephenson.fsnet.co.uk (Postfix, from userid 501) id E765C8633; Wed, 10 Aug 2005 16:06:20 -0400 (EDT) Received: from pwstephenson.fsnet.co.uk (localhost [127.0.0.1]) by pwstephenson.fsnet.co.uk (Postfix) with ESMTP id A413C84C0 for ; Wed, 10 Aug 2005 21:06:20 +0100 (BST) To: zsh-users@sunsite.dk Subject: Re: rm nonexisting*; alias with parameters? In-Reply-To: Message from Deliverable Mail of "Wed, 10 Aug 2005 12:18:53 PDT." <7c737f3005081012187ed74a81@mail.gmail.com> Date: Wed, 10 Aug 2005 21:06:18 +0100 From: Peter Stephenson Message-Id: <20050810200620.E765C8633@pwstephenson.fsnet.co.uk> X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.0.4 Deliverable Mail wrote: > I have a log directory where different logs appear, and an alias to > clear it up. I try to define patterns covering all the logs to avoid > rm *, which is dangerous and asks for a confirmation. So I define all > possible patterns like in an alias, rml: > > alias rml='rm prefix1.* *.suffix2*' > > But when some of the patterns match nothing, zsh prints an error about > that doesn't do anything. How can I change that behavior to the > expected of rm -f ? (Did you miss the -f after the rm? That confused me to begin with but I'll assume so. The shell can't make rm look like rm -f.) I think what you want is that if some patterns *do* match, the ones that don't are silently removed. The neatest way of doing this is "setopt cshnullglob", which uses the csh method: if no patterns match, the shell reports an error, whereas if some do, the others are removed. If you never want the shell error, "setopt nullglob". > While I'm on the subject of aliases, looks like zsh aliases are as > weak as bash's, so when I have my lr: > > alias lr='ls -lt | head' > > which I could not use with a parameter, lr , I still cannot use a > parameter in zsh. In bash, made lr a function -- what the zsh > function would look like? The same, probably. lr() { ls -lt "$@" | head } > And is there a way to do it in an alias, or still not? No, functions are the right way. This is exactly what they're for. -- Peter Stephenson Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk