summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-01-18 04:34:16 +0330
committerAndreas Kling <kling@serenityos.org>2021-01-19 08:19:43 +0100
commitcd6e5c064ba9c9350b06a362ce84f5c674b2e7fe (patch)
tree5ec4b11d4ed3d2839f87f42492f94b999ffc5248
parent39af1f8519d4a33a90ae79e5b3277652aac85270 (diff)
downloadserenity-cd6e5c064ba9c9350b06a362ce84f5c674b2e7fe.zip
Shell: Add a builtin that parses its sole argument and dumps its AST
Pretty useful for debugging.
-rw-r--r--Userland/Shell/Builtin.cpp9
-rw-r--r--Userland/Shell/Shell.h3
2 files changed, 11 insertions, 1 deletions
diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp
index d3a48b5089..731710af43 100644
--- a/Userland/Shell/Builtin.cpp
+++ b/Userland/Shell/Builtin.cpp
@@ -40,6 +40,15 @@ extern char** environ;
namespace Shell {
+int Shell::builtin_dump(int argc, const char** argv)
+{
+ if (argc != 2)
+ return 1;
+
+ Parser { argv[1] }.parse()->dump(0);
+ return 0;
+}
+
int Shell::builtin_alias(int argc, const char** argv)
{
Vector<const char*> arguments;
diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h
index 3530d2e003..b86923e445 100644
--- a/Userland/Shell/Shell.h
+++ b/Userland/Shell/Shell.h
@@ -63,7 +63,8 @@
__ENUMERATE_SHELL_BUILTIN(disown) \
__ENUMERATE_SHELL_BUILTIN(fg) \
__ENUMERATE_SHELL_BUILTIN(bg) \
- __ENUMERATE_SHELL_BUILTIN(wait)
+ __ENUMERATE_SHELL_BUILTIN(wait) \
+ __ENUMERATE_SHELL_BUILTIN(dump)
#define ENUMERATE_SHELL_OPTIONS() \
__ENUMERATE_SHELL_OPTION(inline_exec_keep_empty_segments, false, "Keep empty segments in inline execute $(...)") \