Different behaviour between 15.5 and 15.4 when sourcing environment variables

For years I use /etc/profile.local for sourcing two files that set environment variables and define bash functions.

..........
source "$MY_SCRIPT_PATH/Bin/system_common_function" 1> /dev/null
source "$MY_SCRIPT_PATH/Bin/system_common_general_env_var" 1> /dev/null
...........

What is different to-day with 15.5 is that functions does not survive the end of execution of /etc/profile.local.
Variables are still defined, but function not

Example for function called in a terminal konsole :

user_install@15-5---G731GV:~> stop_or_continue "153" "TEST"
If 'stop_or_continue' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf stop_or_continue

A good response should be :

user_install@15-5---G731GV:~> stop_or_continue "153" "TEST"
LINENO : 153
MESG   : TEST
Strike a key to continue
Strike CTRL-C to abort

Example for a variable in a terminal konsole :

user_install@15-5---G731GV:~> echo "$E_BAD_EXEC"
112

As you can see, variables are still defined.

The following show journald under 15.5 during boot :


Sep 08 15:16:34 15-5---G731GV sddm[1688]: Session started
Sep 08 15:16:34 15-5---G731GV systemd[2614]: Started D-Bus User Message Bus.
Sep 08 15:16:34 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2670]: hBc  - /etc/profile.local ---  -*-µ-*-µ- BEGIN -*-µ-*-µ-
Sep 08 15:16:34 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2675]: hBc  - /etc/profile.local --- [id] uid=1000(user_install) gid=100(users) groups=100(users) -- USER [id -nu] : user_install -- $USER : user_install -- PROFILE_LOG_USER : user_install
Sep 08 15:16:34 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2678]: hBc  - /etc/profile.local ---  RUNNING REAL MACHINE
Sep 08 15:16:34 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2679]: hBc  - /etc/profile.local ---  NON-INTERACTIVE
Sep 08 15:16:34 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2681]: hBc  - /etc/profile.local ---  BACKUP_SYS_SCRIPT_PATH : /backup_sys/000_COMMON
Sep 08 15:16:34 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2684]: hBc  - /etc/profile.local --- SOURCING : /backup_sys/000_COMMON/Bin/system_common_function
Sep 08 15:16:34 15-5---G731GV JCD_SYSTEM_COMMON_FUNC[2687]: /backup_sys/000_COMMON/Bin/system_common_function - ^^^ BEGIN ^^^ - USER : user_install
Sep 08 15:16:34 15-5---G731GV JCD_SYSTEM_COMMON_FUNC[2688]: /backup_sys/000_COMMON/Bin/system_common_function - SYSTEM_COMMON_FUNCTION_EXPORT : 1
Sep 08 15:16:34 15-5---G731GV JCD_SYSTEM_COMMON_FUNC[2691]: /backup_sys/000_COMMON/Bin/system_common_function  - ^^^ END  ^^^ - USER : user_install
Sep 08 15:16:34 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2698]: hBc  - /etc/profile.local --- SUCCESS SOURCED DONE : /backup_sys/000_COMMON/Bin/system_common_function
Sep 08 15:16:34 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2699]: hBc  - /etc/profile.local --- SUCCESS SOURCED FOUND function FUNCTIONS
Sep 08 15:16:34 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2701]: hBc  - /etc/profile.local --- SOURCING : /backup_sys/000_COMMON/Bin/system_common_general_env_var
Sep 08 15:16:34 15-5---G731GV JCD_SYSTEM_COMMON_GEN_ENV[2704]: /backup_sys/000_COMMON/Bin/system_common_general_env_var - BEGIN - USER : user_install
Sep 08 15:16:35 15-5---G731GV JCD_SYSTEM_COMMON_GEN_ENV[2773]: /backup_sys/000_COMMON/Bin/system_common_general_env_var - SYSTEM_COMMON_GENERAL_ENV_VAR_EXPORT : 1
Sep 08 15:16:35 15-5---G731GV JCD_SYSTEM_COMMON_GEN_ENV[2776]: /backup_sys/000_COMMON/Bin/system_common_general_env_var - END - USER : user_install
Sep 08 15:16:35 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2778]: hBc  - /etc/profile.local --- SUCCESS SOURCED DONE : /backup_sys/000_COMMON/Bin/system_common_general_env_var
Sep 08 15:16:35 15-5---G731GV JCD_ETC_PROFILE_LOCAL[2783]: hBc  - /etc/profile.local ---  FOUND  94  FUNCTIONS --- -*-µ-*-µ- END -*-µ-*-µ-
Sep 08 15:16:35 15-5---G731GV JCD_ETC_BASH_BASHRC_LOCAL[2790]: hBc  - /etc/bash.bashrc.local ---  °-&-°-&-° BEGIN °-&-°-&-°
Sep 08 15:16:35 15-5---G731GV JCD_ETC_BASH_BASHRC_LOCAL[2795]: hBc  - /etc/bash.bashrc.local --- [id] uid=1000(user_install) gid=100(users) groups=100(users) -- [id -nu] : user_install -- $USER : user_install -- BASHRC_LOG_USER : user_install
Sep 08 15:16:35 15-5---G731GV JCD_ETC_BASH_BASHRC_LOCAL[2796]: hBc  - /etc/bash.bashrc.local ---  NON-INTERACTIVE
Sep 08 15:16:35 15-5---G731GV JCD_ETC_BASH_BASHRC_LOCAL[2807]: hBc  - /etc/bash.bashrc.local --- FOUND  94  FUNCTIONS --- °-&-°-&-° END °-&-°-&-°
Sep 08 15:16:36 15-5---G731GV systemd[2614]: Reloading.
Sep 08 15:16:36 15-5---G731GV systemd[2614]: Created slice User Background Tasks Slice.

