2012-04-20 30 views
4

爲了簡化我的關心,我把它縮小到以下幾點:傳遞的所有參數git的別名

我定義爲這樣的GIT別名:

cii = "!f() { git commit "[email protected]"; }; f" 

當我運行

$ git cii -m "test1" 

它工作正常,但它失敗

$ git cii -m "test1 and test2" 
error: pathspec 'and' did not match any file(s) known to git. 
error: pathspec 'test2' did not match any file(s) known to git. 

有什麼想法?

請注意,我的真實別名比上述複雜得多,因此用 cii =「commit」進行響應不是一種選擇。這裏的要點是將輸入參數傳遞給函數。

+0

爲什麼「和」?爲什麼不只是git cii -m test test1? – CCC 2013-06-17 21:48:04

回答

4

您需要引用嵌入的雙引號。然後

cii = "!f() { git commit \"[email protected]\"; }; f" 

git會執行"[email protected]"標準殼擴張其轉換爲用於每個參數的單個字 - 像"$1" "$2" "$3" ...

+0

是的,看起來像。但我真正的別名仍然失敗..認爲我沒有縮小正確的問題。 – 2012-04-20 19:01:04