I want to do:
foo || pwd
So as foo command fails I need just to get the second output pwd but I dont want the line No command 'foo' found, did you mean....
How can I do it? thanks
You need to redirect the STDERR output of foo to /dev/null so you don't see the errors.
foo 2>/dev/null || pwd
command_not_found_handle hook which runs in place of the missing command, rather than from the shell that spawns the command.