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/mc-wrapper.sh
ANSIGRAY=\e1;30m
SHELL=/bin/bash

whose definition derives from /usr/share/mc/mc.sh via /etc/profile.d/mc.sh. 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/mc-wrapper.sh 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.

Help?

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

Hi
This thread, factory mailing list and KDE bug report…
https://forums.opensuse.org/showthread.php/537903-KDE-5-17-usr-bin-xdg-su-c-sbin-yast2-gt-Permission-denied
https://lists.opensuse.org/opensuse-.../msg00221.html
https://bugs.kde.org/show_bug.cgi?id=413130

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 (https://bugzilla.opensuse.org/show_bug.cgi?id=1154345):

The fix is in Tumbleweed meanwhile.

Hi
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.