It is not possible to modify the variables of a shell from any child process. Since launching csh from bash launches a child process, there is no way that can be done.
Options you have :
- Convert your
csh script to bash, and source it from your bash script.
- Convert your
bash script to csh, and again source the other script
- Make sure the variables you need are marked for
export in the csh script, and launch your bash script from inside the csh script (which may or may not work for your specific need), thereby turning things inside out
- Merge the code from both scripts to have a single (
bash or csh) script
"Sourcing" is done with a . or the (non-POSIX) source builtin. For instance :
#!/bin/bash
echo $PATH
. setevnvar.converted_to_bash -dir "$ROOT_DIR/"
echo $PATH
"Sourcing" causes the current process to read commands from an other file and execute them as if they were part of the current script, rather than starting a new shell to execute that other file. This is why variable assignments will work with this method.
Please note I added double quotes to your "$ROOT_DIR/" expansion, to protect for the case where it would contain special characters, like spaces.
cshscript (which should have an extension like.csh, if any, not.sh) cannot directly set variables in abashscript.is in the form of csh script that has many artifacts on the environment variables--> The environment variables undercshorbash?cshscript which changes somebashenvironment variables for you?