Bash high memory usage in simple for loop?

2010-09-26 Thread Thomas Guyot-Sionnest
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey there, I just encountered some dubious behaviour... Feeding a large data set in a "for i in..." loop doing nothing causes exponentially large memory usage, and that memory is never freed (although is seems to be re-used over multiple runs...) For

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