diff options
author | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2019-09-22 11:35:07 +0000 |
---|---|---|
committer | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2019-09-22 11:35:07 +0000 |
commit | f2b996da8fff8d719eb9432a1b83bf36798c0673 (patch) | |
tree | 9f023143f3c412d0b5abdbe2a57c34a91cadc0ea | |
parent | ac0194d62d0004fb98ee6f639d3f8232c8749996 (diff) | |
download | cpt-f2b996da8fff8d719eb9432a1b83bf36798c0673.tar.gz |
kiss: move prompts to a function
FossilOrigin-Name: c0105d721e97f3d209a93b966ff4afad32a94667809122bc652992fb3eacfaca
-rwxr-xr-x | kiss | 33 |
1 files changed, 14 insertions, 19 deletions
@@ -41,6 +41,16 @@ contains() { 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() { # Check that each mandatory file in the package entry exists. log "$1" "Checking repository files" @@ -362,14 +372,7 @@ pkg_build() { log "Building: $*" # Only ask for confirmation if more than one package needs to be built. - [ $# -gt 1 ] || [ "$pkg_update" ] && { - 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 - } + [ $# -gt 1 ] || [ "$pkg_update" ] && { prompt || exit; } log "Checking to see if any dependencies have already been built" 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. [ $# -gt 1 ] && { 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' - # etc etc. This is the most basic usage of 'read'. - # '_' is used as 'dash' errors when no variable is given to 'read'. - read -r _ && { + prompt && { args i "$@" return } } - log "Run 'kiss i $*' to install the package" + log "Run 'kiss i $*' to install the package(s)" } pkg_checksums() { @@ -797,12 +796,8 @@ pkg_updates() { contains "$outdated" kiss && { log "Detected package manager update" 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' - # 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 + prompt || exit pkg_build kiss args i kiss |