nixos/ebusd: fix device access (#352743)
[NixPkgs.git] / pkgs / build-support / bintools-wrapper / darwin-strip-wrapper.sh
bloba67699547a6f64a1ccba46bbd6e42e6d3cee7e3a
1 #! @shell@
2 # shellcheck shell=bash
4 set -eu -o pipefail +o posix
5 shopt -s nullglob
7 if (( "${NIX_DEBUG:-0}" >= 7 )); then
8 set -x
9 fi
11 source @signingUtils@
13 extraAfter=()
14 extraBefore=()
15 params=("$@")
17 output=
18 inputs=()
20 restAreFiles=
21 prev=
22 for p in \
23 ${extraBefore+"${extraBefore[@]}"} \
24 ${params+"${params[@]}"} \
25 ${extraAfter+"${extraAfter[@]}"}
27 if [ "$restAreFiles" ]; then
28 inputs+=("$p")
29 else
30 case "$prev" in
31 -s|-R|-d|-arch)
32 # Unrelated arguments with values
34 -o)
35 # Explicit output
36 output="$p"
39 # Any other orgument either takes no value, or is a file.
40 if [[ "$p" != -* ]]; then
41 inputs+=("$p")
44 esac
46 if [ "$p" == - ]; then
47 restAreFiles=1
51 prev="$p"
52 done
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
65 @prog@ \
66 ${extraBefore+"${extraBefore[@]}"} \
67 ${params+"${params[@]}"} \
68 ${extraAfter+"${extraAfter[@]}"}
70 if [ "$output" ]; then
71 # Single explicit output
72 signIfRequired "$output"
73 else
74 # Multiple inputs, rewritten in place
75 for input in "${inputs[@]}"; do
76 signIfRequired "$input"
77 done