Shell: Add a "noop" builtin aliased to ":"

POSIX comes up with such silly names sometimes...
This builtin does nothing. at all.
This commit is contained in:
Ali Mohammad Pur 2022-01-09 11:41:53 +03:30 committed by Andreas Kling
parent 6a245de911
commit 5c0c126122
Notes: sideshowbarker 2024-07-17 21:20:39 +09:00
2 changed files with 15 additions and 1 deletions

View File

@ -25,6 +25,11 @@ extern char** environ;
namespace Shell {
int Shell::builtin_noop(int, const char**)
{
return 0;
}
int Shell::builtin_dump(int argc, const char** argv)
{
if (argc != 2)
@ -1142,6 +1147,9 @@ bool Shell::run_builtin(const AST::Command& command, const NonnullRefPtrVector<A
Core::EventLoop loop;
setup_signals();
if (name == ":"sv)
name = "noop"sv;
#define __ENUMERATE_SHELL_BUILTIN(builtin) \
if (name == #builtin) { \
retval = builtin_##builtin(argv.size() - 1, argv.data()); \
@ -1160,6 +1168,9 @@ bool Shell::run_builtin(const AST::Command& command, const NonnullRefPtrVector<A
bool Shell::has_builtin(StringView name) const
{
if (name == ":"sv)
return true;
#define __ENUMERATE_SHELL_BUILTIN(builtin) \
if (name == #builtin) { \
return true; \

View File

@ -48,7 +48,8 @@
__ENUMERATE_SHELL_BUILTIN(bg) \
__ENUMERATE_SHELL_BUILTIN(wait) \
__ENUMERATE_SHELL_BUILTIN(dump) \
__ENUMERATE_SHELL_BUILTIN(kill)
__ENUMERATE_SHELL_BUILTIN(kill) \
__ENUMERATE_SHELL_BUILTIN(noop)
#define ENUMERATE_SHELL_OPTIONS() \
__ENUMERATE_SHELL_OPTION(inline_exec_keep_empty_segments, false, "Keep empty segments in inline execute $(...)") \
@ -333,6 +334,8 @@ private:
ENUMERATE_SHELL_BUILTINS()
#undef __ENUMERATE_SHELL_BUILTIN
":", // POSIX-y name for "noop".
};
bool m_should_ignore_jobs_on_next_exit { false };