error importing function definition for `mc'

This is an error that started popping up some days ago.
Under KDE console (Konsole), whenever a shell starts (Bash, sh, shell scripts), this error message is printed:

$ bash
bash: mc: line 1: syntax error: unexpected end of file
bash: error importing function definition for `mc'

Note that this does not happen on the text console.
My investigation led to an environment variable BASH_FUNC_mc:

$ env | head -n 3
BASH_FUNC_mc%%=() {  . /usr/share/mc/

whose definition derives from /usr/share/mc/ via /etc/profile.d/ Apparently the full definition of the function mc is truncated (the closing brace is missing), and I believe that when Bash is started and it inherits the parent environment, it tries to evaluate that BASH_FUNC_mc%%=() { . /usr/share/mc/ and triggers that error (in fact, running env -i bash does not trigger the error).
It looks like almost all processes owned by my user which show a “standard” environment also have that feature. The ones which do not are gpg-agent and startplasma-x11, both started by sddm rather than kdeinit5.
I feel like something (kdeinit5?) is misparsing the environment and leaving it in a messy state for the daughter processes, but I don’t know how to identify the prime cause and solve the issue.


I’m pretty sure that there’s an open bug report on this problem. It is a problem in Plasma initialization.

This thread, factory mailing list and KDE bug report…

Ah, yes, thank you.
The forum thread link seems to be unrelated, the mailing list link is unreachable to me, but the KDE bug report is right on spot.
To that I add a relevant quotation from yesterday in the originating OpenSUSE report (

The fix is in Tumbleweed meanwhile.

Try this instead :wink:

I had the same issue. It went away when logging into plasma with a fresh user account and recent updates seem to have resolved it.
No longer have issues with kdesu.