Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/uu/pgrep/src/process_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,19 @@ pub fn get_match_settings(matches: &ArgMatches) -> UResult<Settings> {
));
}

if !settings.full && pattern.len() > 15 {
let msg = format!("pattern that searches for process name longer than 15 characters will result in zero matches\n\
Try `{} -f' option to match against the complete command line.", uucore::util_name());
return Err(USimpleError::new(1, msg));
}

Ok(settings)
}

pub fn find_matching_pids(settings: &Settings) -> UResult<Vec<ProcessInformation>> {
let mut pids = collect_matched_pids(settings)?;

if pids.is_empty() {
if !settings.full && settings.regex.as_str().len() > 15 {
let msg = format!("pattern that searches for process name longer than 15 characters will result in zero matches\n\
Try `{} -f' option to match against the complete command line.", uucore::util_name());
return Err(USimpleError::new(1, msg));
}

uucore::error::set_exit_code(1);
Ok(pids)
} else {
Expand Down
Loading