kiss: move prompts to a function

This commit is contained in:
Dylan Araps 2019-09-22 14:35:07 +03:00
parent abc770ac32
commit 25201d6961

33
kiss
View File

@ -41,6 +41,16 @@ contains() {
return 1 return 1
} }
prompt() {
# As the user for some input.
log "Continue?: Press Enter to continue or Ctrl+C to abort here"
# POSIX 'read' has none of the "nice" options like '-n', '-p'
# etc etc. This is the most basic usage of 'read'.
# '_' is used as 'dash' errors when no variable is given to 'read'.
read -r _
}
pkg_lint() { pkg_lint() {
# Check that each mandatory file in the package entry exists. # Check that each mandatory file in the package entry exists.
log "$1" "Checking repository files" log "$1" "Checking repository files"
@ -362,14 +372,7 @@ pkg_build() {
log "Building: $*" log "Building: $*"
# Only ask for confirmation if more than one package needs to be built. # Only ask for confirmation if more than one package needs to be built.
[ $# -gt 1 ] || [ "$pkg_update" ] && { [ $# -gt 1 ] || [ "$pkg_update" ] && { prompt || exit; }
log "Continue?: Press Enter to continue or Ctrl+C to abort here"
# POSIX 'read' has none of the "nice" options like '-n', '-p'
# etc etc. This is the most basic usage of 'read'.
# '_' is used as 'dash' errors when no variable is given to 'read'.
read -r _ || exit
}
log "Checking to see if any dependencies have already been built" log "Checking to see if any dependencies have already been built"
log "Installing any pre-built dependencies" log "Installing any pre-built dependencies"
@ -486,18 +489,14 @@ pkg_build() {
# Only ask for confirmation if more than one package needs to be installed. # Only ask for confirmation if more than one package needs to be installed.
[ $# -gt 1 ] && { [ $# -gt 1 ] && {
log "Install built packages? [$*]" log "Install built packages? [$*]"
log "Press Enter to continue or Ctrl+C to abort here"
# POSIX 'read' has none of the "nice" options like '-n', '-p' prompt && {
# etc etc. This is the most basic usage of 'read'.
# '_' is used as 'dash' errors when no variable is given to 'read'.
read -r _ && {
args i "$@" args i "$@"
return return
} }
} }
log "Run 'kiss i $*' to install the package" log "Run 'kiss i $*' to install the package(s)"
} }
pkg_checksums() { pkg_checksums() {
@ -797,12 +796,8 @@ pkg_updates() {
contains "$outdated" kiss && { contains "$outdated" kiss && {
log "Detected package manager update" log "Detected package manager update"
log "The package manager will be updated first" log "The package manager will be updated first"
log "Continue?: Press Enter to continue or Ctrl+C to abort here"
# POSIX 'read' has none of the "nice" options like '-n', '-p' prompt || exit
# etc etc. This is the most basic usage of 'read'.
# '_' is used as 'dash' errors when no variable is given to 'read'.
read -r _ || exit
pkg_build kiss pkg_build kiss
args i kiss args i kiss