aboutsummaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorAndré Erdmann <dywi@mailerd.de>2013-09-06 12:18:59 +0200
committerAndré Erdmann <dywi@mailerd.de>2013-09-06 12:18:59 +0200
commit9f4d5cecf2de280506c0e96b94de56ea6a603ecb (patch)
tree148b90cd0a87f49c70b4d9b2bf787b0d6f4c4ad1 /files
parentfiles/hooks/mux.sh: set $this (diff)
downloadR_overlay-9f4d5cecf2de280506c0e96b94de56ea6a603ecb.tar.gz
R_overlay-9f4d5cecf2de280506c0e96b94de56ea6a603ecb.tar.bz2
R_overlay-9f4d5cecf2de280506c0e96b94de56ea6a603ecb.zip
files/hooks/mux: run hooks in a subshell
Diffstat (limited to 'files')
-rwxr-xr-xfiles/hooks/mux.sh39
1 files changed, 17 insertions, 22 deletions
diff --git a/files/hooks/mux.sh b/files/hooks/mux.sh
index efda723..c78d9e8 100755
--- a/files/hooks/mux.sh
+++ b/files/hooks/mux.sh
@@ -30,28 +30,23 @@ for hookfile in \
${FILESDIR}/hooks/?*.${ROVERLAY_PHASE}
do
if [ -f "${hookfile}" ]; then
- #subshell?
- #( . "${hookfile}"; ) || ...
-
- hookfile_name="${hookfile##*/}"
- this="${hookfile_name#[0-9]*-}"; this="${this%.*}"
-
- if [ -n "${this}" ]; then
- veinfo "Running hook ${this} ('${hookfile_name}')"
- else
- this="${hookfile_name}"
- veinfo "Running hook '${hookfile_name}'"
- fi
-
- # initial directory should always be $S
- cd "${S}" && . "${hookfile}" || \
- die "errors occured while running hook '${hookfile}'"
-
- # restore signals
- trap - INT TERM EXIT
-
- this="${SCRIPT_NAME}"
- unset -v hookfile_name
+ # subshell: don't leak hook vars/functions
+ (
+ readonly hookfile_name="${hookfile##*/}"
+ this="${hookfile_name#[0-9]*-}"; this="${this%.*}"
+
+ if [ -n "${this}" ]; then
+ veinfo "Running hook ${this} ('${hookfile_name}')"
+ else
+ this="${hookfile_name}"
+ veinfo "Running hook '${hookfile_name}'"
+ fi
+
+ readonly this
+
+ # initial directory should always be $S
+ cd "${S}" && . "${hookfile}"
+ ) || die "errors occured while running hook '${hookfile}'"
fi
done