bug-bash
[Top][All Lists]
Advanced

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

Assignments to FUNCNAME break FUNCNAME


From: Arfrever Frehtes Taifersar Arahesis
Subject: Assignments to FUNCNAME break FUNCNAME
Date: Sat, 29 Nov 2014 01:53:22 +0100
User-agent: KMail (GNU/Linux)

Manual of BASH claims:
"Assignments to FUNCNAME have no effect and return an error status."

However assignments to FUNCNAME actually break FUNCNAME.
I use BASH 4.3.30.


Variant with "local":

$ A() { echo A; declare -p FUNCNAME; local FUNCNAME=(); }
$ B() { echo B; declare -p FUNCNAME; }
$ A
A
declare -a FUNCNAME='([0]="A")'
bash: FUNCNAME: variable may not be assigned value
$ A
A
declare -a FUNCNAME='([0]="A" [1]="A")'
bash: FUNCNAME: variable may not be assigned value
$ A
A
declare -a FUNCNAME='([0]="A" [1]="A" [2]="A")'
bash: FUNCNAME: variable may not be assigned value
$ B
B
declare -a FUNCNAME='([0]="B" [1]="A" [2]="A" [3]="A")'
$ A
A
declare -a FUNCNAME='([0]="A" [1]="A" [2]="A" [3]="A")'
bash: FUNCNAME: variable may not be assigned value
$ B
B
declare -a FUNCNAME='([0]="B" [1]="A" [2]="A" [3]="A" [4]="A")'
$ 


Variant without "local":

$ A() { echo A; declare -p FUNCNAME; FUNCNAME=(); }
$ B() { echo B; declare -p FUNCNAME; }
$ A
A
declare -a FUNCNAME='([0]="A")'
$ A
A
declare -a FUNCNAME='([0]="A" [1]="A")'
$ A
A
declare -a FUNCNAME='([0]="A" [1]="A" [2]="A")'
$ B
B
declare -a FUNCNAME='([0]="B" [1]="A" [2]="A" [3]="A")'
$ A
A
declare -a FUNCNAME='([0]="A" [1]="A" [2]="A" [3]="A")'
$ B
B
declare -a FUNCNAME='([0]="B" [1]="A" [2]="A" [3]="A" [4]="A")'
$ 


Also is it intentional that code after attempt of assignment to FUNCNAME is not 
run?
The sentence in manual could be interpreted as simply setting $? to non-zero 
value and still running subsequent code.

$ A() { echo A; local FUNCNAME=(); echo AAA; }   
$ A
A
bash: FUNCNAME: variable may not be assigned value
$

--
Arfrever Frehtes Taifersar Arahesis

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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