bash 解压:给出:checkdir 错误:.../目录存在但不是目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32467871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 13:32:36  来源:igfitidea点击:

unzip: gives: checkdir error: .../directory exists but is not a directory

bashcygwin

提问by Ray

My team produces a build.zip file using windows that I want to do some post processing on using cygwin/bash script, unzipping it, and then doing further processing.

我的团队使用 windows 生成了一个 build.zip 文件,我想对使用 cygwin/bash 脚本进行一些后期处理,将其解压缩,然后进行进一步处理。

I can use the Windows 7 GUI "Extract All" and everything works fine -- extraction works, getting into the "problem directory" is no problem. Everyone has been doing that for ages.

我可以使用 Windows 7 GUI“全部提取”并且一切正常——提取工作正常,进入“问题目录”没有问题。多年来,每个人都这样做。

The directory it is complaining about contains .obj and .md files. In a bash shell I can go to it and list it and all is good (list it after Windows extracted it). But using the unzip command, I can't extract this part of the build.zip. I get the following error (and the preceding success before it):

它抱怨的目录包含 .obj 和 .md 文件。在 bash shell 中,我可以转到它并列出它,一切都很好(在 Windows 解压缩后列出)。但是使用unzip命令,我无法解压build.zip的这部分。我收到以下错误(以及之前的成功):

  inflating: bld_731/build_20150731/GVII/Software/_bld/rel/tcf/TscControlFmtCtrl.obj
  inflating: bld_731/build_20150731/GVII/Software/_bld/rel/tdl.exe
  checkdir error:  bld_731/build_20150731/GVII/Software/_bld/rel/tdl exists but is not directory
                 unable to process build_20150731/GVII/Software/_bld/rel/tdl/.
       ...

 checkdir error:  bld_731/build_20150731/GVII/Software/_bld/rel/tdl exists but is not directory
             unable to process build_20150731/GVII/Software/_bld/rel/tdl/CmfCmd.obj.

As you can see, it's both the directory and the files it finds inside the directory.

如您所见,它既是目录,又是它在目录中找到的文件。

Do you know how to resolve this? Do I need to go another extraction utility, perhaps ?? Thanks.

你知道如何解决这个问题吗?我是否需要去另一个提取实用程序,也许??谢谢。

回答by wojtow

The problem is with Cygwin. It interprets the existence of "tld.exe" as "tld" also existing. unzip is probably just using a standard stat call to check if "tld" already exists and check if it is a directory. stat is probably saying yes "tld" exists (because "tld.exe" exists)

问题在于 Cygwin。它将“tld.exe”的存在解释为“tld”也存在。unzip 可能只是使用标准的 stat 调用来检查“tld”是否已经存在并检查它是否是一个目录。stat 可能是说“tld”存在(因为“tld.exe”存在)

touch testfile.exe
if [ -f testfile ] ; then echo y ; else echo n; fi 

On a normal linux type system you would expect the above to answer 'n'. However on cygwin, the result is 'y'.

在普通的 linux 类型系统上,您会期望以上回答“n”。但是在 cygwin 上,结果是 'y'。

This is part of cygwin's mechanism to allow windows .exe files to be executed without the .exe in the command.

这是 cygwin 机制的一部分,允许在命令中没有 .exe 的情况下执行 windows .exe 文件。

See: https://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-exe

请参阅:https: //cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-exe

回答by Cameron Reed

I had the same problem with maven installin a git bash environment. I solved it by manually creating the directory next to the *.exefile. The mvn installthen unzipped my artifact without issue. In your case, simply go to the target directory and do mkdir tdl

maven install在 git bash 环境中遇到了同样的问题。我通过手动创建文件旁边的目录来解决它*.exe。在mvn install随后拉开我的神器没有问题。在您的情况下,只需转到目标目录并执行mkdir tdl