From 049fca4d7709a41b919803854db4f6e7db9eee9c Mon Sep 17 00:00:00 2001 From: Gaurav Bankar Date: Thu, 8 Aug 2024 10:12:01 +0530 Subject: [PATCH] better script info and visibility --- scripts/installer/helper.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/installer/helper.sh b/scripts/installer/helper.sh index c589c95..cd22f2f 100755 --- a/scripts/installer/helper.sh +++ b/scripts/installer/helper.sh @@ -71,11 +71,18 @@ function run_command { local description="$2" local ask_confirm="${3:-yes}" # Default to asking for confirmation local use_sudo="${4:-yes}" # Default to using sudo + + local full_cmd="" + if [[ "$use_sudo" == "no" ]]; then + full_cmd="sudo -u $SUDO_USER $cmd" + else + full_cmd="$cmd" + fi log_message "Attempting to run: $description" - + print_info "\nCommand: $full_cmd" if [[ "$ask_confirm" == "yes" ]]; then - if ! ask_confirmation "\n$description"; then + if ! ask_confirmation "$description"; then # print_info "$description was skipped." log_message "$description was skipped by user choice." return 1 @@ -84,13 +91,6 @@ function run_command { print_info "\n$description" # Echo what it's doing without confirmation fi - local full_cmd="" - if [[ "$use_sudo" == "no" ]]; then - full_cmd="sudo -u $SUDO_USER $cmd" - else - full_cmd="$cmd" - fi - while ! eval "$full_cmd"; do print_error "Command failed." log_message "Command failed: $cmd"