37 lines
877 B
C
37 lines
877 B
C
/**
|
|
* @file Command.h
|
|
* @author apio (cloudapio.eu)
|
|
* @brief Command parsing and execution.
|
|
*
|
|
* @copyright Copyright (c) 2024, the Luna authors.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include "sh.h"
|
|
#include <luna/OwnedPtr.h>
|
|
#include <luna/String.h>
|
|
#include <luna/Vector.h>
|
|
#include <os/File.h>
|
|
|
|
struct Command
|
|
{
|
|
Vector<String> args;
|
|
};
|
|
|
|
Result<void> init_builtins();
|
|
|
|
Result<Option<String>> read_command(SharedPtr<os::File> file);
|
|
|
|
Result<OwnedPtr<Command>> parse_command(StringView command);
|
|
|
|
[[noreturn]] void execute_command(OwnedPtr<Command> command);
|
|
|
|
[[noreturn]] void execute_command_or_builtin(OwnedPtr<Command> command);
|
|
|
|
Result<void> run_builtin(const Vector<String>& args, shell_builtin_t builtin);
|
|
|
|
shell_builtin_t* check_builtin(Command& command);
|
|
|
|
Result<int> execute_command_in_subprocess(OwnedPtr<Command> command, SharedPtr<os::File> input_file, bool interactive);
|