forked from extern/nushell
Return error early if seconds part of timestamp is invalid (#6193)
Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
@ -121,7 +121,15 @@ impl Command for Touch {
|
||||
|
||||
// Checks for the seconds stamp and removes the '.' delimiter if any
|
||||
let (val, has_sec): (String, bool) = match stamp.split_once('.') {
|
||||
Some((dtime, sec)) => (format!("{}{}", dtime, sec), true),
|
||||
Some((dtime, sec)) => match sec.parse::<u8>() {
|
||||
Ok(sec) if sec < 60 => (format!("{}{}", dtime, sec), true),
|
||||
_ => {
|
||||
return Err(ShellError::UnsupportedInput(
|
||||
"input has an invalid timestamp".to_string(),
|
||||
span,
|
||||
))
|
||||
}
|
||||
},
|
||||
None => (stamp.to_string(), false),
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user