summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-07-06 20:38:53 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2009-07-06 20:38:53 +0200
commit2f2756ab422102fb686a2d7fc1e4f65e82ec7f01 (patch)
tree451b258a66fdfb1778f059f2dcb7f24dc92f5083
parent6efcf520749fbfc491920816da764dbab94d8417 (diff)
pkg: Execute prereqs in function scope
This should encourage the use of typeset / setopt localoptions where neccessary
-rwxr-xr-xbin/pkg21
-rw-r--r--man/7/pkg4
2 files changed, 17 insertions, 8 deletions
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
diff --git a/man/7/pkg b/man/7/pkg
index bce5e79..c260975 100644
--- a/man/7/pkg
+++ b/man/7/pkg
@@ -139,6 +139,10 @@ The prerequisites are stored in a package in the file F<prereqs>.
It as an ordinary shell script which is sourced by pkg's global post-update
hook; so it will be sourced after pulling, pushing or refreshing a package.
+Note that the file will be sourced in function scope. It is recommended to
+introduce parameters and options local to the prereqs script with
+C<< typeset >> and C<< setopt localoptions >>, respectively.
+
It's main use is to check for dependencies. To help with this, the following
functions are available: