Bug 9344 – A program takes a console comand as an argument.
Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2013-01-17T22:50:00Z
Last change time
2013-01-18T10:26:20Z
Assigned to
nobody
Creator
yolkati
Comments
Comment #0 by yolkati — 2013-01-17T22:50:53Z
import std.stdio;
int main(char[][] p_Args)
{
foreach(char[] l_Arg; p_Args)
{
writefln("Argument '%s'", l_Arg);
}
return 0;
}
/+
Input and output example:
$ ./a.out MY NAME HERE
Argument './a.out'
Argument 'MY'
Argument 'NAME'
Argument 'HERE'
On Ubuntu 12.10 compiled with gdc,the version that can be found on its repositories.
+/
Comment #1 by k.hara.pg — 2013-01-17T23:28:16Z
(In reply to comment #0)
> import std.stdio;
>
> int main(char[][] p_Args)
> {
> foreach(char[] l_Arg; p_Args)
> {
> writefln("Argument '%s'", l_Arg);
> }
> return 0;
> }
>
> /+
> Input and output example:
>
> $ ./a.out MY NAME HERE
> Argument './a.out'
> Argument 'MY'
> Argument 'NAME'
> Argument 'HERE'
>
> On Ubuntu 12.10 compiled with gdc,the version that can be found on its
> repositories.
> +/
Sorry, what is the problem? As far as I see, the input/output example works as expected.
The `main` function always receive the command string by p_Args[0]. It is same as C/C++ behavior.
Comment #2 by ibuclaw — 2013-01-18T02:36:22Z
(In reply to comment #1)
> (In reply to comment #0)
> > import std.stdio;
> >
> > int main(char[][] p_Args)
> > {
> > foreach(char[] l_Arg; p_Args)
> > {
> > writefln("Argument '%s'", l_Arg);
> > }
> > return 0;
> > }
> >
> > /+
> > Input and output example:
> >
> > $ ./a.out MY NAME HERE
> > Argument './a.out'
> > Argument 'MY'
> > Argument 'NAME'
> > Argument 'HERE'
> >
> > On Ubuntu 12.10 compiled with gdc,the version that can be found on its
> > repositories.
> > +/
>
> Sorry, what is the problem? As far as I see, the input/output example works as
> expected.
>
> The `main` function always receive the command string by p_Args[0]. It is same
> as C/C++ behavior.
Yep, not a bug, not even a feature request.