Hello.
I have two files which contains useful stuff for me.
One file contain global variables values and one function for testing if that files has been sourced.
This file is named : ‘system_common_general_env_var’
The second file contain only functions and is named ‘system_common_function’.
I use these two files for years. **We should admit for my question that they have no bugs.
**
I am testing a new script named ‘main.sh’ which is started from an usb stick.
Every necessaries things are on the usb stick.
I started my tests from a console by typing the name of the program.
The main script start by changing to root environment.
# ensure running as root
if "$(id -u)" != "0" ]; then
exec sudo "$0" "$@"
fi
#
Then it sources my stuff
source /run/media/user_install/BESTRUNNER-8Go-14/NEW_INSTALL_SYSTEM/DATA/backup_sys/000_COMMON/Bin/system_common_function
source /run/media/user_install/BESTRUNNER-8Go-14/NEW_INSTALL_SYSTEM/DATA/backup_sys/000_COMMON/Bin/system_common_general_env_var
Then it verifies if the two files has been sourced.
# test a function from the first sourced file
if -n "$(LC_ALL=C type -t ok_to_do_task)" && "$(LC_ALL=C type -t ok_to_do_task)" = function ] ; thenecho "OK"
elseecho "KO"
exit 126
fi
# test a function from the second sourced file
if -n "$(LC_ALL=C type -t system_common_general_env_var_is_sourced)" && "$(LC_ALL=C type -t system_common_general_env_var_is_sourced)" = function ] ; thenecho "OK"
elseecho "KO"
exit 126
fi
There is no problem when starting from a console as a normal user nor as root user.
Now I decide to start the program from a shortcut on the desktop.
I configure the shortcut to run in terminal, to stay open and to run as another user : ‘root’
The second files seems to be not sourced :
FAILURE SCREEN LOGS : https://paste.opensuse.org/4203146
Now if i change the shortcut configuration by removing the option run as : that works
SUCCESS SCREEN LOGS : https://paste.opensuse.org/5873533The main script is here :
https://paste.opensuse.org/11344153
Any help is welcome