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
- X-seq: zsh-workers 24709
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxxxxx>
- Subject: Re: zkbd fails: must be run as a function or shell script, not sourced
- Date: Thu, 13 Mar 2008 16:28:18 -0700
- In-reply-to: <20080313202748.GV30518@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080313202748.GV30518@xxxxxxxxxxxxxxx>
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