Re: Possible bug: Race condition when calling external commands during trap handling

2012-05-03 Thread Bob Proulx
tillmann.crue...@telekom.de wrote: > I have produced the following script as a small example: A good small example! I do not understand the problem but I do have a question about one of the lines in it and a comment about another. > trap "kill $?; exit 0" INT TERM What did you intend with "kill

Re: ((i++)) no longer supported?

2012-05-03 Thread DJ Mills
On Thu, May 3, 2012 at 2:53 AM, Pierre Gaston wrote: > On Thu, May 3, 2012 at 9:34 AM, Pan ruochen wrote: >> Hi All, >> >> Suddenly I found that ((i++)) is not supported on bash. >> Just try the following simple case: >> $i=0; ((i++)); echo $? >> And the result is >> 1 >> which means an error. >>

Possible bug: Race condition when calling external commands during trap handling

2012-05-03 Thread Tillmann.Crueger
Yes, you are correct, that line is buggy and contains a typo. I added it later in a hurry after I could reproduce the error, to ensure a clean shutdown of the script. What I meant to type was: > trap "kill $!; exit 0" INT TERM However thinking about it, this also does not work as intended. The

Re: Possible bug: Race condition when calling external commands during trap handling

2012-05-03 Thread Andreas Schwab
Bob Proulx writes: > And lastly I will comment that you are doing quite a bit inside of an > interrupt routine. Typically in a C program it is not safe to perform > any operation that may call malloc() within an interupt service > routine since malloc isn't reentrant. Bash is a C program and I

Re: ((i++)) no longer supported?

2012-05-03 Thread Greg Wooledge
On Thu, May 03, 2012 at 02:34:16PM +0800, Pan ruochen wrote: > $i=0; ((i++)); echo $? > And the result is > 1 Which means it's supported. > which means an error. http://mywiki.wooledge.org/BashFAQ/105

Fwd: Bash bug interpolating delete characters

2012-05-03 Thread Chet Ramey
--- Begin Message --- Hi, please try the following bash script: a=x del="$(echo -e "\\x7f")" echo "$del${a#x}" | od -ta echo "$del ${a#x}" | od -ta echo " $del${a#x}" | od -ta Using bash 3.2, the output is: 000 del nl 002 000 del sp nl 003 000 sp del nl 003 howeve

Re: Fwd: Bash bug interpolating delete characters

2012-05-03 Thread Greg Wooledge
> Yours, Rüdiger. > a=x > del="$(echo -e "\\x7f")" > > echo "$del${a#x}" | od -ta > echo "$del ${a#x}" | od -ta > echo " $del${a#x}" | od -ta Yup, confirmed that it breaks here, and only when the # parameter expansion is included. imadev:~$ del=$'\x7f' a=x b= imadev:~$ echo " $del$b" | od -ta 0

Re: Fwd: Bash bug interpolating delete characters

2012-05-03 Thread John Kearney
Am 03.05.2012 15:01, schrieb Greg Wooledge: >> Yours, Rüdiger. >> a=x >> del="$(echo -e "\\x7f")" >> >> echo "$del${a#x}" | od -ta >> echo "$del ${a#x}" | od -ta >> echo " $del${a#x}" | od -ta > Yup, confirmed that it breaks here, and only when the # parameter expansion > is included. > > imadev:~$

Re: Fwd: Bash bug interpolating delete characters

2012-05-03 Thread John Kearney
Am 03.05.2012 19:41, schrieb John Kearney: > Am 03.05.2012 15:01, schrieb Greg Wooledge: >>> Yours, Rüdiger. >>> a=x >>> del="$(echo -e "\\x7f")" >>> >>> echo "$del${a#x}" | od -ta >>> echo "$del ${a#x}" | od -ta >>> echo " $del${a#x}" | od -ta >> Yup, confirmed that it breaks here, and only when t

Re: ((i++)) no longer supported?

2012-05-03 Thread Chris F.A. Johnson
On Thu, 3 May 2012, DJ Mills wrote: On Thu, May 3, 2012 at 2:53 AM, Pierre Gaston wrote: On Thu, May 3, 2012 at 9:34 AM, Pan ruochen wrote: Hi All, Suddenly I found that ((i++)) is not supported on bash. Just try the following simple case: $i=0; ((i++)); echo $? And the result is 1 which me

Parallelism a la make -j / GNU parallel

2012-05-03 Thread Colin McEwan
Hi there, I don't know if this is anything that has ever been discussed or considered, but would be interested in any thoughts. I frequently find myself these days writing shell scripts, to run on multi-core machines, which could easily exploit lots of parallelism (eg. a batch of a hundred indepe

