Anyway to get *un*parsed shell arguments for a portable C program?

5 posts / 0 new
Last post
ChrisH
ChrisH's picture
Offline
Last seen: 3 years 6 months ago
Joined: 2010-12-07 20:22
Anyway to get *un*parsed shell arguments for a portable C program?

This is a not an Amiga-specific question, but one aimed at a C program which would compile with GCC equally well on Windows or Amiga or whatever:

If I use main(int argc, char *argv[]) to get the Shell parameters supplied to a program, then they come pre-parsed... WHICH I DO NOT WANT. Is there a portable-C way of getting the original unparsed parameters?

whose
whose's picture
Offline
Last seen: 6 years 3 months ago
Joined: 2011-08-09 02:25
Uhm, I dont think so... there

Uhm, I dont think so... there is even no "portable" way to get parameters at all. Its all up to the (machine/system specific) startup code. The standard even demands pre-parsed parameters, given to the main function by the startup code.

So you would have to develop a corresponding non-parsing startup code yourself, for all platforms/compilers you wish to support.

It should be quite clear why this is. Its because the different systems transmit command line or "desktop" parameters in a very different way, using different data types and even different ways of transmitting data at all (stack based, register based, fixed addresses in main memory and so on). For Amiga there are even two different ways how parameters are transmitted to a C program, requiring a specialized startup code. CLI standard C parameters and WBMsg-type.

Why you would like to have them "unparsed", btw.?

Coder Insane-Software

www.insane-software.de

salass00
salass00's picture
Offline
Last seen: 1 year 3 weeks ago
Joined: 2011-02-03 11:27
@ChrisH As I wrote in your

@ChrisH

As I wrote in your thread on amigans.net you can use GetArgStr() from dos.library to do this.

salass00
salass00's picture
Offline
Last seen: 1 year 3 weeks ago
Joined: 2011-02-03 11:27
@whose Uhm, I dont think

@whose

Uhm, I dont think so... there is even no "portable" way to get parameters at all.

I think he means just portable between AmigaOS (m68k and PPC) and Amiga-like OSes like AROS and MorphOS.

whose
whose's picture
Offline
Last seen: 6 years 3 months ago
Joined: 2011-08-09 02:25
@salass00: No, I dont think

@salass00:

No, I dont think so, as he wrote about "Windows or whatever".

There is even no POSIX way to get the unparsed parameters, seems that Amiga (and maybe another niche OS, I dont know) is the only one which present the full command line without pre-parsing, if the developer wants to see it.

Coder Insane-Software

www.insane-software.de

Log in or register to post comments