Bug 142125 - PROMPT_COMMAND breaks for cwd with trailing \
PROMPT_COMMAND breaks for cwd with trailing \
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: setup (Show other bugs)
3
All Linux
medium Severity medium
: ---
: ---
Assigned To: Phil Knirsch
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-12-07 10:23 EST by Joe Orton
Modified: 2015-03-04 20:14 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-01-24 14:39:19 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Joe Orton 2004-12-07 10:23:32 EST
The default PROMPT_COMMAND screws up for a directory name ending in a
slash: 

[root@emcee root]# set -x
++ echo -ne '\033]0;root@emcee:~\007'
[root@emcee root]# cd /local/jorton/php/scratch/a\\/
+ cd '/local/jorton/php/scratch/a\/'
++ echo -ne '\033]0;root@emcee:/local/jorton/php/scratch/a\\007'

because it escapes the \, thereby preventing the \007 from being
printed and terminating the escape sequence.  Subsequently shell
output is broken until a real \007 is printed.

Maybe that gun was pointing at *my* foot...
Comment 1 Phil Knirsch 2006-01-24 14:33:06 EST
I've reproduced this bug and found a solution, i'm just not sure i'm really
happy with it as it splits the PROMPT_COMMAND in 2 parts:

instead of doing:
  PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'

using this works:
  PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}";
echo -ne "\007"'

This might be a problem as a user could press CTRL-C exactly at the time the
first echo stops, possibly causing the same deranged output again.

Read ya, Phil
Comment 2 Phil Knirsch 2006-01-24 14:39:19 EST
Oh, i'll include the fix in the next version. It surely can't be worse then it
already was, so if a user willfully tries to break the prompt now there's
nothing i can do about it (except maybe not using PROMPT_COMMAND at all, but
thats for a later date...).

Read ya, Phil

Note You need to log in before you can comment on or make changes to this bug.