diff --git a/Shell/Builtin.cpp b/Shell/Builtin.cpp index a0a7c539c4..e19e8cfce3 100644 --- a/Shell/Builtin.cpp +++ b/Shell/Builtin.cpp @@ -327,6 +327,23 @@ int Shell::builtin_export(int argc, const char** argv) return 0; } +int Shell::builtin_glob(int argc, const char** argv) +{ + Vector globs; + Core::ArgsParser parser; + parser.add_positional_argument(globs, "Globs to resolve", "glob"); + + if (!parser.parse(argc, const_cast(argv), false)) + return 1; + + for (auto& glob : globs) { + for (auto& expanded : expand_globs(glob, cwd)) + outln("{}", expanded); + } + + return 0; +} + int Shell::builtin_fg(int argc, const char** argv) { int job_id = -1; diff --git a/Shell/Shell.h b/Shell/Shell.h index eca2f47a20..f552595814 100644 --- a/Shell/Shell.h +++ b/Shell/Shell.h @@ -47,6 +47,7 @@ __ENUMERATE_SHELL_BUILTIN(pwd) \ __ENUMERATE_SHELL_BUILTIN(exit) \ __ENUMERATE_SHELL_BUILTIN(export) \ + __ENUMERATE_SHELL_BUILTIN(glob) \ __ENUMERATE_SHELL_BUILTIN(unset) \ __ENUMERATE_SHELL_BUILTIN(history) \ __ENUMERATE_SHELL_BUILTIN(umask) \