Sat Nov 09, 2019 3:38 pm
Depending of the opensuse distrib
Login shell read :
/etc/profile.local ( for customization )
eventually for specific programms : /etc/profile.d/
~/.profile for user specificity
Non login shell read :
/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
The other file contains function definitions
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.
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 shortcut is configured to run the file in konsole (kde terminal) and to stay open when finished.
The shortcut is configured to run the file as a normal user.
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, but all my functions are undefined.
My question :
What is the inheritance of a bash script executed from a shortcut on the desktop.
Any help is welcome.
Mon Nov 11, 2019 8:24 pm
Probably depends on what you are using for the EXEC line of the desktop shortcut file. Are you invoking bash to run the command or are you invoking the command directly (possibly using raw sh instead of bash)?
As I understand it, the environment variables are shell agnostic and are inherited directly from parent to child process (unless overridden or blocked), while the functions are bash-specific and would require a bash session in order to be made available. If you aren't explicit about invoking bash it may just be using plain-old sh which would inherit the environment variables but ignore the function declarations. Reviewing bash's man page may provide additional explanation for its behavior.
airdrik, proud to be a member of KDE forums since 2008-Dec.
Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Majestic-12 [Bot], reaperx3, Sogou [Bot]