Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 3a0891f

Browse files
authored
1.1.3 (#12)
* reduced overly-verbose logging * updated readme * set null default for variable to avoid error * set null default for variable to avoid error * changed requireuser to use EUID
1 parent 4b4bc17 commit 3a0891f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The _"Better BASH Library"_: A set of functions to assist with creating well-wri
77
Add this to the top of your BASH script:
88

99
```bash
10-
source <(wget -qO- https://raw.githubusercontent.com/MrDrMcCoy/bblib/1.1.2/bblib.bash)
10+
source <(wget -qO- https://raw.githubusercontent.com/MrDrMcCoy/bblib/1.1.3/bblib.bash)
1111
```
1212

1313
Alternately, clone this repo locally and use `source` with the full path to `bblib.bash`.

bblib.bash

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ log () {
119119
# Send message to logger
120120
if [ "${NUMERIC_SEVERITY}" -le "${NUMERIC_LOGLEVEL}" ] ; then
121121
tr '\n' ' ' <<< "${LOGMSG}" | logger -s -p "user.${NUMERIC_SEVERITY}" -t "${LOGTAG} " |& \
122-
if [ -n "${LOGFILE}" ] ; then
122+
if [ -n "${LOGFILE:-}" ] ; then
123123
tee -a "${LOGFILE}" | pprint ${LOGCOLORS[$NUMERIC_SEVERITY]}
124124
elif [ ! -t 0 ]; then
125125
pprint ${LOGCOLORS[$NUMERIC_SEVERITY]} < /dev/stdin
@@ -182,13 +182,13 @@ requireuser () {
182182
# Checks to see if current user matches $REQUIREUSER and exits if not.
183183
# REQUIREUSER can be set as a variable or passed in as an argument.
184184
# Usage: requireuser [user]
185-
local REQUIREUSER="${1:-$REQUIREUSER}"
186-
if [ -z "$REQUIREUSER" ] ; then
185+
local REQUIREUSER="${1:-${REQUIREUSER:-}}"
186+
if [ -z "${REQUIREUSER:-}" ] ; then
187187
quit "ERROR" "requireuser was called, but \$REQUIREUSER is not set"
188-
elif [ "$REQUIREUSER" != "$USER" ] ; then
188+
elif [ "$REQUIREUSER" != "$EUID" ] ; then
189189
quit "ERROR" "Only $REQUIREUSER is allowed to run this script"
190190
else
191-
log "DEBUG" "User '$USER' matches '$REQUIREUSER' and is allowed to run this script"
191+
log "DEBUG" "User '$EUID' matches '$REQUIREUSER' and is allowed to run this script"
192192
fi
193193
}
194194

0 commit comments

Comments
 (0)