无法将变量设置为 C-shell 的脚本

Unable to set variable as a script for C-shell

这个很简单。我试图在第二个脚本中设置我的变量。我尝试了多种方法但不起作用。因此,所有注释掉的部分。第一个脚本你 运行 IE:unit3.2a.sh 3 5 这将 return 8。第二个脚本应该将结果读取为 8。我正在使用 cygwin。

unit3.2a.sh '''

#!/bin/csh

set a = 0
set b = 0
set c = 0

@ a = 
@ b = 

@ c = $a + $b

echo $c

'''

unit3.sh '''

#!/bin/csh

a=$(~./unit3.2a.sh)
#below is all that don't work!
#instructors: a =~./unit3.2a.sh 2 200
#./unit3.2a.sh "2" "200"
#~./unit3.2a.sh 2 200
#=$(./unit3.2a.sh 2 200)
#=$(./unit3.2a.sh)+(2 200)
#$(./unit3.2a.sh 2 200)
#$(/home/Admin/unit3.2a.sh)
#$(/home/Admin/unit3.2a.sh 2 200)
#added echo $a to see if I wasnt seeing  anything the echo text works fine but a variable does not read?
#set a='./unit3.2a.sh 2 200'
##set a=$(cat ./unit3.2a.sh 2 200)
#$ ./unit3.sh
#cat: 2: No such file or directory
#cat: 200: No such file or directory
#set a=$(~./unit3.2a.sh 2 200)
#a=$(~./unit3.2a.sh 2 200)



echo $a

echo "The result is: $a"

echo "Storing the results.............."

echo "Storing the result: $a" >> unit3.txt

echo "The script is over"

'''

请注意:

~./unit3.2a.sh 指的是特定文件位置 而 ./unit3.2a.sh 指的是当前目录中的文件

形式 $( command ) 是 bash 特定的,在 C shell 中不起作用,参见
https://www.grymoire.com/Unix/Csh.html#uh-21

#!/bin/csh

set a = `./unit3.2a.sh 2 2`

echo $a
echo "The result is: $a"
echo "Storing the results.............."
echo "Storing the result: $a" >> unit3.txt
echo "The script is over"

产生:

$ ./unit3.sh
4
The result is: 4
Storing the results..............
The script is over