`find -exec` in git alias

2019-07-19 01:38发布

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.

标签: git find alias
1条回答
神经病院院长
2楼-- · 2019-07-19 01:53

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.

)

查看更多
登录 后发表回答