FS#39543 - [bash] Bug in homedir-shortening in PROMPT_COMMAND set in bashrc

Attached to Project: Arch Linux
Opened by ... (spider007) - Wednesday, 19 March 2014, 19:13 GMT
Last edited by Bartłomiej Piotrowski (Barthalion) - Sunday, 23 March 2014, 11:37 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Bartłomiej Piotrowski (Barthalion)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

There is a bug in https://projects.archlinux.org/svntogit/packages.git/tree/trunk/system.bashrc?h=packages/bash

The $PROMPT_COMMAND no longer shortens the homedir to tilde. The bug is in the replacement:

$ echo ~/asdf
/home/user/asdf
$ echo ${PWD/#$HOME/~}/asdf
/home/user/asdf

The solution is to escape the replacement:

$ echo ${PWD/#$HOME/\~}/asdf
~/asdf
This task depends upon

Closed by  Bartłomiej Piotrowski (Barthalion)
Sunday, 23 March 2014, 11:37 GMT
Reason for closing:  Fixed
Additional comments about closing:  bash 4.3-3
Comment by Bartłomiej Piotrowski (Barthalion) - Saturday, 22 March 2014, 12:26 GMT
What makes you think this is a bug? It seems to be perfectly sane, whatever the previous behavior was.
Comment by ... (spider007) - Saturday, 22 March 2014, 13:41 GMT
Previously, my terminal would show a tilde instead of my homedir; eg user@hostname:~/Downloads. Since bash was updated this has become user@hostname:/home/user/Downloads; which is annoying.

If you think this behaviour is sane regardless of the feature that was previously present; why would $PWD be subjected to a string-replacement in the bashrc file? I don't agree with you here; but the last argument could simply be $PWD if you're right
Comment by Bartłomiej Piotrowski (Barthalion) - Saturday, 22 March 2014, 13:46 GMT
Are you using the default prompt or you modified it?
Comment by ... (spider007) - Saturday, 22 March 2014, 14:00 GMT
This is the default behaviour (which is why I reported this bug in the default bashrc).
Comment by Bartłomiej Piotrowski (Barthalion) - Saturday, 22 March 2014, 14:11 GMT
Oh, ok, I understand the problem now. For some reason I'm unable to reproduce it, but escaping the tilde explicitly won't hurt anyway.
Comment by ... (spider007) - Saturday, 22 March 2014, 14:12 GMT
That would be great. I can reproduce this issue in both xfce-terminal and gnome-terminal btw (this is visible in the title of the window; not the $PS1/prompt)
Comment by Bartłomiej Piotrowski (Barthalion) - Saturday, 22 March 2014, 16:52 GMT
I have pushed bash 4.3-3 to [testing], let me know if it fixes the issue.
Comment by ... (spider007) - Saturday, 22 March 2014, 22:16 GMT
Thanks, that release fixes this issue!

Loading...