This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Sourcing other .sh files from .config/plasma-workspace/env

Tags: None
(comma "," separated)
StMartin81
Registered Member
Posts
26
Karma
0
I put a script in ~/.config/plasma-workspace/env which should source another .sh script which is installed on the system. The other script files sets some environment variables and it needs to be called with a parameter. The parameter doesn't get propagated to the script though. Is it possible to source the other script file so that it gets called with the parameter intel64?

The script looks like this:
Code: Select all
#!/bin/bash

. /opt/intel/bin/compilervars.sh intel64 #<- script is  called without the parameter
User avatar
raphaelra
Registered Member
Posts
209
Karma
0
OS
StMartin81
Registered Member
Posts
26
Karma
0
If I just run the script instead of sourcing it the environment variables won't get exported, which is what I actually want. :)
User avatar
raphaelra
Registered Member
Posts
209
Karma
0
OS
You are right, i was wrong o)

I checked /usr/bin/startkde ... The *.sh files from ~/.config/plasma-workspace/env are sourced and not executed as mentioned in link above:
Code: Select all
#!/bin/sh
[...]
# Source scripts found in <config locations>/plasma-workspace/env/*.sh
[...]
# Add /env/ to the directory to locate the scripts to be sourced
for prefix in `echo $scriptpath`; do
  for file in "$prefix"/env/*.sh; do
    test -r "$file" && . "$file" || true
  done
done

startkde is running with /bin/sh which is dash on Kubuntu an dash ignores arguments when sourcing another scripts :-\ You can write your own script that sets same env variables as /opt/intel/bin/compilervars.sh intel64 or modify startkde to use bash. The last may be bad way because updates can overwrite startkde.
StMartin81
Registered Member
Posts
26
Karma
0
I wasn't aware that Ubuntu was using Dash as default shell. It's really hard to find some informations about Dash. I guess not many people are using it.

Thanks a lot for pointing out why the parameter wasn't used!

Fortunately the programmers of the shell script made it also possible to pass the parameters also by setting environment variables. So my script looks like this now:
Code: Select all
#!/bin/sh
export COMPILERVARS_ARCHITECTURE=intel64
. /opt/intel/bin/compilervars.sh
User avatar
raphaelra
Registered Member
Posts
209
Karma
0
OS
StMartin81 wrote:I wasn't aware that Ubuntu was using Dash as default shell.

Code: Select all
raphael@tofilius:~$ ll /bin/sh
lrwxrwxrwx 1 root root 4 May 26  2017 /bin/sh -> dash*
I wasn't aware to ... (til now ;) ). It seams that the Debian family is using dash and RHEL family (Centos, Fedora) - bash.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell