[Konsole-devel] [Bug 242114] Konsole resolves symlinks for initial path, should mimic CD/PWD behavior

Jekyll Wu adaptee at gmail.com
Sun Sep 4 08:05:05 UTC 2011


https://bugs.kde.org/show_bug.cgi?id=242114





--- Comment #7 from Jekyll Wu <adaptee gmail com>  2011-09-04 08:05:05 ---
(In reply to comment #6)
> 
Thanks for that reply. Yeah, I totally misunderstood the problem in the
opposite direction.

However, after making some investigation, I think there is no elegant solution
for this wish.  Below is a brief description of the involved implementation
details.

1). Before the terminal process(in this case, shell) is started, konsole calls
QProcess:setWorkingDirectory(dir) to set its initial working directory. In this
case, Konsole does pass the 'dir' argument in the form of the symlink itself,
instead of the target. 

2). Under Unix, the implementation of QProcess::setworkingdirectory(dir) calls
POSIX function chdir(3p) to do its job. According to this page[1], chdir(3p)
always resolves symlink into target. So although konsole does pass the symlink
itself, the started terminal process uses the taget as its initial working
directory.


One possible way is konsole automatically sends 'cd init-cwd-as-symlink' into
shell after starting a shell session. But I don't think that is a good idea:

1). It is a hack, not nice solution.
2). Users might be confused or scared by that coming-from-nowhere 'cd
init-cwd-as-symlink' command.

If you have some nice solution, please inform me.


Below is a simple program illustrating the behavior of chdir(3p)

#include <unistd.h>
#include <stdio.h>

int main(int argc, char const* argv[])
{
    char cwd[128] = {0,};

    chdir("/path/of/symlink");
    printf("cwd: %s\n", getcwd(cwd, 128) );
    printf("\n");

    return 0;
}

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/chdir.html

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the konsole-devel mailing list