Skip to content

Commit 471307c

Browse files
committed
be safer when constructing command args
1 parent 9285ac5 commit 471307c

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

features/src/rapids-build-utils/install.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ done
9696

9797
# Install bash_completion script
9898
if command -v devcontainer-utils-generate-bash-completion >/dev/null 2>&1; then
99-
devcontainer-utils-generate-bash-completion \
100-
--out-file /etc/bash_completion.d/rapids-build-utils-completions \
101-
${commands[@]/#/--command rapids-} \
102-
;
99+
read -ra commands <<< "${commands[*]/#/--command rapids-}";
100+
if test "${#commands[@]}" -gt 0; then
101+
devcontainer-utils-generate-bash-completion \
102+
--out-file /etc/bash_completion.d/rapids-build-utils-completions \
103+
"${commands[@]}" \
104+
;
105+
fi
103106
fi
104107

105108
find /opt/rapids-build-utils \

features/src/rapids-build-utils/opt/rapids-build-utils/bin/generate-scripts.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ generate_completions() {
1717
. devcontainer-utils-debug-output 'rapids_build_utils_debug' 'generate-scripts';
1818

1919
readarray -t commands < <(find "${TMP_SCRIPT_DIR}"/ -maxdepth 1 -type f -exec basename {} \;);
20-
21-
devcontainer-utils-generate-bash-completion \
22-
--out-file "$(realpath -m "${COMPLETION_FILE}")" \
23-
--template "$(realpath -m "${COMPLETION_TMPL}")" \
24-
${commands[@]/#/--command } \
25-
;
20+
read -ra commands <<< "${commands[*]/#/--command }";
21+
22+
if test "${#commands[@]}" -gt 0; then
23+
devcontainer-utils-generate-bash-completion \
24+
--out-file "$(realpath -m "${COMPLETION_FILE}")" \
25+
--template "$(realpath -m "${COMPLETION_TMPL}")" \
26+
"${commands[@]}" \
27+
;
28+
fi
2629
fi
2730
}
2831

features/src/utils/install.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,13 @@ done
125125
declare -a commands="($(for pair in "${commands_and_sources[@]}"; do cut -d' ' -f1 <<< "${pair}"; done))";
126126

127127
# Install bash_completion script
128-
devcontainer-utils-generate-bash-completion \
129-
--out-file /etc/bash_completion.d/devcontainer-utils-completions \
130-
${commands[@]/#/--command devcontainer-utils-} \
131-
;
128+
read -ra commands <<< "${commands[*]/#/--command devcontainer-utils-}";
129+
if test "${#commands[@]}" -gt 0; then
130+
devcontainer-utils-generate-bash-completion \
131+
--out-file /etc/bash_completion.d/devcontainer-utils-completions \
132+
"${commands[@]}" \
133+
;
134+
fi
132135

133136
find /opt/devcontainer \
134137
\( -type d -exec chmod 0775 {} \; \

0 commit comments

Comments
 (0)