Registered Member
|
When I start a new tab with ctrl-shft-t I get the deafult bash session, but with the wrong PWD when the PWD contains symlinks. It instead sets PWD to `pwd -P`. Example:
In the first tab I type:
...then I open a new tab with ctrl-shft-t:
I get two different behaviors depending on how I start the new bash session! I already opened a bug ticket at: https://bugs.kde.org/show_bug.cgi?id=336618 Are there any workarounds? I tried various combinations with the Command: in Konsole's profile manager, with no luck. It seems by the time I get to run the Command: the old $PWD is already lost. |
Administrator
|
What is the output of "ls -lah /proc/$$"?
At least on my system, the kernel provided value of "cwd" will be the actual address. As Konsole has no way of accessing the bash interpreter itself, it must rely on the kernel provided information - which is why you are observing this behaviour.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
The output of "ls -lah /proc/$$/cwd" gives the same path as `pwd -P`, as expected. It seems that the kernel does not also keep track of the Logical path.
I understand that Konsole does not try to integrate with the given shell, as it probably should not, and that is why I asked for a workaround, hoping someone might have found a way to extract the $PWD from the bash process, and feed it to the Command: line in the Edit Profile/General tab. Any such workaround would not touch Konsole's source code, but simply be a user configuration issue. I looked at the /proc/$$/environ, but the PWD in there only refers to the initial wd and not the current one. Ok, I almost figured it out: 1. Extract the PWD of another bash process using @Gilles' python program at: http://unix.stackexchange.com/questions/6301/how-do-i-read-from-proc-pid-mem-under-linux, modified to use the bash Pid. I just tried it, it works. 2. Pass the new PWD to the new bash process in EditProfile/General/Command with
Only problem left: How do I pass the $$ to my user code in Command? The $$ there already refers to the new process. (Also, is there any way to read the error message given by Command since it flashes by in 1/1000th of a second?) |
Administrator
|
You could try launching Konsole with the --noclose option which should ensure it remains open after the application exits.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
I tried konsole --noclose, but it does not work. I have the latest konsole-4.12.4-1-rosa2012.1.x86_64. Should I report it as a bug?
Also I think that Konsole should not exit on error so quickly anyway. Adding sleep(2) should benefit everyone. Should I report this also as a bug? And what about the main question: is there a way to get $$ to the Command? If there is not, could it be added? I see there is already an environment variable widget -- perhaps it could be added there in the form of: CURRENT_TAB_ID=$$ or similar. Or even have a special $$$ code to be used in the Command line like: mybash $$$. Should I put in a request for this feature? |
Administrator
|
Can you please post details of the exact changes you're making to the Konsole configuration?
In my tests locally the --noclose argument to Konsole worked fine, so it is a bit weird it didn't work for you.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
Ok, I finally got to read the complete error messages, but only by chance. Here is a recap of what I did and my expectation of what should happen instead of what in fact did:
1. I make a change to the Command line, which unfortunately contains an error. 2. I hotkey a new tab: some error message flashes by and no new tab appears. This is the first behavior I consider wrong. Error messages should be readable. 3. I change the Command line back to the default /bin/bash so I can continue to work, open new tabs, read man pages, take notes about this problem, etc. 4. I start a second Konsole with --noprofile so I can do various experiments with the Command line. 5. In this second Konsole I reintroduce the Command error and try hotkeying a new tab again. Same behavior: flashing error message and no new tab! Huh??? This is the second point I consider strange. I expected the new tab with the error message not to close (I understand now that the noclose only applies to the first tab). 6. By chance I happen to notice that the first Konsole also happens to display a partial error message (see later). This, with hindsight, is the third surprising behavior. The first Konsole, if anything, should display the whole error message stack. 7. By further chance I happen to retry everything, except this time not clearing up the error before starting the second konsole. Mistery cleared! Ignore the new tab hotkey! You get the entire error message on the first tab of the new Konsole, and a partial message on the first Konsole! In sum, I consider this a very convoluted and confusing behavior. Upon a new tab hotkey Konsole should simply open the new tab in all cases. If error, it should stay open, displaying the error message. Should I file a bug fix request? Back to the main reason for this topic. How do I get enough information (the old shell pid would suffice) to my Command to be able to recreate Bash' logical PWD? I think this is very important and it makes Konsole useless for serious work if a new tab's environment is different from the tab that created it, thus making some software fail. |
Administrator
|
I'm afraid from what I can tell of the source code, that information is not available.
You could use the D-Bus interface to extract the information if you're willing to rely on picking a certain session to get the information - however it is not possible to determine which session was previously in use (you can switch to it though).
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]