![引用「find -execdir test [command]」的指令 (Bash)](https://rvso.com/image/1482231/%E5%BC%95%E7%94%A8%E3%80%8Cfind%20-execdir%20test%20%5Bcommand%5D%E3%80%8D%E7%9A%84%E6%8C%87%E4%BB%A4%20(Bash).png)
git fetch
如果有遠端(=git remote
非空),我想在 git repos 中執行以下命令:
find -name .git -execdir test $(git remote) \; -execdir git fetch
^^^^^^^^^^^^^
How to quote/escape/mask this?
嘗試了很多不起作用的變體,例如"$(git remote)"
:'$(git remote)'
,,,,,...\$\(git remote\)
'"$(git remote)'"
答案1
嘗試這個:
find -name .git -execdir sh -c 'test $(git remote)' \; -execdir git fetch \;
因為無論如何都會啟動一個 shell,你甚至可以這樣做:
find -name .git -execdir sh -c 'test $(git remote) && git fetch' \;