This is more of an academic exercise but curious of the answer. Here is the current code in question:
export original_command_not_found_handler="$(type -f command_not_found_handler)" # original func as string
function command_not_found_handler(){ # my custom override
echo "my custom handler: $@"
echo "
${original_command_not_found_handler}
command_not_found_handler "$@"
" | bash
}
what I am trying to do is override the original zsh function with my custom function and then call the original function from the override.
There are two problems with this code:
- I am trying to call the original function from a subshell (piping to bash), but it would be best to call from the current shell not subshell.
- it doesn't work since the original function is not being interpreted as desired in the string.