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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/helpers: eliminate assumptions about login shells #2067

Merged
merged 1 commit into from
Jan 29, 2022

Conversation

gaelicWizard
Copy link
Contributor

@gaelicWizard gaelicWizard commented Jan 26, 2022

Description

Bash loads initialization files on Mac just the same as it does on Linux or WSL. Our previous assumptions were wrong, and my fix was als枚 wrong because I made more assumptions!

This patch eliminates the assumptions. Literally just load either the startup file the shell started with, or fall back to ~/.bashrc. Don't check shopt -q login_shell and don't check $OSTYPE or anything else.

Motivation and Context

I broke @NoahGorny's WSL shell. WSL runs shells as login shells, just like on Mac. But, since it loads an entire Linux distribution under the hood, WSL includes workarounds for Bash's weird startup file behaviours and, therefore, my assumption that the startup file for a login must always be ~/.bash_profile (or ~/.profile) was quickly proven wrong. 馃槥

How Has This Been Tested?

By Noah. 馃槅

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

@gaelicWizard gaelicWizard marked this pull request as ready for review January 26, 2022 18:12
@gaelicWizard
Copy link
Contributor Author

@NoahGorny, this works best with #1902, which is where I added $BASH_IT_BASHRC, but falls back to ~/.bashrc

Copy link
Member

@NoahGorny NoahGorny left a comment

Choose a reason for hiding this comment

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

This is much better now!

Bash loads initialization files on Mac just the same as it does on Linux or WSL. Our previous assumptions were wrong, and my fix was als枚 wrong because I made more assumptions!

This patch eliminates the assumptions. Literally just load either the startup file the shell started with, or fall back to `~/.bashrc`. Don't check `shopt -q login_shell` and don't check `$OSTYPE` or anything else.
@NoahGorny NoahGorny merged commit 1d6f4d7 into Bash-it:master Jan 29, 2022
@gaelicWizard gaelicWizard deleted the BASH_IT_BASHRC branch January 29, 2022 21:18
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.

None yet

2 participants