小编use*_*887的帖子

为另一个脚本调用一个脚本,但如果子进程调用 exit 则不要退出父进程

first.sh

#! /bin/ksh
echo "prova"
. ./second.sh
echo "ho lanciato il secondo"
. ./third.sh
echo "ho lanciato il terzo"
Run Code Online (Sandbox Code Playgroud)

second.sh

echo "sono nel secondo script"
dosomething1
exit $?
Run Code Online (Sandbox Code Playgroud)

如果second.sh检测到错误并以状态 -9first.sh退出,则始终退出。如果子 shell 退出,我如何避免从第一个 shell 退出?

我无法编辑second.sh

shell shell-script exit

16
推荐指数
2
解决办法
6万
查看次数

标签 统计

exit ×1

shell ×1

shell-script ×1