Windows 上的 Makefile For 循环
这是一个与我在这里询问。我运行的是Windows XP。
我正在尝试让 for 循环在 Windows 上工作。按照的建议我必须确保该命令是有效的cmd命令,我构建了一个有效的for循环批处理命令:
@echo off
FOR /F "tokens=4 delims=," %%G IN ("deposit,$4500,123.4,12-AUG-09") ^
DO ^
echo Date paid %%G ^
并将其放入Makefile中。这是 makefile 的内容:
all:
@echo off
FOR /F "tokens=4 delims=," %%G IN ("deposit,$4500,123.4,12-AUG-09") ^
DO ^
echo Date paid %%G ^
但是,我仍然收到错误:
FOR /F "tokens=4 delims=," %%G IN ("存款,500,123.4,12-AUG-09") ^ make: *** [全部] 错误 255
知道如何解决这个问题吗?
This is a similar question to the one I ask here. I am running on Windows XP.
I am trying to get for loop to work on Windows. Following the suggestion that I have to make sure that the command are valid cmd command, I constructed a valid for loop batch command:
@echo off
FOR /F "tokens=4 delims=," %%G IN ("deposit,$4500,123.4,12-AUG-09") ^
DO ^
echo Date paid %%G ^
And put it in a Makefile. This is the content of the makefile:
all:
@echo off
FOR /F "tokens=4 delims=," %%G IN ("deposit,$4500,123.4,12-AUG-09") ^
DO ^
echo Date paid %%G ^
But still, I got an error:
FOR /F "tokens=4 delims=," %%G IN
("deposit,500,123.4,12-AUG-09") ^
make: *** [all] Error 255
Any idea how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我找到了答案,这是在 Makefile Windows 中运行的正确语法:
I've found the answer, this is the correct syntax that runs in Makefile Windows:
我发现通过使用 &&您可以在 for 循环内执行多个命令,如下所示:
这将打印出如下内容:
I've found that by using && you can do multiple commands inside the for loop like so:
This will printout something like:
你的分割是错误的,不要使用^。执行如下操作:
your split is wrong, don't use ^. Do as following:
也许您可以从 Makefile 调用批处理命令文件?
用MyBatch.bat如下。
注意 Makefile 中的 $ 思想。 $ 是转义字符,必须加倍才能在字符串中得到一个真正的 $。
Maybe you can call your batch command file from the Makefile?
With MyBatch.bat as follows.
Beware the $ in the Makefile thought. $ is the escape characher and have to be doubled to get one real $ in strings.