This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Shell script ignores $PATH?!
- From: luke dot kendall at cisra dot canon dot com dot au
- To: cygwin at cygwin dot com
- Date: Tue, 5 Oct 2004 13:56:46 +1000 (EST)
- Subject: Shell script ignores $PATH?!
I have written a shell script to drive a Cygwin upgrade or install.
It checks that it's not being run from a locally-installed Cygwin.
Unfortunately, despite setting PATH to use only a network-installed
Cygwin (and not include /bin, /usr/bin etc.), the shell script still
somehow decides to invoke /usr/bin/sh.
Any idea why/how this happens? I removed the "#!/bin/sh" from the
start of the script, and ran hash -r, thinking that may have been the
cause. But echo $$ still reveals that it's really using my
local-installed Cygwin, not the network one mounted on L:. You'll see
that the interactive shell is PID 3540, but since the /usr/bin/sh
script's parent PID is 3540, somehow it started a shell that wasn't in
$PATH, instead of one that was!
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
D:\home\luke>set PATH=C:\WINDOWS\system32;C:\WINDOWS;l:\bin\cygwin\bin
D:\home\luke>mount
C:\cygwin\usr\X11R6\lib\X11\fonts on /usr/X11R6/lib/X11/fonts type system (binmode)
C:\cygwin\bin on /usr/bin type system (textmode)
C:\cygwin\lib on /usr/lib type system (textmode)
C:\cygwin on / type system (textmode)
d:\home on /home type system (textmode)
c: on /cygdrive/c type user (textmode,noumount)
d: on /cygdrive/d type user (textmode,noumount)
l: on /cygdrive/l type user (textmode,noumount)
p: on /cygdrive/p type user (textmode,noumount)
u: on /cygdrive/u type user (textmode,noumount)
w: on /cygdrive/w type user (textmode,noumount)
x: on /cygdrive/x type user (textmode,noumount)
y: on /cygdrive/y type user (textmode,noumount)
z: on /cygdrive/z type user (textmode,noumount)
D:\home\luke>bash
bash-2.05b$ echo $PATH
/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/l/bin/cygwin/bin
bash-2.05b$ echo $$
3540
bash-2.05b$ /cygdrive/x/cygnus/cisra/cygupgrade.sh latest
The Cygwin mirror looks good
PID is 3344, ps | grep ^[I ] *3344 gives:
3344 3540 3344 3152 con 11021 13:39:59 /usr/bin/sh
PID PPID PGID WINPID TTY UID STIME COMMAND
3752 1 3752 3752 con 11021 Sep 24 /usr/bin/rxvt
3768 3752 3768 3780 1 11021 Sep 24 /usr/bin/bash
2396 1 2396 2396 con 11021 Sep 24 /usr/bin/rxvt
I 2428 2396 2428 2416 0 11021 Sep 24 /usr/bin/bash
I 1996 1 1996 1996 con 11021 Oct 1 /cygdrive/l/bin/cygwin/bin/bash
1100 3768 1100 2164 1 11021 12:42:24 /usr/bin/vim
3540 1 3540 3540 con 11021 13:34:18 /cygdrive/l/bin/cygwin/bin/bash
3344 3540 3344 3152 con 11021 13:39:59 /usr/bin/sh
3852 3344 3344 2736 con 11021 13:40:00 /cygdrive/l/bin/cygwin/bin/ps
SHELL is , PATH is /cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/l/bin/cygwin/bin
How do I stop the script from running commands that aren't in $PATH?
luke
--
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/