mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-04 09:14:21 +03:00
grep: Exit with 1 if nothing matches
This commit is contained in:
parent
9b69c73dfe
commit
6f9e6e63b6
Notes:
sideshowbarker
2024-07-18 22:15:27 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/6f9e6e63b6b Pull-request: https://github.com/SerenityOS/serenity/pull/5325 Issue: https://github.com/SerenityOS/serenity/issues/90 Reviewed-by: https://github.com/BenWiederhake Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/sunverwerth
@ -188,6 +188,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
};
|
||||
|
||||
bool did_match_something = false;
|
||||
if (!files.size() && !recursive) {
|
||||
char* line = nullptr;
|
||||
size_t line_len = 0;
|
||||
@ -201,7 +202,9 @@ int main(int argc, char** argv)
|
||||
if (is_binary && binary_mode == BinaryFileMode::Skip)
|
||||
return 1;
|
||||
|
||||
if (matches(line_view, "stdin", false, is_binary) && is_binary && binary_mode == BinaryFileMode::Binary)
|
||||
auto matched = matches(line_view, "stdin", false, is_binary);
|
||||
did_match_something = did_match_something || matched;
|
||||
if (matched && is_binary && binary_mode == BinaryFileMode::Binary)
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@ -217,5 +220,5 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return did_match_something ? 0 : 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user