Disabling Command Line Argument Expansion (GNAT User’s Guide for Native Platforms)

#### 7.4.5 Disabling Command Line Argument Expansion ¶

By default, an executable compiled for the Windows platform will do the following postprocessing on the arguments passed on the command line:

- If the argument contains the characters `*` and/or `?`, 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"

- You can disable filename expansion for a given argument by using single quotes. Thus, calling:

      $ 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, quote removal might be performed by that 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'"