delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/12/05/19:43:36

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Tue, 5 Dec 2000 19:37:15 -0500
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Possible bug in exec with symlink.
Message-ID: <20001205193715.A16956@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <Pine DOT SOL DOT 3 DOT 91 DOT 1001205155738 DOT 26082C-100000 AT cse DOT cygnus DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.3.11i
In-Reply-To: <Pine.SOL.3.91.1001205155738.26082C-100000@cse.cygnus.com>; from mdejong@cygnus.com on Tue, Dec 05, 2000 at 04:03:44PM -0800

On Tue, Dec 05, 2000 at 04:03:44PM -0800, Mo DeJong wrote:
>Hi all.
>
>I think I have run into a bug in the way Cygwin
>deals with symlinks in an exec. I am using the
>most recent net release on an NT box.
>
>First, the simple case that works correctly.
>
>$ cat one.sh
>#!/bin/sh
>echo one.sh running
>sleep 5
>exit 0
>
>$ ./one.sh
>one.sh running
>
>$ ln -s one.sh two.sh
>
>$ ./two.sh
>one.sh running
>
># An now the bit that does not work.
>
>This script uses the #! like so:
>
>$ head fake_toolchain
>#! /home/mdejong/install/SN452/bin/itcl_sh
>
># This is a faked up compiler that can
># be used to test the GUI toolchain
>
>Note that it runs just fine from the
>cmd line.
>
>$ ./fake_toolchain
>fake_toolcahin script
>
>
>But, a symlink to it does not work.
>
>$ ln -s fake_toolchain mygcc
>
>$ ./mygcc
>invalid command name "!<symlink>fake_toolchain "
>    while executing
>"!<symlink>fake_toolchain "
>    (file "./mygcc" line 1)
>
>It looks like Cygwin is getting confused about which
>file it should pass to the program. It is looking for
>the #! in the symlink but when it gets run, it passes
>the name of the symlink on the cmd line.
>
> ./itcl_sh.exe mygcc
>nvalid command name "!<symlink>fake_toolchain "
>   while executing
>!<symlink>fake_toolchain "
>   (file "mygcc" line 1)

Cygwin sets the argv[0] to be the name of the file which
invoked the script.

In this case, that's 'mygcc'.  'mygcc' is a symbolic link to a script
which is running a non-cygwin program.  The program is apparently
looking at argv[0] for some kind of inspiration but is unable to
decipher cygwin's symlink.

On linux, if you create a file called tst:

#!/bin/sh
echo $0 - $*

then you do:

% chmod a+x tst
% ln -s tst foob
% ./foob bob
foob - bob

So, I think that Cygwin is behaving appropriately.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019