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
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
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
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.
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
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? :)
In C code I can use lockf(), flock(), semaphore and mutex for locking /
unlocking. Can bash provide some similar mechanisms?
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
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
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
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
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
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
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
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:
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
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.
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
18 matches
Mail list logo