delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/01/08/06:58:56

Subject: Re: m4 port: return program name as 'm4' not '/some/path/m4.exe'
[PATCH]
From: Tim Van Holder <tim DOT van DOT holder AT pandora DOT be>
To: djgpp-workers AT delorie DOT com
In-Reply-To: <3E1B35F9.DC4EA825@phekda.freeserve.co.uk>
References: <E18VAre-0000gx-00 AT phekda DOT freeserve DOT co DOT uk>
<003801c2b559$f33a0d60$0100a8c0 AT acp42g>
<3E19BEAE DOT 7CC5B46C AT phekda DOT freeserve DOT co DOT uk>
<200301061840 DOT h06IebI26175 AT envy DOT delorie DOT com>
<3E1B35F9 DOT DC4EA825 AT phekda DOT freeserve DOT co DOT uk>
Organization:
Message-Id: <1042022855.32477.13.camel@leeloo>
Mime-Version: 1.0
X-Mailer: Ximian Evolution 1.2.1
Date: 08 Jan 2003 11:47:36 +0100
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 2003-01-07 at 21:18, Richard Dawe wrote:
> Hello.
> 
> DJ Delorie wrote:
> > Note that for maximum unix compatibility, we should probably do this:
> > 
> > In the crt0 code, compare the path to our executable to the $PATH.  If
> > we were found in some directory already on the $PATH, omit the
> > directory and leave the basename.  If we were not found on the $PATH,
> > leave the full path alone.
> 
> With or without the '.exe'?
>  
> > Another thing we might consider is to remove the drive specifier if it
> > happens to be the current drive.  For many cases, this will make it
> > look unix-like enough to work with dos-unaware programs.
> 
> Why not just munge it from say c:/ to /dev/c/? That makes it Unixy enough and
> doesn't involve information loss.
> 
> I suppose there could be two styles of munging:
> 
> * just return the stem without extension - Unix-style;

Yes and no; on Unix, argv0 is exactly what was typed (e.g. if you run
/bin/rm, argv0 is '/bin/rm', not 'rm').  Many, but not all, GNU tools
use basename(argv0) for --version for exactly this reason.
Canonicalizing argv0 seems like a better idea then; programs can always
use basename() or some such to strip the path.  Might be nice to expand
LFNs in it as well; currently argv0 is always SFN even on LFN platforms
(or so I seem to recall).

Not sure what our bash does now; if it uses exec*(), it can pass image
name and argv0 separately to provide exact Unix-like behaviour.  Maybe
system() could be changed accordingly as well, leaving only invocations
from command.com to get the 'full' path as argv0.

> * return a path converted to /dev-style - Unix-friendly.
> 
> Should either of these argv[0] mungings be on by default?

I'd say yes, possibly with a crt0 flag to disable it.

-- 
Tim Van Holder <tim DOT van DOT holder AT pandora DOT be>

- Raw text -


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