<rdar://problem/13178743>
authorGreg Clayton <gclayton@apple.com>
Tue, 12 Feb 2013 18:52:24 +0000 (18:52 +0000)
committerGreg Clayton <gclayton@apple.com>
Tue, 12 Feb 2013 18:52:24 +0000 (18:52 +0000)
Added a new "env" regular expression alias. If "env" is typed on its own "settings show target.env-vars" will be run. Otherwise it can be used to set and environment variable: "env FOO=BAR".

llvm-svn: 174991

lldb/source/Interpreter/CommandInterpreter.cpp

index 4ba0031..89ed564 100644 (file)
@@ -227,6 +227,12 @@ CommandInterpreter::Initialize ()
         AddAlias ("list", cmd_obj_sp);
     }
 
+    cmd_obj_sp = GetCommandSPExact ("_regexp-env", false);
+    if (cmd_obj_sp)
+    {
+        AddAlias ("env", cmd_obj_sp);
+    }
+
     cmd_obj_sp = GetCommandSPExact ("memory read", false);
     if (cmd_obj_sp)
         AddAlias ("x", cmd_obj_sp);
@@ -600,6 +606,21 @@ CommandInterpreter::LoadCommandDictionary ()
         }
     }
 
+    std::auto_ptr<CommandObjectRegexCommand>
+    env_regex_cmd_ap(new CommandObjectRegexCommand (*this,
+                                                     "_regexp-env",
+                                                     "Implements a shortcut to viewing and setting environment variables.",
+                                                     "_regexp-env\n_regexp-env FOO=BAR", 2));
+    if (env_regex_cmd_ap.get())
+    {
+        if (env_regex_cmd_ap->AddRegexCommand("^$", "settings show target.env-vars") &&
+            env_regex_cmd_ap->AddRegexCommand("^([A-Za-z_][A-Za-z_0-9]*=.*)$", "settings set target.env-vars %1"))
+        {
+            CommandObjectSP env_regex_cmd_sp(env_regex_cmd_ap.release());
+            m_command_dict[env_regex_cmd_sp->GetCommandName ()] = env_regex_cmd_sp;
+        }
+    }
+
 }
 
 int