comp.lang.ada
 help / color / mirror / Atom feed
Subject: Re: Ada.Command_Line.Argument_Count question
Date: Wed, 16 Sep 2009 08:20:54 +0200
Date: 2009-09-16T08:20:54+02:00	[thread overview]
Message-ID: <4ab083c6$0$288$14726298@news.sunsite.dk> (raw)
In-Reply-To: <e3469b38-adca-4896-a5a6-4616db711914@i18g2000pro.googlegroups.com>

Adam Beneschan wrote:
> You can probably trust that Argument_Count will give the same result
> on any Unix, BSD, Linux, or other Unix-like OS (Solaris, HP-UX, IRIX,
> etc.), since the mechanisms that the shell uses for passing arguments
> to programs is the same for all of them.  This is assuming the shells
> handle the argument lines the same way.  Obviously, different shells
> don't parse things the same way.  In fact, you have to be careful
> about how you define "yield the same result"---yield the same result
> under what conditions??  If you type the command
> 
>    application {file1,file2,file3}.dat
> 
> the argument count should be 3 if the shell interprets the curly
> braces to convert the line to "file1.dat file2.dat file3.dat", but 1
> if it doesn't (older Bourne shells don't).  So you could get a
> different Argument_Count even on the *same* system, if you use the
> same command line in a different shell.
> 
> Windows uses a totally different "shell" (Command Prompt) so you can't
> expect it to work the same.  In practice, I don't believe Windows
> breaks down the command line at all (maybe later versions do, I'm not
> sure); it just makes the whole argument string available to the
> program as one string (via GetCommandLine).  It's up to the
> implementation to determine what to do with this string.
> 
> 
>> Or am I missing the point?
> 
> Possibly.  The reason the meaning of "number of arguments" is
> implementation-defined is that the language says nothing at all about
> what an "argument" is or how it gets into the program.  The language
> can't even assume that "arguments" will be passed in from a "command
> line"; they could be passed in from separate boxes in a GUI window, or
> created in an array by another program that executes the application,
> or set up by rotating dials manually on a control panel for all we
> know.

Adam, thank you for this very thorough explanation.

I guess this means that program arguments should be treated as slippery 
litlle buggers, who cannot be trusted.  :o)

-- 
Regards,
Thomas L�cke

Email: tl at ada-dk.org
Web: http:ada-dk.org
IRC nick: ThomasLocke



  reply	other threads:[~2009-09-16  6:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-15 20:58 Ada.Command_Line.Argument_Count question 
2009-09-15 21:37 ` Gautier write-only
2009-09-16  6:21   ` 
2009-09-16 18:43   ` Keith Thompson
2009-09-22 19:52     ` Gautier write-only
2009-09-22 20:00       ` Hyman Rosen
2009-09-23  0:20         ` Gautier write-only
2009-09-23  1:07           ` Adam Beneschan
2009-09-23 13:03             ` Hyman Rosen
2009-09-23 16:06             ` Gautier write-only
2009-09-24  0:31               ` Björn Persson
2009-09-24  1:11                 ` Adam Beneschan
2009-09-25 12:25                   ` Stephen Leake
2009-09-15 21:55 ` Adam Beneschan
2009-09-16  6:20   `  [this message]
2009-09-16 10:41 ` Jeffrey R. Carter
2009-09-17 13:50 ` John McCabe
2009-09-18  5:12   ` sjw
2009-09-18 15:03     ` John McCabe
2009-09-18 22:16       ` Robert A Duff
2009-09-21 15:09         ` John McCabe
2009-09-21 15:17           ` Dmitry A. Kazakov
2009-09-21 19:44           ` sjw
2009-09-22 11:01             ` John McCabe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox