Bash one liner - Test if a file exists and source if it does other exit with error
bash, php, testing
Solution
You can use this one liner:
[[ -e "${MY_HOME}/setup-env.sh" ]] && source "${MY_HOME}/setup-env.sh" || { echo "ERROR: MY_HOME not defined or does not contain srtup-env.sh" 1>&2 ; exit 1; }
Problem
In other words I want to make this into a one-liner: ``` test -e ${MY_HOME}/setup-env.sh || { echo "ERROR: MY_HOME not defined or does not contain srtup-env.sh" 1>&2 ; exit 1; } . ${MY_HOME}/setup-env.sh ```