2 # shellcheck shell=bash
4 set -eu -o pipefail
+o posix
7 if (( "${NIX_DEBUG:-0}" >= 7 )); then
23 ${extraBefore+"${extraBefore[@]}"} \
24 ${params+"${params[@]}"} \
25 ${extraAfter+"${extraAfter[@]}"}
27 if [ "$restAreFiles" ]; then
32 # Unrelated arguments with values
39 # Any other orgument either takes no value, or is a file.
40 if [[ "$p" != -* ]]; then
46 if [ "$p" == - ]; then
54 # Optionally print debug info.
55 if (( "${NIX_DEBUG:-0}" >= 1 )); then
56 # Old bash workaround, see above.
57 echo "extra flags before to @prog@:" >&2
58 printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2
59 echo "original flags to @prog@:" >&2
60 printf " %q\n" ${params+"${params[@]}"} >&2
61 echo "extra flags after to @prog@:" >&2
62 printf " %q\n" ${extraAfter+"${extraAfter[@]}"} >&2
66 ${extraBefore+"${extraBefore[@]}"} \
67 ${params+"${params[@]}"} \
68 ${extraAfter+"${extraAfter[@]}"}
70 if [ "$output" ]; then
71 # Single explicit output
72 signIfRequired
"$output"
74 # Multiple inputs, rewritten in place
75 for input
in "${inputs[@]}"; do
76 signIfRequired
"$input"