mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #7881 from alexs-sh/7736-control-flow-experiments
uucore/echo:handle ControlFlow result
This commit is contained in:
parent
13c0a813eb
commit
7d5cfbc4b6
3 changed files with 16 additions and 6 deletions
|
@ -9,7 +9,7 @@ use std::env;
|
|||
use std::ffi::{OsStr, OsString};
|
||||
use std::io::{self, StdoutLock, Write};
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::format::{EscapedChar, FormatChar, OctalParsing, parse_escape_only};
|
||||
use uucore::format::{FormatChar, OctalParsing, parse_escape_only};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||
|
||||
const ABOUT: &str = help_about!("echo.md");
|
||||
|
@ -191,10 +191,9 @@ fn execute(
|
|||
|
||||
if escaped {
|
||||
for item in parse_escape_only(bytes, OctalParsing::ThreeDigits) {
|
||||
match item {
|
||||
EscapedChar::End => return Ok(()),
|
||||
c => c.write(&mut *stdout_lock)?,
|
||||
};
|
||||
if item.write(&mut *stdout_lock)?.is_break() {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stdout_lock.write_all(bytes)?;
|
||||
|
|
|
@ -283,7 +283,9 @@ fn printf_writer<'a>(
|
|||
let args = args.into_iter().cloned().collect::<Vec<_>>();
|
||||
let mut args = FormatArguments::new(&args);
|
||||
for item in parse_spec_only(format_string.as_ref()) {
|
||||
item?.write(&mut writer, &mut args)?;
|
||||
if item?.write(&mut writer, &mut args)?.is_break() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -762,3 +762,12 @@ fn test_uchild_when_run_no_wait_with_a_non_blocking_util() {
|
|||
// we should be able to call wait without panics and apply some assertions
|
||||
child.wait().unwrap().code_is(0).no_stdout().no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_escape_sequence_ctrl_c() {
|
||||
new_ucmd!()
|
||||
.args(&["-e", "show\\c123"])
|
||||
.run()
|
||||
.success()
|
||||
.stdout_only("show");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue