bash's (built-in) type command can not handle spaces in paths

Curtis Siemens csiemens@real.com
Fri Feb 28 00:29:00 GMT 2003


My platform is Windows 2000 (with all the latest patches).  This problem
probably occurs on a number of Windows platforms.  I'm using the latest
released Cygwin with Cygwin DLL release version 1.3.20-1

I've searched the Web/Faq/Documentation/Mailing-Lists and haven't seen
any reference to this problem.

Cygwin's type command (built into bash.exe) does not work for
executables that are under a directory that has spaces.  I.e. if
the file c:\program files\prog.exe exists then running any of these
does not work (and "/cygdrive/c/dir xy" is in your PATH):
     type "/cygdrive/c/dir xy/prog.exe"
     type /cygdrive/c/dir\ xy/prog.exe
     type prog.exe
The type command just returns nothing.

Likewise this doesn't work:
     $ cd /cygdrive/c/dir\ xy
     $ type ./prog.exe
The above doesn't work because prog.exe full path contains a space
in one of the directories in its path.

An offshoot of this problem, which really makes things bad is if
your Cygwin is installed under a directory that contains spaces
(and you don't mount the standard cygwin directories elsewhere,
you just proceed with the typical default installation), and then
you use the type command on any of the commands that
exist under Cygwin mounts, the type command again does not
work - which is a lot of basic utility programs that can't be "found"
by using the type command.
I.e. if you install Cygwin & all its utilities in the default manner
under something like:
     c:\Program Files\cygwin
or
     c:\cyg win
Then running any of these will not work:
     type grep
     type /bin/grep
     type cat.exe
   etc. -> you get the idea.

Its OK to have spaces in the executable filename itself, but all
directories from the drive to that executable can not have spaces
in their names.  Even trying things like "type c:\progra~1\prog.exe"
does not work around the issue.


How To Reproduce:
-----------------------------------------------------
Install Cygwin under c:\ or c:\cygwin - some directory that doesn't
contain spaces & go with the typical/default installation.  Once installed,
put "/cygdrive/c/program files" & "/cygdrive/c/temp" in your PATH and run:
     type "/cygdrive/c/program files/prog.exe"
     /* Where prog.exe is some executable that EXISTS. */
=> The command doesn't work - it can't find it, returning a blank, but doing:
     ls -ltrF "/cygdrive/c/program files/prog.exe"
does work.
Now run:
     type "/cygdrive/c/temp/prog.exe"
     /* Where prog.exe is some executable that EXISTS under c:\temp. */
See how it works on these types of paths that contain no spaces
in their directories.
-----------------------------------------------------

Curtis Siemens


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list