bug-bash
[Top][All Lists]
Advanced

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

Is this the expected behaviour for nameref in Bash 4.4 now?


From: kjkuan
Subject: Is this the expected behaviour for nameref in Bash 4.4 now?
Date: Thu, 20 Oct 2016 11:45:48 -0700 (PDT)
User-agent: G2/1.0

set -x

var_123=123
f() {
    while (( $# )); do
        shift
        local var=var_123
        local -n var=$var; : status is $?
        local -p
        : var is $var
    done
}

f one two


Running above script gives the follow output:

+ var_123=123
+ f one two
+ ((  2  ))
+ shift
+ local var=var_123
+ local -n var=var_123
+ : status is 0
+ local -p
var=var_123
+ : var is 123
+ ((  1  ))
+ shift
+ local var=var_123
+ local -n var=123
./x.sh: line 10: local: `123': invalid variable name for name reference
+ : status is 1
+ local -p
var=var_123
+ : var is 123
+ ((  0  ))


With Bash 4.3 the output is:

+ var_123=123
+ f one two
+ ((  2  ))
+ shift
+ local var=var_123
+ local -n var=var_123
+ : status is 0
+ local -p
var=var_123
+ : var is 123
+ ((  1  ))
+ shift
+ local var=var_123
+ local -n var=var_123
+ : status is 0
+ local -p
var=var_123
+ : var is 123
+ ((  0  ))


Thanks
Jack


reply via email to

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