Skip to content

Instantly share code, notes, and snippets.

View Vdragon's full-sized avatar

V字龍(Vdragon) Vdragon

  • V字龍軟體開發組(Vdragon Software Development Group)
  • 台灣(Taiwan)
View GitHub Profile
#!/usr/bin/env bash
#shellcheck disable=SC2034
# Comments prefixed by BASHDOC: are hints to specific GNU Bash Manual's section:
# https://www.gnu.org/software/bash/manual/
## Makes debuggers' life easier - Unofficial Bash Strict Mode
## http://redsymbol.net/articles/unofficial-bash-strict-mode/
## BASHDOC: Shell Builtin Commands - Modifying Shell Behavior - The Set Builtin
### Exit prematurely if a command's return value is not 0(with some exceptions), triggers ERR trap if available.
set -o errexit
@Vdragon
Vdragon / prompt_yes_or_no.function.bash
Created November 26, 2017 09:52
prompt_yes_or_no.function.bash
# Prompt for Yy/Nn, if not the expected answer ask again
# Parameter: A string of prompt; Default answer(Y/N)
# return 0 for yes and 1 for no
prompt_yes_or_no(){
if [ ${#} -ne 2 ]; then
printf --\
'Fatal: %s: Function paramater quantity mismatch! Please report bug\n'\
"${FUNCNAME[0]}"\
1>&2
exit 1