`find -exec` in git alias

有些话、适合烂在心里 提交于 2019-12-11 02:44:35

问题


This alias in .git/config:

pycat = !find -iname '*.py' -exec cat {} \;

Gives me this in the shell:

$ git pycat
fatal: bad config file line 19 in .git/config

I've tried quotes, no quotes, switching quote types, escaping everything up to four levels, but I can't figure out what's making git unhappy here.


回答1:


A little farting around says it's the semicolon,

pycat = !find -iname '*.py' -exec cat {} "\\;"
pycat = !find -iname '*.py' -exec cat {} "';'"
pycat = "!find -iname '*.py' -exec cat {} \\;"
pycat = "!find -iname '*.py' -exec cat {} \";\""

all work. Semicolons are old-school comment-to-eol syntax, that may be what's going on here. So the config parser's eating one layer of doublequotes.

(edit: yup. It even says so in the doc:

The syntax is fairly flexible and permissive; whitespaces are mostly ignored. The # and ; characters begin comments to the end of line, blank lines are ignored.

)



来源:https://stackoverflow.com/questions/24216116/find-exec-in-git-alias

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!