# How a command that cannot be executed is reported, and script fallback. /nonexistent/cmd 2>/dev/null; echo $? nonexistent_cmd_xyz 2>/dev/null; echo $? touch noexec; ./noexec 2>/dev/null; echo $? printf '#!/bin/sh\necho shebang $1\n' >s1; chmod +x s1; ./s1 arg printf 'echo no-shebang $1\n' >s2; chmod +x s2; ./s2 arg mkdir bin; printf '#!/bin/sh\necho from-path\n' >bin/mycmd; chmod +x bin/mycmd; PATH=$PWD/bin:$PATH; mycmd PATH=/nonexistent mycmd 2>/dev/null; echo "path-prefix $?"