Bug 142125 - PROMPT_COMMAND breaks for cwd with trailing \
Summary: PROMPT_COMMAND breaks for cwd with trailing \
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: setup
Version: 3
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Phil Knirsch
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-12-07 15:23 UTC by Joe Orton
Modified: 2015-03-05 01:14 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-01-24 19:39:19 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Joe Orton 2004-12-07 15:23:32 UTC
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 19:33:06 UTC
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 19:39:19 UTC
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.