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

Re: _main_complete:343: bad pattern: a[



On 22 November 2009 19:22, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> % zsh -f
> % autoload -U compinit; compinit
> % $a[[<tab>
> _main_complete:343: bad pattern: a[

There are lots of places in the code that say "bad pattern:", after
adding identifiers to all of them, I found it's this one in glob.c

    if (!q || errflag) {	/* if parsing failed */
	restore_globstate(saved);
	if (unset(BADPATTERN)) {
	    if (!nountok)
		untokenize(ostr);
	    insertlinknode(list, node, ostr);
	    return;
	}
	errflag = 0;
        /* $a[[<tab> */
	zerr("bad pattern: %s", ostr);
	return;
    }

around line 1730. The real weird thing is that this is triggered by
_lastcomp=( "${(@kv)compstate}" )
in _main_complete. Trying to just echo $compstate or variations
thereof fail in the same way. Now of course I'm curious why anything
is trying to match a pattern when accessing a variable. Breaking at
the print shows this backtrace, I realize I have no idea what any of
these functions are for.

I notice also that $a[[]<tab> doesn't produce an error, but then
leaves the [] in place which does produce an error when you run the
command since it's obviously broken syntax.

#0  zglob (list=0x7ffff7fee860, np=0x7ffff7feef88, nountok=0) at glob.c:1736
#1  0x00000000004810c9 in globlist (list=0x7ffff7fee860, nountok=0) at
subst.c:353
#2  0x00000000004299a9 in addvars (state=0x7fffffffc4a0, pc=0x6f2284,
addflags=0)
    at exec.c:2157
#3  0x0000000000426d83 in execsimple (state=0x7fffffffc4a0) at exec.c:1053
#4  0x00000000004270ff in execlist (state=0x7fffffffc4a0,
dont_change_job=1, exiting=0)
    at exec.c:1167
#5  0x0000000000426c88 in execode (p=0x768070, dont_change_job=1, exiting=0,
    context=0x499a0f "loadautofunc") at exec.c:1020
#6  0x000000000042f2f8 in execautofn (state=0x7fffffffcc30, do_exec=0)
at exec.c:4272
#7  0x000000000042ca77 in execcmd (state=0x7fffffffcc30, input=0,
output=0, how=18, last1=2)
    at exec.c:3120
#8  0x000000000042861f in execpline2 (state=0x7fffffffcc30, pcode=3,
how=18, input=0,
    output=0, last1=0) at exec.c:1632
#9  0x0000000000427ad2 in execpline (state=0x7fffffffcc30,
slcode=3074, how=18, last1=0)
    at exec.c:1416
#10 0x0000000000427266 in execlist (state=0x7fffffffcc30,
dont_change_job=1, exiting=0)
    at exec.c:1199
#11 0x0000000000426c88 in execode (p=0x768460, dont_change_job=1, exiting=0,
    context=0x499aa6 "shfunc") at exec.c:1020
#12 0x000000000042fe2f in runshfunc (prog=0x768460, wrap=0x0,
    name=0x7ffff7feb030 "_main_complete") at exec.c:4614
#13 0x00007ffff6b69ecf in comp_wrapper (prog=0x768460, w=0x0,
    name=0x7ffff7feb030 "_main_complete") at complete.c:1455
#14 0x000000000042fd95 in runshfunc (prog=0x768460, wrap=0x7ffff6d87d80,
    name=0x7ffff7feb030 "_main_complete") at exec.c:4599
#15 0x000000000042fb0d in doshfunc (shfunc=0x76aa20, doshargs=0x0,
noreturnval=0)
    at exec.c:4508
#16 0x00007ffff6b6c8a3 in callcompfunc (s=0x7ffff7fef690 "",
fn=0x7a5400 "_main_complete")
    at compcore.c:817
#17 0x00007ffff6b6d17e in makecomplist (s=0x7ffff7fef690 "", incmd=1, lst=0)


-- 
Mikael Magnusson



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