Class AwkParameters

java.lang.Object
org.sentrysoftware.jawk.util.AwkParameters

public class AwkParameters extends Object
Manages the command-line parameters accepted by Jawk. The parameters and their meanings are provided below:
  • -v name=val [-v name=val] ...
    Variable assignments prior to the execution of the script.
  • -F regexp
    Field separator (FS).
  • -f filename
    Use the text contained in filename as the script rather than obtaining it from the command-line.
  • Extension -c
    Write intermediate file. Intermediate file can be used as an argument to -f.
  • Extension -o filename
    Output filename for intermediate file, tuples, or syntax tree.
  • Extension -s
    Dump the intermediate code.
  • Extension -S
    Dump the syntax tree.
  • Extension -x
    Enables _sleep, _dump, and exec keywords/functions.
  • Extension -y
    Enables _INTEGER, _DOUBLE, and _STRING type casting keywords.
  • Extension -t
    Maintain array keys in sorted order (using a TreeMap instead of a HashMap)
  • Extension -r
    Do NOT error for IllegalFormatException when using java.util.Formatter for sprintf and printf.
  • Extension -ext
    Enabled user-defined extensions. Works together with the -Djava.extensions property. It also disables blank rule as mapping to a print $0 statement.
  • Extension -ni
    Do NOT consume stdin or files from ARGC/V through input rules. The motivation is to leave input rules for blocking extensions (i.e., Sockets, Dialogs, etc).
followed by the script (if -f is not provided), then followed by a list containing zero or more of the following parameters:
  • name=val
    Variable assignments occurring just prior to receiving input (but after the BEGIN blocks, if any).
  • filename
    Filenames to treat as input to the script.

If no filenames are provided, stdin is used as input to the script (but only if there are input rules).

Author:
Danny Daglas
  • Constructor Details

    • AwkParameters

      public AwkParameters()
  • Method Details

    • parseCommandLineArguments

      public static AwkSettings parseCommandLineArguments(String[] args)
      Parses AWK command line parameters, for example from the VM entry point main().

      The command-line argument semantics are as follows:

      • First, "-" arguments are processed until first non-"-" argument is encountered, or the "-" itself is provided.
      • Next, a script is expected (unless the -f argument was provided).
      • Then, subsequent parameters are passed into the script via the ARGC/ARGV variables.
      Parameters:
      args - The command-line arguments provided by the user.
      Returns:
      a new instance of AwkSettings that reflects the configuration set in the command line arguments