Re: Odd behaviour when running exec inside a signal handler

2010-07-26 Thread Greg Wooledge
On Sun, Jul 25, 2010 at 04:54:53PM -0400, Chet Ramey wrote: > On 7/25/10 8:51 AM, Julien Dessaux wrote: > > I have a script that trap USR1 for reloading purpose. The signal handler > > then does some cleaning, then exec $0. > > With BSD and Posix-style signals, the caught signal is automatical

Re: Odd behaviour when running exec inside a signal handler

2010-07-26 Thread Julien Dessaux
On Mon, Jul 26, 2010 at 2:16 PM, Greg Wooledge wrote: > On Sun, Jul 25, 2010 at 04:54:53PM -0400, Chet Ramey wrote: > > On 7/25/10 8:51 AM, Julien Dessaux wrote: > > > I have a script that trap USR1 for reloading purpose. The signal > handler > > > then does some cleaning, then exec $0. > > >

When to use printf instead of echo?

2010-07-26 Thread Peng Yu
Hi, Although echo is sufficient most of the time, my understanding is that printf may be better for certain situations (for example, formatting the width of a number). The manual doesn't explicitly mention in what situations it is better to use printf than to use echo. I think that this might have

Re: When to use printf instead of echo?

2010-07-26 Thread Eric Blake
On 07/26/2010 03:27 PM, Peng Yu wrote: > Hi, > > Although echo is sufficient most of the time, my understanding is that > printf may be better for certain situations (for example, formatting > the width of a number). The manual doesn't explicitly mention in what > situations it is better to use pr

RFE -or- Howto?

2010-07-26 Thread Linda Walsh
I don't know if there's an easy way, but if not would you consider an RFE -- Is there a syntax for a mult-var assignment, ala: (a b c d)=(1 2 3 4) results would be: a=1, b=2, c=3, d=4 I know I can get the rval into an array, but can't figure out how to move the array vals to discrete variables

Re: RFE -or- Howto?

2010-07-26 Thread Chet Ramey
On 7/26/10 6:25 PM, Linda Walsh wrote: > I don't know if there's an easy way, but if not would you consider an > RFE -- > > Is there a syntax for a mult-var assignment, ala: > (a b c d)=(1 2 3 4) Yes. read a b c d <<<"1 2 3 4" Chet -- ``The lyf so short, the craft so long to lerne.'' - Chauce

How use a local variable in for loop?

2010-07-26 Thread Peng Yu
Hi, The variable f keeps the last value when the for loop is finished. Is there a way to declare it as a local variable, so that it disappears after for-loop is finished? (I could unset it, but I want to know if it can be a local variable) $ for f in a b; do echo $f; done a b $ echo $f b -- Reg

Re: How use a local variable in for loop?

2010-07-26 Thread Eric Blake
On 07/26/2010 07:50 PM, Peng Yu wrote: > Hi, > > The variable f keeps the last value when the for loop is finished. Is > there a way to declare it as a local variable, so that it disappears > after for-loop is finished? (I could unset it, but I want to know if > it can be a local variable) > > $

Strange behavior with job control

2010-07-26 Thread Christoph Dittmann
Hi, consider the following script: #!/bin/bash sleep 0.5 & if [[ $1 = a ]]; then sleep 5 & else { sleep 5; } & fi PID=$! wait %1 kill $PID ps aux | grep '[s]leep 5' exit 0 When I run this script with parameter "a" I get the following output: ./foo.sh: line 11: 12132 Terminated