Skip to content

Commit

Permalink
No local variables #400 (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr authored Mar 15, 2024
1 parent 47dea4f commit 0baf117
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# echo a string, handling different types
safe_echo() {
local value="$1"
if [ -z "$value" ]; then
# $1 = value
if [ -z "$1" ]; then
echo -n "null"
elif printf '%s\n' "$value" | grep -qE '\n.+\n$'; then
echo -n "\`$value\`"
elif printf '%s\n' "$1" | grep -qE '\n.+\n$'; then
echo -n "\`$1\`"
else
echo -n "'$value'"
echo -n "'$1'"
fi
}

# handle boolean
bool() {
# $1 = value
case "$1" in
true | TRUE | yes | t | True)
echo -n true ;;
Expand All @@ -25,29 +26,29 @@ bool() {

# handle array values
array() {
local value="$1"
local arraytype="$2"
if [ -z "$value" ]; then
# $1 = value
# $2 = arraytype
if [ -z "$1" ]; then
echo -n "[]"
else
case "$arraytype" in
case "$2" in
string)
echo -n "['$(echo "$value" | sed "s/,/', '/g")']"
echo -n "['$(echo "$1" | sed "s/,/', '/g")']"
;;
*)
echo -n "[$value]"
echo -n "[$1]"
;;
esac
fi
}

# handle object values
object() {
local value="$1"
if [ -z "$value" ]; then
# $1 = value
if [ -z "$1" ]; then
echo -n "null"
else
echo -n "$value"
echo -n "$1"
fi
}

Expand Down

0 comments on commit 0baf117

Please sign in to comment.