In bash I can do:
#!/bin/bash
validate() {
if [[ "$BASH_COMMAND" == whoami ]]; then
return 1
else
return 0
fi
}
set -T
trap 'validate' DEBUG
shopt -s extdebug
so that if I run whoami nothing happens.
How can I achieve the same in zsh ? I've looked at preexec but I couldn't find much information in the documentation
bashtoo) to usewhoami () { false; }?whoami() falsewould be enough. In Korn-like shells including bash and zsh, you can also dowhoami() ((0))whoami()(())or in zsh:whoami(){!})whoamiwas only for illustration purposes. it was the first command I could think of