Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14776

Re: The builtin array variable 'FUNCNAME' is considered unset by many expansions, even when set.

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: The builtin array variable 'FUNCNAME' is considered unset by many expansions, even when set.
Date 2018-11-08 08:27 -0500
Message-ID <mailman.3644.1541683671.1284.bug-bash@gnu.org> (permalink)
References <CAN6vQO8zM7DwE2ftcy2vRTKQxPAKrf9LaQ3EPfaNRGpVjdg+zg@mail.gmail.com>

Show all headers | View raw


On Thu, Nov 08, 2018 at 01:15:56AM -0500, Great Big Dot wrote:
> Description:
> The builtin array variable FUNCNAME (which provides a way to trace the
> stack of functions called so far) appears to be unset according to certain
> bash expansions, even when it isn't. If the following code is saved to a
> file and executed (this doesn't work at the command line), the problems
> begin to appear:
> 
>     printf -- '%q\n' "${FUNCNAME}"
>     printf -- '%q\n' "${FUNCNAME[0]}"
>     printf -- '%q\n' "${FUNCNAME[*]}"

I don't see any functions there.  From the manual:

       FUNCNAME
              [...]
              This  variable  exists  only when a shell function is executing.
              Assignments to FUNCNAME have no effect.  If FUNCNAME  is  unset,
              it  loses  its  special  properties,  even if it is subsequently
              reset.

Since your example doesn't show a function being defined or called, I
would expect it to show only empty strings.

Also, as a side note, "${x}" and "${x[0]}" are always the same.  Literally
always.  Doesn't matter what type of variable x is (or isn't).

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: The builtin array variable 'FUNCNAME' is considered unset by many expansions, even when set. Greg Wooledge <wooledg@eeg.ccf.org> - 2018-11-08 08:27 -0500

csiph-web