Skip to content

awk: octal and hexadecimal constants in the program are not recognised #176

Open

Description

@sylvestre

gawk (outside --posix / --traditional) reads 010 as octal 8 and 0x1f
as hexadecimal 31 in the program source. uutils awk reads 010 as 10 and
lexes 0x1f as 0 followed by the variable x1f, so it prints 0. 018
is not valid octal and stays 18 in gawk.

Reproduction

Rust (incorrect)

$ ./target/release/awk 'BEGIN { print 010, 0x1f, 018 }'
10 0 18

GNU (correct)

$ gawk 'BEGIN { print 010, 0x1f, 018 }'
8 31 18
$ gawk --posix 'BEGIN { print 010, 0x1f }'
10 0

Test

#[test]
fn octal_and_hex_source_constants() {
    ucmd()
        .arg("BEGIN { print 017, 0X10, 019, 0 }")
        .succeeds()
        .stdout_only("15 16 19 0\n");
}

Exposed by the GNU awk test suite: nondec, octdec.

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