set result if we bail

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
2026-11-28 05:24:11 +00:00
parent 06558f0601
commit 81527c69b2
+7 -5
View File
@@ -107,7 +107,7 @@ error() {
# 3: no handler # 3: no handler
handle_target() { handle_target() {
declare -n result=$1 declare -n result=$1
declare h cmd regex target_is_file target target_left cmd_is_template declare h cmd regex target_is_file target target_left cmd_is_template _ec
cmd_append_target=1 cmd_append_target=1
match=0 match=0
target=$2 target=$2
@@ -118,9 +118,10 @@ handle_target() {
[[ "$target" =~ ^/.* ]] || { target="${PWD}/${target}"; } # Turn relative paths to absolute ones. [[ "$target" =~ ^/.* ]] || { target="${PWD}/${target}"; } # Turn relative paths to absolute ones.
file_raw=$( file -ib "$target" ) file_raw=$( file -ib "$target" ); _ec=$?
(( $? )) && { (( $_ec )) && {
error "Failed to get mimetype, bailing" error "Failed to get mimetype, bailing"
result=$_ec
return 1 return 1
} }
@@ -130,9 +131,10 @@ handle_target() {
[[ $target_mimetype == 'inode/symlink' ]] && { [[ $target_mimetype == 'inode/symlink' ]] && {
unset file_raw unset file_raw
file_raw=$( file -ibL "$target" ) file_raw=$( file -ibL "$target" ); _ec=$?
(( $? )) && { (( $_ec )) && {
error "Failed to get mimetype, bailing" error "Failed to get mimetype, bailing"
result=$_ec
return 1 return 1
} }