Skip to content

Make /etc/profile.d/path.sh POSIX sh compatible to avoid breaking login dash#3199

Open
haithamseelawi-synth wants to merge 1 commit into
aws:developfrom
haithamseelawi-synth:fix/profile-path-posix-sh
Open

Make /etc/profile.d/path.sh POSIX sh compatible to avoid breaking login dash#3199
haithamseelawi-synth wants to merge 1 commit into
aws:developfrom
haithamseelawi-synth:fix/profile-path-posix-sh

Conversation

@haithamseelawi-synth

Copy link
Copy Markdown

Description of changes

aws-parallelcluster-shared::setup_envars renders /etc/profile.d/path.sh from profile/path.sh.erb. The template uses bash-only syntax (a PATH_REQUIRED_DIRECTORIES=(...) array and [[ ... ]]).

Scripts in /etc/profile.d are sourced (not executed) by the login shell, so the #!/bin/bash shebang is ignored. On Debian/Ubuntu /etc/profile is processed by dash, which has no arrays, so any sh -l login aborts with:

/etc/profile.d/path.sh: 3: Syntax error: "(" unexpected

This breaks tooling that relies on a working login sh on cluster nodes (e.g. remote dev-container / IDE setup steps that read the remote env via sh -lc). Interactive users in bash/zsh don't notice it.

This rewrites the template in portable POSIX sh (a plain for loop + case), preserving the existing behavior: append each required directory to PATH only if not already present, in the same order.

Tests

  • sh -n / dash -n on the rendered file: exits 0 (previously exit 2).
  • Sourced under dash and bash: PATH gets the required directories, and is idempotent when a directory is already present.
  • Added an InSpec regression assertion (sh -n /etc/profile.d/path.sh exits 0) to setup_envars_spec.rb; existing assertions unchanged.

References

  • N/A

Checklist

  • Pointing to the right branch (develop).
  • Behavior-preserving change with an added regression test.
  • Commit message describes what and why.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@haithamseelawi-synth haithamseelawi-synth requested review from a team as code owners June 10, 2026 12:32
@haithamseelawi-synth haithamseelawi-synth force-pushed the fix/profile-path-posix-sh branch from f55ec46 to 640dc48 Compare June 16, 2026 13:08
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.

1 participant