mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
uucore/quoting_style: Add support for quoting/escaping empty strings
This commit is contained in:
@@ -428,7 +428,7 @@ fn escape_name_inner(name: &[u8], style: &QuotingStyle, dirname: bool) -> Vec<u8
|
||||
(Quotes::Single, true)
|
||||
} else if name.contains(&b'\'') {
|
||||
(Quotes::Double, true)
|
||||
} else if *always_quote {
|
||||
} else if *always_quote || name.is_empty() {
|
||||
(Quotes::Single, true)
|
||||
} else {
|
||||
(Quotes::Single, false)
|
||||
@@ -609,6 +609,25 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_empty_string() {
|
||||
check_names(
|
||||
"",
|
||||
&[
|
||||
("", "literal"),
|
||||
("", "literal-show"),
|
||||
("", "escape"),
|
||||
("\"\"", "c"),
|
||||
("''", "shell"),
|
||||
("''", "shell-show"),
|
||||
("''", "shell-always"),
|
||||
("''", "shell-always-show"),
|
||||
("''", "shell-escape"),
|
||||
("''", "shell-escape-always"),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_spaces() {
|
||||
check_names(
|
||||
|
||||
Reference in New Issue
Block a user