1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #5828 from samueltardieu/printf-double-quote

printf: output of double-quote should not be escaped
This commit is contained in:
Daniel Hofstetter 2024-01-11 08:52:51 +01:00 committed by GitHub
commit 5b860cb428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -108,6 +108,7 @@ pub fn parse_escape_code(rest: &mut &[u8]) -> EscapedChar {
*rest = new_rest; *rest = new_rest;
match c { match c {
b'\\' => EscapedChar::Byte(b'\\'), b'\\' => EscapedChar::Byte(b'\\'),
b'"' => EscapedChar::Byte(b'"'),
b'a' => EscapedChar::Byte(b'\x07'), b'a' => EscapedChar::Byte(b'\x07'),
b'b' => EscapedChar::Byte(b'\x08'), b'b' => EscapedChar::Byte(b'\x08'),
b'c' => EscapedChar::End, b'c' => EscapedChar::End,

View file

@ -36,6 +36,11 @@ fn escaped_slash() {
.stdout_only("hello\\ world"); .stdout_only("hello\\ world");
} }
#[test]
fn unescaped_double_quote() {
new_ucmd!().args(&["\\\""]).succeeds().stdout_only("\"");
}
#[test] #[test]
fn escaped_hex() { fn escaped_hex() {
new_ucmd!().args(&["\\x41"]).succeeds().stdout_only("A"); new_ucmd!().args(&["\\x41"]).succeeds().stdout_only("A");