After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 733504 - bash 4.3+ replaces ~ (tilde) with $HOME undoing the $HOME->~ replacement in __vte_prompt_command
bash 4.3+ replaces ~ (tilde) with $HOME undoing the $HOME->~ replacement in _...
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
0.37.x
Other Linux
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-07-21 14:06 UTC by Colin Guthrie
Modified: 2014-07-23 20:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix ~ replacement in bash > 4.3 (1.24 KB, patch)
2014-07-21 14:06 UTC, Colin Guthrie
none Details | Review
fix v2 (441 bytes, patch)
2014-07-23 19:27 UTC, Egmont Koblinger
committed Details | Review

Description Colin Guthrie 2014-07-21 14:06:31 UTC
Created attachment 281312 [details] [review]
Fix ~ replacement in bash > 4.3

Since bash 4.3 things the nice replacement of /home/colin -> ~ in the terminal titles is undone by bash which flips it back to /home/colin again. Boo! Bad bash.

Attached patch restores this behaviour and also fixes a small bug where the cd'ing into another users home dir which happens to share your own homedirs prefix (e.g. /home/colintesting) would result in a slightly odd and misleading replacement.
Comment 1 Colin Guthrie 2014-07-21 14:07:37 UTC
Incidentally, if it's deemed too much "work" being done here, then the alternative is to simply change the:
 "${PWD/#$HOME/~}"
to just:
 "${PWD}"
Comment 2 Egmont Koblinger 2014-07-21 17:39:15 UTC
Bug confirmed. The patch indeed fixes it with bash 4.3 (and doesn't break with 4.2) - thanks.

However, it breaks it with zsh - where the title doesn't reflect the cwd by default, but if you alter it to do so (or execute __vte_profile_command manually) then the replacement doesn't work.
Comment 3 Egmont Koblinger 2014-07-21 17:43:26 UTC
Looks like we need backslash-escaping instead of quoting:
 "${PWD/#$HOME/\~}"
               ^
Comment 4 Colin Guthrie 2014-07-21 18:24:51 UTC
(In reply to comment #3)
> Looks like we need backslash-escaping instead of quoting:
>  "${PWD/#$HOME/\~}"

I've not tested but I thought that that would break in older bashes (the \ making it through to display), but if not, that's a much simpler fix 


Although note that the (existing) bug where if there are two user's with homes /home/colin and /home/colintesting, the title would end up being "~testing" if I (colin) did a cd into /home/colintesting folder.
Comment 5 Egmont Koblinger 2014-07-21 18:43:04 UTC
> I've not tested but I thought that that would break in older bashes (the \
> making it through to display), but if not, that's a much simpler fix 

Sure we'd need to test with older bashes too.

> Although note that the (existing) bug where if there are two user's with homes
> /home/colin and /home/colintesting, the title would end up being "~testing" if
> I (colin) did a cd into /home/colintesting folder.

Definitely, the additional lines of "local pwd" and conditional assigning is required, nice catch.
Comment 6 Colin Guthrie 2014-07-21 20:23:18 UTC
(In reply to comment #5)
> Definitely, the additional lines of "local pwd" and conditional assigning is
> required, nice catch.

Can't take credit for that one TBH, it was Mantas Mikulėnas who highlighted it to me when we were chatting about this issue! :)
Comment 7 Egmont Koblinger 2014-07-23 19:27:49 UTC
Created attachment 281502 [details] [review]
fix v2

This works for me with bash 3.2, 4.0, 4.2, 4.3 and zsh 5.0.  Please test ;)
Comment 8 Colin Guthrie 2014-07-23 20:32:46 UTC
Review of attachment 281502 [details] [review]:

Works for me in Bash 4.3 and 4.2, and I'll take your word for it on the others (looks good generally - seems my concern about the \~ being printed literally in bash < 4.2 was unfounded according to both your and my tests.

Ship it!!!