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 - `-l` offset column is 19 characters wide when one operand is stdin · Issue #348 · uutils/diffutils

cmp - -l offset column is 19 characters wide when one operand is stdin #348

New issue
Copy link
New issue
Copy link
Open
#373
Open
cmp - -l offset column is 19 characters wide when one operand is stdin#348
#373
Copy link
Labels
bugSomething isn't workingSomething isn't workinggnu-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: #330 (merged PR) — #330

GNU cmp -l sizes the byte-offset column from the smallest number of bytes that can
still be compared: the -n limit, and the size (minus skip) of every operand that is a
regular file. #330 implemented this, but only when both operands can be stat'ed as
paths. When one operand is standard input (or a pipe or device), uutils falls back to
the width of u64::MAX (19 columns) even though the other operand is a regular file of
known size.

Reproduction

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

Rust (incorrect)

$ cat c1 | ./target/release/diffutils cmp -l - c2
                   6 146 130
                  10 152 131
# Exit code: 1

GNU (correct)

$ cat c1 | LC_ALL=C cmp -l - c2
 6 146 130
10 152 131
# Exit code: 1

Root cause

cmp() in src/cmp.rs:309-331 only narrows the width when the metadata of both paths
is available:

let mut offset_width = params.max_bytes.unwrap_or(BytesLimitU64::MAX);

if let (Ok(a_meta), Ok(b_meta)) = (fs::metadata(&params.from), fs::metadata(&params.to)) {

Test

Add to tests/by-util/test_cmp.rs, next to cmp_verbose_offset_width_after_skip:

#[test]
fn cmp_verbose_offset_width_stdin() -> Result<(), Box<dyn std::error::Error>> {
    let tmp_dir = tempdir()?;
    let b_path = tmp_dir.path().join("b");
    std::fs::write(&b_path, b"abcdeXghiY")?;
    let mut cmd = cargo_bin_cmd!("diffutils");
    cmd.arg("cmp").arg("-l").arg("-").arg(&b_path);
    cmd.write_stdin("abcdefghij");
    cmd.assert()
        .code(predicate::eq(1))
        .stdout(predicate::eq(" 6 146 130\n10 152 131\n"));
    Ok(())
}

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

Activity

  1. sylvestre
    added
    bugSomething isn't workingSomething isn't working
    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

    bugSomething isn't workingSomething isn't workinggnu-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.