'"source" command inside a CSH scrip
I wrote CSH script, include the following line:
bash -c 'source $file; exec csh'
When running, I get the next error:
bash: line 0: source: filename argument required source: usage: source
filename [arguments]
Thanks too much!
Solution 1:[1]
Lookup the difference between single quotes (') and double quotes (").
Since you are using single quotes, the variable is not expanded. I assume $file is a variable in the program where you are doing this.
Bash sees source $file; exec csh literally. It expands $file, but since that is not a variable to Bash, it expands to nothing. So the source command complains.
This works for me:
% set file='/tmp/bash_prog'
% bash -c "source $file; exec csh"
Hello from Bash!
%
Note how the last % is the prompt from the nested csh.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | fork2execve |
