We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 445abbe commit cc101faCopy full SHA for cc101fa
src/uu/date/src/date.rs
@@ -185,7 +185,17 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
185
DateSource::Now
186
};
187
188
- let set_to = match matches.get_one::<String>(OPT_SET).map(parse_date) {
+ let set_option = matches.get_one::<String>(OPT_SET);
189
+
190
+ // Before parsing an eventual OPT_SET, check if it can't be present.
191
+ if !matches!(date_source, DateSource::Now) && set_option.is_some() {
192
+ return Err(USimpleError::new(
193
+ 1,
194
+ "the options to print and set the time may not be used together",
195
+ ));
196
+ }
197
198
+ let set_to = match set_option.map(parse_date) {
199
None => None,
200
Some(Err((input, _err))) => {
201
return Err(USimpleError::new(
0 commit comments