@@ -36,6 +36,7 @@ struct Settings {
3636 exact : bool ,
3737 full : bool ,
3838 ignore_case : bool ,
39+ inverse : bool ,
3940 newest : bool ,
4041 oldest : bool ,
4142 older : Option < u64 > ,
@@ -64,6 +65,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
6465 exact : matches. get_flag ( "exact" ) ,
6566 full : matches. get_flag ( "full" ) ,
6667 ignore_case : matches. get_flag ( "ignore-case" ) ,
68+ inverse : matches. get_flag ( "inverse" ) ,
6769 newest : matches. get_flag ( "newest" ) ,
6870 oldest : matches. get_flag ( "oldest" ) ,
6971 parent : matches
@@ -235,11 +237,12 @@ fn collect_matched_pids(settings: &Settings) -> Vec<ProcessInformation> {
235237 _ => true ,
236238 } ;
237239
238- if run_state_matched
240+ if ( run_state_matched
239241 && pattern_matched
240242 && tty_matched
241243 && older_matched
242- && parent_matched
244+ && parent_matched)
245+ ^ settings. inverse
243246 {
244247 tmp_vec. push ( pid) ;
245248 }
@@ -343,12 +346,13 @@ pub fn uu_app() -> Command {
343346 . about ( ABOUT )
344347 . override_usage ( format_usage ( USAGE ) )
345348 . args_override_self ( true )
346- . group ( ArgGroup :: new ( "oldest_newest" ) . args ( [ "oldest" , "newest" ] ) )
349+ . group ( ArgGroup :: new ( "oldest_newest" ) . args ( [ "oldest" , "newest" , "inverse" ] ) )
347350 . args ( [
348351 // arg!(-<sig> "signal to send (either number or name)"),
349352 arg ! ( -H --"require-handler" "match only if signal handler is present" ) ,
350353 // arg!(-q --queue <value> "integer value to be sent with the signal"),
351354 arg ! ( -e --echo "display what is killed" ) ,
355+ arg ! ( --inverse "negates the matching" ) ,
352356 arg ! ( -c --count "count of matching processes" ) ,
353357 arg ! ( -f --full "use full process name to match" ) ,
354358 // arg!(-g --pgroup <PGID> "match listed process group IDs")
0 commit comments