helpThe GNU Bourne-Again SHell - Support: sr #110270, corrupted exit code with certain...


sr #110270: corrupted exit code with certain local definitions

Submitter:  None
Submitted:  Thu 16 Jul 2020 12:35:08 PM UTC
Category:  None Priority:  5 - Normal
Severity:  4 - Important Status:  Invalid
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Fri 17 Jul 2020 01:49:27 PM UTC, comment #1: 

This is not a bug. The `local' command successfully performs the variable assignment and its exit status reflects that.

The special case is a command consisting only of variable assignments, which returns as its exit status the status of the last command substitution.

Chet Ramey <chet>
Project Administrator
Thu 16 Jul 2020 12:35:08 PM UTC, original submission:  

I'm sorry if this is an inappropriate place to submit this bug.   The mailing list doesnt work for me.

This bash bug occurs in 5.0.17, 4.2.46 and 3.2.25:


function f() {
   local f=$( false )
   local -i c=$?
   # $c is always incorrectly zero
   echo $c

function g() {
   local f
   f=$( false )
   local -i c=$?
   # $c is correctly set
   echo $c


The unexpected output for me is:
brian@desktop:~$ ./



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.





    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-07-17 chet StatusNone Invalid

    Back to the top

    Powered by Savane 3.9