[Bug 1203617] In plasma5 midnight commander doesn't exit to current directory anymore
https://bugzilla.suse.com/show_bug.cgi?id=1203617 https://bugzilla.suse.com/show_bug.cgi?id=1203617#c54 Fabian Vogt <fabian@ritter-vogt.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Flags|needinfo? | --- Comment #54 from Fabian Vogt <fabian@ritter-vogt.de> --- The Xsession resp. wayland-session scripts run during login source /etc/profile to set up the environment for the graphical environment. This sets variables like "$BASH_FUNC_mc%%" but also "$PROFILEREAD". Plasma's components are started through systemd user services and dbus activation. To set up the environment for those, variables of the session process are sent to dbus and systemd. However, there are some exceptions! % is not a valid variable name in the systemd context so this is not actually sent. Other variables like $PROFILEREAD are. konsole is eventually started and the shell inherits the environment from systemd, meaning without $BASH_FUNC_mc%%. Even if the shell was invoked as login shell or /etc/profile sourced manually, it sees that $PROFILEREAD is already set and doesn't do anything. The root cause and fix should be relatively simple: /etc/profile is only meant for "normal" environment variables. Bash specific stuff like this mc() function must be in bashrc instead. (In reply to Dave Plater from comment #52)
I asked the mc developers about this issue (the first reply insisted that exiting to the starting directory is normal) and I now understand fully what the issue is - kde make every script executed in a virtual console run in a sandbox.
That's not really the case, there's no sandboxing going on. It's just independent shell processes.
The most important element in: "[ $(type -t mc) = "file" ] && . /etc/profile.d/mc.sh" which I've been missing is "." which help . in a bash shell says is: "Execute commands from a file in the current shell"
Starting mc like this ". /etc/profile.d/mc.sh && mc" lets mc to exit to it's CWD.
To prove this I created a script: #! /usr/bin/bash
dirc() { pushd ../../ }
dirc
and when executing the script although the output of pushd is clear it exits to the directory it was started in. Prepending "." changes directory to the two upper levels as if "pushd ../../" is executed from the command line.
Perhaps a KDE expert can shed more light on this.
That's unrelated to KDE, it's just a shell thing: If you execute a script, it starts a new shell. Changing directory in there has no impact on the parent (interactive) shell. If instead of executing you *source* this script (that's what "." is) it is like you typed in the commands into the shell itself. -- You are receiving this mail because: You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@suse.com