我有一个简单的(甚至愚蠢的:)问题:在bash脚本中,我试图使用将命令的返回代码存储到变量中S?
,以便稍后在脚本中使用它,但S?
实际上存储为S?。
我运行这个测试 bash 脚本:
#!/bin/bash
echo "trying to store this command's return code. it should be 0"
rtrn_code=S?
echo $rtrn_code
Run Code Online (Sandbox Code Playgroud)
但我得到的不是 0(成功返回代码)而是 S?:
trying to store this command return code. it should be 0
S?
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?有任何想法吗?
先感谢您。
bash ×1