From 4a5d1db7f69231f6a4aa16a833b9696fef2ba5f8 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 20 Mar 2022 18:43:08 +0100 Subject: [PATCH] grep: Recognize mode based on the program name --- Userland/Utilities/grep.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index bfc26d14f1..dc8d971c7b 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -36,10 +37,12 @@ ErrorOr serenity_main(Main::Arguments args) { TRY(Core::System::pledge("stdio rpath", nullptr)); + String program_name = AK::LexicalPath::basename(args.strings[0]); + Vector files; - bool recursive { false }; - bool use_ere { false }; + bool recursive = (program_name == "rgrep"sv); + bool use_ere = (program_name == "egrep"sv); Vector patterns; BinaryFileMode binary_mode { BinaryFileMode::Binary }; bool case_insensitive = false;