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: prefer $HOME over tilde notation #5196

Closed
wants to merge 1 commit into from

Conversation

jparise
Copy link
Collaborator

@jparise jparise commented Jan 18, 2025

This reverts part of #5075. While the ~ notation is more concise, I think the consensus is that using $HOME is more explicit, so prefer it.

We've also seen reports (#5169) that something about #5075 breaks the startup sequence in some environments. Reverting this part of the change will help us narrow that down.

Fixes #5206

This reverts part of ghostty-org#5075. While the ~ notation is more concise, I
think the consensus is that using $HOME is more explicit, so prefer it.

We've also seen reports that something about ghostty-org#5075 breaks the startup
sequence in some environments. Reverting this part of the change will
help us narrow that down.
@tristan957
Copy link
Member

I did some testing on my side. I think this is the reason for the regressions that I discovered. Only time will tell I guess after this is merged.

Copy link
Member

@tristan957 tristan957 left a comment

Choose a reason for hiding this comment

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

on line 59, there is a comment which includes a tilde. Might as well use $HOME there too

@jparise
Copy link
Collaborator Author

jparise commented Jan 18, 2025

on line 59, there is a comment which includes a tilde. Might as well use $HOME there too

I think I'll let that one be for line length reasons.

@jparise
Copy link
Collaborator Author

jparise commented Jan 18, 2025

I did some testing on my side. I think this is the reason for the regressions that I discovered. Only time will tell I guess after this is merged.

Great! I'm still unclear why the ~/ wouldn't be expanded to $HOME/ here. (I know it would be treated as a literal if it were quoted, but there weren't any cases of that here.) And I don't think we're changing $HOME to something different than what bash would expand. Still a mystery!

@tristan957
Copy link
Member

On my side, all I did was remove the tildes from the variables, reinstalled Ghostty, checked that the edited bash integration was in place, and reverted my Ghostty config and bashrc changes.

Now, I could have made a mistake somewhere along the way. I guess we will see after this PR merges for more confirmation.

Copy link

@keszybz keszybz left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -47,7 +47,7 @@ if [ -n "$GHOSTTY_BASH_INJECT" ]; then
if builtin shopt -q login_shell; then
if [[ $__ghostty_bash_flags != *"--noprofile"* ]]; then
[ -r /etc/profile ] && builtin source "/etc/profile"
for rcfile in ~/.bash_profile ~/.bash_login ~/.profile; do
for rcfile in "$HOME/.bash_profile" "$HOME/.bash_login" "$HOME/.profile"; do
Copy link

Choose a reason for hiding this comment

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

This has the advantage that it'll behave correctly if $HOME includes whitespace. Of course it's a niche case, but it's better to be resilient.

@@ -62,7 +62,7 @@ if [ -n "$GHOSTTY_BASH_INJECT" ]; then
for rcfile in /etc/bash.bashrc /etc/bash/bashrc /etc/bashrc; do
[ -r "$rcfile" ] && { builtin source "$rcfile"; break; }
done
if [[ -z "$GHOSTTY_BASH_RCFILE" ]]; then GHOSTTY_BASH_RCFILE=~/.bashrc; fi
if [[ -z "$GHOSTTY_BASH_RCFILE" ]]; then GHOSTTY_BASH_RCFILE="$HOME/.bashrc"; fi
Copy link

Choose a reason for hiding this comment

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

As I wrote in the original PR, this is iffy:

I have doubts about the expansion of the tilde here. Bash does expand ~ in the middle, but pure sh does not:

[zbyszek@x1c ghostty]$ sh -c 'echo VAR=~'
VAR=~
[zbyszek@x1c ghostty]$ bash -c 'echo VAR=~'
VAR=/home/zbyszek

@JacobCallahan
Copy link

@jparise I tested these changes locally and it didn't resolve the issue I'm seeing with the bashrc loading. However, after adding an echo, I did verify that your changes are correctly pointing to the correct file location. With that in mind, it seems like something else is going on than just not identifying the correct location.

New diff - also notice starship prompt
Screenshot From 2025-01-20 09-42-51

Correct bashrc location - also notice no starship prompt
Screenshot From 2025-01-20 09-43-07

@tristan957
Copy link
Member

tristan957 commented Jan 20, 2025

@JacobCallahan to work around, you can probably source the shell integration manually in your bashrc. That would bypass all the bash_preexec stuff.

@jparise
Copy link
Collaborator Author

jparise commented Jan 20, 2025

Closing this in favor of #5249, which includes these changes.

@jparise jparise closed this Jan 20, 2025
@JacobCallahan
Copy link

@tristan957 can you elaborate?

@tristan957
Copy link
Member

https://github.com/tristan957/dotfiles/blob/master/bash/.bashrc#L228-L241

@jparise jparise deleted the bash-home branch January 20, 2025 19:26
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.

bash: profile files not being sourced
4 participants