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 clu
On Fri, Apr 16, 2010 at 10:52 AM, Bob Proulx 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.
>
> True.
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
advanta
On Thu, Apr 15, 2010 at 11:43 PM, Eric Blake 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:
> http://www.o
On Fri, Apr 16, 2010 at 12:57 AM, Bob Proulx 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 insta
On Fri, Apr 16, 2010 at 12:04 AM, Jan Schampera wrote:
> 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
> atom
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 wrote:
> On 04/15/2010 08:28 AM, Clark J. Wa
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
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 purpos
On 04/15/2010 08:28 AM, 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/
--
Eric Blake eb
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 abou
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
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:
http://www.opengroup.org/onlinepubs/9699919799/utilities/printf.html
"If the leadin
In C code I can use lockf(), flock(), semaphore and mutex for locking /
unlocking. Can bash provide some similar mechanisms?
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? :)
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
"Clark J. Wang" 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.
I see. Thank you.
On Thu, Apr 15, 2010 at 10:05 PM, Greg Wooledge 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
>> #
>>
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
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
20 matches
Mail list logo