shell 和腳本中的退出程式碼不同

shell 和腳本中的退出程式碼不同

以下區塊在腳本中執行正常,但給出退出程式碼 1。

tar:從成員名稱中刪除前導“/”

並給出退出代碼 0。如何修復此問題以避免使用腳本執行時退出程式碼 1。

tar -czf $tracedir/dbtrace.tar.gz $tracedir

status=$?

if [ $status -ne 0 ]; then
    echo "The error code is---"$status >> output.log
fi

使用腳本運行時如何避免退出程式碼 1?

相關內容