2

I have a folder on my HD which contains parentheses in its name. Like: C:/stuff (really cool)/. The make $(wildcard ..) function does not work properly with this directory.

$(wildcard C:/stuff (really cool)/*.jpg)`

evaluates to no results at all. I guess this is due to the fact that the closing parentheses in the directory-name is treated as the closing parentheses for the $(wildcard ..) function. Escaping the ( and ) with a backslash does not work. What also does not work, is putting the directory-name into a variable and then using the wildcard function.

DIR = C:/stuff (really cool)
all:
    @echo "$(wildcard $(DIR)/*.jpg)"

No results at all, again.

How should I properly escape the parentheses?

4

2 回答 2

0

您没有提到您在哪种环境中运行,但以下两种打印机制都适用于常规 DOS 提示符以及 msys/mingw:

DIR = C:/stuff\ (really\ cool)
$(info Files in subdir are: $(wildcard $(DIR)/*.jpg))

all:
    @echo "Files in subdir are: $(wildcard $(DIR)/*.jpg)"

-ed 表达式周围的双引号echo仅对 msys/mingw 是必需的。

于 2012-11-08T22:37:34.787 回答
0

以下不起作用,不断警告他人:

特殊字符通常被“保护”或转义,并带有引号。要创建带括号的变量,请使用双引号。

DIR = "C:/stuff (really cool)"

在您的情况下,最大的问题是空间会导致您的路径被分解为几个部分而不是一个部分。

这有效:

GNU Make 让你可以转义空格,\\这样你的调用$wildcard就会变成

$(wildcard C:/stuff\\ (really\\ cool)/*.jpg)
于 2012-11-08T12:44:17.450 回答