/etc/profile.local define with success my functions and my variables.
/etc/bash.bashrc.local confirm the existance of my functions.

Now if i start a terminal konsole, /etc/bash.bashrc.local confirm the disappearance of my functions.
Only two functions founded :

Sep 08 15:16:53 15-5---G731GV systemd[1]: systemd-hostnamed.service: Deactivated successfully.
Sep 08 15:16:53 15-5---G731GV systemd[1]: systemd-localed.service: Deactivated successfully.
Sep 08 15:17:18 15-5---G731GV systemd[2614]: Started Konsole - Terminal.
Sep 08 15:17:18 15-5---G731GV JCD_ETC_BASH_BASHRC_LOCAL[3577]: himBH  - /etc/bash.bashrc.local ---  °-&-°-&-° BEGIN °-&-°-&-°
Sep 08 15:17:18 15-5---G731GV JCD_ETC_BASH_BASHRC_LOCAL[3582]: himBH  - /etc/bash.bashrc.local --- [id] uid=1000(user_install) gid=100(users) groups=100(users) -- [id -nu] : user_install -- $USER : user_install -- BASHRC_LOG_USER : user_install
Sep 08 15:17:18 15-5---G731GV JCD_ETC_BASH_BASHRC_LOCAL[3583]: himBH  - /etc/bash.bashrc.local ---  INTERACTIVE
Sep 08 15:17:18 15-5---G731GV JCD_ETC_BASH_BASHRC_LOCAL[3594]: himBH  - /etc/bash.bashrc.local --- FOUND  2  FUNCTIONS --- °-&-°-&-° END °-&-°-&-°

It had worked for years , but failed with 15.5.

Any help is welcome.

Shell in konsole is not login shell and does not read your /etc/profile.

That is not the purpose of my question.
For the scope of my question, I don’t care in detail what kind of shell konsole is using.
What I am interested in is why a leap configuration ( up to 15.4 ) was doing what i was expecting even if it is stupid, and why the same stupidity is not doing what i was expecteing in 15.5.
Depending of the answers I may made corrections.
In short why I get my env variables initialized as expected(from my point of view) and why my functions are not.

Linux does not itself a favor with the mess with login and non-login shells. Fine you want to make a difference but most people do not care so use only one file. If you still want something to be done different for a login and non-login shells provide a variable that indicates this so you can condition code/settings.

It looks like this is also the opinion of the Opensuse maintainers:

In my ~.bashrc there is:

# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.

So this is where I do my settings.

Do you have still the 15.4 system running? If not, I think it is close to impossible to find out.

Yes I have

I have made a new 15.5 install this morning.
Looking at journald there are plenty errors of different kind.

About my question all my functions are ignored because of name contains unsupported characters :

Sep 11 15:57:08 15-3-G731GV startplasma-x11[2640]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "BASH_FUNC_abort_because_test%%" as name contains unsupported characters
Sep 11 15:57:08 15-3-G731GV startplasma-x11[2640]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "BASH_FUNC_abort_because_test_no_trap%%" as name contains unsupported characters
Sep 11 15:57:08 15-3-G731GV startplasma-x11[2640]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "BASH_FUNC_abort_by_user%%" as name contains unsupported characters
Sep 11 15:57:08 15-3-G731GV startplasma-x11[2640]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "BASH_FUNC_activate_all_repo_but_source_debug%%" as name contains unsupported characters
Sep 11 15:57:08 15-3-G731GV startplasma-x11[2640]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "BASH_FUNC_array_contains_element%%" as name contains unsupported characters

And some of my variables definitions are also ignored for the same reason :

Sep 11 15:57:08 15-3-G731GV startplasma-x11[2640]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "MY_LIGHT_BLUE" as value contains unsupported characters
Sep 11 15:57:08 15-3-G731GV startplasma-x11[2640]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "MY_LIGHT_CYAN" as value contains unsupported characters
Sep 11 15:57:08 15-3-G731GV startplasma-x11[2640]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "MY_LIGHT_GREEN" as value contains unsupported characters

My light blue is defined like this :

MY_LIGHT_BLUE=$'\033[1;34m'		# Light Blue		1;34

The current locale is defined as this ( the same as computer running 15.4 ):

locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Current version is :

NAME="openSUSE Leap"
VERSION="15.5"
ID="opensuse-leap"
ID_LIKE="suse opensuse"
VERSION_ID="15.5"
PRETTY_NAME="openSUSE Leap 15.5"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:15.5"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
DOCUMENTATION_URL="https://en.opensuse.org/Portal:Leap"
LOGO="distributor-logo-Leap"

Linux 15-5---G731GV 5.14.21-150500.55.19-default #1 SMP PREEMPT_DYNAMIC Tue Aug 8 22:15:01 UTC 2023 (9908c29) x86_64 x86_64 x86_64 GNU/Linux

@jcdole:

Please check the characters your scripts are injecting into the environment variables against the characters supported by US English UTF-8.

  • Just a thought → you may be surprised …

Both messages come from KDE and do exactly what they say. I assume Leap 15.4 had older KDE version that did not include these checks.

The just add echo statements to all files involved on both systems and see which are executed and which are not. Is there a difference between 15.4 and 15.5?

I have made some test.
On the same machine, i reinstall leap 15.4 → that runs as expected.
On the same machine, i reinstall leap 15.5 after a new download and using a new usb stick → that bad results (from what i am expected)
On the same machine, i reinstall leap 15.6 after a new download and using a new usb stick → that bad results (from what i am expected)
On the same machine, running leap 15.6, I boot in text mode → that runs as expected. But I cannot start the GUI. I got a black screen whith the mouse. Even after killing X11 server, cannot get the GUI.
I was using startx; I don’t know if there is another command.

I have read that there are numerous problem since KDE changed startkde to startplasma-x11.

All my function name are like this

function activate_all_repo_but_source_debug () {

}
export -f  activate_all_repo_but_source_debug 

All my color var are like this :

MY_LIGHT_GREEN=$'\033[1;32m'

What can I do ? if the problem comes from kde startplasma-x11
Thank you every body for helping.

Define them in bashrc.

Replacing color definitions :

MY_LIGHT_GREEN=$'\033[1;32m'

by

MY_LIGHT_GREEN="\e[1;32m"

Suppress the error concerning sourcing the color definitions.
But this need to replace :

echo "${MY_BLUE}Some text"

by

echo  -e  "${MY_BLUE}Some text"

In all script

No change where printf is use