问题描述
我遇到过这段用csh写的代码:
I've encountered this code written in csh:
if ( ! $?LM_LICENSE_FILE ) then
setenv LM_LICENSE_FILE $_LmLicense
else
switch("$LM_LICENSE_FILE")
case *${_LmLicense}*:
breaksw
default:
setenv LM_LICENSE_FILE "${_LmLicense}:$LM_LICENSE_FILE"
endsw
endif
请注意这一行:
if ( ! $?LM_LICENSE_FILE ) then
$?
在 $?LM_LICENSE_FILE
中有什么作用?
What does $?
do in $?LM_LICENSE_FILE
?
LM_LICENSE_FILE
是一个 shell 变量(或者更准确地说是宏),我知道 $LM_LICENSE_FILE
用于检索它的值,但是在 $
,即$?LM_LICENSE_FILE
,是什么意思?
LM_LICENSE_FILE
is a shell variable (or macro, more precisely), and I know that $LM_LICENSE_FILE
is used to retrieve its value, but a trailing question mark following $
, that is $?LM_LICENSE_FILE
, what is its meaning?
推荐答案
$?VAR
如果设置了 $VAR
则扩展为 1 (true)(任何东西,甚至空字符串),如果不是,则为 0(假).
$?VAR
expands to 1 (true) if $VAR
is set (to anything, even the empty string), 0 (false) if it isn't.
这在 csh 手册中有记录;点击链接并搜索 $?
,或输入 man csh
或 man tcsh
.
This is documented in the csh manual; follow the link and search for $?
, or type man csh
or man tcsh
.
哦,而且 csh 没有宏.
Oh, and csh doesn't have macros.
这篇关于$?VAR 在 csh 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!