Is there a way to grab a custom bash command that was not found and do something with it?
3 answers
bash has a callback command_not_found_handle
: http://www.gnu.org/software/bash/manual/bashref.html#Command-Search-and-Execution
There is information here about this answer on askubuntu.com about messy default usage.
+5
source to share
From the bash man page,
* If the search is unsuccessful, the shell looks for a specific shell named command_not_found_handle. If this function exists, it is called with the original command and the original command arguments as its arguments, and the exit status of the function becomes the shell exit status. If this function is not defined, the shell prints an error message and returns an exit status of 127. *
I also found this article on this subject,
+1
source to share