If, from csh, youre trying to reach session variables defined in a bash shell script, you must call the bash script prior to starting up the csh.
A session gets inherited into subprocesses, like so, where the csh.SESSION and csh.SESSION_INHERITED are merged once the csh 'boots':
bash/
├── csh
│ ├── SESSION
│ └── SESSION_INHERITED
└── SESSION
The bash.SESSION is NOT accessible from within csh shell as this would expose the init
runlevel to any subprocesses.. Its is a fork
, which during spawn duplicates the environment.
So, you can run from bash: source test.sh; csh
. This will expose the exports from test.sh to csh - but its a static export which cannot be modified programatically in the csh.
Haven't 100% understood your question since its very abstract.. But this hopefully helps :)
ps -o "%a" -p "$$"
rather thanecho $0
and parse output, but not really sure why you're trying to have the same behavior while sourcing the file. – Broadcastbash
command, that creates a subprocess, so any environment variables it defines will not be part of the calling script's environment. (BTW, thebash -c 'test.sh'
version actually creates two subprocesses.) There is inherently no way to source a bash script from csh -- the point ofsource
is that it runs the script in the same shell (rather than a subshell), and bash just isn't the same shell as csh. – Urial