Since we know that the program works in bash, one solution - instead of "hiding" the program - is to emulate the behavior of bash in this case. We can find out what bash does when a command is not found quite easily:
$ bash $ not-a-command > stdout 2> stderr $ echo $? 127 $ cat stdout $ cat stderr bash: not-a-command: command not found
Then we can write this behavior in a script with an executable name, for example git in the example:
$ echo 'echo >&2 "bash: git: command not found" && exit 127' > git $ chmod +x git $ PATH="$PWD:$PATH" git $ echo $? 127 $ cat stdout $ cat stderr bash: git: command not found
source share