Compare commits

...

2 Commits

Author SHA1 Message Date
6b4d41529e
libc: Fix execvp() calling the shell after an ENOEXEC
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-03 17:00:24 +02:00
6ad7491300
sh: Skip comments (and shebangs!) 2023-06-03 16:59:18 +02:00
3 changed files with 8 additions and 1 deletions

View File

@ -23,6 +23,8 @@ static Result<Vector<String>> split_command_into_args(StringView cmd)
static Result<void> execute_command(StringView command)
{
if (strcspn(command.chars(), " #") == 0) return {};
auto args = TRY(split_command_into_args(command));
if (args.size() < 1) exit(0);
@ -94,6 +96,8 @@ Result<int> luna_main(int argc, char** argv)
if (strspn(cmd.chars(), " \n") == cmd.length()) continue;
if (strcspn(cmd.chars(), " #") == 0) continue;
if (!strncmp(cmd.chars(), "cd", 2))
{
auto args = TRY(split_command_into_args(cmd.view()));

View File

@ -1,3 +1,5 @@
#!/bin/sh
mkdir -p /tmp
mount -t tmpfs /tmp
chmod 1777 /tmp

View File

@ -42,7 +42,8 @@ static Result<int> try_execvpe(const char* name, char* const* argv, char* const*
{
Vector<char*> shell_argv;
TRY(shell_argv.try_append(const_cast<char*>("sh")));
char* const* arg = argv;
TRY(shell_argv.try_append(file.mutable_data()));
char* const* arg = argv + 1;
do {
TRY(shell_argv.try_append(*arg));
} while (*(arg++));