Bash environment variables errors detected during startup - Again

My bash function definition are not sourced in /etc/profile.d because of error : as name contains unsupported characters ???

Feb 05 16:22:09 localhost.localdomain JCD_PROFILE.D_COMMON_FUNCTION[3311]: /etc/profile.d/zzzz1_system_common_function_full.sh - BEGIN - ID : uid=1002(user_test_step1_vb) gid=100(users) groups=100(users),464(vboxsf) - USER : user_test_step1_vb - HOME : /home/user_test_step1_vb - LOG_USER :
Feb 05 16:22:10 localhost.localdomain JCD_SYSTEM_COMMON_FUNC[3312]: zzzz1_system_common_function_full.sh - SYSTEM_COMMON_FUNCTION_EXPORT : 1
Feb 05 16:22:10 localhost.localdomain JCD_SYSTEM_COMMON_FUNC[3315]: /etc/profile.d/zzzz1_system_common_function_full.sh  - ^^^ END  ^^^ - USER : user_test_step1_vb
Feb 05 16:22:10 localhost.localdomain JCD_PROFILE.D_COMMON_GEN_ENV[3320]: /etc/profile.d/zzzz2_system_common_general_env_var - BEGIN - ID : uid=1002(user_test_step1_vb) gid=100(users) groups=100(users),464(vboxsf) - USER : user_test_step1_vb - HOME : /home/user_test_step1_vb - LOG_USER :
Feb 05 16:22:10 localhost.localdomain JCD_PROFILE.D_COMMON_GEN_ENV[3349]: zzzz2_system_common_general_env_var - SYSTEM_COMMON_GENERAL_ENV_VAR_EXPORT : 1
Feb 05 16:22:10 localhost.localdomain JCD_PROFILE.D_COMMON_GEN_ENV[3352]: /etc/profile.d/zzzz2_system_common_general_env_var - ^^^ END  ^^^ -  USER : user_test_step1_vb
Feb 05 16:22:10 localhost.localdomain startplasma-x11[3227]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "BASH_FUNC__MY_ECHO_%%" as name contains unsupported characters
Feb 05 16:22:10 localhost.localdomain startplasma-x11[3227]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "BASH_FUNC__MY_LS_%%" as name contains unsupported characters
Feb 05 16:22:10 localhost.localdomain startplasma-x11[3227]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "BASH_FUNC_abort_because_test%%" as name contains unsupported characters
Feb 05 16:22:10 localhost.localdomain startplasma-x11[3227]: org.kde.plasma.libkworkspace: Skipping syncing of environment variable  "BASH_FUNC_abort_because_test_no_trap%%" as name contains unsupported characters

journald : https://paste.opensuse.org/pastes/077da402c834

There is more detail in : https://forums.opensuse.org/t/bash-environment-variables-errors-detected-during-startup/171218

If the file is manually sourced , there is no problem.

This has worked for very very long time.

Any help is welcome.

My very simple test (without reading all the links you provide, too lazy):

henk@boven:~> export BASH_FUNC__MY_ECHO_%%="bloep"
bash: export: 'BASH_FUNC__MY_ECHO_%%=bloep': is geen geldige naam
henk@boven:~>

or in English

henk@boven:~> LANG=C export BASH_FUNC__MY_ECHO_%%="bloep"
bash: export: `BASH_FUNC__MY_ECHO_%%=bloep': not a valid identifier
henk@boven:~

Without the % characters there is no problem:

henk@boven:~> export BASH_FUNC__MY_ECHO="bloep"
henk@boven:~>

Here also on Leap 15.5 and, hunting around in rather large library, I happened to notice the following –

This stackoverflow entry points to the Open Group Base Specifications – IEEE Std 1003.1 – <https://pubs.opengroup.org/onlinepubs/9699919799/> →

  • Base Definitions – Chapter 3 – 3.235 Name →

In the shell command language, a word consisting solely of underscores, digits, and alphabetics from the portable character set. The first character of a name is not a digit.

The Portable Character Set includes the Glyph “%” – the PERCENT SIGN


And, I get the same results as Henk –

 > LANG=C export BASH_FUNC__MY_ECHO_%%="Blöd"
bash: export: `BASH_FUNC__MY_ECHO_%%=Blöd': not a valid identifier
 > LANG=C set BASH_FUNC__MY_ECHO_%%="Blöd"
 > LANG=C echo $BASH_FUNC__MY_ECHO_%%
%%
 >

What is an “alphabetic” ???

The Cambridge English Dictionary defines an “alphabetic” as being –

An alphabetic language has a letter or combinations of letters and marks to represent each speech sound in the language.

In other words –

  • If can’t speak it, it ain’t an alphabetic.

Please define the speech sound associated with the “%” character …

  • «Possibly only true for the spoken English language … »

The sign ‘%%’ is printed by systemd in the message.
It is not in the files sourced during startup in the folder /etc/profile.d

And as said in my question, if I source the files myself from a terminal there is no errors.

The problem arise somewhere during startup.

The sign ‘%%’ is printed by systemd in the message.
It is not in the files sourced during startup in the folder /etc/profile.d

And as said in my question, if I source the files myself from a terminal there is no errors.

The problem arise somewhere during startup.

bash creates such names for exported functions.

The problem is that you cannot push exported functions into systemd environment.

- Doctor, it hurts when I stab myself in the eye.
- Do not do it.

From /etc/profile

#
# Source profile.d files and UTF8 settings
#
# But do not source this if PROFILEREAD is already set to avoid
# overriding locale variables already present in the environment
#
if test -z "$PROFILEREAD" ; then
    test -r /etc/profile.d/sh.ssh && . /etc/profile.d/sh.ssh
fi

#
# Source profile extensions for certain packages, the super
# may disable some of them by setting the sticky bit.
#
if test -d /etc/profile.d -a -z "$PROFILEREAD" ; then
    for s in /etc/profile.d/*.sh ; do
	test -r $s -a ! -k $s && . $s
    done
    unset s
fi

That seems not relative to systemd it is just sourced bash script

Environment is uploaded into systemd during GUI session startup.

I have made another test.
If I source my functions definition in user .profile (~/.profile) I got the same errors in journald, but in this case the functions are available for the logged user. That is not the case when sourcing from /etc/profile.d

I found comments on the internet that confirm the rejection of environmental variables by systemd if they contain errors.
In particular the use of ‘%’ seems unauthorized.
This is not my case, because I only use '[A-Za-z0-9] and [_].
So who can afford to replace

_MY_ECHO_
by
_MY_ECHO_%%

J’ai aussi trouvé un commentaire de Mr Lennart Poettering

It exports a shell function to get this function defined in sub-shell. And when you export a function in bash you get such variable defined in the environment.

Well, but it does so much more than exporting it to the subshell: every process will inherit that, not just bash… Isn’t the clean approach here to make those subshells source these functions in themselves from somewhere, so that only bash gets it? i.e. propagating bash functions by env vars down the tree and into systemd --user sounds like a pretty poor way of doing these things to me…

Is there a better way to add functions to bash without rewrite bash iself?
A yes ! Don’t use bash.

https://bugzilla.redhat.com/show_bug.cgi?id=1754395
Jump to comment #45

https://github.com/systemd/systemd/issues/14878
NOTE : Lmod is not installed on my computers.

Because you launch your shells as login shells and they explicitly source ~/.profile.

Step 1: computer boot
Step 2 : normal user logged in
Step 3 : Verifying in journald that functions are not exported
Step 4 : Open a terminal and type :

source /run/media/$(logname)/INS_STEP2_MINI/NEW_INSTALL_LINUX_2023/2024_02_01_19h00/MY_PROJECTS/MY_INSTALL_STEP_1/2024_02_01_19h00/002_DATA/SYSTEM_CONFIG/000_CURRENT_VERSION/etc/zzzz1_system_common_function_full.sh

Verify in journald the execution of the command.
Got the same errors as in booting session but the function are exported.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.