]> glassweightruler.freedombox.rocks Git - xdg-ninja.git/blobdiff - xdg-ninja.sh
Exit status = amount of fixable files
[xdg-ninja.git] / xdg-ninja.sh
index f8e12b55b5342c5392e0802b1c2b3e6e4e10b657..833220783382e40650d2d42c008577f2abd28a85 100755 (executable)
@@ -136,6 +136,9 @@ decode_string() {
 /' # Replace \n with literal newline and \" with ", normalize number of trailing newlines to 2
 }
 
+# Counter to keep track of how many files can be moved
+FIXABLE=0
+
 # Function to handle the formatting of output
 log() {
     MODE="$1"
@@ -147,6 +150,7 @@ log() {
 
     ERR)
         printf '[%b%s%b]: %b%s%b\n' "${FX_BOLD}${FG_RED}" "$NAME" "${FX_RESET}" "${FX_BOLD}${FX_ITALIC}" "$FILENAME" "${FX_RESET}"
+        FIXABLE=$((FIXABLE+1))
         ;;
 
     WARN)
@@ -206,7 +210,7 @@ do_check_programs() {
 " read -r name; read -r filename; read -r movable; read -r help; do
         check_file "$name" "$filename" "$movable" "$help"
     done <<EOF
-$(jq 'inputs as $input | $input.files[] as $file | $input.name, $file.path, $file.movable, $file.help' "$(realpath "$0" | dirname -)"/programs/* | sed -e 's/^"//' -e 's/"$//')
+$(jq 'inputs as $input | $input.files[] as $file | $input.name, $file.path, $file.movable, $file.help' "$(realpath "$0" | xargs dirname)"/programs/* | sed -e 's/^"//' -e 's/"$//')
 EOF
 # sed is to trim quotes
 }
@@ -223,3 +227,4 @@ check_programs() {
 
 
 check_programs
+exit $FIXABLE