diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2023-12-26 22:30:49 -0500 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2024-03-28 23:13:52 -0400 |
commit | fe9fe581197d17d6738d871a81e2efe31e2630b5 (patch) | |
tree | 3f5cf71d92d5e605bb6ecb66dd9d819394c18c6d | |
parent | 8b92d4f979c0c78e0b80916c15a1871fbd86ab37 (diff) |
conf.sh: add include guard and silence non-existing $SUDO_USER error
-rw-r--r-- | src/lib/conf.sh.in | 6 | ||||
-rw-r--r-- | src/lib/messages.sh | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/conf.sh.in b/src/lib/conf.sh.in index ec3c090..e370e73 100644 --- a/src/lib/conf.sh.in +++ b/src/lib/conf.sh.in @@ -34,10 +34,14 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +# include guard +[[ ! -v _INCLUDE_CONF_SH ]] && readonly _INCLUDE_CONF_SH='' || return 0 + + ## prepare environment ## # define $LIBREUSER -if [[ "$(id -u "${SUDO_USER:-root}")" == 0 ]]; then +if [[ "$(id -u "${SUDO_USER:-root}" 2> /dev/null)" == 0 ]]; then unset SUDO_USER fi LIBREUSER="${SUDO_USER:-$USER}" diff --git a/src/lib/messages.sh b/src/lib/messages.sh index 504a53a..d833c9d 100644 --- a/src/lib/messages.sh +++ b/src/lib/messages.sh @@ -35,8 +35,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -[[ -z ${_INCLUDE_MESSAGES_SH:-} ]] || return 0 -_INCLUDE_MESSAGES_SH=true +# include guard +[[ ! -v _INCLUDE_MESSAGES_SH ]] && readonly _INCLUDE_MESSAGES_SH='' || return 0 ################################################################################ |