我的最新迭代
jinit= !git init && printf "* text=auto\n*.java text\n*.jsp text\n*.css text\n*.html text\n*.js text\n*.xml text\n*.sql text\n*.MF text\n*.tld text\n*.md text\n\n# git files\n*.gitignore text\n*.gitattributes text\n\n# eclipse files\n*.classpath text\n*.project text\n*.prefs text\n*.properties text\n*.component text\n" >> .gitattributes && echo "bin/" >> .gitignore && git add .
这实际上会尝试执行 gitattributes 中的行!更改\n
for\r\n
将使脚本崩溃,并且 for\\\n
将成功运行脚本,尽管 gitattributes 将仅包含
*
那么我如何用新行来呼应呢?视窗、明文、msysgit
编辑:我也试过单引号
编辑 2014.03.13:
jinit= !git init && `echo '* text=auto\n\n*.java text\n*.jsp text\n\
*.css text\n*.html text\n*.js text\n*.xml text\n*.sql text\n*.MF text\n\
*.tld text\n*.md text\n\n*.gitignore text\n*.gitattributes text\n\n\
*.classpath text\n*.project text\n*.prefs text\n*.properties text\n\
*.component text\n' >> .gitattributes` && `echo "bin/" >> .gitignore`
编辑 2014.03.14:\
用于包装命令 - 仍然有效,但在 *.css、*.tld、*.classpath 和 *.component 之前引入了一个空格。
似乎无法管理回显评论。因此,如果我添加\n# git files\n\*.gitignore text\n (...)
它 EOF - 有什么解决方法吗?
最后我使用了不同的方法(见评论):
jinit= !git init\
&& `ln /c/Dropbox/_/_git/java_eclipse.gitattributes .gitattributes`\
&& `echo "bin/" >> .gitignore`\
&& git add .
但我暂时把它打开,对于句法部分