Sample Header Ad - 728x90

How to alias a function and call from function with original name

3 votes
1 answer
525 views
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: 1. 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. 2. it doesn't work since the original function is not being interpreted as desired in the string.
Asked by Alexander Mills (10744 rep)
Feb 20, 2022, 11:53 PM
Last activity: Feb 21, 2022, 06:53 AM