diff --git a/scripts/get_basis.sh b/scripts/get_basis.sh index ec07aa6d..1e969d5c 100755 --- a/scripts/get_basis.sh +++ b/scripts/get_basis.sh @@ -8,6 +8,8 @@ # Prints in stdout the name of a temporary file containing the basis set. # + + if [[ -z ${QP_ROOT} ]] then print "The QP_ROOT environment variable is not set." @@ -15,6 +17,7 @@ then exit -1 fi + export EMSL_API_ROOT="${QP_ROOT}"/install/emsl tmpfile="$1" diff --git a/scripts/save_current_mos.sh b/scripts/save_current_mos.sh index 4ad81e93..3a0d7e56 100755 --- a/scripts/save_current_mos.sh +++ b/scripts/save_current_mos.sh @@ -4,6 +4,9 @@ # directory, where xxx is the corresponding mo_label. # Wed Apr 2 14:35:15 CEST 2014 +set -u # Crashes if a variable is uninitialized +set -e # Exits if any statement returns a non-true return value + if [[ -z ${QP_ROOT} ]] then print "The QP_ROOT environment variable is not set." @@ -11,40 +14,40 @@ then exit -1 fi -EZFIO=$1 +EZFIO="$1" -if [[ -z ${EZFIO} ]] +if [[ -z "${EZFIO}" ]] then echo "Error in $0" exit 1 fi -if [[ ! -f ${EZFIO}/mo_basis/mo_label ]] +if [[ ! -f "${EZFIO}/mo_basis/mo_label" ]] then LABEL='no_label' else - LABEL=$(head -1 ${EZFIO}/mo_basis/mo_label) + LABEL=$(head -1 "${EZFIO}/mo_basis/mo_label") fi DESTINATION="save/mo_basis/${LABEL}" -cd ${EZFIO} +cd "${EZFIO}" if [[ ! -d save/mo_basis ]] then mkdir -p save/mo_basis fi -BACKUP=${DESTINATION}.old -if [[ -d ${BACKUP} ]] +BACKUP="${DESTINATION}.old" +if [[ -d "${BACKUP}" ]] then - rm -rf ${BACKUP} + rm -rf "${BACKUP}" fi -if [[ -d ${DESTINATION} ]] +if [[ -d "${DESTINATION}" ]] then - mv ${DESTINATION} ${BACKUP} + mv "${DESTINATION}" "${BACKUP}" fi -cp -r mo_basis ${DESTINATION} +cp -r mo_basis "${DESTINATION}"