argv[0] handling

Peter Naulls peter at chocky.org
Tue Jun 14 04:08:24 PDT 2005


We've briefly mumbled about this in the past, but it's time for a
revisit.

Presently, argv[0] is just the literal value passed from RISC OS.  It
may contain a RISC OS path name, or RISC OS path variables, etc.   This
means that programs that use argv[0] as the basis of their display can
often do odd things.  It's possible to see "<Obey$Dir>.progname" as a
program's title.  Or a full RISC OS path name as a bash prompt as
programs attempt to trim to a Unix leafname.

This is clearly easily fixed with OS_FSControl 37 and unixfy, which I've
just put into my build.  Without wanting to add nth degree
configurability, does anyone thing that this might not always be
appropriate?   In particular, this will result in programs which are
just called with a leaf name always ending up with the full path.  And
of course, pathnames in argv[0] will always be in Unix form.
Heuristics may be sensible here.

Bear in mind that any handling like this will have to be either a system
variable or a weak symbol, since this occurs before main() is called,
and therefore beyond the control of the runtime riscosify flags.

-- 
Peter Naulls - peter at chocky.org        | http://www.chocky.org/
----------------------------------------------------------------------------
Unix Programs on RISC OS               | http://www.riscos.info/unix/



More information about the gcc mailing list