Strange cd/CDPATH behavior

Bob McGowan rmcgowan@veritas.com
Tue Sep 26 10:56:00 GMT 2000


Others have commented on the use of cygpath, and I have seen your
response, so I will not add to that part of the discussion.

Regarding the CDPATH variable, I just did some experiments with various
types of paths.  It looks like it will print the path cd'd to, if there
is a possibility that the path was the result of a cd to one of the
other directories in the variable.  Put another way, if the path
argument to cd is either absolute (begins with a slash) OR begins with
either a dot or a dotdot, there is only one place to go.  But a 'cd tmp'
could get you to /tmp or /var/tmp (or others, if present).

And this happens both interactively and in scripts.  I had this problem
with a Solaris ksh script (/usr/bin/dircmp), when I had CDPATH set, when
it changed directory I'd get this 'spurious' output.  I ended up having
to unset CDPATH when I ran this script.

And finally, by the above criteria, the dos directory names that start
with a drive letter are going to match the "print the new current
directory" case and will generate output.

Erik Nolte wrote:
> 
> When I combine a CDPATH containing "." and a cd to a DOS style path, cd
> echos the cd'd directory.  That's the behavior I'd expect in an interactive
> shell, but not within a script.
> 
> For example,
>     #!/bin/bash
>     export CDPATH=.
>     echo `cd c:/; ls`
> produces
>     /c AUTOEXEC.BAT AUTOEXEC.DOS BOOTLOG.PRV BOOTLOG.TXT BOOTSECT.DOS ...
> notice the leading "/c".
> 
> If CDPATH doesn't contain ".", "/c" doesn't appear:
>     #!/bin/bash
>     export CDPATH=/c:/d
>     echo `cd c:/; ls`
> produces
>     AUTOEXEC.BAT AUTOEXEC.DOS BOOTLOG.PRV BOOTLOG.TXT BOOTSECT.DOS ...
> notice there's no "/c".
> 
> The problem doesn't occur if I use UNIX style paths for the cd, i.e. echo
> `cd /c; ls` works as expected.
> 
> The obvious answer is to stop using DOS style paths with cygwin cd's.
> Unfortunately, what I'm really doing is "cd $SRC_PATH" where SRC_PATH is
> "W:/src".  SRC_PATH must be a DOS style path to keep javac and other
> windows-based software happy (they can't grok paths without drive letters).
> Another workaround is to unset CDPATH in each script.
> 
> I can't find the cygwin bash source code, so I'm unable to poke around on my
> own.  Is there a common place the cygwin application sources are kept, e.g.
> bash, textutils, fileutils, etc?
> 
> ----------------------------------------------------------------------------
> ------------------
> Here's my config:
> 
> /home/erik 586> cygcheck -s -r -v
> 
> Cygnus Win95/NT Configuration Diagnostics
> Current System Time: Tue Sep 26 10:28:30 2000
> 
> WinNT Ver 5.0 build 2195 Service Pack 1
> 
> Path:   /usr/local/bin
>         /usr/bin
>         /usr/bin
>         /d/gsj31/bin
>         /d/WINNT/system32
>         /d/WINNT
>         /d/WINNT/System32/Wbem
>         /d/vim/vim57
>         /w/bin
>         /w/src/bin
>         /w/3rd-party/NT
>         /e/pipeline/build/bin
>         .
> 
> SysDir: D:\WINNT\System32
> WinDir: D:\WINNT
> 
> HOME = `/home/erik'
> MAKE_MODE = `unix'
> PWD = `/home/erik'
> USER = `erik sean nolte'
> 
> !D: = `D:\cygwin\bin'
> ALLUSERSPROFILE = `D:\Documents and Settings\All Users'
> APPDATA = `D:\Documents and Settings\Erik Sean Nolte\Application Data'
> BLASTER = `A220 I5 D1 T4 '
> CDPATH =
> `.:/w//src/com/pipeline:/w/:/w//src:/w//docs:/w//src/html:/w//src/com/p
> ipeline/CVS:/w//src/com/pipeline/Makefile:/w//src/com/pipeline/abm:/w//src/c
> om/p
> ipeline/ad:/w//src/com/pipeline/addrbk:/w//src/com/pipeline/admin:/w//src/co
> m/pi
> peline/aio:/w//src/com/pipeline/alert:/w//src/com/pipeline/applications:/w//
> src/
> com/pipeline/awt:/w//src/com/pipeline/bom:/w//src/com/pipeline/build.mak:/w/
> /src
> /com/pipeline/cad:/w//src/com/pipeline/campus:/w//src/com/pipeline/collabora
> tion
> :/w//src/com/pipeline/content:/w//src/com/pipeline/core:/w//src/com/pipeline
> /cpt
> ool:/w//src/com/pipeline/criteria:/w//src/com/pipeline/db:/w//src/com/pipeli
> ne/d
> c:/w//src/com/pipeline/devonly:/w//src/com/pipeline/diagnostics:/w//src/com/
> pipe
> line/doctemplate:/w//src/com/pipeline/ds:/w//src/com/pipeline/dxp:/w//src/co
> m/pi
> peline/email:/w//src/com/pipeline/error:/w//src/com/pipeline/extsys:/w//src/
> com/
> pipeline/framework:/w//src/com/pipeline/gist:/w//src/com/pipeline/install:/w
> //sr
> c/com/pipeline/io:/w//src/com/pipeline/jndi:/w//src/com/pipeline/lang:/w//sr
> c/co
> m/pipeline/log:/w//src/com/pipeline/messageboard:/w//src/com/pipeline/migrat
> ion:
> /w//src/com/pipeline/mypipe:/w//src/com/pipeline/naming:/w//src/com/pipeline
> /net
> :/w//src/com/pipeline/oid:/w//src/com/pipeline/performance:/w//src/com/pipel
> ine/
> portal:/w//src/com/pipeline/schoolsvc:/w//src/com/pipeline/sctip:/w//src/com
> /pip
> eline/sdk:/w//src/com/pipeline/security:/w//src/com/pipeline/support:/w//src
> /com
> /pipeline/system:/w//src/com/pipeline/test:/w//src/com/pipeline/testold:/w//
> src/
> com/pipeline/tools:/w//src/com/pipeline/topnav:/w//src/com/pipeline/util:/w/
> /src
> /com/pipeline/web:/w//src/com/pipeline/webad:/w//src/com/pipeline/webutils:/
> w//s
> rc/com/pipeline/woo:/w//src/com/pipeline/xml'
> COMMONPROGRAMFILES = `D:\Program Files\Common Files'
> COMPUTERNAME = `C1144585-A'
> COMSPEC = `D:\WINNT\system32\cmd.exe'
> CP_DOC_ROOT = `d:/Netscape/SuiteSpot/docs'
> CP_ROOT = `w:/'
> CP_WEB_ROOT = `d:/Netscape/SuiteSpot'
> GEMSTONE = `D:\gsj31'
> HOMEDRIVE = `D:'
> HOMEPATH = `\'
> HOST = `c1144585-a'
> HOSTNAME = `C1144585-A'
> HOSTTYPE = `i586'
> LOGONSERVER = `\\C1144585-A'
> MACHTYPE = `i586-pc-cygwin'
> NUMBER_OF_PROCESSORS = `1'
> OLDPWD = `/f/cygwin/src/winsup'
> OS2LIBPATH = `D:\WINNT\system32\os2\dll;'
> OS = `Windows_NT'
> OSTYPE = `cygwin'
> PATHEXT = `.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH'
> PROCESSOR_ARCHITECTURE = `x86'
> PROCESSOR_IDENTIFIER = `x86 Family 6 Model 5 Stepping 2, GenuineIntel'
> PROCESSOR_LEVEL = `6'
> PROCESSOR_REVISION = `0502'
> PROGRAMFILES = `D:\Program Files'
> PROMPT = `$P$G'
> PS1 = `$PWD \!> '
> SHELL = `/bin/sh'
> SHLVL = `1'
> SUN_JVM = `d:/jdk1.2.2/bin/java'
> SYSTEMDRIVE = `D:'
> SYSTEMROOT = `D:\WINNT'
> TEMP = `/d/DOCUME~1/ERIKSE~1/LOCALS~1/Temp'
> TERM = `cygwin'
> USERDOMAIN = `C1144585-A'
> USERNAME = `Erik Sean Nolte'
> USERPROFILE = `D:\Documents and Settings\Erik Sean Nolte'
> VIM = `D:\vim\vim57'
> WINDIR = `D:\WINNT'
> _ = `/usr/bin/cygcheck'
> TZ = `MST7MDT6,M4.1.0/2,M10.5.0/2'
> 
> HKEY_CURRENT_USER\Software\Cygnus Solutions
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
>   (default) = `/cygdrive'
>   cygdrive flags = 0x00000020
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/
>   (default) = `D:/cygwin'
>   flags = 0x00000002
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/c
>   (default) = `c:'
>   flags = 0x00000000
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/d
>   (default) = `d:'
>   flags = 0x00000000
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/f
>   (default) = `f:'
>   flags = 0x00000000
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/usr/bin
>   (default) = `D:/cygwin/bin'
>   flags = 0x00000002
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/usr/lib
>   (default) = `D:/cygwin/lib'
>   flags = 0x00000002
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/w
>   (default) = `w:'
>   flags = 0x00000000
> HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
> HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup
> HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0
> HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts
> HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\00
>   (default) = `w:'
>   unix = `/w'
>   fbinary = 0x00000000
>   fsilent = 0x00000000
> HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\01
>   (default) = `D:'
>   unix = `/'
>   fbinary = 0x00000000
>   fsilent = 0x00000000
> HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrd
> er\S
> tart Menu\Programs\Cygnus Solutions
>   (default) = (unsupported type)
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\00
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\01
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\02
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\03
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\04
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\05
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\06
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\07
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\08
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\09
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\0A
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\0B
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\0C
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\0D
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\0E
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\0F
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\10
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\11
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\12
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\13
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\14
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\15
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\16
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\17
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\18
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\19
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\1A
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\1B
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\1C
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL
> setup\b15.0\mounts\1D
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\GNUPro
> HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\GNUPro\i586-cygwin32
> 
> a:  fd           N/A    N/A
> c:  hd  FAT32   6748Mb  11% CP    UN
> d:  hd  NTFS    7051Mb  51% CP CS UN PA FC
> e:  fd           N/A    N/A
> f:  hd  FAT32   1000Mb  85% CP    UN           DATA
> g:  cd           N/A    N/A
> h:  cd           N/A    N/A
> w:  hd  NTFS    7051Mb  51% CP CS UN PA FC
> 
> D:\cygwin\bin  /usr/bin  user    binmode
> D:\cygwin\lib  /usr/lib  user    binmode
> D:\cygwin  /        user    binmode
> c:    /c       user    textmode
> d:    /d       user    textmode
> f:    /f       user    textmode
> w:    /w       user    textmode
> 
> Found: D:\cygwin\bin\bash.exe
> Found: D:\cygwin\bin\cat.exe
> Found: w:\3rd-party\NT\cpp.exe
> Found: D:\cygwin\bin\find.exe
> Not Found: gcc
> Not Found: gdb
> Found: D:\cygwin\bin\ld.exe
> Found: D:\cygwin\bin\ls.exe
> Found: D:\cygwin\bin\make.exe
> Found: D:\cygwin\bin\sh.exe
> 
>   586k 2000/08/04 D:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
>                   "cygwin1.dll" v0.0 ts=2000/8/3 18:53
>     Cygwin DLL version info:
>         dll major: 1001
>         dll minor: 4
>         dll epoch: 19
>         dll bad signal mask: 19005
>         dll old termios: 5
>         api major: 0
>         api minor: 26
>         shared data: 3
>         dll identifier: cygwin1
>         mount registry: 2
>         cygnus registry name: Cygnus Solutions
>         cygwin registry name: Cygwin
>         program options name: Program Options
>         cygwin mount registry name: mounts v2
>         build date: Thu Aug 3 20:53:46 EDT 2000
>         CVS tag: cygwin-1-1-4
>         shared id: cygwin1S3
> 
> Use -h to see help about each section
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com

-- 
Bob McGowan
Staff Software Quality Engineer
VERITAS Software
rmcgowan@veritas.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list