}
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
;;
HELP)
- if $USE_GLOW; then
+ if [ "$USE_GLOW" = true ]; then
decode_string "$HELP" | glow -
- elif $USE_BAT; then
+ elif [ "$USE_BAT" = true ]; then
decode_string "$HELP" | bat -pp --decorations=always --color=always --language markdown
else
decode_string "$HELP"
;;
1)
- if [ "$MOVABLE" ]; then
+ if [ "$MOVABLE" = true ]; then
log ERR "$NAME" "$FILENAME" "$HELP"
else
log WARN "$NAME" "$FILENAME" "$HELP"