我正在扔这条毛巾。
我有一个相当成功的makefile,它在子目录中找到文件并将它们作为过滤器传递给pandoc。 它在没有空格的路径中工作得很好,但是我不能让它在包含空格的路径中运行。
这是MWE:
BASEDIR=$(CURDIR) STYLEDIR=$(BASEDIR)/style FILFILES := "$(shell find "$(STYLEDIR)" -name *.py)" FILTER := $(foreach "$(FILFILES)", "$(FILFILES)", --filter $(FILFILES)) TEXFLAGS = --filter pandoc-crossref --filter pandoc-citeproc $(FILTER) --latex-engine=xelatex pdf: pandoc document.md $(TEXFLAGS)为了使示例工作,您必须在带有空格的某个目录中运行makefile,尝试使用this md dir ,创建子目录style并添加任何.py文件。 现在运行,你会发现FILFILES选择了正确的python文件,但是foreach将创建三个实例,因此--filter --filter --filter 。 这是为什么? 我究竟做错了什么?
如果你想要完整的makefile: 这里
I am throwing the towel with this one.
I have a fairly successful makefile, that finds files in a subdirectory an pass them as filters to pandoc. It works great in paths without spaces, but I cant make it behave in paths that includes spaces.
Here is the MWE:
BASEDIR=$(CURDIR) STYLEDIR=$(BASEDIR)/style FILFILES := "$(shell find "$(STYLEDIR)" -name *.py)" FILTER := $(foreach "$(FILFILES)", "$(FILFILES)", --filter $(FILFILES)) TEXFLAGS = --filter pandoc-crossref --filter pandoc-citeproc $(FILTER) --latex-engine=xelatex pdf: pandoc document.md $(TEXFLAGS)In order for the example to work you have to run the makefile in some directory with spaces, try this md dir, create a subdirectory style and add any .py file. Now run, and you will see that FILFILES pick the proper python file, but the foreach will create three instances, hence --filter --filter --filter. Why is that? What am I doing wrong?
In case you want the full makefile: here
最满意答案
使用包含空格的单词(包括文件名)几乎不可能。
要清楚,make完全忽略所有类型的引号字符(double,single,back)。
在某些特定情况下,您可以使用技巧来使其工作。 但是,您没有向我们提供有关您实际行动的信息; 您将展示如何分配变量FILFILES和FILTER但不显示如何使用它们。
如果这些变量仅用于配方中,那么您通常可以使其工作。 如果您将它们作为先决条件使用,那么即使不是不可能,也将非常困难。
It's all but impossible to use words (including filenames) containing spaces with make.
To be clear, make completely ignores all types of quoting characters (double, single, back).
In some particular situations you can use tricks to allow it to work. However you didn't give us any information about what you're actually doing; you show how you assign the variables FILFILES and FILTER but you don't show how you use those.
If those variables are only used inside recipes then you can often make it work. If you're using them as prerequisites then it will be very difficult if not impossible.
更多推荐
发布评论