X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Tue, 5 Aug 2008 18:02:11 +1000 (EST) From: Luke Kendall Subject: RE: Bizarre Cygwin/Explorer/paths problem half-solved To: cygwin AT cygwin DOT com In-Reply-To: <31DDB7BE4BF41D4888D41709C476B6570929B262@NIHCESMLBX5.nih.gov> MIME-Version: 1.0 Content-Type: TEXT/plain; CHARSET=US-ASCII Message-Id: <20080805080211.E723585E52@pessard.research.canon.com.au> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 4 Aug, Buchbinder, Barry (NIH/NIAID) [E] wrote: > 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 I'd have to cygpath it to Unix format first ... I found your cygstart suggestion a nicer approach - thanks! It works well, except that none of the options to prevent the window from taking focus work when explorer is the thing that gets started. That's annoying when I run my script to restore bash/Explorer/Internet Explorer session (i.e. windows) in interactive mode, but I can live with it. Thanks again! luke > 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/