不難理解,bash script-name是產(chǎn)生了一個子進(jìn)程shell,而我們當(dāng)前的操作還在父shel中因此得不到該變量值。 執(zhí)行第三種方法. test_sh.sh,效果如下: 可以成功的輸出變量的值。 這是因為source script-name和. script-name是將script-name中的內(nèi)容直接加載到當(dāng)前的shell,因此能夠輸出當(dāng)前變
www.dbjr.com.cn/server/305919q...htm 2025-5-30