BASH 讀取傳入值的坑
那些年的心酸血淚
前言
進入正題前想到這則推特,真是心情寫照阿!
Debugging is like being the detective in a crime movie where you are also the murderer.
— Filipe Fortes (@fortes) November 10, 2013
辛酸血淚
最近利用 bash 寫測試程式,需要將參數傳入 function 內
#!/bin/bash
test() {
echo $1
}
test "foobar"
今天卻遇到個百思不得其解的問題,程式、參數大致看起來沒有問題
#!/bin/bash
test() {
echo $1 $2 ... $9 $10
}
test "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
程式輸出卻變成
$ ./test.sh
a b ... i a0