makeWrapper: fix flag handling

When `--add-flags` is not used, `flagsBefore` is unset.  This causes an error when invoking `makeWrapper` from a context that sets `-o nounset`, as is done in `buildDotnetModule`.
This change makes `makeWrapper` safe for use in these conditions.
This commit is contained in:
James Kay 2021-12-02 13:42:40 +00:00 committed by Artturin
parent 4e6190bec3
commit 40fbc97988

View file

@ -166,11 +166,11 @@ makeShellWrapper() {
elif [[ "$p" == "--add-flags" ]]; then
flags="${params[$((n + 1))]}"
n=$((n + 1))
flagsBefore="$flagsBefore $flags"
flagsBefore="${flagsBefore-} $flags"
elif [[ "$p" == "--append-flags" ]]; then
flags="${params[$((n + 1))]}"
n=$((n + 1))
flagsAfter="$flagsAfter $flags"
flagsAfter="${flagsAfter-} $flags"
elif [[ "$p" == "--argv0" ]]; then
argv0="${params[$((n + 1))]}"
n=$((n + 1))
@ -183,7 +183,7 @@ makeShellWrapper() {
done
echo exec ${argv0:+-a \"$argv0\"} \""$original"\" \
"$flagsBefore" '"$@"' "$flagsAfter" >> "$wrapper"
"${flagsBefore-}" '"$@"' "${flagsAfter-}" >> "$wrapper"
chmod +x "$wrapper"
}