From 809c8806d0c0f86c016780c0b6625a0452ff8de8 Mon Sep 17 00:00:00 2001 From: Bishoy Ehab Date: Fri, 17 Oct 2025 14:31:54 +0300 Subject: [PATCH] Test --- sdata/exp/update.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sdata/exp/update.sh b/sdata/exp/update.sh index 639f00ed3..0caffdf9c 100755 --- a/sdata/exp/update.sh +++ b/sdata/exp/update.sh @@ -111,7 +111,8 @@ safe_read() { local input_value="" echo -n "$prompt" - if read -r input_value /dev/null || read -r input_value 2>/dev/null; then + # Try to read from tty only if it's an interactive session + if [[ -t 0 ]] && read -r input_value /dev/null || read -r input_value 2>/dev/null; then # Use printf instead of eval for security printf -v "$varname" '%s' "$input_value" return 0 @@ -706,10 +707,17 @@ if ! git diff --quiet || ! git diff --cached --quiet; then git status --short echo - if ! safe_read "Do you want to continue? This will stash your changes. (y/N): " response "N"; then - echo - log_error "Failed to read input. Aborting." - exit 1 + response="n" + # The 'check' variable is set to false when --skip-notice is used, which we use to detect non-interactive mode. + if [[ "$check" == false ]]; then + log_info "Non-interactive mode detected, automatically stashing changes." + response="y" + else + if ! safe_read "Do you want to continue? This will stash your changes. (y/N): " response "N"; then + echo + log_error "Failed to read input. Aborting." + exit 1 + fi fi if [[ ! "$response" =~ ^[Yy]$ ]]; then