我在 Windows 上使用 Interix 来实现 Unix 兼容性,但发现它的-p
行为mkdir
不符合我的预期:
> which mkdir
C:\SFU\bin\mkdir
> mkdir -p c:\Program Files\
A subdirectory or file -p already exists.
Error occurred while processing: -p.
SUA 手册页中 mkdir 的部分内容如下:
NAME
mkdir - make directories
SYNOPSIS
mkdir [-p] [-m mode] directory_name [...]
DESCRIPTION
The mkdir utility creates the directories named as operands, in the order
specified, using mode rwxrwxrwx (0777) as modified by the current
umask(2).
-p Create intermediate directories as required. If this option is
not specified, the full path prefix of each operand must already
exist. Intermediate directories are created with permission bits
of rwxrwxrwx (0777) as modified by the current umask, plus write
and search permission for the owner. Do not consider it an error
if the argument directory already exists.
为什么我传递了 却收到有关现有目录的错误-p
?似乎-p
未被识别为标志,而是创建了一个名为 的目录-p
。您如何传递-p
参数?
答案1
mkdir
选取的是窗口,而不是 Interix 窗口。我通过提供 Interixmkdir
位置的完整路径来避免此问题。即使which mkdir
提供了 Interix 路径,这也是必要的。