您现在的位置是:首页 > 电脑 > 

Foreach python文件在子目录中(Foreach python file in subdirectory)

2025-07-18 06:36:27
Foreach python文件在子目录中(Foreach python file in subdirectory) 我正在扔这条毛巾。 我有一个相当成功的makefile,它在子目录中到文件并将它们作为过滤器传递给pandoc。 它在没有空格的路径中工作得很好,但是我不能让它在包含空格的路径中运行。 这是MWE: BASEDIR=$(CURD
Foreach python文件在子目录中(Foreach python file in subdirectory)

我正在扔这条毛巾。

我有一个相当成功的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 $(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 $(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. ow 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 situati 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.

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/79491.html

相关标签:无
上传时间: 2023-04-28 04:54:18
留言与评论(共有 12 条评论)
本站网友 深圳家教
20分钟前 发表
这是MWE: BASEDIR=$(CURDIR) STYLEDIR=$(BASEDIR)/style FILFILES
本站网友 北京欢乐谷门票团购
14分钟前 发表
= "$(shell find "$(STYLEDIR)" -name *.py)" FILTER
本站网友 博客大巴
22分钟前 发表
"$(FILFILES)"
本站网友 巨能钙
14分钟前 发表
make completely ignores all types of quoting characters (double
本站网友 白醋作用
12分钟前 发表
这是MWE: BASEDIR=$(CURDIR) STYLEDIR=$(BASEDIR)/style FILFILES
本站网友 鑫苑鑫城
29分钟前 发表
但是foreach将创建三个实例
本站网友 永恒不变的幸福
13分钟前 发表
这是MWE: BASEDIR=$(CURDIR) STYLEDIR=$(BASEDIR)/style FILFILES
本站网友 网文快捕
29分钟前 发表
那么即使不是不可能
本站网友 zhitong
19分钟前 发表
您可以使用技巧来使其工作
本站网友 细哥细妹
19分钟前 发表
Foreach python文件在子目录中(Foreach python file in subdirectory) 我正在扔这条毛巾
本站网友 巴塞尔协议2
16分钟前 发表
它在子目录中到文件并将它们作为过滤器传递给pandoc