I have a shell script that exports variables to be used in tool setup for a multiuser environment. As different projects (history of 100+ projects) use different setups, my script sets variables for different shell kinds.
Example:
#!/bin/sh
#some XY_VAR setting happening here
case "$1" in
'-c')
echo "setenv XY $XY_VAR;"
;;
'-b')
echo "export XY=$XY_VAR;"
;;
esac
when used in a project's script, it is evaled like this
eval `set_my_vars -c` #when using (t)c-shell
eval `set_my_vars -b` #when using bash
My question is can I make the script detect the shell it is evaled from and input that to the case statement?
ps -hp $$
doesn't work when the script is evaled, this was my first idea (with awk of course). I have found multiple ways where people wanted to detect in which shell they are running in, but all I have found fail when using eval.
Can anybody help? Maybe I am just to stupid to find the solution on my own.
Thanks and best regards rws