Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in alias expansion



On Nov 15,  8:03pm, Peter Stephenson wrote:
}
} On Fri, 13 Nov 2015 13:03:52 -0500
} Kynn Jones <kynnjo@xxxxxxxxx> wrote:
} > % typeset -A frobozz
} > % alias -g foo='echo xyz'
} > % frobozz[$(foo)]=9
} > zsh: not an identifier: frobozz[$(fooech9
} 
} This is somewhere in the vicinity of parse_subscript().  That's called
} both from isident() and getindex(); I got as far as the case called from
} isident(), but it may be the second one gets called, too.

[...]

} I don't know why this works in other contexts.

When called from "typeset frobozz[$(foo)]=9" the ($foo) has been expanded
before parse_subscript() is called the first time [via isident()]:

Breakpoint 1, parse_subscript (s=0xb7d919e8 "xyz]", sub=1, endchar=93)
    at ../../zsh-5.0/Src/lex.c:1620

When called as a plain assignment without the "typeset" keyword, $(foo)
has not yet been expanded:

Breakpoint 1, parse_subscript (s=0xb7d917f8 "$(foo)]", sub=1, endchar=93)
    at ../../zsh-5.0/Src/lex.c:1620

This call is originating from addvars():

#0  parse_subscript (s=0xb7d91820 "$(foo)]", sub=1, endchar=93)
    at ../../zsh-5.0/Src/lex.c:1620
#1  0x080b2334 in isident (s=0xb7d91818 "frobozz[$(foo)]")
    at ../../zsh-5.0/Src/params.c:1078
#2  0x080b6660 in assignsparam (s=0xb7d91818 "frobozz[$(foo)]", 
    val=0x88bbdf0 "9", flags=0) at ../../zsh-5.0/Src/params.c:2741
#3  0x08078342 in addvars (state=0xbfe30f70, pc=0xb7d917a8, addflags=0)
    at ../../zsh-5.0/Src/exec.c:2348
#4  0x08074dff in execsimple (state=0xbfe30f70)
    at ../../zsh-5.0/Src/exec.c:1118

So the real question may be, how did we get as far as execsimple()
without having expanded all the aliases first?



Messages sorted by: Reverse Date, Date, Thread, Author