Skip to content

Commit 574aec5

Browse files
committed
Take comments into account
1 parent 070bbe2 commit 574aec5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/uu/stat/src/stat.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ pub enum OutputType {
9797
Unknown,
9898
}
9999

100+
#[derive(Default)]
100101
enum QuotingStyle {
101102
Locale,
102103
Shell,
103-
Default,
104+
#[default]
105+
ShellEscapeAlways,
104106
Quote,
105107
}
106108

@@ -111,6 +113,7 @@ impl std::str::FromStr for QuotingStyle {
111113
match s {
112114
"locale" => Ok(QuotingStyle::Locale),
113115
"shell" => Ok(QuotingStyle::Shell),
116+
"shell-escape-always" => Ok(QuotingStyle::ShellEscapeAlways),
114117
// The others aren't exposed to the user
115118
_ => Err(format!("Invalid quoting style: {}", s)),
116119
}
@@ -324,7 +327,7 @@ fn quote_file_name(file_name: &str, quoting_style: &QuotingStyle) -> String {
324327
let escaped = file_name.replace('\'', r"\'");
325328
format!("'{}'", escaped)
326329
}
327-
QuotingStyle::Default => format!("\"{}\"", file_name),
330+
QuotingStyle::ShellEscapeAlways => format!("\"{}\"", file_name),
328331
QuotingStyle::Quote => file_name.to_string(),
329332
}
330333
}
@@ -338,7 +341,7 @@ fn get_quoted_file_name(
338341
let quoting_style = env::var("QUOTING_STYLE")
339342
.ok()
340343
.and_then(|style| style.parse().ok())
341-
.unwrap_or(QuotingStyle::Default);
344+
.unwrap_or_default();
342345

343346
if file_type.is_symlink() {
344347
let quoted_display_name = quote_file_name(display_name, &quoting_style);
@@ -362,7 +365,7 @@ fn get_quoted_file_name(
362365
}
363366
}
364367

365-
fn process_token_fs(t: &Token, meta: StatFs, display_name: &str) {
368+
fn process_token_filesystem(t: &Token, meta: StatFs, display_name: &str) {
366369
match *t {
367370
Token::Byte(byte) => write_raw_byte(byte),
368371
Token::Char(c) => print!("{c}"),
@@ -943,7 +946,7 @@ impl Stater {
943946

944947
// Usage
945948
for t in tokens {
946-
process_token_fs(t, meta, &display_name);
949+
process_token_filesystem(t, meta, &display_name);
947950
}
948951
}
949952
Err(e) => {

0 commit comments

Comments
 (0)