Luke Kendall wrote on Monday, August 04, 2008 4:18 AM: > I discovered today that if I try to run Windows Explorer from the > Cygwin command line, and give it a pathname with spaces, it fails, > but if I give the same command line to a cmd.exe command line, > Explorer works! > > I.e. from Bash, explorer fails with an error message like "The path > '/e,c:\temp\space dir' does not exist or is not a directory." > > I've tried every quote combo I can. If I leave off the /e option > then it does open the directory, but without the side pane (which is > what you'd expect with the /e option omitted). > > Bash shell: > > $ mkdir c:/temp/"space dir" > > $ explorer /e,c:\\temp\\space\ dir > $ # NBG^ > $ explorer /e,c:\\temp > $ # GOOD^ > $ explorer c:\\temp\\space\ dir > $ # GOOD^ (but no side pane) > $ explorer /e,"c:\temp\space dir" > $ # NBG^ > $ explorer /e,"\"c:\temp\space dir\"" > $ # NBG^ > > DOS shell: > > c>explorer /e,c:\temp\space dir > c>rem GOOD^ > c>explorer /e,"c:\temp\space dir" > c>rem GOOD^ > c>explorer /e,'c:\temp\space dir' > c>rem NBG^ > c>explorer /e,c:\temp\space dir > c>rem NBG^ > > Until I tried the same stuff under the DOS shell, I assumed it was > explorer.exe that was busted. Now I'm just confused. > > I find this quite bizarre. Any suggestions? Is bash or Cygwin > guessing the /e option is part of a path, and doing some extra > quoting of its own or something? > > I just tried an strace on bash, and it looks like this guess is > correct: > > 140 4166625 [main] bash 5696 spawn_guts: null_app_name 0 > (c:\WINDOWS\explorer.exe, c:\WINDOWS\explorer.exe > "/e,c:\temp\space dir") > > It's collected all the arguments and put them inside double quotes, > and if I do that in a DOS shell too I get the exact same failure. > > If the directory contains no spaces, then bash does this, in contrast: > > 12217 33394057 [main] bash 5284 spawn_guts: 5284 = spawn_guts > (/cygdrive/c/WINDOWS/explorer, c:\WINDOWS\explorer.exe /e,c:\temp) > > Is there some way to tell Bash/Cygwin not to do this? Or is it > simply that my bash is too old? > > $ bash --version > GNU bash, version 3.2.9(10)-release (i686-pc-cygwin) Copyright (C) > 2005 Free Software Foundation, Inc.
As a work-around, you might try the -x or --explore option of cygstart. I use it in the following script (which I cal "explore"), though a shell function might be better if you use this a lot. ====[ cut ]==== #!/bin/bash /bin/cygstart --explore "${1:-.}" ====[ cut ]==== "${1:-.}" makes explorer open in the current working directory run without an argument. If this does not do what you want, you could always try launching explorer with cygstart (without -x, giving you control of explorer's command line arguments) or cmd /c start. And one way to get rid of spaces is to go to that directory. You could just $ pushd /cygpath/c/temp/space\ dir $ explorer /e,. $ popd Good luck! - Barry - Disclaimer: Statements made herein are not made on behalf of NIAID. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/