比较 tcsh 中的两个句子
Comparing two sentences in tcsh
我有一个程序
set signal="Normal Completion of program MRGGRID"`
if ( $signal == "Normal Completion of program MRGGRID" ) then
echo "yes"
endif
错误信息是
if: Expression Syntax.
您需要在 if
中的 $signal
变量周围添加引号。
tcsh
在使用前扩展变量;最好不要将它们视为 "variables",而更像是 "macro's",它们在使用前会被扩展,因此您的 if
语句被解释为:
if ( Normal Completion of program MRGGRID == "Normal Completion of program MRGGRID" )
并且不是作为:
if ( "Normal Completion of program MRGGRID" == "Normal Completion of program MRGGRID" )
这不是 tcsh
特有的,Bourne shell 也可以这样工作...但是 tcsh
的错误消息几乎普遍没有帮助(如您所见),这是原因之一为什么通常不鼓励将 tcsh
用于脚本目的。
我有一个程序
set signal="Normal Completion of program MRGGRID"`
if ( $signal == "Normal Completion of program MRGGRID" ) then
echo "yes"
endif
错误信息是
if: Expression Syntax.
您需要在 if
中的 $signal
变量周围添加引号。
tcsh
在使用前扩展变量;最好不要将它们视为 "variables",而更像是 "macro's",它们在使用前会被扩展,因此您的 if
语句被解释为:
if ( Normal Completion of program MRGGRID == "Normal Completion of program MRGGRID" )
并且不是作为:
if ( "Normal Completion of program MRGGRID" == "Normal Completion of program MRGGRID" )
这不是 tcsh
特有的,Bourne shell 也可以这样工作...但是 tcsh
的错误消息几乎普遍没有帮助(如您所见),这是原因之一为什么通常不鼓励将 tcsh
用于脚本目的。