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

chore: add quotes to variables in shell scripts #340

Open
wants to merge 3 commits into
base: mainline
Choose a base branch
from

Conversation

moorec-aws
Copy link
Contributor

What was the problem/requirement? (What/Why)

We have a bunch of unquoted variables in our shell scripts

What was the solution? (How)

Add the quotes

What is the impact of this change?

n/a

How was this change tested?

hatch run test

Was this change documented?

No

Is this a breaking change?

No


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@moorec-aws moorec-aws marked this pull request as ready for review June 20, 2024 22:49
@moorec-aws moorec-aws requested a review from a team as a code owner June 20, 2024 22:49
@moorec-aws moorec-aws force-pushed the moorec/unqouted-variables branch from 3e8d9b7 to 21b72de Compare June 20, 2024 22:52
@moorec-aws moorec-aws changed the title chore: add qoutes to variables in shell scripts chore: add quotes to variables in shell scripts Jun 20, 2024
@@ -1,7 +1,7 @@
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

export ENV_JSON=$(dirname $0)/queue-env.json
export ENV_JSON=$(dirname "$0")/queue-env.jso
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export ENV_JSON=$(dirname "$0")/queue-env.jso
export ENV_JSON=$(dirname "$0")/queue-env.json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

-v "$(pwd)":/code:ro \
-v "${HOME}"/.aws:/aws \
--env-file "${TMP_ENV_FILE}" \
"${ARGS}" \
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"${ARGS}" \
${ARGS} \

I don't think that this one should be quotes. ARGS is built-up in this script and contains multiple command-line arguments appended together. Quoting this turns that list of args into a single argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

sudo -u agentuser -i "${ENVS}" /home/agentuser/run_agent.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sudo -u agentuser -i "${ENVS}" /home/agentuser/run_agent.sh
sudo -u agentuser -i ${ENVS} /home/agentuser/run_agent.sh

ENVS is built-up in this script by appending multiple env var definitions together. This needs to be interpreted as multiple args to the shell, so it cannot be quoted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@moorec-aws moorec-aws force-pushed the moorec/unqouted-variables branch 2 times, most recently from e5a5694 to e184024 Compare June 29, 2024 01:22
-v $(pwd):/code:ro \
-v ${HOME}/.aws:/aws \
--env-file ${TMP_ENV_FILE} \
--name test_worker_agentss \
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like an unintended change, right?

This container name is referenced in a few other places:

docker exec test_worker_agent /home/agentuser/term_agent.sh

docker exec -it test_worker_agent /bin/bash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was unintended. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there is still an unintended change from test_worker_agenttest_worker_agents. We should restore the original name (test_worker_agent)

@moorec-aws moorec-aws force-pushed the moorec/unqouted-variables branch from e184024 to 70d90b1 Compare July 4, 2024 16:41
@moorec-aws moorec-aws force-pushed the moorec/unqouted-variables branch from 70d90b1 to 6e0550b Compare July 4, 2024 16:43
-v $(pwd):/code:ro \
-v ${HOME}/.aws:/aws \
--env-file ${TMP_ENV_FILE} \
--name test_worker_agents \
Copy link
Contributor

Choose a reason for hiding this comment

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

This is still breaks the docker workflows I think. This should now have changed and should actually be test_worker_agent

-v $(pwd):/code:ro \
-v ${HOME}/.aws:/aws \
--env-file ${TMP_ENV_FILE} \
--name test_worker_agentss \
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there is still an unintended change from test_worker_agenttest_worker_agents. We should restore the original name (test_worker_agent)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants