surround ALL variables with {}

This commit is contained in:
LinuxSquare 2024-03-16 21:14:18 +01:00
parent 6593dabf42
commit d6e4ca0973
4 changed files with 15 additions and 14 deletions

View file

@ -5,6 +5,6 @@ function attach() {
log e "Container '${1}' is not running!" log e "Container '${1}' is not running!"
exit 1 exit 1
fi fi
log i "Attaching to container '$1'" log i "Attaching to container '${1}'"
podman container attach "$1" podman container attach "${1}"
} }

View file

@ -19,5 +19,5 @@ function delete() {
done done
rm -rf "$delDir" rm -rf "$delDir"
log s "Server '$1' deleted!" log s "Server '${1}' deleted!"
} }

View file

@ -15,40 +15,41 @@ readonly RESET="\033[0m"
function log() { function log() {
local prefix local prefix
type=$1 type=${1}
print=false print=false
shift shift
message=$@ message=$@
case $type in case ${type} in
"s") "s")
print=true print=true
prefix="${GREEN}[SUCCESS]${RESET}" prefix="${GREEN}[SUCCESS]${RESET}"
;; ;;
"d") "d")
if [[ "$debuglevel" -ge 4 ]]; then if [[ "${debuglevel}" -ge 4 ]]; then
print=true print=true
fi fi
prefix="${MAGENTA}[DEBUG]${RESET}" prefix="${MAGENTA}[DEBUG]${RESET}"
;; ;;
"i") "i")
if [[ "$debuglevel" -ge 1 ]]; then if [[ "${debuglevel}" -ge 1 ]]; then
print=true print=true
fi fi
prefix="${BLUE}[INFO]${RESET}" prefix="${BLUE}[INFO]${RESET}"
;; ;;
"w") "w")
if [[ "$debuglevel" -ge 2 ]]; then if [[ "${debuglevel}" -ge 2 ]]; then
print=true print=true
fi fi
prefix="${YELLOW}[WARN]${RESET}" prefix="${YELLOW}[WARN]${RESET}"
;; ;;
"e") "e")
if [[ "$debuglevel" -ge 3 ]]; then if [[ "${debuglevel}" -ge 3 ]]; then
print=true print=true
fi fi
prefix="${RED}[ERR]${RESET}" prefix="${RED}[ERR]${RESET}"
;; ;;
esac esac
"$print" && echo -e "$prefix $message" "${print}" && echo -e "${prefix} ${message}"
return 0
} }

View file

@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
function stop() { function stop() {
if [[ -z $(podman container ps | grep "$1") ]]; then if [[ -z $(podman container ps | grep "${1}") ]]; then
log w "Container '$1' is not running!" log w "Container '${1}' is not running!"
return 1 return 1
fi fi
log i "Stopping container '$1'" log i "Stopping container '${1}'"
stopContainer "$1" stopContainer "${1}"
} }