By default, an executable compiled for the Windows platform will do the following postprocessing on the arguments passed on the command line:
*
and/or ?
, then
file expansion will be attempted. For example, if the current directory
contains a.txt
and b.txt
, then when calling:
$ my_ada_program *.txt
The following arguments will effectively be passed to the main program
(for example when using Ada.Command_Line.Argument
):
Ada.Command_Line.Argument (1) -> "a.txt" Ada.Command_Line.Argument (2) -> "b.txt"
$ my_ada_program '*.txt'
will result in:
Ada.Command_Line.Argument (1) -> "*.txt"
Note that if the program is launched from a shell such as Cygwin Bash then quote removal might be performed by the shell.
In some contexts it might be useful to disable this feature (for example if
the program performs its own argument expansion). In order to do this, a C
symbol needs to be defined and set to 0
. You can do this by
adding the following code fragment in one of your Ada units:
Do_Argv_Expansion : Integer := 0; pragma Export (C, Do_Argv_Expansion, "__gnat_do_argv_expansion");
The results of previous examples will be respectively:
Ada.Command_Line.Argument (1) -> "*.txt"
and:
Ada.Command_Line.Argument (1) -> "'*.txt'"