這可能是一個愚蠢的錯誤。我使用this as a basis for a bash function嘗試爲this git function創建一個bash腳本:巴什腳本的Git分支列出
branch() {
if [[ [email protected] == "-r" ]]; then
command for k in `git branch -r | perl -pe 's/^..(.*?)(->.*)?$/\1/'`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r
else
command for k in `git branch | perl -pe s/^..//`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r
fi
}
當我嘗試這個來源,它實際上是試圖執行的命令 - 然後給出因爲這個語法錯誤。
我能夠在本地執行命令,所以顯然我失去了一些東西在這裏創建我的功能顯而易見。
在你的其他條款,即在GIT命令前單引號應該是一個反勾:'K在「git'成爲'K在\'git'。 – bishop
@bishop改變這個結果的結果相同。 – enderland
'command'具有'command [-pVv]命令[arg ...]'的用法。這不是'for'循環會給你帶來的。你想多次運行一個命令嗎?如果是這樣,把'command'放在'for'裏面。作爲一個建議,刪除「命令」,看看會發生什麼。 – bishop