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

Re: [ksh emulation] zle and bindkey commands not available when called from /etc/kshrc



On Thu, 10 Sep 2009 11:37:24 +0200
"Tristan TERPELLE" <tristan.terpelle@xxxxxxxxxxxxxxx> wrote:
> When I use zsh' ksh emulation mode, the following lines in /etc/kshrc
> result in errors:
> 
> autoload -Uz edit-command-line
> zle -N edit-command-line
> bindkey -M vicmd 'v' edit-command-line
> 
> The errors are:
> 
> /etc/kshrc:4: command not found: zle
> /etc/kshrc:5: command not found: bindkey
> /etc/kshrc:4: command not found: zle
> /etc/kshrc:5: command not found: bindkey
> /etc/kshrc:4: command not found: zle
> /etc/kshrc:5: command not found: bindkey

When it starts up in ksh emulation, zsh doesn't arrange to load modules
with its own extensions automatically when they are accessed by command
names, so that the names of the builtins don't clash.  It's probably worth
pointing out that zsh isn't really designed to do it's own clever
extensions in other emulations---they're there as an alternative, to make
it easier to use stuff written for other shells.  So you're going a bit
beyond the design criteria.  However, there are usually ways of fixing
things up.

For an interactive shell you can load the zle module by hand:

zmodload zsh/zle

(if you have an older version of zsh, not a recent 4.3 release, use
"zmodload -i zsh/zle" to avoid an error if the module was already loaded).
This is slightly simpler than the code it's replacing, actually, which
would mark the command zle and bindkey for autoloading---however, if you're
about to call the commands anyway, that's pointless.

You might encounter similar problems with completion, if you're using
that, and need to load the modules zsh/complete and zsh/computil.  I'm not
sure how well the completion system is set up to be called from ksh
emulation.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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