diff --git a/bootstrap.sh b/bootstrap.sh index 284188e..17a1269 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -60,17 +60,29 @@ function ensureBinary() { printSuccess 'done' } -function main() { +function configureTerminal() { if [ -t 0 ]; then - trap "stty $(stty -g)" INT TERM EXIT + traps+=("stty $(stty -g)") stty -echo fi - [ -t 1 ] && tput civis && export TERMINAL_CURSOR_HIDDEN=true + + if [ -t 1 ]; then + traps+=('tput cnorm') + tput civis + export TERMINAL_CURSOR_HIDDEN=true + fi +} + +function main() { + local traps=() local -A colors=() errColors=() defineColors id -Gn | grep admin >&! /dev/null || { printError 'This script requires root access. Please run as an admin user.'; return 10 } + + configureTerminal local tmpdir="`mktemp -d -t 'macos-system'`" - isDebug || trap "rm -fr -- '${tmpdir}'; return" INT TERM EXIT + isDebug || traps+=("rm -fr -- '${tmpdir}'") + trap ${(j.;.)traps} INT TERM EXIT pushd -q "${tmpdir}" print -l "Working directory is: ${tmpdir}" diff --git a/install.sh b/install.sh index 7d6c61e..f715b4d 100755 --- a/install.sh +++ b/install.sh @@ -81,16 +81,22 @@ function checkPrerequisites() { test "`id -u`" -eq 0 || { lop -- -e 'This module requires root access. Please run as root.'; return 11 } } -function main() { +function configureTerminal() { if [ -t 0 ]; then - trap "stty $(stty -g)" INT TERM EXIT + traps+=("stty $(stty -g)") stty -echo fi if [ -t 1 ]; then - trap "tput cnorm" INT TERM EXIT + traps+=('tput cnorm') tput civis export TERMINAL_CURSOR_HIDDEN=true fi +} + +function main() { + local traps=() + configureTerminal + trap ${(j.;.)traps} INT TERM EXIT autoloadZShLib || return checkPrerequisites || return eval "`docopts -f -V - -h - : "$@" <<- USAGE