Subject: RE: More on relative pathname
From: [email-masked] (Gordon Watts Brown University)

13 Jan 1999 23:42:15 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8BIT
To: Bernard Dautrevaux <[email-masked]>,
        gnu-win cygnus mailing list <[email-masked]>

Taking the suggestion of Earnie Boyd, I replaced the #!/bin/sh in my sample
script with #!/bin/bash. Now the relative path names work fine.
Unfortunately, I can't make this change in all the code I'm running (this is
a port with a common source base), so I still need to get sh to work
correctly, but it is an interesting data point, none the less. Would this
indicate a problem in sh or in the cygwin dll below it? I guess it depends
upon how sh invokes sub-shells.

	Cheers,
		Gordon.

> -----Original Message-----
> From: Bernard Dautrevaux [mailto:[email-masked]]
> Sent: Tuesday, January 12, 1999 12:57 PM
> To: 'Gordon Watts (Brown University)'; gnu-win cygnus mailing list
> Subject: RE: More on relative pathname
>
>
>
> > -----Message d'origine-----
> > De:	Gordon Watts (Brown University) [SMTP:[email-masked]]
> > Date:	Monday, January 11, 1999 19:27
> > À:	Bernard Dautrevaux; gnu-win cygnus mailing list
> > Objet:	RE: More on relative pathname
> >
> > Hi,
> >   Thanks. Forgetting the "!" was a typo. Some people can reproduce
> > this
> > error and others have my script work just fine. I'm starting to wonder
> > if it
> > has something to do with the file system or locking or permissions.
> >
> OK, so I try to reproduce here and here we are:
>
> > The symptoms are the same weather or not the "!" is present, btw. The
> > error
> > I get is the following:
> >
> > bash-2.01$ PATH=./junk123:${PATH}
> > bash-2.01$ export PATH
> > bash-2.01$ stuff.sh
> > stuff.sh: Can't open stuff.sh
> > bash-2.01$ type stuff.sh
> > stuff.sh is hashed (././junk123/stuff.sh)
> >
> I effectively get this, with or without the '!'
>
> > Note -- the error is different than if it can't find the command:
> >
> > bash-2.01$ bogus.fruitcake
> > bash: bogus.fruitcake: command not found
> >
> Then I look at my path, adn see that it starts by some relative
> directory, and seems to remember I already get some problems with that;
> I then changed:
> 	PATH=./junk123:${PATH}
> by
> 	PATH=`pwd`/junk123:${PATH}
> and it works... (but I bet you already know that).
>
> Then I try to understand what happens: it is not the current bash that
> can't read stuff.sh: type find it... So I try this:
> I change the script like this:
>
> =============
> #!/bin/sh
>
> mkdir junk123
> cat > junk123/stuff.sh <<EOF
> #!/bin/sh `pwd`/junk123/stuff.sh
> echo hi
> pwd
> EOF
>
> chmod a+x junk123/stuff.sh
>
> PATH=./junk123:${PATH}
> export PATH
>
> echo Will now try to run the thing
> stuff.sh
> =============
>
> And it works too... And you can see that pwd prints the correct
> directory...
>
> I then suppress the `pwd` in the first line of stuff.sh:
>
> ==============
> #!/bin/sh
>
> mkdir junk123
> cat > junk123/stuff.sh <<EOF
> #!/bin/sh junk123/stuff.sh
> echo hi "'$0'"
> EOF
>
> chmod a+x junk123/stuff.sh
>
> PATH=./junk123:${PATH}
> export PATH
> type stuff.sh
>
> echo Will now try to run the thing
> # I get an error on this line
> stuff.sh
> ==============
>
> And it still work... But look at what is printed after hi:
> './junk.sh'!... There's the problem. Bash when it find something in the
> path using a relative entry just thinks it find it in the current
> directory!...
>
> I don't know if this is correct but it sounds like an error in path
> searching, probably not in bash (type finds stuff.sh) but probably in
> cygwin1.dll (where the code for exec is I think)
>
> So could anyone familiar with this code look at it?
>
> In the meanwhile, I don't exactly know how to work around the bug, but
> placing the full path in the script (like my first modified script above
> (note that the `pwd`was expanded when constructing the script that
> contains an absolute path name) could be a (temporary? ;-( ) solution.
>
> Hope this helps
>
> ------------------------------------------------------------------------
> ------
> Bernard Dautrevaux
> Microprocess Ingéniérie
> 97 bis, rue de Colombes
> 92400 COURBEVOIE
> FRANCE
> Tel:	+33 (0) 1 47 68 80 80
> Fax:	+33 (0) 1 47 88 97 85
> e-mail:	[email-masked]
> 	[email-masked]
> ------------------------------------------------------------------------
> ------
>
>

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".