Skip to content

Commit 3cd1010

Browse files
committed
fix
1 parent 31a86b4 commit 3cd1010

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

usr/bin/text-safety-scan

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ run_plugin_command() {
3131
fi
3232

3333
log info "${plugin_cmd} OK"
34+
unset plugin_cmd
3435
}
3536

3637
cleanup() {
3738
local _exit_code="${1:-$?}"
3839
trap - EXIT
39-
## captured_stdin_file is inherited from text_safety_scan function.
40-
## captured_stdin_file is set prior setting up the 'trap'.
40+
trap - ERR
4141
if [ -n "${captured_stdin_file-}" ]; then
4242
safe-rm --force --verbose -- "${captured_stdin_file}"
4343
fi
@@ -56,12 +56,13 @@ error_handler() {
5656
exit "${_exit_code}"
5757
}
5858

59-
trap 'cleanup' EXIT
59+
trap "cleanup" EXIT
6060

6161
trap "error_handler" ERR
6262

6363
text_safety_scan() {
64-
local file_list captured_stdin_file file_name plugin_list plugin_item
64+
declare -g captured_stdin_file
65+
local file_list file_name plugin_list plugin_item
6566

6667
file_list=( "$@" )
6768
plugin_list=( 'unicode-show' 'modeline-show' )
@@ -84,9 +85,7 @@ text_safety_scan() {
8485
done
8586
else
8687
for file_name in "${file_list[@]}"; do
87-
if ! test -r "$file_name"; then
88-
die 1 "File '$file_name' does not exist or is not readable!"
89-
fi
88+
## Leave handling if it is a readable file versus a folder to plugins.
9089
for plugin_item in "${plugin_list[@]}"; do
9190
run_plugin_command "${plugin_item}" "${file_name}"
9291
done

0 commit comments

Comments
 (0)