From 2f2756ab422102fb686a2d7fc1e4f65e82ec7f01 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 6 Jul 2009 20:38:53 +0200 Subject: pkg: Execute prereqs in function scope This should encourage the use of typeset / setopt localoptions where neccessary --- bin/pkg | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'bin/pkg') diff --git a/bin/pkg b/bin/pkg index 82e05d1..b40ede0 100755 --- a/bin/pkg +++ b/bin/pkg @@ -465,6 +465,18 @@ function check_prereqs { wrap_info $1 info "checking prerequisites\n" + # function scope → typeset and localoptions are possible + function source_prereqs { + { + source prereqs + } always { + if (( TRY_BLOCK_ERROR )) { + warn "Error in prereqs script\n" + TRY_BLOCK_ERROR=0 + } + } + } + function is_installed { [[ -d $PKG_DIR/$1 ]] } @@ -507,14 +519,7 @@ function check_prereqs { } } - { - source prereqs - } always { - if (( TRY_BLOCK_ERROR )) { - warn "Error in prereqs script\n" - TRY_BLOCK_ERROR=0 - } - } + source_prereqs if [[ -n $warn || -n $info ]] { [[ -n $warn ]] && warn $warn -- cgit v1.2.3