# A script that cannot be read is an error, not an empty script. "$TSH" /nonexistent/x >/dev/null 2>&1; echo "missing $?" "$TSH" /nonexistent/x >/dev/null 2>msg; cat msg "$TSH" /tmp >/dev/null 2>&1; echo "dir $?" "$TSH" /tmp >/dev/null 2>msg; cat msg # root can read anything; only test the permission denied case as a user. if [ "$(id -u)" != 0 ]; then echo 'echo hi' >unreadable.sh chmod 000 unreadable.sh "$TSH" unreadable.sh >/dev/null 2>&1; echo "unreadable $?" chmod 644 unreadable.sh fi