zsh-users
 help / color / mirror / code / Atom feed
* chpwd, precmd hooks have "zsh" in $0
@ 2021-08-09 20:15 Roman Neuhauser
  2021-08-09 21:26 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Roman Neuhauser @ 2021-08-09 20:15 UTC (permalink / raw)
  To: zsh-users

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-15 21:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 20:15 chpwd, precmd hooks have "zsh" in $0 Roman Neuhauser
2021-08-09 21:26 ` Bart Schaefer
2021-08-10 11:33   ` Roman Neuhauser
2021-08-10 17:31     ` Bart Schaefer
2021-08-12  4:40       ` Roman Neuhauser
2021-08-15 21:10         ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).