shell
错误退出
set -e
错误不退出
#!/bin/bash
command1 || { echo "command1 failed, but we'll continue"; exit 1; }
command2
bat
@echo off
setlocal enabledelayedexpansion
call :execute_command command1
if !errorlevel! neq 0 (
echo 第一个命令执行失败,停止执行后续命令
goto :eof
)
call :execute_command command2
goto :eof
:execute_command
%~1
exit /b %errorlevel%
相互学习,共同进步!
浙公网安备 33010602011771号