@@ -157,19 +157,11 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
157157 } ;
158158 let check = matches. get_flag ( "check" ) ;
159159
160- let check_flag = |flag| match ( check, matches. get_flag ( flag) ) {
161- ( _, false ) => Ok ( false ) ,
162- ( true , true ) => Ok ( true ) ,
163- ( false , true ) => Err ( ChecksumError :: CheckOnlyFlag ( flag. into ( ) ) ) ,
164- } ;
165-
166- // Each of the following flags are only expected in --check mode.
167- // If we encounter them otherwise, end with an error.
168- let ignore_missing = check_flag ( "ignore-missing" ) ?;
169- let warn = check_flag ( "warn" ) ?;
170- let quiet = check_flag ( "quiet" ) ?;
171- let strict = check_flag ( "strict" ) ?;
172- let status = check_flag ( "status" ) ?;
160+ let ignore_missing = matches. get_flag ( "ignore-missing" ) ;
161+ let warn = matches. get_flag ( "warn" ) ;
162+ let quiet = matches. get_flag ( "quiet" ) ;
163+ let strict = matches. get_flag ( "strict" ) ;
164+ let status = matches. get_flag ( "status" ) ;
173165
174166 let files = matches. get_many :: < OsString > ( options:: FILE ) . map_or_else (
175167 // No files given, read from stdin.
@@ -301,35 +293,40 @@ pub fn uu_app_common() -> Command {
301293 . long ( options:: QUIET )
302294 . help ( translate ! ( "hashsum-help-quiet" ) )
303295 . action ( ArgAction :: SetTrue )
304- . overrides_with_all ( [ options:: STATUS , options:: WARN ] ) ,
296+ . overrides_with_all ( [ options:: STATUS , options:: WARN ] )
297+ . requires ( options:: CHECK ) ,
305298 )
306299 . arg (
307300 Arg :: new ( options:: STATUS )
308301 . short ( 's' )
309302 . long ( "status" )
310303 . help ( translate ! ( "hashsum-help-status" ) )
311304 . action ( ArgAction :: SetTrue )
312- . overrides_with_all ( [ options:: QUIET , options:: WARN ] ) ,
305+ . overrides_with_all ( [ options:: QUIET , options:: WARN ] )
306+ . requires ( options:: CHECK ) ,
313307 )
314308 . arg (
315309 Arg :: new ( options:: STRICT )
316310 . long ( "strict" )
317311 . help ( translate ! ( "hashsum-help-strict" ) )
318- . action ( ArgAction :: SetTrue ) ,
312+ . action ( ArgAction :: SetTrue )
313+ . requires ( options:: CHECK ) ,
319314 )
320315 . arg (
321316 Arg :: new ( "ignore-missing" )
322317 . long ( "ignore-missing" )
323318 . help ( translate ! ( "hashsum-help-ignore-missing" ) )
324- . action ( ArgAction :: SetTrue ) ,
319+ . action ( ArgAction :: SetTrue )
320+ . requires ( options:: CHECK ) ,
325321 )
326322 . arg (
327323 Arg :: new ( options:: WARN )
328324 . short ( 'w' )
329325 . long ( "warn" )
330326 . help ( translate ! ( "hashsum-help-warn" ) )
331327 . action ( ArgAction :: SetTrue )
332- . overrides_with_all ( [ options:: QUIET , options:: STATUS ] ) ,
328+ . overrides_with_all ( [ options:: QUIET , options:: STATUS ] )
329+ . requires ( options:: CHECK ) ,
333330 )
334331 . arg (
335332 Arg :: new ( "zero" )
0 commit comments