【发布时间】:2016-01-23 23:24:00
【问题描述】:
我正在尝试将 Makefile 移植到 Windows(使用 GNU Make)。我在删除目录时遇到问题。我发现了这个关于如何有条件地删除目录的问题 (Delete a directory and its files using command line but don't throw error if it doesn't exist),但尝试使用该解决方案时出现错误,大致翻译为 The use of ""doc\html"" is syntactically impermissible in this context
导致它的sn-p是这样的:
if exists "doc\html\" rmdir /Q /S doc\html
我也试过
cmd /c if exists "doc\html" cmd /c rmdir /Q /S doc\html
和
cmd /c if exists "doc\html\" cmd /c rmdir /Q /S doc\html.
我也试过rmdir /Q /S doc\html 2>nul。这有点工作。错误被重定向,但 Make 仍然抛出错误并停止。
我怎样才能做到这一点?
【问题讨论】:
标签: if-statement makefile directory exists rmdir