Skip to content

Commit a0cec00

Browse files
Merge pull request #329 from cakebaker/pgrep_dont_show_msg_if_pattern_is_15_chars
pgrep: don't show msg if pattern is 15 chars long
2 parents b03e8ce + a044ad4 commit a0cec00

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/uu/pgrep/src/process_matcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn get_match_settings(matches: &ArgMatches) -> UResult<Settings> {
7878
));
7979
}
8080

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

tests/by-util/test_pgrep.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,13 @@ fn test_does_not_match_pid() {
380380
#[cfg(target_os = "linux")]
381381
fn test_too_long_pattern() {
382382
new_ucmd!()
383-
.arg("THIS_IS_OVER_16_CHARS")
383+
.arg("A".repeat(15))
384+
.fails()
385+
.code_is(1)
386+
.no_output();
387+
388+
new_ucmd!()
389+
.arg("A".repeat(16))
384390
.fails()
385391
.code_is(1)
386392
.stderr_contains("pattern that searches for process name longer than 15 characters will result in zero matches");

0 commit comments

Comments
 (0)