Re: triggering of ERR trap differs between bash 3.2.39 4.0.28

2009-11-09 Thread Amit Dor-Shifer
Seems like I've erroneously switched between bash versions exhibiting 
the difference. It's 3.2.39 that evaluates 'on_error' when catching the 
trap.


From the start:

# bash-4.0_p28/image/bin/bash --version
GNU bash, version 4.0.28(2)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
http://gnu.org/licenses/gpl.html


This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
# bash-4.0_p28/image/bin/bash -xc 'set -eE;on_error() { echo ERROR 
ERROR; };trap on_error ERR;if [ -n $(echo $0 |grep a) ];then echo 
input contains 'a';fi' b

+ set -eE
+ trap on_error ERR
++ echo b
++ grep a
+ '[' -n '' ']'
# bash-3.2_p39/image/bin/bash --version
GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
# bash-3.2_p39/image/bin/bash -xc 'set -eE;on_error() { echo ERROR 
ERROR; };trap on_error ERR;if [ -n $(echo $0 |grep a) ];then echo 
input contains 'a';fi' b

+ set -eE
+ trap on_error ERR
++ echo b
++ grep a
+++ on_error
+++ echo ERROR ERROR
+ '[' -n 'ERROR ERROR' ']'
+ echo 'input contains a'
input contains a

Amit

Chet Ramey wrote:
Ok. Same here. (4.0.35 is not yet stable on my distro, gentoo, hence I 
quoted results with 4.0.28).



But I can't reproduce it with bash-4.0.28, either:

$ ./bash --version
GNU bash, version 4.0.28(2)-release (i386-apple-darwin9.8.0)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ ./bash -xc 'set -eE;on_error() { echo ERROR ERROR; };trap on_error ERR;if [ -n $(echo $0 
|grep a) ];then echo input contains 'a';fi' a
+ set -eE
+ trap on_error ERR
++ echo a
++ grep a
+ '[' -n a ']'
+ echo 'input contains a'
input contains a
$ ./bash -xc 'set -eE;on_error() { echo ERROR ERROR; };trap on_error ERR;if [ -n $(echo $0 
|grep a) ];then echo input contains 'a';fi' b
+ set -eE
+ trap on_error ERR
++ echo b
++ grep a
+ '[' -n '' ']'


  



Chet Ramey wrote:
Ok. Same here. (4.0.35 is not yet stable on my distro, gentoo, hence I 
quoted results with 4.0.28).



But I can't reproduce it with bash-4.0.28, either:

$ ./bash --version
GNU bash, version 4.0.28(2)-release (i386-apple-darwin9.8.0)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ ./bash -xc 'set -eE;on_error() { echo ERROR ERROR; };trap on_error ERR;if [ -n $(echo $0 
|grep a) ];then echo input contains 'a';fi' a
+ set -eE
+ trap on_error ERR
++ echo a
++ grep a
+ '[' -n a ']'
+ echo 'input contains a'
input contains a
$ ./bash -xc 'set -eE;on_error() { echo ERROR ERROR; };trap on_error ERR;if [ -n $(echo $0 
|grep a) ];then echo input contains 'a';fi' b
+ set -eE
+ trap on_error ERR
++ echo b
++ grep a
+ '[' -n '' ']'


  





Re: triggering of ERR trap differs between bash 3.2.39 4.0.28

2009-11-08 Thread pk
Amit Dor-Shifer wrote:

 I've the following script:
 
 set -eE
 on_error() { echo ERROR ERROR; }
 trap on_error ERR
 
 if [ -n $(echo $1 |grep a) ];then
echo input contains 'a'
 fi
 
 When executed under bash-4, on_error is evaluated as part of the
 expression in the 'if'. This does not happen in 3.2:

I think this is part of the new behavior of -e in bash 4. See for example 
here:

http://www.mail-archive.com/bug-bash@gnu.org/msg06288.html



Re: triggering of ERR trap differs between bash 3.2.39 4.0.28

2009-11-08 Thread Chet Ramey
Amit Dor-Shifer wrote:

 cm.stargate ~ # bash -xc 'set -eE;on_error() { echo ERROR ERROR; };trap
 on_error ERR;if [ -n $(echo $0 |grep a) ];then echo input contains
 'a';fi' b
 + set -eE
 + trap on_error ERR
 ++ echo b
 ++ grep a
 +++ on_error
 +++ echo ERROR ERROR
 + '[' -n 'ERROR ERROR' ']'
 + echo 'input contains a'
 input contains a
 /bash-4

I can't reproduce it with bash-4.0.35:

$ ../bash-4.0-patched/bash -xc 'set -eE;on_error() { echo ERROR ERROR;
};trap on_error ERR;if [ -n $(echo $0 |grep a) ];then echo input
contains 'a';fi' b
+ set -eE
+ trap on_error ERR
++ echo b
++ grep a
+ '[' -n '' ']'
$ ../bash-4.0-patched/bash --version
GNU bash, version 4.0.35(9)-release (i386-apple-darwin10.0.0)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/




Re: triggering of ERR trap differs between bash 3.2.39 4.0.28

2009-11-08 Thread Amit Dor-Shifer
Ok. Same here. (4.0.35 is not yet stable on my distro, gentoo, hence I 
quoted results with 4.0.28).


I'm wondering: CHANGES doesn't refer to any bug numbers or anything. 
Isn't bash using some issue-tracking framework?

I suppose this issue falls under:
quote
l.  Changed behavior of shell when -e option is in effect to reflect 
consensus

   of Posix shell standardization working group.
/quote

Thanks,
Amit



Chet Ramey wrote:

Amit Dor-Shifer wrote:

  

cm.stargate ~ # bash -xc 'set -eE;on_error() { echo ERROR ERROR; };trap
on_error ERR;if [ -n $(echo $0 |grep a) ];then echo input contains
'a';fi' b
+ set -eE
+ trap on_error ERR
++ echo b
++ grep a
+++ on_error
+++ echo ERROR ERROR
+ '[' -n 'ERROR ERROR' ']'
+ echo 'input contains a'
input contains a
/bash-4



I can't reproduce it with bash-4.0.35:

$ ../bash-4.0-patched/bash -xc 'set -eE;on_error() { echo ERROR ERROR;
};trap on_error ERR;if [ -n $(echo $0 |grep a) ];then echo input
contains 'a';fi' b
+ set -eE
+ trap on_error ERR
++ echo b
++ grep a
+ '[' -n '' ']'
$ ../bash-4.0-patched/bash --version
GNU bash, version 4.0.35(9)-release (i386-apple-darwin10.0.0)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.