commit 4b4355c73376e70976a9b583e99952d9b4d67d0d
parent 7b31a356d2ac11d1fba266121d28c857cf134df0
Author: Jonathan Rash <jonathanmrash@gmail.com>
Date: Tue, 20 Jul 2021 19:12:37 -0400
Added execute fallback to nuke
Diffstat:
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/plugins/nuke b/plugins/nuke
@@ -21,9 +21,10 @@
# Guards against accidentally opening mime types like executables, shared libs etc.
#
# Tries to play 'file' (1st argument) in the following order:
-# i. by extension
-# ii. by mime (image, video, audio, pdf)
-# iii. by mime (other file types)
+# 1. by extension
+# 2. by mime (image, video, audio, pdf)
+# 3. by mime (other file types)
+# 4. by mime (prompt and run executables)
#
# Modification tips:
# 1. Invokes CLI utilities by default. Set GUI to 1 to enable GUI apps.
@@ -63,8 +64,9 @@
# 1. Adapt, test and enable all mimes
# 2. Clean-up the unnecessary exit codes
-# set to 1 to enable GUI apps
+# set to 1 to enable GUI apps and/or BIN execution
GUI="${GUI:-0}"
+BIN="${BIN:-0}"
set -euf -o noclobber -o noglob -o nounset
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
@@ -513,10 +515,25 @@ handle_blocked() {
esac
}
+handle_bin() {
+ case "${MIMETYPE}" in
+ application/x-executable|application/x-shellscript)
+ clear
+ echo '-------- Executable File --------' && file --dereference --brief -- "${FPATH}"
+ printf "Run executable (y/N)? "
+ read -r answer
+ case "$answer" in
+ [Yy]* ) exec "${FPATH}";;
+ [Nn]* ) exit;;
+ esac
+ esac
+}
+
MIMETYPE="$( file -bL --mime-type -- "${FPATH}" )"
handle_extension
handle_multimedia "${MIMETYPE}"
handle_mime "${MIMETYPE}"
+[ "$BIN" -ne 0 ] && [ -x "${FPATH}" ] && handle_bin
handle_blocked "${MIMETYPE}"
handle_fallback