Skip to content

Text output prints the line number twice (line:line:column) #7

Description

@catinspace-au

Summary

Text output renders the position prefix as <line>:<line>:<column>: instead of the conventional <line>:<column>:. Every finding shows the line number twice.

Repro

$ cat sedcheck.sh
#!/usr/bin/env bash
sed -i 's/still/broken/' file.txt

$ macbash sedcheck.sh
sedcheck.sh
  2:2:1: ERROR [sed-inplace-no-backup]

The finding is on line 2, column 1. The prefix should read 2:1:.

Cause

src/output.rs writes the line number once as a styled field and then again in the plain format string:

self.write_styled(gray(), &format!("{}", m.line))?;
write!(self.w, ":{}:{}: ", m.line, m.column)?;

Not a port regression

The Go implementation macbash replaced had the identical bug -- fmt.Fprintf(f.writer, " %s:%d:%d: ...", color(gray, m.Line), m.Line, m.Column). The Rust port reproduced it faithfully. So this is an inherited upstream defect, not something the rewrite introduced.

Why it needs a decision, not just a patch

The Rust rewrite's acceptance bar was byte-for-byte behavioural parity with the Go binary (see docs/decisions/0001-rewrite-macbash-in-rust.md), and macbash is intended to replace the upstream repo. Fixing the prefix is a user-visible text-output change:

  • --format json is the documented stable contract and is unaffected -- it carries line and column as separate fields.
  • Text output is explicitly NOT a contract (README, ARCHITECTURE.md), so nothing formally breaks.
  • But anything grepping the text output for ^ N:N: would need updating.

Suggested fix

self.write_styled(gray(), &format!("{}", m.line))?;
write!(self.w, ":{}: ", m.column)?;

That keeps the grey styling on the line number and produces 2:1:, matching every other linter's file:line:col convention.

Also worth adding an integration-test assertion on the prefix shape so it cannot silently regress again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions