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

Running dynamic zsh from the build directory



For a very long time I've been building two versions of zsh, one with
dynamic linkage to be installed and one with static linkage that I can
run straight from the build directory,  This is imperfect as the wrong
fpath is used, and I finally decided to figure out how to run a dynamic
zsh binary straight from the build tree without installing the .so files.
(It used to work just to set module_path, but that was before all the
modules became named zsh/whatever and began insisting that they hide in
a directory named zsh relative to the module_path.)

What I came up with is below, but I also encountered a couple of problems.

The first is that with FUNCTION_ARGZERO set, there's no way to get at the
original $0 from inside a function or `source'd file.  I wanted to modify
module_path and fpath only when [[ $0 = ./Src/zsh ]], but $0 is always the
name of the function/file that caused FUNCTION_ARGZERO to become unset.

Then, having reset fpath, I wanted to go on to module_path only if the
shell was dynamically linked; but (as mentioned in another message) I
found that $+module_path doesn't work as advertised for static shells.
That one caused me a lot of confusion before I thought to check it.

Last, I found that parameter autoloads respect aliased module names, but
loading builtins does not.  So I had to throw out all the -ab dependencies
and re-assert them with the "zsh/" deleted.

Finally I ended up with this (the %-^[1-9]* has to do with my naming
convention for build directories when separate from the source, and the
_*(N:h) is to eliminate CVS subdirectories without using extendedglob):

----------
# Run zsh from the build directory with dynamic module loading

[[ $(ps $$) = *([[:space:]]|./)Src/zsh(|[[:space:]]*) ]] || return

typeset -U fpath
fpath=(${PWD%-[^1-9]*}/{Completion{,/**/_*(N:h)},Functions/{Misc,Prompts}}
       $fpath)

so=(Src/{Builtins,Modules,Zle}/*.so(Nx:t:s/.so/))
(( $#so )) || { unset so; return }

module_path=($PWD/Src/{Builtins,Modules,Zle})
dab="${$(zmodload -Ld;zmodload -Lab):fs,zsh/,}"
for m in $so
do
    zmodload -ubi $m
    zmodload -ud zsh/$m
done
for m in $so
do
    zmodload -ui zsh/$m
    zmodload -A zsh/$m=$m
done
eval $dab
unset m so dab
----------


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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