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

bash: Fix bashisms being applied to non-bash shells #4334

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TraceyC77
Copy link
Contributor

@TraceyC77 TraceyC77 commented Nov 12, 2024

Summary

Move sourcing of bashrc.d directory to default skel/.bashrc
Make all scripts in profile.d POSIX compliant
Fixes issues with errors being emitted by non-bash shells
Fixes bash specific user scripts improperly being loaded by other shells
Add README for profile.d files needing to be POSIX compliant

Test Plan

Installed the new eopkgs & rebooted. Verified:
bash loads properly with no errors
Scripts in ~/.bashrc.d/ loaded
zsh loads properly with no errors
Scripts in
Scripts in /usr/share/defaults/etc/profile were loaded for both shells

Checklist

  • Package was built and tested against unstable

Fixes #4214

Tracey Clark added 2 commits November 11, 2024 20:13
Move sourcing of bashrc.d directory to default skel/.bashrc
Make all scripts in profile.d POSIX compliant
Fixes issues with errors being emitted by non-bash shells
Fixes bash specific user scripts improperly being loaded by other shells
Add README for profile.d files needing to be POSIX compliant
Source profile.d files again to regain default settings now that they are POSIX compliant
@TraceyC77
Copy link
Contributor Author

There is one problem I still need to solve. The block to source ~/.bashrc.d has been moved from /usr/share/defaults/etc/profile to /etc/skel/.bashrc so that a user's bash scripts are only sourced by bash, not all shells. This will be find for new users on a system, but we need a way to add that block for existing users on the system. I am not sure how to approach that, ideas are welcome

@TraceyC77 TraceyC77 self-assigned this Nov 12, 2024
@TraceyC77 TraceyC77 linked an issue Nov 12, 2024 that may be closed by this pull request
1 task
@ermo
Copy link
Contributor

ermo commented Nov 13, 2024

As requested:

Gentle suggestion to perhaps also consider adding zsh /etc/skel files that support ~/.zshrc.d/* auto-loading?

Another (alternative?) option is to check the shell being run in the vendor scripts under /usr/share/defaults, and then, depending on shell, auto-loading ~/{ba,z}shrc.d/* files?

@TraceyC77
Copy link
Contributor Author

Gentle suggestion to perhaps also consider adding zsh /etc/skel files that support ~/.zshrc.d/* auto-loading?

I can add that to the .zshrc file, similar to how .bashrc loads ~/.bashrc.d/*
This is pretty standard

Another (alternative?) option is to check the shell being run in the vendor scripts under /usr/share/defaults, and then, depending on shell, auto-loading ~/{ba,z}shrc.d/* files?

That is not standard, and fragile. If you load a shell, it loads its startup files (like .bashrc / .zshrc) which then (per this PR) load the scripts directory. What you suggest would add unnecessary complication IMO.

Thanks for the feedback :)

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

Successfully merging this pull request may close these issues.

bash: fix 50-prompt.sh
2 participants