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

timeout: add support for -f and -p short options

This commit is contained in:
Daniel Hofstetter 2025-01-23 16:05:14 +01:00
parent 5b056704da
commit df91808649
2 changed files with 22 additions and 7 deletions

View file

@ -129,6 +129,7 @@ pub fn uu_app() -> Command {
.arg(
Arg::new(options::FOREGROUND)
.long(options::FOREGROUND)
.short('f')
.help(
"when not running timeout directly from a shell prompt, allow \
COMMAND to read from the TTY and get TTY signals; in this mode, \
@ -148,6 +149,7 @@ pub fn uu_app() -> Command {
.arg(
Arg::new(options::PRESERVE_STATUS)
.long(options::PRESERVE_STATUS)
.short('p')
.help("exit with the same status as COMMAND, even when the command times out")
.action(ArgAction::SetTrue),
)

View file

@ -83,15 +83,28 @@ fn test_command_empty_args() {
}
#[test]
fn test_preserve_status() {
fn test_foreground() {
for arg in ["-f", "--foreground"] {
new_ucmd!()
.args(&["--preserve-status", ".1", "sleep", "10"])
.args(&[arg, ".1", "sleep", "10"])
.fails()
.code_is(124)
.no_output();
}
}
#[test]
fn test_preserve_status() {
for arg in ["-p", "--preserve-status"] {
new_ucmd!()
.args(&[arg, ".1", "sleep", "10"])
.fails()
// 128 + SIGTERM = 128 + 15
.code_is(128 + 15)
.no_stderr()
.no_stdout();
}
}
#[test]
fn test_preserve_status_even_when_send_signal() {