Makefile bash和xargs变量不起作用

hol*_*lms 1 bash makefile

这是一个Makefile

roman@debian ~/D/O/devops> cat Makefile 
install:
        -cat projects.txt  | xargs -n 2 bash -c 'git clone $0 $1'
Run Code Online (Sandbox Code Playgroud)

这是projects.txt

roman@debian ~/D/O/devops> cat projects.txt
git@github.com:xxx/xxx1.git   app-xxx1
git@github.com:xxx/xxx2.git   app-xxx2
Run Code Online (Sandbox Code Playgroud)

这是当我将此命令复制到bash时会发生什么 - 它的工作原理:

roman@debian ~/D/O/devops> cat projects.txt  | xargs -n 2 bash -c 'git clone $0 $1'

fatal: destination path 'app-xxx1' already exists and is not an empty directory.
Run Code Online (Sandbox Code Playgroud)

它正确使用git clone它只是repo存在.

现在,当您执行make install此操作失败时,所有变量都为空:

roman@debian ~/D/O/devops> make install 
cat projects.txt  | xargs -n 2 bash -c 'git clone  '
You must specify a repository to clone.
Run Code Online (Sandbox Code Playgroud)

我想在这里只使用xargs方法,否则它变得过于冗长,使用循环时还会遇到更多问题.我也尝试过$(1)但没有运气

G.M*_*.M. 5

make是解释$0$1制作变量并尝试扩展它们.尝试替换$$$......

install:
        -cat projects.txt  | xargs -n 2 bash -c 'git clone $$0 $$1'
Run Code Online (Sandbox Code Playgroud)