
我在 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.
mkdir 的 SUA 手冊頁部分說明:
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 一個,這也是需要的。