问题描述
我遇到了用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
中做什么?
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
设置为(true,则为空字符串),则扩展为1(true),如果未设置,则扩展为0(false). t.
$?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中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!