Skip to content

Commit a2b92c5

Browse files
Abort installation on sudo or command failure in sudo_if_install_dir_not_writeable
The function silently returned non-zero exit codes to callers (wrong password, missing source file, permission denied, etc.), which allowed the script to continue in a broken state. Capturing $? immediately after the command and calling exit preserves the original exit code and ensures any failure stops the installation with a clear error message.
1 parent 617fbec commit a2b92c5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ echo "🧹 Cleaned up temporary files"
212212
# This checks if the install directory is writable before using sudo
213213
sudo_if_install_dir_not_writeable() {
214214
local command="$1"
215+
local exit_code
215216
if [ -w "$INSTALL_DIR" ]; then
216217
# Directory is writable, run without sudo
217218
sh -c "$command"
@@ -220,6 +221,11 @@ sudo_if_install_dir_not_writeable() {
220221
echo "🔐 Administrator privileges required for installation to $INSTALL_DIR"
221222
sudo sh -c "$command"
222223
fi
224+
exit_code=$?
225+
if [ "$exit_code" -ne 0 ]; then
226+
echo "❌ ERROR: Command failed or was interrupted (exit code: $exit_code)"
227+
exit "$exit_code"
228+
fi
223229
}
224230

225231
# Create install directory if it doesn't exist

0 commit comments

Comments
 (0)