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

chpwd, precmd hooks have "zsh" in $0



as the subject says, at least the chpwd and precmd hooks
have the shell's argv[0] in $0.
seen in both zsh-5.8-0-g77d203f
and zsh-5.8-462-g765bc14. put the reproducer below in
argzero.zsh and source it into a fresh shell (zsh -f).
start the shell using its absolute path, that's what you'll
see.

% /usr/local/bin/zsh -f
% . ./argzero.zsh 
ZSH_PATCHLEVEL: zsh-5.8-462-g765bc14
top: nofunctionargzero     off
top: posixargzero          off

precmd output should be below this message.
'cd .' will utilize all three hooks.

precmd: nofunctionargzero     off                                                                        
precmd: posixargzero          off
precmd: /usr/local/bin/zsh <------
% cd .
preexec: nofunctionargzero     off
preexec: posixargzero          off
preexec: preexec <------
chpwd: nofunctionargzero     off
chpwd: posixargzero          off
chpwd: /usr/local/bin/zsh <------
precmd: nofunctionargzero     off                                                                        
precmd: posixargzero          off
precmd: /usr/local/bin/zsh <------

argzero.zsh:

print ZSH_PATCHLEVEL: $ZSH_PATCHLEVEL
set -o > >(sed -n "/argzero/s/^/top: /p")
function chpwd {
  set -o > >(sed -n "/argzero/s/^/chpwd: /p")
  print chpwd: "$0" '<------'
}
function precmd {
  set -o > >(sed -n "/argzero/s/^/precmd: /p")
  print precmd: "$0" '<------'
}
function preexec {
  set -o > >(sed -n "/argzero/s/^/preexec: /p")
  print preexec: "$0" '<------'
}
cat <<EOF

precmd output should be below this message.
'cd .' will utilize all three hooks.

EOF

-- 
roman




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