bash Cygwin 'cd' 命令总是告诉我“没有这样的文件或目录”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16696732/
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 05:29:39  来源:igfitidea点击:

Cygwin 'cd' command always tells me "No such file or directory"

bashpathcygwincd

提问by thalm

When i login to the cygwin terminal and type:

当我登录到 cygwin 终端并输入:

cd "cygdrive/c/existing/path"

it tells me, "no such file or directory". i am sure the path exists... do i miss a special cygwin package, or do i have a false configuration? i am puzzled...

它告诉我,“没有这样的文件或目录”。我确定路径存在...我是否错过了一个特殊的 cygwin 包,或者我是否有错误的配置?我很困惑...

It behaves the same when i try to call the cygwin bash from a windows batch file. what i basically want to do is creating a windows batch file which starts cygwin and executes a shell script with a specified working directory as its described in this blog post: http://blog.dotsmart.net/2011/01/27/executing-cygwin-bash-scripts-on-windows/

当我尝试从 Windows 批处理文件调用 cygwin bash 时,它的行为相同。我基本上想要做的是创建一个 Windows 批处理文件,该文件启动 cygwin 并使用指定的工作目录执行 shell 脚本,如本博客文章所述:http: //blog.dotsmart.net/2011/01/27/executing -cygwin-bash-scripts-on-windows/

my batch file seems to work, it does the following command:

我的批处理文件似乎可以工作,它执行以下命令:

%_CYGBIN%\bash.exe --login "cd %_CYGPATH%" "./%_CYGSCRIPT%"

but cygwin won't execute the 'cd' command. The console output of my batch file is:

但 cygwin 不会执行 'cd' 命令。我的批处理文件的控制台输出是:

/usr/bin/bash: cd /cygdrive/c/existing/path: No such file or directory

回答by Steven Penny

cd '/cygdrive/c/existing/path'
#   ^
#    \
#     --- need forward slash (/) before the "c"