bash 參數傳遞問題 - Linux

By Puput
at 2010-11-12T15:39
at 2010-11-12T15:39
Table of Contents
大家好
想請教關於 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:/'
請問有辦法讓變數傳遞時不要拆成兩個嘛?
謝謝
--
Tags:
Linux
All Comments

By Thomas
at 2010-11-13T08:45
at 2010-11-13T08:45

By Mason
at 2010-11-13T14:46
at 2010-11-13T14:46

By Xanthe
at 2010-11-14T19:13
at 2010-11-14T19:13

By Damian
at 2010-11-15T19:06
at 2010-11-15T19:06

By Blanche
at 2010-11-18T20:48
at 2010-11-18T20:48

By Adele
at 2010-11-23T03:07
at 2010-11-23T03:07

By Olive
at 2010-11-27T04:03
at 2010-11-27T04:03
Related Posts
安裝完UBUNTU 10.10...卻只有文字介面

By Aaliyah
at 2010-11-12T00:09
at 2010-11-12T00:09
另一硬碟顆xp加入grub

By Sierra Rose
at 2010-11-11T22:44
at 2010-11-11T22:44
另一硬碟顆xp加入grub

By Hedda
at 2010-11-11T22:34
at 2010-11-11T22:34
另一硬碟顆xp加入grub

By Rachel
at 2010-11-11T22:12
at 2010-11-11T22:12
wubi沒反應

By Zora
at 2010-11-11T20:43
at 2010-11-11T20:43