Skip to content

Commit 8fa06ea

Browse files
Fix bash issues in osx_cc_wrapper.sh.tpl (#685)
This PR fixes two issues with the `osx_cc_wrapper.sh.tpl` and `cc_wrapper.sh.tpl` templates: 1. (Both files) The condition for entering the loop to process parameter files included `-r ${i:1}`, which was checking the loop index value, not the argument that corresponds to the name of the parameter file. This was changed to `-r ${!i:1}`. 2. (Only `osx_cc_wrapper.sh.tpl`) The temporary file was being appended to with the result of `parse_option`, which doesn't return any value, resulting in the tempfile being empty. This was changed to run `parse_option "${opt}"` separately from appending the option to the file, ensuring that the temporary file is being populated with the sanitized commands. The first fix addresses the issue of arguments in the param files not being sanitized, while the second addresses the issue of the sanitized arguments in the parameter file not being passed through. --------- Co-authored-by: Trevor Elliott <trevor@stripe.com>
1 parent 65be3e9 commit 8fa06ea

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

toolchain/cc_wrapper.sh.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function sanitize_option() {
118118

119119
cmd=()
120120
for ((i = 0; i <= $#; i++)); do
121-
if [[ ${!i} == @* && -r "${i:1}" ]]; then
121+
if [[ ${!i} == @* && -r "${!i:1}" ]]; then
122122
# Create a new, sanitized file.
123123
tmpfile=$(mktemp)
124124
CLEANUP_FILES+=("${tmpfile}")

toolchain/osx_cc_wrapper.sh.tpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,16 @@ function sanitize_option() {
146146

147147
cmd=()
148148
for ((i = 0; i <= $#; i++)); do
149-
if [[ ${!i} == @* && -r "${i:1}" ]]; then
149+
if [[ ${!i} == @* && -r "${!i:1}" ]]; then
150150
tmpfile=$(mktemp)
151151
CLEANUP_FILES+=("${tmpfile}")
152152
while IFS= read -r opt; do
153153
opt="$(
154154
set -e
155155
sanitize_option "${opt}"
156156
)"
157-
parse_option "${opt}" >>"${tmpfile}"
157+
parse_option "${opt}"
158+
echo "${opt}" >>"${tmpfile}"
158159
done <"${!i:1}"
159160
cmd+=("@${tmpfile}")
160161
else

0 commit comments

Comments
 (0)