我遇到过$?我在其中一个shell脚本中进行集成(不是由我编写的).
只是想确认它意味着上一个命令的返回码.
用法类似于
runSomeCommand $VAR1 $VAR2 $VAR3
processResult $?
Run Code Online (Sandbox Code Playgroud)
$? 是上次执行的命令的退出状态.
ls
....
echo $?
0
$ ls notexistingfile
ls: cannot access notexistingfile: No such file or directory
echo $?
2
Run Code Online (Sandbox Code Playgroud)