From 124d7870459d4ede0510a2a5b519f3ba15acf339 Mon Sep 17 00:00:00 2001 From: Misakait Date: Sat, 4 Oct 2025 17:30:52 +0800 Subject: [PATCH] fix(ptx): Correct reference format for stdin --- src/uu/ptx/src/ptx.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index f3afc58df..111d74d39 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -352,11 +352,15 @@ fn create_word_set(config: &Config, filter: &WordFilter, file_map: &FileMap) -> fn get_reference(config: &Config, word_ref: &WordRef, line: &str, context_reg: &Regex) -> String { if config.auto_ref { - format!( - "{}:{}", - word_ref.filename.maybe_quote(), - word_ref.local_line_nr + 1 - ) + if word_ref.filename == "-" { + format!(":{}", word_ref.local_line_nr + 1) + } else { + format!( + "{}:{}", + word_ref.filename.maybe_quote(), + word_ref.local_line_nr + 1 + ) + } } else if config.input_ref { let (beg, end) = match context_reg.find(line) { Some(x) => (x.start(), x.end()),