Skip to content

Commit

Permalink
printf: output of double-quote should not be escaped
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu committed Jan 10, 2024
1 parent 0071442 commit a04ba64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/uucore/src/lib/features/format/mod.rs
Expand Up @@ -127,6 +127,9 @@ impl FormatChar for EscapedChar {
Self::Char(c) => {
write!(writer, "{c}")?;
}
Self::Backslash(b'"') => {
write!(writer, "\"")?;
}
Self::Backslash(c) => {
writer.write_all(&[b'\\', *c])?;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/by-util/test_printf.rs
Expand Up @@ -36,6 +36,11 @@ fn escaped_slash() {
.stdout_only("hello\\ world");
}

#[test]
fn unescaped_double_quote() {
new_ucmd!().args(&["\\\""]).succeeds().stdout_only("\"");
}

#[test]
fn escaped_hex() {
new_ucmd!().args(&["\\x41"]).succeeds().stdout_only("A");
Expand Down

0 comments on commit a04ba64

Please sign in to comment.