Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ feat_common_core = [
[workspace.dependencies]
bytesize = "2.0.0"
chrono = { version = "0.4.38", default-features = false, features = ["clock"] }
clap = { version = "4.5.4", features = ["wrap_help", "cargo"] }
clap = { version = "4.5.4", features = ["wrap_help", "cargo", "env"] }
clap_complete = "4.5.2"
clap_mangen = "0.2.20"
crossterm = "0.29.0"
Expand Down
19 changes: 18 additions & 1 deletion src/uu/watch/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ fn parse_interval(input: &str) -> Result<Duration, ParseIntError> {
// Find index where to split string into seconds and nanos
let Some(index) = input.find([',', '.']) else {
let seconds: u64 = input.parse()?;
return Ok(Duration::new(seconds, 0));

return if seconds == 0 {
Ok(Duration::from_millis(100))
} else {
Ok(Duration::new(seconds, 0))
};
};

// If the seconds string is empty, set seconds to 0
Expand Down Expand Up @@ -250,4 +255,16 @@ mod parse_interval_tests {
let interval = parse_interval("1.00000000000a");
assert!(interval.is_err())
}

#[test]
fn test_minimum_seconds() {
let interval = parse_interval("0");
assert_eq!(Ok(Duration::from_millis(100)), interval);
}

#[test]
fn test_minimum_nanos() {
let interval = parse_interval("0.0");
assert_eq!(Ok(Duration::from_millis(100)), interval);
}
}
Loading