Registered Member
|
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
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. 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, 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. |
Registered Member
|
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 Member
|
Just the full path
bash's man page ignore every things about kde. My question mean : What kde is doing as soon as I double click on the program icon shortcut ? And why in that case my bash function are not sourced ? |
Registered Member
|
As I understand it, when invoked in such a manner, it runs that command the same as if you ran the script directly in a terminal, assuming that the script is executable and has the appropriate #! line. If the shebang line is referencing bash, then I would expect it to end up using bash to run the contents of the script (in non-login, non-interactive mode, see the bash manual for what all that entails). If there is no shebang line then it may just use plain-old 'sh' to run, in which case none of your bash functions would apply.
Besides making sure the shebang line in the script is correct, you could also try changing the EXEC line of the .desktop file to explicitly use bash to invoke the script, passing whatever options and flags may be necessary to invoke the required startup scripts.
airdrik, proud to be a member of KDE forums since 2008-Dec.
|
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]