mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:07:34 +00:00
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:
parent
6a245de911
commit
5c0c126122
2 changed files with 15 additions and 1 deletions
|
@ -25,6 +25,11 @@ extern char** environ;
|
||||||
|
|
||||||
namespace Shell {
|
namespace Shell {
|
||||||
|
|
||||||
|
int Shell::builtin_noop(int, const char**)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int Shell::builtin_dump(int argc, const char** argv)
|
int Shell::builtin_dump(int argc, const char** argv)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
|
@ -1142,6 +1147,9 @@ bool Shell::run_builtin(const AST::Command& command, const NonnullRefPtrVector<A
|
||||||
Core::EventLoop loop;
|
Core::EventLoop loop;
|
||||||
setup_signals();
|
setup_signals();
|
||||||
|
|
||||||
|
if (name == ":"sv)
|
||||||
|
name = "noop"sv;
|
||||||
|
|
||||||
#define __ENUMERATE_SHELL_BUILTIN(builtin) \
|
#define __ENUMERATE_SHELL_BUILTIN(builtin) \
|
||||||
if (name == #builtin) { \
|
if (name == #builtin) { \
|
||||||
retval = builtin_##builtin(argv.size() - 1, argv.data()); \
|
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
|
bool Shell::has_builtin(StringView name) const
|
||||||
{
|
{
|
||||||
|
if (name == ":"sv)
|
||||||
|
return true;
|
||||||
|
|
||||||
#define __ENUMERATE_SHELL_BUILTIN(builtin) \
|
#define __ENUMERATE_SHELL_BUILTIN(builtin) \
|
||||||
if (name == #builtin) { \
|
if (name == #builtin) { \
|
||||||
return true; \
|
return true; \
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
__ENUMERATE_SHELL_BUILTIN(bg) \
|
__ENUMERATE_SHELL_BUILTIN(bg) \
|
||||||
__ENUMERATE_SHELL_BUILTIN(wait) \
|
__ENUMERATE_SHELL_BUILTIN(wait) \
|
||||||
__ENUMERATE_SHELL_BUILTIN(dump) \
|
__ENUMERATE_SHELL_BUILTIN(dump) \
|
||||||
__ENUMERATE_SHELL_BUILTIN(kill)
|
__ENUMERATE_SHELL_BUILTIN(kill) \
|
||||||
|
__ENUMERATE_SHELL_BUILTIN(noop)
|
||||||
|
|
||||||
#define ENUMERATE_SHELL_OPTIONS() \
|
#define ENUMERATE_SHELL_OPTIONS() \
|
||||||
__ENUMERATE_SHELL_OPTION(inline_exec_keep_empty_segments, false, "Keep empty segments in inline execute $(...)") \
|
__ENUMERATE_SHELL_OPTION(inline_exec_keep_empty_segments, false, "Keep empty segments in inline execute $(...)") \
|
||||||
|
@ -333,6 +334,8 @@ private:
|
||||||
ENUMERATE_SHELL_BUILTINS()
|
ENUMERATE_SHELL_BUILTINS()
|
||||||
|
|
||||||
#undef __ENUMERATE_SHELL_BUILTIN
|
#undef __ENUMERATE_SHELL_BUILTIN
|
||||||
|
|
||||||
|
":", // POSIX-y name for "noop".
|
||||||
};
|
};
|
||||||
|
|
||||||
bool m_should_ignore_jobs_on_next_exit { false };
|
bool m_should_ignore_jobs_on_next_exit { false };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue