Bug 293710

Summary: A trailing / in --workdir argument messes up how PS1 is displayed in konsole
Product: konsole Reporter: Ahmad Samir <a.samirh78>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: normal CC: adaptee
Priority: NOR    
Version: 2.8.999   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In: 4.8.1

Description Ahmad Samir 2012-02-09 12:48:22 UTC
It seems that --workdir doesn't handle trailing /'s correctly:

$ konsole --workdir /usr/share/icons/
Konsole displays this:
[a@localhost ]$ 

But this works correctly:
$ konsole --workdir /usr/share/icons
[a@localhost icons]$ 

notice how the basename of the dir path, "icons", isn't displayed in the first case.

My shell is BASH, here's some info:
$ echo $PS1
[\u@\h \W]\$

$ echo $PROMPT_COMMAND
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"

$ echo $PWD
/usr/share/icons/
Comment 1 Jekyll Wu 2012-02-09 13:56:39 UTC
Thanks for reporting. 

This looks like a side effect of commit 790e835c6fab58a5c4bfe00559d3a4ee97b84e38, which sets environment $PWD additionally.

Will fix it soon.
Comment 2 Jekyll Wu 2012-02-09 14:03:43 UTC
Git commit fdca5195cc46a12bb62444b31867ce69a75830e7 by Jekyll Wu.
Committed on 09/02/2012 at 14:47.
Pushed by jekyllwu into branch 'master'.

Remove trailing slash when settings initial working directory
FIXED-IN: 2.8.1

M  +11   -3    src/Pty.cpp

http://commits.kde.org/konsole/fdca5195cc46a12bb62444b31867ce69a75830e7
Comment 3 Jekyll Wu 2012-02-09 14:14:44 UTC
Git commit 16233a4b2b9d1c39f4c0ea6d5272ffcaa8bbde6c by Jekyll Wu.
Committed on 09/02/2012 at 14:47.
Pushed by jekyllwu into branch 'KDE/4.8'.

Remove trailing slash when settings initial working directory
FIXED-IN: 2.8.1
(cherry picked from commit fdca5195cc46a12bb62444b31867ce69a75830e7)

M  +11   -3    src/Pty.cpp

http://commits.kde.org/konsole/16233a4b2b9d1c39f4c0ea6d5272ffcaa8bbde6c
Comment 4 Ahmad Samir 2012-02-09 14:37:55 UTC
I can confirm the fix.

This fixes a bug with Dolphin where opening a terminal, using Shift+F4, in a dir:
- After going up, Alt+Up OR
- Right clicking a search result in Dolphin and selecting "Open path in a new tab"

would exhibit this bug, where the current working dir isn't shown in the prompt.

Thanks :)