mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
timeout: add support for -f and -p short options
This commit is contained in:
parent
5b056704da
commit
df91808649
2 changed files with 22 additions and 7 deletions
|
@ -129,6 +129,7 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FOREGROUND)
|
Arg::new(options::FOREGROUND)
|
||||||
.long(options::FOREGROUND)
|
.long(options::FOREGROUND)
|
||||||
|
.short('f')
|
||||||
.help(
|
.help(
|
||||||
"when not running timeout directly from a shell prompt, allow \
|
"when not running timeout directly from a shell prompt, allow \
|
||||||
COMMAND to read from the TTY and get TTY signals; in this mode, \
|
COMMAND to read from the TTY and get TTY signals; in this mode, \
|
||||||
|
@ -148,6 +149,7 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::PRESERVE_STATUS)
|
Arg::new(options::PRESERVE_STATUS)
|
||||||
.long(options::PRESERVE_STATUS)
|
.long(options::PRESERVE_STATUS)
|
||||||
|
.short('p')
|
||||||
.help("exit with the same status as COMMAND, even when the command times out")
|
.help("exit with the same status as COMMAND, even when the command times out")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
|
|
|
@ -83,15 +83,28 @@ fn test_command_empty_args() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_preserve_status() {
|
fn test_foreground() {
|
||||||
|
for arg in ["-f", "--foreground"] {
|
||||||
new_ucmd!()
|
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()
|
.fails()
|
||||||
// 128 + SIGTERM = 128 + 15
|
// 128 + SIGTERM = 128 + 15
|
||||||
.code_is(128 + 15)
|
.code_is(128 + 15)
|
||||||
.no_stderr()
|
.no_stderr()
|
||||||
.no_stdout();
|
.no_stdout();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_preserve_status_even_when_send_signal() {
|
fn test_preserve_status_even_when_send_signal() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue