X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/xdg-ninja.git/blobdiff_plain/e2accd7cb8598500c7f5d799964476f73ac4fc56..4e9316b332eaa0ed5832a1246878dd6b015cb038:/xdg-ninja.sh diff --git a/xdg-ninja.sh b/xdg-ninja.sh index 3c9054a..94a8969 100755 --- a/xdg-ninja.sh +++ b/xdg-ninja.sh @@ -98,8 +98,10 @@ check_if_file_exists() { } 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 @@ -129,9 +131,9 @@ log() { ;; 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" @@ -157,7 +159,7 @@ check_file() { ;; 1) - if [ "$MOVABLE" ]; then + if [ "$MOVABLE" = true ]; then log ERR "$NAME" "$FILENAME" "$HELP" else log WARN "$NAME" "$FILENAME" "$HELP"