Skip to content

Commit ec0541c

Browse files
author
Eric Crosson
committed
Use POSIX approach for cross-compatibility
using tempfiles... but it should be ok. Will it be okay when a script in the pipeline crashes captian-hook? Deliberate.
1 parent b529ab1 commit ec0541c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

captain-hook.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ runHook() {
8181
local -r executing_hook=$1; shift
8282
local rc=0
8383

84-
local -r pipeline=$(_getPipeline "${executing_hook}.d")
85-
debug "Pipeline is ${pipeline}"
86-
while IFS= read -rd '' script; do
84+
local -r _tmpfile=$(mktemp captain-hook.XXXX)
85+
_getPipeline "${executing_hook}.d" > "${_tmpfile}"
86+
debug "PWD is $PWD"
87+
debug "Pipeline is $(cat "${_tmpfile}")"
88+
while IFS= read -r script; do
8789
# if part of the pipeline has failed, skip forward to the
8890
# "ensured" scripts
8991
if [[ "${rc}" -ne 0 ]]; then
@@ -94,7 +96,8 @@ runHook() {
9496
"${script}" "$@"
9597
rc=$(_updateRc "${rc}" $?)
9698
debug "Executing script: '${script}'...done"
97-
done < <("${pipeline}")
99+
done < "${_tmpfile}"
100+
rm -f "${_tmpfile}"
98101

99102
exit "$(_determineExitCode "${rc}")"
100103
}

0 commit comments

Comments
 (0)