bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BASH_COMMAND is incorrect when working with subshells and error trap


From: Chet Ramey
Subject: Re: BASH_COMMAND is incorrect when working with subshells and error traps
Date: Wed, 22 Aug 2012 20:44:30 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:14.0) Gecko/20120713 Thunderbird/14.0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/22/12 3:35 PM, Mike Frysinger wrote:
> On Wednesday 22 August 2012 12:30:11 Mike Frysinger wrote:
>> consider this simple code:
>>
>> $ cat test.sh
>> #!/bin/bash
>> trap 'echo $BASH_COMMAND; exit 1' ERR
>> set -e
>> true
>> (false)
>> true
>>
>> when run, we see:
>> $ ./test.sh
>> true 1
> 
> err, i tweaked my shell script slightly so this output would not be 
> ambiguous, 
> but forgot to post the updated shell script.
> 
> #!/bin/bash
> trap 'echo $BASH_COMMAND; exit 1' ERR
> set -e
> true 1
> (false)
> true 2
> -mike

Thanks for the report.  This will be fixed for the next bash version.

Chet

- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlA1fOMACgkQu1hp8GTqdKvXkACfUXigH7aqdk/hOgYWPwxqP65/
MDIAnRhAr4jsW7UkWeXikv/bfIhj8x0z
=rHgq
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]