]> Sergey Matveev's repositories - nnn.git/commitdiff
shellcheck fixes
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 22 Nov 2020 14:39:14 +0000 (20:09 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 22 Nov 2020 15:00:52 +0000 (20:30 +0530)
20 files changed:
.circleci/config.yml
plugins/README.md
plugins/boom
plugins/diffs
plugins/finder
plugins/fzhist
plugins/hexview
plugins/imgresize
plugins/imgthumb
plugins/imgur
plugins/launch
plugins/mediainf
plugins/mimelist
plugins/moclyrics
plugins/nmount
plugins/pdfread
plugins/pdfview
plugins/pskill
plugins/upload
plugins/wall

index 7724129e17896c4866f031d6bda3edefd760ae16..8b1f56339efc33340ff2490d481f986cee7843d2 100644 (file)
@@ -70,7 +70,7 @@ jobs:
             echo "########## clang-tidy-10 ##########"
             clang-tidy-10 src/* -- -I/usr/include -I/usr/include/ncursesw
             echo "########## shellcheck ##########"
-            find plugins/ -type f -not -name "*.md" -exec shellcheck -e SC1090 {} +
+            find plugins/ -type f -not -name "*.md" -exec shellcheck -e SC1090,SC2230 {} +
 
   package-and-publish:
     machine: true
index a3d3700dee66bfe7e31c67c0c05a1eab17ac60af..d802cffd52c8c4a5babe1a34b4b073d1afbd09bd 100644 (file)
@@ -41,7 +41,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
 | [kdeconnect](kdeconnect) | Send selected files to an Android device | sh | kdeconnect-cli |
 | [launch](launch) | GUI application launcher | sh | fzf |
 | [mediainf](mediainf) | Show media information | sh | mediainfo |
-| [mimelist](mimelist) | List files by mime in subtree | sh | fd/find |
+| [mimelist](mimelist) | List files by mime in subtree | sh | - |
 | [moclyrics](moclyrics) | Show lyrics of the track playing in moc | sh | [ddgr](https://github.com/jarun/ddgr), [moc](http://moc.daper.net/) |
 | [mocplay](mocplay) | Append (and/or play) selection/dir/file in moc | sh | [moc](http://moc.daper.net/) |
 | [mp3conv](mp3conv) | Extract audio from multimedia as mp3 | sh | ffmpeg |
index 5debfad7f247f2d9b3dda04256d59f7d7eb2698b..10f14f6097ae7150b1b3f8828a150af9c47d7d91 100755 (executable)
@@ -9,7 +9,7 @@
 GUIPLAYER="${GUIPLAYER}"
 NUMTRACKS="${NUMTRACKS:-100}"
 
-if [ ! -z "$GUIPLAYER" ]; then
+if [ -n "$GUIPLAYER" ]; then
     find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf -n "$NUMTRACKS" | xargs -d "\n" "$GUIPLAYER" > /dev/null 2>&1 &
 
     # detach the player
index 294c5e77a6a2e2b9df85392e42d20befb889287d..d20cc5dafbdf28892d176ccc8ab533924e001ce5 100755 (executable)
@@ -41,7 +41,7 @@ if [ -s "$selection" ]; then
 
             eval xargs -0 "$diffcmd" < "$selection"
         fi
-    elif ! [ -z "$1" ]; then
+    elif [ -n "$1" ]; then
         f1="$(echo "$arr" | sed -n '1p')"
         if [ -d "$f1" ] && [ -d "$1" ]; then
             dirdiff "$f1" "$1"
index 649b711351da1ddd46ff7e94b2a1a6b54911677d..bd34d5d9afebbfa26c8d33e61913881e5c1595d8 100755 (executable)
@@ -22,7 +22,7 @@ printf "  fzf -m | tr %s %s\n\n" "'\n'" "'\0'"
 printf "cmd: "
 read -r cmd
 
-if ! [ -z "$cmd" ]; then
+if [ -n "$cmd" ]; then
     printf "%s" "+l" > "$NNN_PIPE"
     eval "$cmd" > "$NNN_PIPE"
 fi
index a3aac3a3af0e9ed2bf6d1db73157625b2cb9205d..e824fc2f008b8455d13ab69ae00c43d86e37a8ec 100755 (executable)
@@ -22,7 +22,7 @@ elif [ "$shellname" = "fish" ]; then
     entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | "$fuzzy")"
 fi
 
-if ! [ -z "$entry" ]; then
+if [ -n "$entry" ]; then
     tmpfile=$(mktemp)
     echo "$entry" >> "$tmpfile"
     $EDITOR "$tmpfile"
index ce17a60d39ef39a2260c7a7298338b50e6aa88f3..22936bc8398de8b0151d1a7f839ac00f6fe968fa 100755 (executable)
@@ -6,7 +6,7 @@
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
     if which hx >/dev/null 2>&1; then
         hx "$1"
     else
index d85d4b519762ca5fdd4bbd24f825a05d2b8cde22..f04a883b5befb824f65c6ec19584b7661f3a9c2d 100755 (executable)
@@ -25,6 +25,6 @@ if [ -z "$res" ]; then
     read -r res
 fi
 
-if ! [ -z "$res" ] && ! [ -z "$MINSIZE" ]; then
+if [ -n "$res" ] && [ -n "$MINSIZE" ]; then
     imgp -ackx "$res" -s "$MINSIZE"
 fi
index 88821152247638e3c3edbbd74d446675a8d1c31b..8e217077347ba4c52f166e25676c9ca18785ce88 100755 (executable)
@@ -5,7 +5,7 @@
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
     if [ -d "$1" ]; then
         lsix "$1"/*
     else
index e95360c76e5707fe047a07b215f48910b66016ef..9115c480fd4204cd19b1679b8e7ed9cfada626d9 100755 (executable)
@@ -172,8 +172,8 @@ function take_screenshot() {
 function check_for_update() {
   # exit non-zero on HTTP error, output only the body (no stats) but output errors, follow redirects, output everything to stdout
   remote_version="$(curl --compressed -fsSL --stderr - "https://api.github.com/repos/jomo/imgur-screenshot/releases" | grep -Em 1 --color 'tag_name":\s*".*"' | cut -d '"' -f 4)"
-  if ! [ -z "$remote_version" ]; then
-    if [ ! "${current_version}" = "${remote_version}" ] && [ ! -z "${current_version}" ] && [ ! -z "${remote_version}" ]; then
+  if [ -n "$remote_version" ]; then
+    if [ ! "${current_version}" = "${remote_version}" ] && [ -n "${current_version}" ] && [ -n "${remote_version}" ]; then
       echo "Update found!"
       echo "Version ${remote_version} is available (You have ${current_version})"
       notify ok "Update found" "Version ${remote_version} is available (You have ${current_version}). https://github.com/jomo/imgur-screenshot"
@@ -209,7 +209,7 @@ function load_access_token() {
   current_time="$(date +%s)"
   preemptive_refresh_time="$((10*60))"
   expired="$((current_time > (token_expire_time - preemptive_refresh_time)))"
-  if [ ! -z "${refresh_token}" ]; then
+  if [ -n "${refresh_token}" ]; then
     # token already set
     if [ "${expired}" -eq "0" ]; then
       # token expired
@@ -320,7 +320,7 @@ function upload_authenticated_image() {
     img_ext="$(grep -Eo '"link":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4 | rev | cut -d "." -f 1 | rev)" # "link" itself has ugly '\/' escaping and no https!
     del_id="$(grep -Eo '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)"
 
-    if [ ! -z "${auto_delete}" ]; then
+    if [ -n "${auto_delete}" ]; then
       export -f delete_image
       echo "Deleting image in ${auto_delete} seconds."
       nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" &
@@ -348,7 +348,7 @@ function upload_anonymous_image() {
     img_ext="$(grep -Eo '"link":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4 | rev | cut -d "." -f 1 | rev)" # "link" itself has ugly '\/' escaping and no https!
     del_id="$(grep -Eo '"deletehash":\s*"[^"]+"' <<<"${response}" | cut -d "\"" -f 4)"
 
-    if [ ! -z "${auto_delete}" ]; then
+    if [ -n "${auto_delete}" ]; then
       export -f delete_image
       echo "Deleting image in ${auto_delete} seconds."
       nohup /bin/bash -c "sleep ${auto_delete} && delete_image ${imgur_anon_id} ${del_id} ${log_file}" &
index 19855f980cdce27b408a1e7f3df8da112187fd1b..c131235e78ba79a55895155153623b923ab93ef7 100755 (executable)
@@ -34,7 +34,7 @@ get_selection() {
 if selection=$( get_selection ); then
     setsid "$selection" 2>/dev/null 1>/dev/null &
 
-    if ! [ -z "$1" ]; then
+    if [ -n "$1" ]; then
         sleep "$1"
     else
         sleep 1
index 15640b4d4d20f763320ba668e531da167181679c..22ae8240edfb2beaf93a60ec7a45639d0fe2503b 100755 (executable)
@@ -7,7 +7,7 @@
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
-if ! [ -z "$1" ] && [ -f "$1" ]; then
+if [ -n "$1" ] && [ -f "$1" ]; then
     mediainfo "$1" | $PAGER
     # exiftool "$1" | $PAGER
 fi
index 743d30563a95818b8a849c41b9d55de4f5572eaa..586cc7cd1b507356070796e422ff8df7d8f38670 100755 (executable)
@@ -1,21 +1,14 @@
 #!/usr/bin/env sh
 
-# Description: Run fd/find in subtree and list files by mime type in smart context
-# Dependencies: fd/find
+# Description: Find and list files by mime type in smart context
 #
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
 . "$(dirname "$0")"/.nnn-plugin-helper
 
-if [ "$(cmd_exists fd)" -eq "0" ]; then
-       fd=fd
-else
-       fd=find
-fi
-
 printf "mime (e.g., video/audio/image): "
 read -r mime
 
 printf "%s" "+l" > "$NNN_PIPE"
-$fd | file -if- | grep "$mime" | awk -F: '{printf "%s\0", $1}' > "$NNN_PIPE"
+find . | file -if- | grep "$mime" | awk -F: '{printf "%s\0", $1}' > "$NNN_PIPE"
index 04e899ea93febafbebef01401c28575f7509ae35..0dc3cd79f66b02d94cbb68e3d26f401e9226575f 100755 (executable)
@@ -26,14 +26,14 @@ fi
 ARTIST="$(echo "$out" | grep 'Artist:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
 TITLE="$(echo "$out" | grep 'SongTitle:' | cut -d':' -f2 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')"
 
-if ! [ -z "$ARTIST" ] && ! [ -z "$TITLE" ]; then
+if [ -n "$ARTIST" ] && [ -n "$TITLE" ]; then
     ddgr -w azlyrics.com --ducky "$ARTIST" "$TITLE"
 else
     # Try by file name
     FILENAME="$(basename "$(echo "$out" | grep 'File:' | cut -d':' -f2)")"
     FILENAME="$(echo "${FILENAME%%.*}" | tr -d -)"
 
-    if ! [ -z "$FILENAME" ]; then
+    if [ -n "$FILENAME" ]; then
         ddgr -w azlyrics.com --ducky "$FILENAME"
     fi
 fi
index 566119ec6037cdd1a18face4dd3211fe07052ed7..6a9ed8cecb06ef6a6dc8379a22bba5c9a6de6760 100755 (executable)
@@ -24,7 +24,7 @@ printf "\nEnsure you aren't still in the mounted device.\n"
 printf "%s" "$prompt"
 read -r dev
 
-while ! [ -z "$dev" ]
+while [ -n "$dev" ]
 do
     if [ "$dev" = "l" ]; then
         lsblk
index 4f47992b2de4701c53655df4885fbcf0ff97b462..1e889be1e78f96cdc113c92881d0827c7dc3ff6b 100755 (executable)
@@ -5,7 +5,7 @@
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
     tmpf="$(basename "$1")"
     tmpf="${TMPDIR:-/tmp}"/"${tmpf%.*}"
 
index 2b953b5d85cb1330e903f0f88fc7498b96dcbb9e..262e34fea4b34b6b4c8ce7414d9b96a14df5f323 100755 (executable)
@@ -9,7 +9,7 @@
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
     if [ "$(head -c 4 "$1")" = "%PDF" ]; then
         # Convert using pdftotext
         pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER
index 979492aba16560c029f7c20a5798e35c75d0fc96..89008097838677a39f54f280805de8c2dbfb191c 100755 (executable)
@@ -13,7 +13,7 @@ printf "Enter process name ['defunct' for zombies]: "
 read -r psname
 
 # shellcheck disable=SC2009
-if ! [ -z "$psname" ]; then
+if [ -n "$psname" ]; then
     if which sudo >/dev/null 2>&1; then
         sucmd=sudo
     elif which doas >/dev/null 2>&1; then
index 196e8f70f12f8f9e101ac92209c33d12a1c78ea3..56ed0a31a88cb4c8bca88dcbc15e4039f740d61d 100755 (executable)
@@ -9,7 +9,7 @@
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
-if ! [ -z "$1" ] && [ -s "$1" ]; then
+if [ -n "$1" ] && [ -s "$1" ]; then
     if which ffsend >/dev/null 2>&1; then
         ffsend -iq u "$1"
     elif [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "text" ]; then
index 0fc6de7822cc8d2abb622409c7a29d542b1d2e67..a35412fa63c904b551528ecf5bd4a66f287e6287 100755 (executable)
@@ -11,7 +11,7 @@ cmd_exists () {
        echo $?
 }
 
-if ! [ -z "$1" ]; then
+if [ -n "$1" ]; then
     if [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "image" ]; then
         if [ "$(cmd_exists nitrogen)" -eq "0" ]; then
                nitrogen --set-zoom-fill --save "$1"