shell中获取执行另一个shell的返回值

1、通过 sh 执行另一个脚本
2、过 $? 获取上一条命令的返回值。

#!/bin/bash

sh ./test.sh
ret = $?
if [ $ret -eq -1 ]; then
	echo " test.sh failed."
fi
posted @ 2022-03-12 22:04  xiaomodecnblogs  阅读(76)  评论(0编辑  收藏  举报