Use "#!/usr/bin/env bash" shebang in all shell scripts - #1426
Closed
rjeffman wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="infra/image/build.sh" line_range="1" />
<code_context>
-#!/bin/bash -eu
+#!/usr/bin/env bash -eu
# This file shoud be source'd (. set_test_modules) rather than executed.
#
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `env` in the shebang with options changes how arguments are passed and may break `-eu` handling.
On most systems, `#!/usr/bin/env bash -eu` will treat `/usr/bin/env` as the interpreter and pass `'bash -eu'` as a single argument, so `env` won’t split out `-eu` as options to `bash`. That means the script may run without `-eu` or fail, depending on the platform. To keep portability and strict flags, use `#!/usr/bin/env bash` and add `set -eu` in the script body, or revert to `#!/bin/bash -eu` if you rely on the shebang for `-eu`.
</issue_to_address>
### Comment 2
<location path="infra/image/system-service/fixipaip.sh" line_range="1" />
<code_context>
-#!/bin/bash -eu
+#!/usr/bin/env bash -eu
# This file shoud be source'd (. set_test_modules) rather than executed.
#
</code_context>
<issue_to_address>
**issue (bug_risk):** Shebang change here has the same `env` + options concern and may affect script behavior.
This change makes the script rely on `/usr/bin/env` correctly handling `bash -eu` as separate arguments, which is not portable and may change exit/error behavior. Please switch to a safer pattern such as `#!/usr/bin/env bash` with `set -eu` inside the script, or keep `#!/bin/bash -eu` if `/bin/bash` is guaranteed in your environments, and apply the same approach to the other updated scripts.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
rjeffman
force-pushed
the
hashbang
branch
5 times, most recently
from
July 10, 2026 00:57
e3991d1 to
cf4b0df
Compare
Replace hardcoded "#!/bin/bash" with "#!/usr/bin/env bash" across all shell scripts in infra/, tests/, and utils/ to improve portability on systems where bash is not at /bin/bash (e.g., macOS with Homebrew bash). Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
Member
Author
|
Closing as we can't actually use this solution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace hardcoded "#!/bin/bash" with "#!/usr/bin/env bash" across all shell scripts in infra/, tests/, and utils/ to improve portability on systems where bash is not at /bin/bash (e.g., macOS with Homebrew bash).
Summary by Sourcery
Enhancements: