Bash inherits

Hello .
Preamble :
Depending of the opensuse distrib :
Login shell read :

  • /etc/profile
  • /etc/profile.local ( for customization )
  • eventually for specific programms : /etc/profile.d/
  • ~/.profile for user specificity

Non login shell read :

  • /etc/bash.bashrc
  • /etc/bash.bashrc.local ( for customization )
  • ~/.bashrc for user specificity

Note that the login shell also sources the configuration files listed for non login shell.

What I have done :
I have configured '/etc/profile' to source two files
One file contains a list of global environment variables

export NAME=VALUE

The other file contains function definitions

function MY_FUNCTION () {
........
........
}
 export -f MY_FUNCTION

Using logger commands here or there, and reading the journal, I know that the two files are sourced as soon as I log on as a normal user.
I am using KDE graphical environment.

The problem :

  • I have a script that I can start from a shortcut on the user's desktop or from a command line by typing the script name ( including the full path ).
  • The short is configured to run the file in konsole (kde terminal) and to stay open when finished.
  • The short is configured to run the file as a normal user.

A -)

  • I start a session in a terminal using kde konsole.
  • When I run a bash script from command line all my environnment variables are set and accessible, and all my functions are defined and accessible

.
B - )

  • I start the program by clicking on the desktop shortcut icon.
  • All my environnment variables are set and accessible, nad all my function are undefined.

My question :

What is the inheritance of a bash script executed from a shortcut on the desktop.

Any help is welcome

Have you looked into using SHELLOPTS ?

Ok I will read what SHELLOPTS is for.

But For my problem, I have found that there is some syntax error(s) in some function(s) ( found using shellcheck ).
If I run my test script from command line, all my function ( ~77 ) are all accessible to the test program.
If I run the same test script from user's desktop shortcut, only 2 are accessible.

So I must find and remove all errors in my sourced file before continuing.

Thank you for helping