Skip to content

Replace hardcoded shebangs with /usr/bin/env for portability#1105

Merged
devacts merged 1 commit intocarvel-dev:developfrom
Lillecarl:shebangs
Feb 16, 2026
Merged

Replace hardcoded shebangs with /usr/bin/env for portability#1105
devacts merged 1 commit intocarvel-dev:developfrom
Lillecarl:shebangs

Conversation

@Lillecarl
Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Replaces hardcoded shebang paths (#!/bin/bash and #!/bin/sh) with portable versions (#!/usr/bin/env bash and #!/usr/bin/env sh) in all shell scripts in the hack/ directory.

This improves portability across different Unix-like systems where shell interpreters may not be in standard locations, such as:

  • NixOS: Bash is located at /run/current-system/sw/bin/bash
  • BSD variants: May have bash in /usr/local/bin/bash
  • Custom environments: Where bash is installed in non-standard locations

Using /usr/bin/env is the POSIX-recommended approach and is already widely adopted in the Go ecosystem.

Which issue(s) this PR fixes:

Fixes #1104

Does this PR introduce a user-facing change?

NONE

Additional Notes for your reviewer:

This is a straightforward portability fix that doesn't change any functionality. All 10 shell scripts in the hack/ directory have been updated. The scripts will continue to work exactly as before on systems with bash in /bin/bash, while now also working on systems where bash is in other locations.

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated (N/A - shebang-only change)
  • Relevant docs in this repo added or updated (N/A - no doc changes needed)
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR (N/A - no doc changes needed)
  • Code is at least as readable and maintainable as it was before this
    change

Additional documentation e.g., Proposal, usage docs, etc.:

N/A

Changes all scripts to use #!/usr/bin/env bash/sh instead of
hardcoded paths like #!/bin/bash and #!/bin/sh. This improves
portability across different systems (NixOS, BSD, etc.) where
interpreters may not be in standard locations.
Copy link
Copy Markdown
Member

@CodesbyUnnati CodesbyUnnati left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks for raising this PR.

@devacts devacts merged commit ce711af into carvel-dev:develop Feb 16, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this to Closed in Carvel Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

hack scripts doesn't respect $PATH

4 participants