}
decode_string() {
- printf "%s\n" "$1" | sed -e 's/\\n/\
-/g' -e 's/\\\"/\"/g' # Replace \n with literal newline and \" with "
+ printf "%s" "$1" | sed -e 's/\\n/\
+/g' -e 's/\\\"/\"/g' -e '$ s/\n*$/\
+\
+/' # Replace \n with literal newline and \" with ", normalize number of trailing newlines to 2
}
# Function to handle the formatting of output
else
log WARN "$NAME" "$FILENAME" "$HELP"
fi
- if [ "$HELP" = true ]; then
+ if [ "$HELP" ]; then
log HELP "$NAME" "$FILENAME" "$HELP"
else
log HELP "$NAME" "$FILENAME" "_No help available._"