2
我必須修改現有的ksh腳本,它使用'shift'查看命令行參數,並清空$ @,但現在要將原始參數傳遞給之後的第二個劇本。將ksh輸入數組存儲到變量並傳遞給另一個腳本
在主線情況下,我可以通過將$ @複製到一個變量並將其傳遞給第二個腳本來完成此操作,但是我無法讓它適用於引用的命令行參數。
如果我有一個叫做 '打印機' 像下面的腳本:
#!/bin/ksh
[email protected]
echo "Printing args"
until [[ $# -eq 0 ]];do
echo $1
shift
done
./printer2 $INPUT
和PRINTER2象下面這樣:
#!/bin/ksh
echo "Printing second args"
until [[ $# -eq 0 ]];do
echo $1
shift
done
我想的
./printer first second "third forth"
輸出爲:
Printing args
first
second
third forth
Printing second args
first
second
third forth
我試過各種各樣的變量組合(在$ INPUT的賦值和將它傳遞給printer2時),但無法弄清楚。誰能幫忙?
與我的興趣有關。感謝您的幫助! – Katerberg 2011-01-21 21:20:24
請參閱http://unix.stackexchange.com/questions/41357/what-is-the-most-correct-way-to-pass-an-array-to-a-function進行推理。 – 2012-08-31 13:57:10