Bug 336618

Summary: new tab shell loses symlink path
Product: [Applications] konsole Reporter: Mayavimmer <mayavimmer>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: major CC: egmont, martin.sandsmark
Priority: NOR    
Version: 2.12.4   
Target Milestone: ---   
Platform: Mandriva RPMs   
OS: Linux   
Latest Commit: Version Fixed In:

Description Mayavimmer 2014-06-23 14:51:24 UTC
The shell created by new tab does not preserve the correct path info when a path component is symlinked. Therefore pwd in the new tab gives the "physical directory structure" oath instad of the logical one. See example below.
This is very bad because complex software fails in subtle ways if the symlinks are wrong.
I can no longer trust a quick ctl-alt-t.

Reproducible: Always

Steps to Reproduce:
1. cd /tmp
2. mkdir -p d1/d2
3. ln -s d1/d2 .
4. cd d2
5. <open new tab>
6. pwd
Actual Results:  
tab1: /tmp/d2
tab2: /tmp/d1/d2


Expected Results:  
tab1: /tmp/d2
tab2: /tmp/d2

I consider it a major bug because it breaks some user code.
I had a Makefile fail after I do "cd d2", but only in new tabs!
Comment 1 Egmont Koblinger 2014-09-13 15:13:52 UTC
As far as I can tell, konsole digs into /proc to figure out the current directory. With this approach it cannot tell if a symlink was followed, it only sees the actual resolved physical directory.

In order to address this bug (and anyway to have a cleaner, less OS dependent, more flexible solution), konsole should abandon this approach and follow Mac Terminal (probably also iTerm2) and Gnome-Terminal (>= 3.8) in using OSC 7. This way konsole wouldn't dig into /proc, but it would be the application's (e.g. bash's) responsibility to tell the current directory to the terminal. This path could potentially contain symlinks. Konsole would, apart from cd'ing there, also set $PWD to let the shell know about the symlink components. (bash duplicates get_current_dir_name()'s behavior, that is, if $PWD contains a symlink but actually points to the current directory then uses this value including the symlink components.)
Comment 2 Kurt Hindenburg 2014-09-27 02:40:51 UTC
I agree comment:1
Comment 3 Martin Sandsmark 2016-07-03 01:58:31 UTC
https://git.reviewboard.kde.org/r/128351/
Comment 4 Martin Sandsmark 2016-07-06 18:30:53 UTC
Git commit bb6abc0bc8a23f46752f7341d43e4275e9085fa9 by Martin T. H. Sandsmark.
Committed on 06/07/2016 at 18:30.
Pushed by sandsmark into branch 'master'.

Implement support for getting the current URL from OSC 7

Implements support for the OSC 7 "standard" for tracking open
directories in the terminal (e. g. for bookmarks).

>From the bug report, this is apparently what the osx terminal, iterm and
gnome terminal uses to keep track of stuff. I kept the existing tracking
as a fallback.

REVIEW: 128351

M  +15   -0    src/Session.cpp
M  +2    -0    src/Session.h

http://commits.kde.org/konsole/bb6abc0bc8a23f46752f7341d43e4275e9085fa9