diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2025-11-01 21:25:17 -0400 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2025-11-01 21:25:17 -0400 |
| commit | fe351483777c8d053d9f8b584278a4c2b162db0e (patch) | |
| tree | 15af9419e315bfad090c940be4a61625bf785876 /shlib/prompt.sh | |
| parent | Move /usr/local/bin farther up the path (diff) | |
| download | dotfiles-fe351483777c8d053d9f8b584278a4c2b162db0e.zip | |
Update install scripts for macos and linux and use sh
Diffstat (limited to 'shlib/prompt.sh')
| -rw-r--r-- | shlib/prompt.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/shlib/prompt.sh b/shlib/prompt.sh new file mode 100644 index 0000000..6a63db0 --- /dev/null +++ b/shlib/prompt.sh @@ -0,0 +1,23 @@ +# shellcheck shell=sh +[ -n "${DOTFILES_PROMPT_LOADED}" ] && return +readonly DOTFILES_PROMPT_LOADED=1 + +# Prompt the user for confirmation on an action. +# +# Args: +# $1: The question to prompt for. Answer choices +# will be added onto the end. +# +# Returns: +# 0 on yes. 1 on no. +prompt_for_confirmation() { + ( + printf "%s [y/n]: " "$1" + read -r answer + if [ "$answer" != "${answer#[Yy]}" ]; then + return 0 + else + return 1 + fi + ) +} |