Skip to content

awk: --lint, --profile, --debug, --dump-variables, --pretty-print take the program text as their value #181

Open

Description

@sylvestre

These gawk options take an optional value, which must be attached:
--lint=fatal, -Lfatal, --profile=file. uutils awk (clap with
num_args = 0..=1) also takes the next argument, so awk --lint 'PROGRAM'
treats the program as the option value.

Reproduction

Rust (incorrect)

$ ./target/release/awk --lint 'BEGIN { print "hi" }'
error: invalid value 'BEGIN { print "hi" }' for '--lint [<LINT>]'
  [possible values: basic, fatal, invalid, no-ext]
# Exit code: 1

$ ./target/release/awk --profile 'BEGIN { print "hi" }'
error: the following required arguments were not provided:
  <CODE>

GNU (correct)

$ gawk --lint 'BEGIN { print "hi" }'
hi
$ gawk --profile 'BEGIN { print "hi" }'
hi

Test

#[test]
fn optional_option_values_must_be_attached() {
    for opt in ["--lint", "--profile", "--dump-variables"] {
        ucmd()
            .args(&[opt, "BEGIN { print \"prog\" }"])
            .succeeds()
            .stdout_contains("prog");
    }
}

(Run it in a temporary directory: GNU writes awkprof.out / awkvars.out.
--pretty-print is left out on purpose: it writes the program and does not
run it.)

Exposed by the GNU awk test suite: modifiers (once the harness sets AWKPROG,
see INDEX.md); every --lint test once lint warnings exist.

Activity

  1. added
    bug
    good first issue
    gnu-compat
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggnu-compatgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions