大家好
想請教關於 bash script 參數傳遞問題
目前有兩隻 script
a.sh:
nfsroot="-kernel vmlinuz -append 'root=/dev/nfs nfsroot=$ip:/'"
disk="-drive file=$1"
$arg="$disk $nfsroot"
/root/b.sh $arg
b.sh:
echo "num of arg:$#"
當執行$ ./a.sh
num of arg:7
但預期應該是要 6
因為 nfsroot 後面的 'root=.. nfsroot=..' 被當成兩個參數來傳遞了
分別為 'root=/dev/nfs 和 nfsroot=$ip:/'
請問有辦法讓變數傳遞時不要拆成兩個嘛?
謝謝
--
想請教關於 bash script 參數傳遞問題
目前有兩隻 script
a.sh:
nfsroot="-kernel vmlinuz -append 'root=/dev/nfs nfsroot=$ip:/'"
disk="-drive file=$1"
$arg="$disk $nfsroot"
/root/b.sh $arg
b.sh:
echo "num of arg:$#"
當執行$ ./a.sh
num of arg:7
但預期應該是要 6
因為 nfsroot 後面的 'root=.. nfsroot=..' 被當成兩個參數來傳遞了
分別為 'root=/dev/nfs 和 nfsroot=$ip:/'
請問有辦法讓變數傳遞時不要拆成兩個嘛?
謝謝
--
All Comments