forked from Shinonome/dots-hyprland
Test
This commit is contained in:
+13
-5
@@ -111,7 +111,8 @@ safe_read() {
|
|||||||
local input_value=""
|
local input_value=""
|
||||||
|
|
||||||
echo -n "$prompt"
|
echo -n "$prompt"
|
||||||
if read -r input_value </dev/tty 2>/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/tty 2>/dev/null || read -r input_value 2>/dev/null; then
|
||||||
# Use printf instead of eval for security
|
# Use printf instead of eval for security
|
||||||
printf -v "$varname" '%s' "$input_value"
|
printf -v "$varname" '%s' "$input_value"
|
||||||
return 0
|
return 0
|
||||||
@@ -706,10 +707,17 @@ if ! git diff --quiet || ! git diff --cached --quiet; then
|
|||||||
git status --short
|
git status --short
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if ! safe_read "Do you want to continue? This will stash your changes. (y/N): " response "N"; then
|
response="n"
|
||||||
echo
|
# The 'check' variable is set to false when --skip-notice is used, which we use to detect non-interactive mode.
|
||||||
log_error "Failed to read input. Aborting."
|
if [[ "$check" == false ]]; then
|
||||||
exit 1
|
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
|
fi
|
||||||
|
|
||||||
if [[ ! "$response" =~ ^[Yy]$ ]]; then
|
if [[ ! "$response" =~ ^[Yy]$ ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user