Re: asking for a better way to implement this

2010-09-28 Thread Andreas Schwab
Andre Majorel writes: > On 2010-09-27 18:39 +0200, Christopher Roy Bratusek wrote: > >> I'm using GNU/Linux for seven years now, it's now almost >> impossible to learn to use `xrm' instead of `rm'. > > Put rm(){su} in your .bashrc. You'll be surprised. :-> syntax error near unexpected token `{su

Re: asking for a better way to implement this

2010-09-27 Thread Andre Majorel
On 2010-09-27 18:39 +0200, Christopher Roy Bratusek wrote: > I'm using GNU/Linux for seven years now, it's now almost > impossible to learn to use `xrm' instead of `rm'. Put rm(){su} in your .bashrc. You'll be surprised. :-> -- André Majorel http://www.teaser.fr/~amajorel/

Re: asking for a better way to implement this

2010-09-27 Thread Christopher Roy Bratusek
> > You might reinstall your OS one day, either due to hardware failure or > > simply upgrading. Then you might forget to build the rm alias. ... it's set by one of my applications and xrm is part of that applications script-chain. It's rc is called from .bashrc and that sets-up the alias. Whe

Re: asking for a better way to implement this

2010-09-27 Thread Chris F.A. Johnson
On Mon, 27 Sep 2010, Greg Wooledge wrote: On Mon, Sep 27, 2010 at 06:39:56PM +0200, Christopher Roy Bratusek wrote: It's a bad idea to alias rm. It would be better to use your xrm directly. If you alias rm and get in the habit of it protecting you, one of these days the alias won't be there and

Re: asking for a better way to implement this

2010-09-27 Thread Greg Wooledge
On Mon, Sep 27, 2010 at 06:39:56PM +0200, Christopher Roy Bratusek wrote: > > It's a bad idea to alias rm. It would be better to use your xrm > > directly. If you alias rm and get in the habit of it protecting you, > > one of these days the alias won't be there and OOPS, gone! > > Well... I know w

Re: asking for a better way to implement this

2010-09-27 Thread Christopher Roy Bratusek
> It's a bad idea to alias rm. It would be better to use your xrm > directly. If you alias rm and get in the habit of it protecting you, > one of these days the alias won't be there and OOPS, gone! Well... I know what you mean, but I'm using GNU/Linux for seven years now, it's now almost impossib

Re: asking for a better way to implement this

2010-09-27 Thread Christopher Roy Bratusek
Am Sun, 26 Sep 2010 18:09:16 -0400 (EDT) schrieb "Chris F.A. Johnson" : > On Sun, 26 Sep 2010, Christopher Roy Bratusek wrote: > > > btw. How can I remove the last arguement ${!#} ? > > > > I tried args=${@:-${!#}} but that won't work. > > args=( "$@" ) > unset args[$#-1] > set -- "${ar...@]}" >

Re: asking for a better way to implement this

2010-09-26 Thread Chris F.A. Johnson
On Sun, 26 Sep 2010, Christopher Roy Bratusek wrote: btw. How can I remove the last arguement ${!#} ? I tried args=${@:-${!#}} but that won't work. args=( "$@" ) unset args[$#-1] set -- "${ar...@]}" -- Chris F.A. Johnson, Author: Pro Bash Programming: Scripti

Re: asking for a better way to implement this

2010-09-26 Thread Dennis Williamson
On Sun, Sep 26, 2010 at 3:42 PM, Christopher Roy Bratusek wrote: > btw. How can I remove the last arguement ${!#} ? > > I tried args=${@:-${!#}} but that won't work. > > Chris > > > That says substitute the last argument if there are no arguments (pretty much impossible). Try this: args=${@:1:$

Re: asking for a better way to implement this

2010-09-26 Thread Dennis Williamson
On Sun, Sep 26, 2010 at 2:31 PM, Christopher Roy Bratusek wrote: >> Style is a matter of taste, but I think this is equivalent (not tested): >> >>     xrm () { >>         for path in "$@"; do >>             test ${path:0:1} == - && local RMO+="$path " && continue >>             for try in "$path"

Re: asking for a better way to implement this

2010-09-26 Thread Andreas Schwab
Ken Irving writes: > I'm guessing your $(which rm) is intended to avoid calling rm(), but maybe > \rm > would do the same thing? No, that still calls the function... I'm not sure > how to do that. $ command rm Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 5

Re: asking for a better way to implement this

2010-09-26 Thread Christopher Roy Bratusek
btw. How can I remove the last arguement ${!#} ? I tried args=${@:-${!#}} but that won't work. Chris

Re: asking for a better way to implement this

2010-09-26 Thread Christopher Roy Bratusek
> Style is a matter of taste, but I think this is equivalent (not tested): > > xrm () { > for path in "$@"; do > test ${path:0:1} == - && local RMO+="$path " && continue > for try in "$path" "${path%/*}"; do > test -e "$try"/.dirinfo || continue

Re: asking for a better way to implement this

2010-09-26 Thread Ken Irving
On Sun, Sep 26, 2010 at 06:15:57PM +0200, Christopher Roy Bratusek wrote: > Hi all, > > I'm writing a wrapper for rm, which does not let the file/directory be > removed, if > there's a .dirinfo file in the directory containing "NoDelete". > > (feel free to ask what that's all about.) > > This i

asking for a better way to implement this

2010-09-26 Thread Christopher Roy Bratusek
Hi all, I'm writing a wrapper for rm, which does not let the file/directory be removed, if there's a .dirinfo file in the directory containing "NoDelete". (feel free to ask what that's all about.) This is what I have: xrm () { for path in $@; do if [[ $path == -* || $p