Mail Archives: djgpp-workers/2003/01/08/06:58:56
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 -