Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: rm nonexisting*; alias with parameters?
- X-seq: zsh-users 9284
- From: Deliverable Mail <deliverable@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: rm nonexisting*; alias with parameters?
- Date: Wed, 10 Aug 2005 13:31:18 -0700
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=bddjR+RmOH/JAug0bUgJXg4oYeZBw2YjfFuTq9KDmzOXTHCnE0Qpl1zNojX2J3ZcOSr936anA4lzgknqTHBdb1Rmty5pDh+4lgxfiVB/Pi7CyMni00wdeNs12oHrBwEP4DR1Z4JAiq0hk4eqzFuYCAjcbEeu6mego949LoxXS3g=
- In-reply-to: <20050810200620.E765C8633@xxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <deliverable@xxxxxxxxx> <7c737f3005081012187ed74a81@xxxxxxxxxxxxxx> <20050810200620.E765C8633@xxxxxxxxxxxxxxxxxxxxxxxx>
Thanks, Peter! (I hear you, Ligesh... will do later :) Worked as
described. Making rm -f does not change zsh behavior, of course, as
globbing happens before -f can kick in -- so it's a bit confusing that
-f doesn't work. Thankfully zsh says zsh: before its globbing error.
It's a tricky fault for those who expect rm -f to shut up and do it...
Alexy
On 8/10/05, Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 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 <dir>, 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 <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
> Work: pws@xxxxxxx
> Web: http://www.pwstephenson.fsnet.co.uk
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author