Skip to content

Commit df91808

Browse files
committed
timeout: add support for -f and -p short options
1 parent 5b05670 commit df91808

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/uu/timeout/src/timeout.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ pub fn uu_app() -> Command {
129129
.arg(
130130
Arg::new(options::FOREGROUND)
131131
.long(options::FOREGROUND)
132+
.short('f')
132133
.help(
133134
"when not running timeout directly from a shell prompt, allow \
134135
COMMAND to read from the TTY and get TTY signals; in this mode, \
@@ -148,6 +149,7 @@ pub fn uu_app() -> Command {
148149
.arg(
149150
Arg::new(options::PRESERVE_STATUS)
150151
.long(options::PRESERVE_STATUS)
152+
.short('p')
151153
.help("exit with the same status as COMMAND, even when the command times out")
152154
.action(ArgAction::SetTrue),
153155
)

tests/by-util/test_timeout.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,28 @@ fn test_command_empty_args() {
8282
.stderr_contains("timeout: empty string");
8383
}
8484

85+
#[test]
86+
fn test_foreground() {
87+
for arg in ["-f", "--foreground"] {
88+
new_ucmd!()
89+
.args(&[arg, ".1", "sleep", "10"])
90+
.fails()
91+
.code_is(124)
92+
.no_output();
93+
}
94+
}
95+
8596
#[test]
8697
fn test_preserve_status() {
87-
new_ucmd!()
88-
.args(&["--preserve-status", ".1", "sleep", "10"])
89-
.fails()
90-
// 128 + SIGTERM = 128 + 15
91-
.code_is(128 + 15)
92-
.no_stderr()
93-
.no_stdout();
98+
for arg in ["-p", "--preserve-status"] {
99+
new_ucmd!()
100+
.args(&[arg, ".1", "sleep", "10"])
101+
.fails()
102+
// 128 + SIGTERM = 128 + 15
103+
.code_is(128 + 15)
104+
.no_stderr()
105+
.no_stdout();
106+
}
94107
}
95108

96109
#[test]

0 commit comments

Comments
 (0)