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


Groups > gnu.bash.bug > #14778 > unrolled thread

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

Started byGreat Big Dot <greatbigdot@gmail.com>
First post2018-11-08 10:19 -0500
Last post2018-11-08 10:19 -0500
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: The builtin array variable 'FUNCNAME' is considered unset by many expansions, even when set. Great Big Dot <greatbigdot@gmail.com> - 2018-11-08 10:19 -0500

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

FromGreat Big Dot <greatbigdot@gmail.com>
Date2018-11-08 10:19 -0500
SubjectRe: The builtin array variable 'FUNCNAME' is considered unset by many expansions, even when set.
Message-ID<mailman.3653.1541690420.1284.bug-bash@gnu.org>
> Since your example doesn't show a function being defined or called, I
> would expect it to show only empty strings.

Oh yeah, right. For some reason I thought the part about "main" still
applied. But the actual expected behavior doesn't occur either;
"${FUNCNAME[0]}" and "${FUNCNAME[*]}" are both nonempty! I thought
"${FUNCNAME}" was the incorrect one since it alone was empty, but it turns
out that's the only one that's correct.

> 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).

That's what I thought too, before finding this bug. When executing from a
file, "${FUNCNAME[0]}" exists but "${FUNCNAME}" doesn't. I incorrectly
thought the latter was wrong, but the inconsistency is still there!



On Thu, Nov 8, 2018 at 8:28 AM Greg Wooledge <wooledg@eeg.ccf.org> wrote:

> 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).
>
>

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web