Wal*_*sen 5 unix shell csh tcsh
我有一个tcsh shell脚本,我想在大多数时间以非零状态的错误停止,但在某些情况下我想忽略它.例如:
#!/bin/tcsh -vxef
cp file/that/might/not/exist . #Want to ignore this status
cp file/that/might/not/exist . ; echo "this doesn't work"
cp file/that/must/exist . #Want to stop if this status is nonzero
Run Code Online (Sandbox Code Playgroud)
我们开始吧:生成一个新的 shell,使用 ';' 忽略第一个状态,它返回全部清除。
$SHELL -c 'cp file/that/might/not/exist . ; echo "good"'
Run Code Online (Sandbox Code Playgroud)