Re: Parallelism a la make -j / GNU parallel

2012-05-03 Thread Elliott Forney
Here is a construct that I use sometimes... although you might wind up waiting for the slowest job in each iteration of the loop: maxiter=100 ncore=8 for iter in $(seq 1 $maxiter) do startjob $iter & if (( (iter % $ncore) == 0 )) then wait fi done On Thu, May 3, 2012 at 12:49 PM,

Re: Parallelism a la make -j / GNU parallel

2012-05-03 Thread Colin McEwan
Indeed, I've used variations of most of these in the past. :) My contention is that this is the sort of thing that more people will want to do more frequently, and that this is a reasonable argument in favour of including the functionality *correctly* in the core language for maximum expressive

Re: Parallelism a la make -j / GNU parallel

2012-05-03 Thread Greg Wooledge
On Thu, May 03, 2012 at 08:45:57PM +0100, Colin McEwan wrote: > My contention is that this is the sort of thing that more people will want to > do more frequently, and that this is a reasonable argument in favour of > including the functionality *correctly* in the core language for maximum > expres

Re: Parallelism a la make -j / GNU parallel

2012-05-03 Thread John Kearney
I tend to do something more like this function runJobParrell { local mjobCnt=${1} && shift jcnt=0 function WrapJob { "${@}" kill -s USR2 $$ } function JobFinised { jcnt=$((${jcnt}-1)) } trap JobFinised

Re: Parallelism a la make -j / GNU parallel

2012-05-03 Thread Greg Wooledge
On Thu, May 03, 2012 at 10:12:17PM +0200, John Kearney wrote: > function runJobParrell { > local mjobCnt=${1} && shift > jcnt=0 > function WrapJob { > "${@}" > kill -s USR2 $$ > } > function JobFinised { > jcnt=$((${jcn

Re: Parallelism a la make -j / GNU parallel

2012-05-03 Thread John Kearney
Am 03.05.2012 22:30, schrieb Greg Wooledge: > On Thu, May 03, 2012 at 10:12:17PM +0200, John Kearney wrote: >> function runJobParrell { >> local mjobCnt=${1} && shift >> jcnt=0 >> function WrapJob { >> "${@}" >> kill -s USR2 $$ >> } >>

Re: Parallelism a la make -j / GNU parallel

2012-05-03 Thread John Kearney
This version might be easier to follow. The last version was more for being able to issue commands via a fifo to a job queue server. function check_valid_var_name { case "${1:?Missing Variable Name}" in [!a-zA-Z_]* | *[!a-zA-Z_0-9]* ) return 3;; esac } CNiceLevel=$(nice)

Re: Parallelism a la make -j / GNU parallel

2012-05-03 Thread Mike Frysinger
On Thursday 03 May 2012 16:12:17 John Kearney wrote: > I tend to do something more like this > > function runJobParrell { > local mjobCnt=${1} && shift > jcnt=0 > function WrapJob { > "${@}" > kill -s USR2 $$ > } neat trick. all my para

Bash-4.2 Official Patch 25

2012-05-03 Thread Chet Ramey
BASH PATCH REPORT = Bash-Release: 4.2 Patch-ID: bash42-025 Bug-Reported-by:Bill Gradwohl Bug-Reference-ID: Bug-Reference-URL: http://lists.gnu.org/archive/html/help-bash/2012-03/msg00078.html

Bash-4.2 Official Patch 26

2012-05-03 Thread Chet Ramey
BASH PATCH REPORT = Bash-Release: 4.2 Patch-ID: bash42-026 Bug-Reported-by:Greg Wooledge Bug-Reference-ID: <20120425180443.go22...@eeg.ccf.org> Bug-Reference-URL: http://lists.gnu.org/archive/ht

Bash-4.2 Official Patch 27

2012-05-03 Thread Chet Ramey
BASH PATCH REPORT = Bash-Release: 4.2 Patch-ID: bash42-027 Bug-Reported-by:Mike Frysinger Bug-Reference-ID: <201204211243.30163.vap...@gentoo.org> Bug-Reference-URL: http://lists.gnu.org/archive

Bash-4.2 Official Patch 28

2012-05-03 Thread Chet Ramey
BASH PATCH REPORT = Bash-Release: 4.2 Patch-ID: bash42-028 Bug-Reported-by:Mark Edgar Bug-Reference-ID: Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2012-03/msg00109.html Bug