bash - 如何检查PS1中的dotnet恢复是否正常?

标签 bash powershell docker .net-core ps1

我有带dotnet restore命令的dockertask.ps1文件,问题是如何确保它运行时没有错误?

最佳答案

执行完程序后,您可以使用$?捕获退出代码,但只能在执行后立即捕获。

dotnet restore
ErrNo="$?"
if [ "$ErrNo" -ne 0 ]
then 
echo "error code ${ErrNo} received."
fi
$?包含上次执行的错误代码。

带有if-ne命令表示不等于

关于bash - 如何检查PS1中的dotnet恢复是否正常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43182631/

相关文章:

linux - bash: terraform: 未找到命令,导出 $PATH 未解析

bash - 存在字符串时如何在两个定界符之间提取文本

powershell - 作为登录脚本运行时,PowerShell 中的 cmdkey 不起作用?

python - 在 Docker 容器中导入 python 文件

docker - 从 docker 容器运行 ansible playbook 并部署在主机上

Linux - 检查文件是否有多行

linux - 参数未传递给 shell 脚本 copyfile.sh : 1: copyfile. sh: [d: 未找到

powershell - 使用 Start-Job 同时运行多个脚本 block (而不是循环)

powershell - 在 PowerShell 中使用双引号

windows - 无法将 Windows docker 镜像推送到 Artifactory