2012-12-13 34 views
1

如何從git pull將顏色讀取stdout爲bash變量?從git pull --stat如何讀取從顏色變化的git pull --stat的輸出

$ output=$(ls --color=always) 
$ echo -e "$output" 

但不是:

躲過ls --color=always序列很容易被讀取到$output

$ git config color.ui always 
$ output=$(git pull --stat <repository> <refspec>) 
$ echo -e "$output" 

換句話說,我怎麼能欺騙git pull,以爲它不會輸出到一個變量?這不起作用:$ env TERM=xterm-color git pull --stat

回答

1

你的配置變量有一個錯字,應該是color.ui,單數,而不是colors.ui。 在我的系統上使用git 1.7.10版本,然後按預期工作。

更新:見截圖: screenshot

+0

你的意思是,你能捕捉到綠 - 紅characteres嗎?感謝您注意問題中的錯字。我仍然做不到。 –

+0

你的git版本是什麼? – Jester

+0

1.7.2.5謝謝。 –