Forráskód Böngészése

grep: Recognize mode based on the program name

Tim Schumacher 3 éve
szülő
commit
4a5d1db7f6
1 módosított fájl, 5 hozzáadás és 2 törlés
  1. 5 2
      Userland/Utilities/grep.cpp

+ 5 - 2
Userland/Utilities/grep.cpp

@@ -5,6 +5,7 @@
  */
 
 #include <AK/Assertions.h>
+#include <AK/LexicalPath.h>
 #include <AK/ScopeGuard.h>
 #include <AK/String.h>
 #include <AK/Vector.h>
@@ -36,10 +37,12 @@ ErrorOr<int> serenity_main(Main::Arguments args)
 {
     TRY(Core::System::pledge("stdio rpath", nullptr));
 
+    String program_name = AK::LexicalPath::basename(args.strings[0]);
+
     Vector<const char*> files;
 
-    bool recursive { false };
-    bool use_ere { false };
+    bool recursive = (program_name == "rgrep"sv);
+    bool use_ere = (program_name == "egrep"sv);
     Vector<const char*> patterns;
     BinaryFileMode binary_mode { BinaryFileMode::Binary };
     bool case_insensitive = false;