bash-4.1.5 crashes when trying to edit multiline command in vi mode

2010-04-15 Thread Roman Rakus
In bash-4.1 patchlevel 5 (probably all older versions) crashes. Reproducer: 1. set -o vi #set ups vi command line editing 2. type the following command as seen, but do not hit enter at last one for i in `ls` do echo $i done 3.After typeing done (but not enter), hit escape 4.type the letter v to

Strange behavior of IFS?

2010-04-15 Thread Clark J. Wang
Look at following result: # cat foo.sh string=aa:bb:cc oldIFS=$IFS IFS=: for i in $string; do     echo $i done IFS=$oldIFS # bash foo.sh aa bb cc # I don't understand why the $string was still splitted into words since it's double quoted. Anyone can give a reasonable explanation? -Clark

Re: Strange behavior of IFS?

2010-04-15 Thread Clark J. Wang
I see. Thank you. On Thu, Apr 15, 2010 at 10:05 PM, Greg Wooledge wool...@eeg.ccf.org wrote: On Thu, Apr 15, 2010 at 09:58:42PM +0800, Clark J. Wang wrote: # cat foo.sh string=aa:bb:cc oldIFS=$IFS IFS=: for i in $string; do     echo $i done IFS=$oldIFS # bash foo.sh aa bb cc # I

Re: Strange behavior of IFS?

2010-04-15 Thread Andreas Schwab
Clark J. Wang dearv...@gmail.com writes: Look at following result: # cat foo.sh string=aa:bb:cc oldIFS=$IFS IFS=: for i in $string; do     echo $i done IFS=$oldIFS # bash foo.sh aa bb cc # I don't understand why the $string was still splitted into words since it's double quoted.

Re: Strange behavior of IFS?

2010-04-15 Thread Greg Wooledge
On Thu, Apr 15, 2010 at 09:58:42PM +0800, Clark J. Wang wrote: # cat foo.sh string=aa:bb:cc oldIFS=$IFS IFS=: for i in $string; do     echo $i done IFS=$oldIFS # bash foo.sh aa bb cc # I don't understand why the $string was still splitted into words since it's double quoted. Anyone

Undocumented usage of printf?

2010-04-15 Thread Clark J. Wang
I saw a printf usage from a Linux forum's post: # printf %d\n 'a 97 # It's really cool but I found no info in bash's manual. Are there any other undocumented interesting features? :)

Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
In C code I can use lockf(), flock(), semaphore and mutex for locking / unlocking. Can bash provide some similar mechanisms?

Re: Strange behavior of IFS?

2010-04-15 Thread Marc Herbert
Le 15/04/2010 14:58, Clark J. Wang a écrit : I don't understand why the $string was still splitted into words since it's double quoted. Anyone can give a reasonable explanation? set -x is often very good at giving explanations. Try this: sh -x foo.sh

Re: Undocumented usage of printf?

2010-04-15 Thread Jan Schampera
Clark J. Wang schrieb: I saw a printf usage from a Linux forum's post: # printf %d\n 'a 97 # It's really cool but I found no info in bash's manual. Are there any other undocumented interesting features? :) I documented it, though I don't remember where I first heard about it. Maybe I

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Jan Schampera
Clark J. Wang schrieb: In C code I can use lockf(), flock(), semaphore and mutex for locking / unlocking. Can bash provide some similar mechanisms? For simple things, which don't need to be 1000% rocksolid, you can use atomic operations like mkdir or noclobbered redirection for mutex

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Bob Proulx
Eric Blake wrote: Clark J. Wang wrote: In C code I can use lockf(), flock(), semaphore and mutex for locking / unlocking. Can bash provide some similar mechanisms? man 1 flock If necessary, you may need to install: ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/ There is also

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
Yes, flock(1) can do the right job but personally I don't like the way a command is invoked by flock. :) And flock can only run external commands, it cannot do with things like bash builtins or functions. On Fri, Apr 16, 2010 at 12:04 AM, Eric Blake ebl...@redhat.com wrote: On 04/15/2010

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
On Fri, Apr 16, 2010 at 12:04 AM, Jan Schampera jan.schamp...@web.dewrote: Clark J. Wang schrieb: In C code I can use lockf(), flock(), semaphore and mutex for locking / unlocking. Can bash provide some similar mechanisms? For simple things, which don't need to be 1000% rocksolid, you

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
On Fri, Apr 16, 2010 at 12:57 AM, Bob Proulx b...@proulx.com wrote: Eric Blake wrote: Clark J. Wang wrote: In C code I can use lockf(), flock(), semaphore and mutex for locking / unlocking. Can bash provide some similar mechanisms? man 1 flock If necessary, you may need to

Re: Undocumented usage of printf?

2010-04-15 Thread Clark J. Wang
On Thu, Apr 15, 2010 at 11:43 PM, Eric Blake ebl...@redhat.com wrote: On 04/15/2010 08:21 AM, Clark J. Wang wrote: I saw a printf usage from a Linux forum's post: # printf %d\n 'a 97 # POSIX requires this behavior, so you could claim that this serves as documentation:

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Bob Proulx
Clark J. Wang wrote: Bob Proulx wrote: There is also 'lockfile' distributed with 'procmail'. By using `lockfile' we must make sure that our script will not crash and the file is unlocked when the script exits. True. That is true of any of the file based locking methods. And advantage to

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
On Fri, Apr 16, 2010 at 10:52 AM, Bob Proulx b...@proulx.com wrote: Clark J. Wang wrote: Bob Proulx wrote: There is also 'lockfile' distributed with 'procmail'. By using `lockfile' we must make sure that our script will not crash and the file is unlocked when the script exits.

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Jan Schampera
Clark J. Wang schrieb: And if the script crashes the dir will be left unlocked. System crashes and kill -9 are the problem. The rest is none. If the area isn't too complex, noclobbered redirection serves well. But if you have other options, they should be used, of course. (doing this on a