Bash 保留从Makefile调用的脚本换行符stdout
我需要从Makefile echo多行脚本stdout::Bash 保留从Makefile调用的脚本换行符stdout,bash,makefile,Bash,Makefile,我需要从Makefile echo多行脚本stdout:: $ more Makefile mydir: a=$(shell ls -la) echo "$(a)" 所以我想要:: $ make mydir total 12 drwxrwxr-x 2 luis luis 4096 nov. 6 18:55 . drwxrwxr-x 14 luis luis 4096 nov. 6 18:45 .. -rw-rw-r-- 1 luis luis 40 nov.
$ more Makefile
mydir:
a=$(shell ls -la)
echo "$(a)"
所以我想要::
$ make mydir
total 12
drwxrwxr-x 2 luis luis 4096 nov. 6 18:55 .
drwxrwxr-x 14 luis luis 4096 nov. 6 18:45 ..
-rw-rw-r-- 1 luis luis 40 nov. 6 18:55 Makefile
$
但我明白了:
$ make mydir
a=total 12 drwxrwxr-x 2 luis luis 4096 nov. 6 18:55 . drwxrwxr-x 14 luis luis 4096 nov. 6 18:45 .. -rw-rw-r-- 1 luis luis 40 nov. 6 18:55 Makefile
/bin/sh: 1: 12: not found
Makefile:2 : la recette pour la cible « mydir » a échouée
make: *** [mydir] Erreur 127
顺便说一句,我的真实脚本有一个带负号的名称,像这样我的脚本aa
此帖子未给出Makefile结果:
我正在使用
gnubash,版本4.3.46
和gnumake4.1
当您已经在shell中时(因为您在配方中),为什么要使用shell
Make函数
尝试:
请注意,这相当于在shell提示符下运行以下命令:
a=$(ls -la); echo "$a"
但是我们通过键入两次来避开$
,这样make
就不会解释它
a=$(ls -la); echo "$a"