From: b3nj5m1n <47924309+b3nj5m1n@users.noreply.github.com> Date: Sun, 15 May 2022 10:38:41 +0000 (+0200) Subject: Merge pull request #23 from fourchettes/fix/dash X-Git-Tag: v0.2.0.0~64 X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/xdg-ninja.git/commitdiff_plain/b4125c6c863543f1b7359a5caf0c7a1028d73e39?ds=inline;hp=-c Merge pull request #23 from fourchettes/fix/dash xdg-ninja: change jq json source --- b4125c6c863543f1b7359a5caf0c7a1028d73e39 diff --combined xdg-ninja.sh index d873df2,d3e43d8..56b970e --- a/xdg-ninja.sh +++ b/xdg-ninja.sh @@@ -1,18 -1,12 +1,18 @@@ #!/usr/bin/env sh # shellcheck disable=SC2016 -USE_GLOW=true -if ! command -v glow >/dev/null 2>/dev/null; then - printf "Glow not found, markdown rendering not available.\n" +USE_GLOW=false +USE_BAT=false +if command -v glow >/dev/null 2>/dev/null; then + USE_GLOW=true +elif command -v bat >/dev/null 2>/dev/null; then + USE_BAT=true + printf "Glow not found, markdown rendering will be done by bat.\n" + printf "Install glow for easier reading & copy-paste.\n" +else + printf "Glow or bat not found, markdown rendering not available.\n" printf "Output will be raw markdown and might look weird.\n" printf "Install glow for easier reading & copy-paste.\n" - USE_GLOW=false fi unalias -a @@@ -128,11 -122,9 +128,11 @@@ log() HELP) if $USE_GLOW; then - printf "%s" "$HELP" | glow - + printf "%s\n" "$HELP" | glow - + elif $USE_BAT; then + printf "%s\n" "$HELP" | bat -pp -f --language markdown else - printf "%s" "$HELP" + printf "%s\n" "$HELP" fi ;; @@@ -174,14 -166,14 +174,14 @@@ check_file() # Reads a file from programs/, calls check_file on each file specified for the program check_program() { - INPUT=$1 + PROGRAM=$1 - NAME=$(printf "%s" "$INPUT" | jq -r .name) + NAME=$(jq -r .name "$PROGRAM") while IFS= read -r file; do check_file "$file" "$NAME" done <