diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2022-05-11 01:19:49 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2022-05-15 09:19:49 -0400 |
commit | 843f7eb999a9456a2ebccd702b8afb8d832b9457 (patch) | |
tree | ccb7fb51f48c2b3597cbb265e54f12e1cbcca82b | |
parent | 2f8ebc00cd0d8a8efb5efbbe4ab698e917c00de1 (diff) |
sanity checks
-rw-r--r-- | session-common.sh.inc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/session-common.sh.inc b/session-common.sh.inc index 7529b7c..a487cd9 100644 --- a/session-common.sh.inc +++ b/session-common.sh.inc @@ -36,8 +36,12 @@ readonly DEF_TIMEZONE='UTC' ## sanity checks ## -! which dialog &> /dev/null && echo "can not find the \`dialog\` program" && exit -(( $EUID )) && echo "this program requires superuser privilege" && exit +readonly DIALOG_ERR_MSG="ERROR: can not find the \`dialog\` program" +readonly PRIVILEGE_ERR_MSG="ERROR: this program requires superuser privilege" +readonly STATEFILE_ERR_MSG="ERROR: can not write to state file" +which dialog &> /dev/null || ! echo "${DIALOG_ERR_MSG}" || exit +(( ! $EUID )) || ! echo "${PRIVILEGE_ERR_MSG}" || exit +[[ -w "${THIS_DIR}"/.session_state ]] || ! echo "${STATEFILE_ERR_MSG}" || exit ## state helpers ## |