From 81527c69b2473342155d401aaa4ce3360c3cc39f Mon Sep 17 00:00:00 2001 From: fbt Date: Sat, 28 Nov 2026 05:24:11 +0000 Subject: [PATCH] set result if we bail Signed-off-by: fbt --- sx-open | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sx-open b/sx-open index 18a0b22..bf71127 100755 --- a/sx-open +++ b/sx-open @@ -107,7 +107,7 @@ error() { # 3: no handler handle_target() { 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 match=0 target=$2 @@ -118,9 +118,10 @@ handle_target() { [[ "$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" + result=$_ec return 1 } @@ -130,9 +131,10 @@ handle_target() { [[ $target_mimetype == 'inode/symlink' ]] && { unset file_raw - file_raw=$( file -ibL "$target" ) - (( $? )) && { + file_raw=$( file -ibL "$target" ); _ec=$? + (( $_ec )) && { error "Failed to get mimetype, bailing" + result=$_ec return 1 }