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

Re: zkbd fails: must be run as a function or shell script, not sourced



On Mar 13,  9:27pm, Frank Terbeck wrote:
}
} The zkbd function currently fails to start. In particular, it seems to
} be the following test (I don't actually understand how that test works
} at all :-):
} 
} [snip]
} [[ -o interactive ]] && {
}     local -i ARGC
}     (ARGC=0) 2>/dev/null || {
}         print -u2 ${0}: must be run as a function or shell script, not sourced
}         return 1
}     }
} }
} [snap]

If you remove the "2>/dev/null" you get the error message:

zkbd:5: read-only variable: ARGC

The trick here is that, at the top level of the shell, declaring ARGC to
be local is a no-op.  Inside a function, however, declaring it local is
creating a new parameter, which should lose its read-only-ness.  Somehow
ARGC has lost the PM_HIDE attribute.

Changing "local -i ARGC" to "local -ih ARGC" to explicitly hide the
special-ness of ARGC will make zkbd work again, but I am puzzled as to
why it suddenly became necessary to include "-h".  The call signature
of load_module() changed a bit and consequently so did module.c, but
I can't see how that would have changed the way the builtin special
parameters are created; the IPDEF1 macro and its usage for ARGC have
not changed in quite some time.

So although I say "lost PM_HIDE", in point of fact I don't know how it
had PM_HIDE in the first place.



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