one
two
three
declare -n fee="flip"
declare -n foo="bar"
turning off nameref attribute on foo
bar
after +n foo bar = other
one
two
one
expect <one>
argv[1] = <one>
expect <two>
argv[1] = <two>
expect <one>
one
expect <one>
one
expect <one>
argv[1] = <one>
changevar: expect <two>
argv[1] = <two>
expect <two>
argv[1] = <two>
changevar: expect <three four five>
argv[1] = <three four five>
expect <three four five>
argv[1] = <three four five>
./nameref.tests: line 93: foo: readonly variable
./nameref.tests: line 94: foo: readonly variable
one
one
./nameref.tests: line 106: foo: readonly variable
./nameref.tests: line 103: foo: readonly variable
one
abxde
abxde
one
bar

./nameref2.sub: line 5: foo: readonly variable

expect <unset>
argv[1] = <unset>
expect <unset>
argv[1] = <unset>
expect <bar>
argv[1] = <bar>
expect <unset>
argv[1] = <unset>
./nameref3.sub: line 21: unset: bar: cannot unset: readonly variable
expect <two>
two
expect <two>
two
three
unset
four
0
expect <a b>
a b
expect <foo>
foo
1 3 5 7 9
9
1 3 42 7 9
1 3 42 7 9
9
1 3 44 7 9
unset
expect <a b c d e>
argv[1] = <a b c d e>
expect <zero> <one> <seven> <three> <four>
argv[1] = <zero>
argv[2] = <one>
argv[3] = <seven>
argv[4] = <three>
argv[5] = <four>
16
expect <4>
4
expect <4>
4
expect <4>
4
expect <one>
one
expect <one>
one
expect <one>
one
expect <four>
four
errors = 0
1
2
v1: 1
v2: 2
ref -> first, value: I am first
ref -> second, value: I am in the middle
ref -> third, value: I am last
final state: ref -> third, value: I am last
ref -> one, value: 1
ref -> two, value: 2
ref -> three, value: 3
final state: ref -> three, value: 3
./nameref5.sub: line 43: unset: three: cannot unset: readonly variable
ref -> one, value: 1
ref -> two, value: 2
ref -> three, value: 3
final state: ref -> three, value: 3
./nameref6.sub: line 2: typeset: x: nameref variable self references not allowed
./nameref6.sub: line 5: typeset: x[3]: reference variable cannot be an array
./nameref6.sub: line 12: typeset: x: reference variable cannot be an array
the -- 1
42 -- 0
y -- 0
2 -- 0
2 -- 0
y -- 0
bar
unset
./nameref8.sub: line 3: typeset: warning: v: circular name reference
./nameref8.sub: line 3: warning: v: circular name reference
./nameref8.sub: line 5: warning: v: circular name reference
inside
inside: two
outside:
./nameref8.sub: line 29: typeset: warning: x: circular name reference
./nameref8.sub: line 29: warning: x: circular name reference
./nameref8.sub: line 31: warning: x: circular name reference
foo
./nameref8.sub: line 38: typeset: warning: v: circular name reference
./nameref8.sub: line 38: warning: v: circular name reference
./nameref8.sub: line 38: warning: v: circular name reference
local
./nameref8.sub: line 47: typeset: v: nameref variable self references not allowed
./nameref8.sub: line 54: warning: x: circular name reference
./nameref8.sub: line 55: warning: x: circular name reference
x =
idx2
idX2
idx2
idX2
declare -n foo="x[\$zero]"
42
declare -a x=([0]="4")
declare -n foo="x[\$(echo 0)]"
4
comsub
x[i=0]
comsub
4
comsub
4
comsub
4
declare -n foo="somevariable"
./nameref10.sub: line 38: typeset: somevariable: not found
foo =
declare -n foo="somevariable"
declare -A somevariable=([jug]="brown" )
declare -n foo="somevariable"
declare -A somevariable=([jug]="brown" )
declare -n foo="somevariable"
./nameref10.sub: line 49: typeset: somevariable: not found
./nameref10.sub: line 51: typeset: foo: not found
./nameref10.sub: line 51: typeset: somevariable: not found
declare -n foo="bar"
./nameref10.sub: line 55: typeset: bar: not found
declare -n foo="bar"
./nameref10.sub: line 57: typeset: bar: not found
declare -n foo="bar"
declare -i bar="8"
8
declare -n foo="bar"
./nameref10.sub: line 64: typeset: bar: not found
./nameref11.sub: line 1: declare: `/': invalid variable name for name reference
./nameref11.sub: line 2: declare: `/': invalid variable name for name reference
./nameref11.sub: line 3: `/': not a valid identifier
./nameref11.sub: line 4: declare: `/': not a valid identifier
./nameref11.sub: line 5: `/': not a valid identifier
1) /
#? ./nameref11.sub: line 6: `/': not a valid identifier
x

./nameref11.sub: line 7: ((: `0': not a valid identifier
./nameref11.sub: line 8: declare: `0': invalid variable name for name reference
./nameref11.sub: line 9: declare: `/': invalid variable name for name reference
./nameref11.sub: line 10: declare: `/': invalid variable name for name reference
/
./nameref11.sub: line 12: `/': not a valid identifier
./nameref11.sub: line 13: exec: `10': not a valid identifier
./nameref11.sub: line 13: r: cannot assign fd to variable
./nameref11.sub: line 14: warning: r: removing nameref attribute
63
./nameref11.sub: line 15: declare: RO: readonly variable
./nameref11.sub: line 15: RO: readonly variable
./nameref11.sub: line 16: declare: `/': invalid variable name for name reference
/
./nameref11.sub: line 17: declare: `/': invalid variable name for name reference
./nameref11.sub: illegal option -- h
./nameref11.sub: line 18: getopts: `?': not a valid identifier
./nameref11.sub: line 19: warning: r: removing nameref attribute
declare -a r=()
./nameref11.sub: line 20: declare: r: reference variable cannot be an array
./nameref11.sub: line 21: printf: `/': not a valid identifier
./nameref11.sub: line 23: `': not a valid identifier
./nameref11.sub: line 24: declare: `': not a valid identifier
./nameref11.sub: line 25: `': not a valid identifier
./nameref11.sub: line 26: printf: `': not a valid identifier
./nameref11.sub: line 27: declare: `': invalid variable name for name reference
declare -r ROVAR="42"
./nameref11.sub: line 32: ROVAR: readonly variable
./nameref11.sub: line 32: ROVAR: cannot unset: readonly variable
declare -r ROVAR="42"
./nameref11.sub
./nameref11.sub: line 34: `@': not a valid identifier
./nameref11.sub
declare -n ref="x"
./nameref11.sub: line 39: RO: readonly variable
declare -r RO_PID
./nameref11.sub: line 39: RO: cannot unset: readonly variable
declare -r RO="x"
./nameref11.sub: line 39: declare: RO_PID: not found
./nameref11.sub: line 41: RO2: readonly variable
declare -r RO2="a"
./nameref12.sub: line 6: declare: `/': invalid variable name for name reference
./nameref12.sub: line 9: declare: `%': invalid variable name for name reference
./nameref12.sub: line 13: `^': not a valid identifier
declare -n r
declare -a foo
declare -a foo=([0]="7")
./nameref12.sub: line 26: declare: `42': not a valid identifier
./nameref12.sub: line 27: declare: x: not found
declare -nr RO="foo"
/
./nameref12.sub: line 45: declare: `7*6': not a valid identifier
./nameref12.sub: line 45: declare: foo: not found
./nameref12.sub: line 47: `7*6': not a valid identifier
declare -n ref="var"
declare -n ref="var"
./nameref12.sub: line 74: readonly: `var[0]': not a valid identifier
declare -- var="foo"
declare -r var2="foo"
declare -n ref="var"
declare -a var=([0]="foo")
./nameref12.sub: line 91: `': not a valid identifier
declare -n ref
declare -- ref="global"
declare -a var=([0]="foo2")
./nameref12.sub: line 100: declare: global: not found
declare -- a
declare -n r="a"
declare -- a
declare -n r="a"
0
declare -n r="P"
declare -n ref="var"
declare -- a
declare -n r="a"
0
declare -n r
declare -n r
./nameref13.sub: line 88: typeset: `12345': invalid variable name for name reference
declare -n foo
./nameref13.sub: line 97: typeset: `12345': invalid variable name for name reference
declare -n foo
declare -nx ref="var"
var
var
var
var
foo
foo
foo
foo
before
declare -n ref="var"
./nameref14.sub: line 23: typeset: var: not found
first
declare -n ref="var"
declare -x var="xxx"
invalid
declare -n ref="var"
declare -x var="5"
after
declare -n ref="var"
./nameref14.sub: line 32: typeset: var: not found
declare -n ref="var"
./nameref15.sub: line 1: local: warning: a: circular name reference
./nameref15.sub: line 1: warning: a: circular name reference
./nameref15.sub: line 1: `a[0]': not a valid identifier
declare -a a=([0]="0")
./nameref15.sub: line 1: local: warning: a: circular name reference
./nameref15.sub: line 1: warning: a: circular name reference
./nameref15.sub: line 1: warning: a: circular name reference
declare -a a=([0]="X")
declare -a b=([0]="X")
./nameref15.sub: line 1: local: warning: a: circular name reference
./nameref15.sub: line 1: warning: a: circular name reference
./nameref15.sub: line 1: `a[0]': not a valid identifier
declare -a b=([0]="0")
./nameref15.sub: line 19: typeset: warning: ref: circular name reference
./nameref15.sub: line 19: warning: ref: circular name reference
./nameref15.sub: line 20: warning: ref: circular name reference
./nameref15.sub: line 21: warning: ref: circular name reference
inside
outside X
./nameref15.sub: line 29: typeset: ref: nameref variable self references not allowed
./nameref15.sub: line 31: ref: nameref variable self references not allowed
declare -n ref="re"
declare -n ref="re"
declare -- re="4"
4
declare -n foo="var[@]"
declare -n ref="var[@]"
./nameref15.sub: line 48: var[@]: bad array subscript
declare -n bar="var[@]"
./nameref15.sub: line 53: var[@]: bad array subscript
declare -n a="b"
declare -n b="a[1]"
./nameref15.sub: line 61: warning: a: removing nameref attribute
declare -a a=([1]="foo")
declare -n b="a[1]"
./nameref15.sub: line 66: warning: a: removing nameref attribute
declare -a a=([1]="foo")
declare -n b="a[1]"
declare -n n="v"
declare -a v=([1]="1")
./nameref15.sub: line 82: typeset: n: not found
declare -a v=([0]="0" [1]="1")
declare -n n="v[1]"
declare -a v=([0]="0")
declare -n r1="y"
declare -n r2="x"
./nameref16.sub: line 12: typeset: x: not found
./nameref16.sub: line 12: typeset: y: not found
declare -n r1="y"
declare -n r2="x"
./nameref16.sub: line 21: typeset: x: not found
./nameref16.sub: line 21: typeset: y: not found
declare -n r1="y"
declare -n r2="x"
./nameref16.sub: line 33: typeset: x: not found
./nameref16.sub: line 33: typeset: y: not found
declare -n r1="y"
declare -n r2="x"
declare -- x="one"
declare -- y="two"
./nameref17.sub: line 8: declare: bar: not found
./nameref17.sub: line 9: unset: foo0: cannot unset: readonly variable
declare -nr foo0="bar"
declare -nr foo0="bar"
declare -- bar
./nameref17.sub: line 14: declare: foo0: readonly variable
./nameref17.sub: line 15: declare: foo0: readonly variable
declare -nr foo1
./nameref17.sub: line 24: typeset: foo1: readonly variable
declare -nr foo1
declare -n foo2="bar"
declare -r bar
./nameref17.sub: line 35: bar: readonly variable
./nameref17.sub: line 36: typeset: bar: readonly variable
declare -n foo2="bar"
declare -r bar
declare -- bar3="three"
./nameref17.sub: line 46: unset: foo3: cannot unset: readonly variable
./nameref17.sub: line 49: declare: bar3: readonly variable
declare -nr foo3="bar3"
declare -r bar3="three"
./nameref17.sub: line 51: declare: foo3: readonly variable
declare -nr foo4="bar4"
declare -- bar4="four"
./nameref17.sub: line 63: typeset: foo4: readonly variable
declare -nr foo4="bar4"
declare -nr foo4="bar4"
declare -- bar4="four"
./nameref17.sub: line 79: typeset: foo4: readonly variable
declare -nr foo4="bar4"
declare -nr foo4="bar4"
declare -- bar4="four"
declare -nr foo5
declare -r foo5
declare -nr foo5
declare -r foo5
./nameref18.sub: line 2: mapfile: `XXX[0]': not a valid identifier
./nameref18.sub: line 3: declare: XXX[0]: not found
./nameref18.sub: line 9: `XXX[0]': not a valid identifier
./nameref18.sub: line 10: declare: XXX[0]: not found
declare -n ref="XXX[0]"
declare -a XXX=([0]="4")
./nameref18.sub: line 24: `XXX[0]': not a valid identifier
declare -n ref="XXX[0]"
./nameref18.sub: line 25: declare: XXX[0]: not found
./nameref18.sub: line 29: read: `XXX[0]': not a valid identifier
./nameref18.sub: line 30: declare: XXX[0]: not found
./nameref18.sub: line 35: `XXX[0]': not a valid identifier
declare -n ref="XXX[0]"
./nameref18.sub: line 38: `XXX[0]': not a valid identifier
./nameref18.sub: line 38: declare: XXX[0]: not found
declare -n ref="var[123]"
./nameref18.sub: line 46: declare: var[123]: not found
declare -a var=([123]="")
declare -n ref="var[123]"
./nameref18.sub: line 50: declare: var[123]: not found
declare -a var=([123]="")
declare -n ref="var[123]"
./nameref18.sub: line 54: declare: var[123]: not found
declare -a var=([123]="X")
