Merge pull request #2977 from Dr-Emann/echo_octal_nul

echo: Allow echo with escapes to work with `\0`
This commit is contained in:
Terts Diepraam
2022-02-01 20:13:53 +01:00
committed by GitHub
2 changed files with 11 additions and 6 deletions
+1 -4
View File
@@ -88,10 +88,7 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<bool> {
start = 0;
next
}),
'0' => parse_code(&mut iter, 8, 3, 3).unwrap_or_else(|| {
start = 0;
next
}),
'0' => parse_code(&mut iter, 8, 3, 3).unwrap_or('\0'),
_ => {
start = 0;
next
+10 -2
View File
@@ -138,11 +138,19 @@ fn test_escape_short_octal() {
}
#[test]
fn test_escape_no_octal() {
fn test_escape_nul() {
new_ucmd!()
.args(&["-e", "foo\\0 bar"])
.succeeds()
.stdout_only("foo\\0 bar\n");
.stdout_only("foo\0 bar\n");
}
#[test]
fn test_escape_octal_invalid_digit() {
new_ucmd!()
.args(&["-e", "foo\\08 bar"])
.succeeds()
.stdout_only("foo\u{0}8 bar\n");
}
#[test]