Following setenv works in tcsh script but fails weirdly with eval in tcsh.
I have 2 simple files with the following content
> head *.tcsh
==> set.tcsh <==
set intVar = 10
set strVar = a
==> setenv.tcsh <==
setenv intVar 10
setenv strVar a
The first file with set one works fine with eval, but the second file with setenv fails with the error setenv: Too many arguments
> tcsh -c 'eval `cat set.tcsh` ; (set ; printenv) | grep -P "^...Var"'
intVar 10
strVar a
> tcsh -c 'eval `cat setenv.tcsh` ; (set ; printenv) | grep -P "^...Var"'
setenv: Too many arguments.
But both scripts work fine as standalone tcsh scripts
> echo 'echo $intVar $strVar' >> set.tcsh
> echo 'echo $intVar $strVar' >> setenv.tcsh
> tcsh ./set.tcsh
10 a
> tcsh ./setenv.tcsh
10 a
It sounds weird the eval has all the issues.
Tcsh version
> which eval
eval: shell built-in command.
> tcsh --version
tcsh 6.21.00 (Astron) 2019-05-08 (x86_64-unknown-linux) options wide,nls,dl,al,kan,sm,rh,nd,color,filed
Why eval is behaving that way, anything alternative to eval that is recommended in tcsh?