Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve quoting of command line arguments for build/run scripts #1511

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

jlowe
Copy link
Contributor

@jlowe jlowe commented Oct 19, 2023

Fixes #1092. This adds proper handling of arguments, quoting them when necessary to preserve them through double-parsing by the shell. Tested this by running a standard build-in-docker command along with one that specifies multiple GPU architectures that failed in the past, e.g.: build-in-docker -DGPU_ARCHS="75-real;80-real;86-real;90-real" clean install

@jlowe jlowe added the build label Oct 19, 2023
@jlowe jlowe self-assigned this Oct 19, 2023
@jlowe
Copy link
Contributor Author

jlowe commented Oct 19, 2023

build

Copy link
Collaborator

@gerashegalov gerashegalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -50,7 +50,7 @@ if (( $# == 0 )); then
DOCKER_OPTS="${DOCKER_OPTS} -it"
RUN_CMD="/bin/bash"
else
RUN_CMD="$*"
RUN_CMD="${@@Q}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we would not need to build a string from an array if we used the alternative syntax https://access.redhat.com/documentation/en-us/red_hat_software_collections/3/html/packaging_guide/sect-enabling_the_software_collection
with -- on L77

 if (( $# == 0 )); then
   # no arguments gets an interactive shell
   DOCKER_OPTS="${DOCKER_OPTS} -it"
-  RUN_CMD="/bin/bash"
+  RUN_CMD=("/bin/bash")
 else
-  RUN_CMD="${@@Q}"
+  RUN_CMD=("$@")
 fi
...
-  scl enable devtoolset-11 "$RUN_CMD"
+  scl enable devtoolset-11 -- "${RUN_CMD[@]}"

@jlowe jlowe merged commit 966c5f9 into NVIDIA:branch-23.12 Oct 23, 2023
2 checks passed
@jlowe jlowe deleted the fix-build-quoting branch October 23, 2023 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] build-in-docker and run-in-docker do not quote command line arguments properly
2 participants