diff --git a/Cargo.toml b/Cargo.toml index a707bb2a..0146904d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/uu/watch/src/watch.rs b/src/uu/watch/src/watch.rs index b1e7d6bb..abf2db2c 100644 --- a/src/uu/watch/src/watch.rs +++ b/src/uu/watch/src/watch.rs @@ -19,7 +19,12 @@ fn parse_interval(input: &str) -> Result { // 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 @@ -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); + } }