Re: Command substitution and errexit

2012-10-16 Thread Nikolai Kondrashov
On 10/16/2012 03:21 AM, DJ Mills wrote: On Mon, Oct 15, 2012 at 8:08 PM, DJ Mills wrote: while read -r attr state; do if [[ $shellopts = *:"$attr":* ]]; then set -o "$attr" else set +o "$attr" fi done< <(set -o) Erm, correction, that won't work for the first and last value

Re: Command substitution and errexit

2012-10-16 Thread Nikolai Kondrashov
On 10/16/2012 03:08 AM, DJ Mills wrote: Do not use for to iterate over the output of an unquoted command substitution. Well, I wanted to keep it simple in this case. Instead, use a while read loop. See http://mywiki.wooledge.org/DontReadLinesWithFor and http://mywiki.wooledge.org/BashFAQ/001

Re: Command substitution and errexit

2012-10-16 Thread Nikolai Kondrashov
Hi Chet, On 10/16/2012 02:13 AM, Chet Ramey wrote: On 10/15/12 11:23 AM, Nikolai Kondrashov wrote: I've noticed that errexit is disabled inside command substitution. Is this intentional? Yes. It's been that way since bash-1.14. The reasons why are lost in time -- it was 17 years ago, after

Re: Command substitution and errexit

2012-10-16 Thread Greg Wooledge
On Mon, Oct 15, 2012 at 08:08:10PM -0400, DJ Mills wrote: > done < <(set -o) Huh... that's interesting. I wouldn't have expected it, but it turns out you don't "lose" the value of errexit in a process substitution the way you do in a command substitution. imadev:~$ bash -c 'set -e; x=$(set +o);

Re: Command substitution and errexit

2012-10-16 Thread Nikolai Kondrashov
On 10/16/2012 03:16 PM, Greg Wooledge wrote: On Mon, Oct 15, 2012 at 08:08:10PM -0400, DJ Mills wrote: done< <(set -o) Huh... that's interesting. I wouldn't have expected it, but it turns out you don't "lose" the value of errexit in a process substitution the way you do in a command substitu

Clarification needed on signal spec EXIT

2012-10-16 Thread Francis Moreau
Hi, Currently the description of the builtin trap isn't enough regarding the description of the EXIT signal spec, IMHO. It says: "If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from the shell.", and nothing more, unless I'm missing some other points about it somewhere else (that would be un

Re: Clarification needed on signal spec EXIT

2012-10-16 Thread DJ Mills
On Tue, Oct 16, 2012 at 1:26 PM, Francis Moreau wrote: > Hi, > > Currently the description of the builtin trap isn't enough regarding > the description of the EXIT signal spec, IMHO. > > It says: "If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from > the shell.", and nothing more, unless I'm

Re: Clarification needed on signal spec EXIT

2012-10-16 Thread Francis Moreau
Thanks for your prompt answer. On Tue, Oct 16, 2012 at 7:31 PM, DJ Mills wrote: > On Tue, Oct 16, 2012 at 1:26 PM, Francis Moreau > wrote: >> Hi, >> >> Currently the description of the builtin trap isn't enough regarding >> the description of the EXIT signal spec, IMHO. >> >> It says: "If a SIG

Re: Clarification needed on signal spec EXIT

2012-10-16 Thread Bob Proulx
Francis Moreau wrote: > -- > main_cleanup () { echo main cleanup; } > submain_cleanup () { echo sub cleanup; } > > trap main_cleanup EXIT > > task_in_background () { > echo "subshell $BASHPID" > > while :; do > # echo "FOO" > sleep 1 >

Regular expression matching fails with string RE

2012-10-16 Thread carson
Configuration Information [Automatically generated, do not change]: Machine: i386 OS: solaris2.11 Compiler: cc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='solaris2.11' -DCONF_MACHTYPE='i386-pc-solaris2.11' -DCONF_VENDOR='pc' -DLOCALEDIR='/Tools/SunOS_5.11_i86pc_am

Re: Regular expression matching fails with string RE

2012-10-16 Thread Clark WANG
On Wed, Oct 17, 2012 at 5:18 AM, wrote: > > Bash Version: 4.2 > Patch Level: 37 > > Description: > > bash -c 're=".*([0-9])"; if [[ "foo1" =~ ".*([0-9])" ]]; then echo > ${BASH_REMATCH[0]}; elif [[ "bar2" =~ $re ]]; then echo ${BASH_REMATCH[0]}; > fi' > > This should output foo1. It instead outpu

bug-bash@gnu.org

2012-10-16 Thread Linda Walsh
Dan Douglas wrote: On Sunday, October 14, 2012 05:21:05 PM Linda Walsh wrote: Seriously -- why not just fix it? If you think it is broken -- Fix it. This should fix most scripts. case $- in *e*) exec /bin/sh -c 'cat; rm -f "$1"; exit 1' -- "$BASH_SOURCE" <<-"EOF" >&2 Error: Braindam

Re: Regular expression matching fails with string RE

2012-10-16 Thread John Kearney
Am 17.10.2012 03:13, schrieb Clark WANG: > On Wed, Oct 17, 2012 at 5:18 AM, wrote: > >> Bash Version: 4.2 >> Patch Level: 37 >> >> Description: >> >> bash -c 're=".*([0-9])"; if [[ "foo1" =~ ".*([0-9])" ]]; then echo >> ${BASH_REMATCH[0]}; elif [[ "bar2" =~ $re ]]; then echo ${BASH_REMATCH[0]}; >>