From 05daaf5a49fb829a10900caf005ac7250a9964e1 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Mon, 29 Jun 2026 22:50:52 +0900 Subject: [PATCH] ls: fix QUOTING_STYLE=invalid ls 2>/dev/full SIGABRT --- src/uu/ls/src/config.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/uu/ls/src/config.rs b/src/uu/ls/src/config.rs index fc788e85425..a87d53ef62d 100644 --- a/src/uu/ls/src/config.rs +++ b/src/uu/ls/src/config.rs @@ -9,7 +9,7 @@ use std::{ borrow::Cow, ffi::{OsStr, OsString}, - io::{IsTerminal, stdout}, + io::{self, IsTerminal, Write as _, stdout}, num::IntErrorKind, }; @@ -574,13 +574,14 @@ fn extract_quoting_style( } else { // If set, the QUOTING_STYLE environment variable specifies a default style. if let Ok(style) = std::env::var("QUOTING_STYLE") { - match match_quoting_style_name(style.as_str(), show_control) { - Some(pair) => return pair, - None => eprintln!( - "{}", - translate!("ls-invalid-quoting-style", "program" => std::env::args().next().unwrap_or_else(|| "ls".to_string()), "style" => style.clone()) - ), + if let Some(pair) = match_quoting_style_name(style.as_str(), show_control) { + return pair; } + let _ = writeln!( + io::stderr(), + "{}", + translate!("ls-invalid-quoting-style", "program" => std::env::args().next().unwrap_or_else(|| "ls".to_string()), "style" => style.clone()) + ); } // By default, `ls` uses Shell escape quoting style when writing to a terminal file