macosx has full disk permissions limiting access to certain directories and files. If one app, say iTerm has access but another program does not, say xterm, a bash script might need to check which application can be run with the appropriate permissions.
Look for TERM_PROGRAM