GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cmp - usage errors lack GNU's wording, `cmp:` prefix and "Try --help" line · Issue #347 · uutils/diffutils

cmp - usage errors lack GNU's wording, cmp: prefix and "Try --help" line #347

New issue
Copy link
New issue
Copy link
Open
Open
cmp - usage errors lack GNU's wording, cmp: prefix and "Try --help" line#347
Copy link
Labels
gnu-compatBehaviour differs from GNUBehaviour differs from GNUgood first issueGood for newcomersGood for newcomersoss-scannerFound by Anthropic's OSS ScannerFound by Anthropic's OSS Scanner

Description

@sylvestre
sylvestre
opened on Nov 9, 2026
Issue body actions

Known: #177 (open issue) — #177

For command-line usage errors GNU cmp prints a specific message prefixed with the
program name, followed by cmp: Try 'cmp --help' for more information.. uutils prints a
bare Usage: cmp <from> <to> or an unprefixed message, and never the "Try" line. Scripts
and test suites that match stderr see different text (the exit status, 2, is already right).

Reproduction

printf 'abcdefghij' > c1; printf 'abcdeXghiY' > c2

Rust (incorrect)

$ ./target/release/diffutils cmp
Usage: cmp <from> <to>
# Exit code: 2
$ ./target/release/diffutils cmp --bogus c1 c2
unrecognized option '--bogus'
# Exit code: 2
$ ./target/release/diffutils cmp c1 c2 3 4 extra
Usage: cmp <from> <to>
# Exit code: 2

GNU (correct)

$ LC_ALL=C cmp
cmp: missing operand after 'cmp'
cmp: Try 'cmp --help' for more information.
# Exit code: 2
$ LC_ALL=C cmp --bogus c1 c2
cmp: unrecognized option '--bogus'
cmp: Try 'cmp --help' for more information.
# Exit code: 2
$ LC_ALL=C cmp c1 c2 3 4 extra
cmp: extra operand 'extra'
cmp: Try 'cmp --help' for more information.
# Exit code: 2

cmp a b c d e (invalid skip) already prints cmp: invalid --ignore-initial value 'c'
but is also missing the "Try" line.

Root cause

src/cmp.rs: usage_string (line 42) is used for every operand error, and the
unrecognized-option error at line 211 has no program-name prefix:

fn usage_string(executable: &str) -> String {
    format!("Usage: {executable} <from> <to>")
}
...
return Err(format!("unrecognized option '{}'", param.to_string_lossy()));

Test

Add to tests/by-util/test_cmp.rs:

#[test]
fn cmp_usage_errors_match_gnu() -> Result<(), Box<dyn std::error::Error>> {
    let mut cmd = cargo_bin_cmd!("diffutils");
    cmd.arg("cmp");
    cmd.assert().code(predicate::eq(2)).stderr(predicate::eq(
        "cmp: missing operand after 'cmp'\ncmp: Try 'cmp --help' for more information.\n",
    ));

    let mut cmd = cargo_bin_cmd!("diffutils");
    cmd.arg("cmp").arg("--bogus").arg("a").arg("b");
    cmd.assert().code(predicate::eq(2)).stderr(predicate::eq(
        "cmp: unrecognized option '--bogus'\ncmp: Try 'cmp --help' for more information.\n",
    ));
    Ok(())
}

Reported by Anthropic's OSS Scanner (ANT-2026-VNGOYIV8).

Activity

  1. sylvestre
    added
    good first issueGood for newcomersGood for newcomers
    oss-scannerFound by Anthropic's OSS ScannerFound by Anthropic's OSS Scanner
    gnu-compatBehaviour differs from GNUBehaviour differs from GNU
    on Nov 9, 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

    gnu-compatBehaviour differs from GNUBehaviour differs from GNUgood first issueGood for newcomersGood for newcomersoss-scannerFound by Anthropic's OSS ScannerFound by Anthropic's OSS Scanner

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.