[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unable to dereference function-local nameref to global variable of same
From: |
Andreas Kusalananda Kähäri |
Subject: |
Unable to dereference function-local nameref to global variable of same name |
Date: |
Wed, 10 Aug 2016 18:06:15 +0200 |
User-agent: |
Mutt/1.6.2 (2016-07-01) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: openbsd6.0
Compiler: cc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='openbsd6.0' -DCONF_MACHTYPE='x86_64-unknown-openbsd6.0'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -DUSE_MKTEMP
-DUSE_MKSTEMP -I/usr/local/include -O2 -pipe
uname output: OpenBSD uerfale 6.0 GENERIC.MP#38 amd64
Machine Type: x86_64-unknown-openbsd6.0
Bash Version: 4.3
Patch Level: 46
Release Status: release
Description:
When declaring a variable in a function as a nameref, it can not
be dereferenced if the variable it's a nameref to happen to have
the same name as the nameref itself. This imposes unnecessary
restrictions on the caller.
Also seen in GNU bash, version 4.3.39(1)-release (x86_64-apple-darwin15).
Repeat-By:
function bug {
typeset -n var="$1"
printf "%s\n" "$var"
}
var="hello"
bug var
Result:
bash: warning: var: circular name reference
Expected result: The string "hello" outputted with a terminating
newline (as with ksh93).
- Unable to dereference function-local nameref to global variable of same name,
Andreas Kusalananda Kähäri <=