mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:37:34 +00:00
Shell: Run clang-format on everything.
This commit is contained in:
parent
46527b72d7
commit
f7ede145b4
3 changed files with 47 additions and 48 deletions
|
@ -1,8 +1,8 @@
|
||||||
#include "LineEditor.h"
|
#include "LineEditor.h"
|
||||||
#include "GlobalState.h"
|
#include "GlobalState.h"
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
LineEditor::LineEditor()
|
LineEditor::LineEditor()
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@ Vector<Subcommand> Parser::parse()
|
||||||
commit_token();
|
commit_token();
|
||||||
if (m_tokens.is_empty()) {
|
if (m_tokens.is_empty()) {
|
||||||
fprintf(stderr, "Syntax error: Nothing before pipe (|)\n");
|
fprintf(stderr, "Syntax error: Nothing before pipe (|)\n");
|
||||||
return { };
|
return {};
|
||||||
}
|
}
|
||||||
do_pipe();
|
do_pipe();
|
||||||
break;
|
break;
|
||||||
|
@ -110,7 +110,7 @@ Vector<Subcommand> Parser::parse()
|
||||||
commit_token();
|
commit_token();
|
||||||
if (m_tokens.is_empty()) {
|
if (m_tokens.is_empty()) {
|
||||||
fprintf(stderr, "Syntax error: Nothing before pipe (|)\n");
|
fprintf(stderr, "Syntax error: Nothing before pipe (|)\n");
|
||||||
return { };
|
return {};
|
||||||
}
|
}
|
||||||
do_pipe();
|
do_pipe();
|
||||||
m_state = State::Free;
|
m_state = State::Free;
|
||||||
|
@ -145,7 +145,7 @@ Vector<Subcommand> Parser::parse()
|
||||||
for (auto& redirection : m_subcommands.last().redirections) {
|
for (auto& redirection : m_subcommands.last().redirections) {
|
||||||
if (redirection.type == Redirection::Pipe) {
|
if (redirection.type == Redirection::Pipe) {
|
||||||
fprintf(stderr, "Syntax error: Nothing after last pipe (|)\n");
|
fprintf(stderr, "Syntax error: Nothing after last pipe (|)\n");
|
||||||
return { };
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ static bool handle_builtin(int argc, char** argv, int& retval)
|
||||||
|
|
||||||
class FileDescriptionCollector {
|
class FileDescriptionCollector {
|
||||||
public:
|
public:
|
||||||
FileDescriptionCollector() { }
|
FileDescriptionCollector() {}
|
||||||
~FileDescriptionCollector() { collect(); }
|
~FileDescriptionCollector() { collect(); }
|
||||||
|
|
||||||
void collect()
|
void collect()
|
||||||
|
@ -248,7 +248,7 @@ static Vector<String> process_arguments(const Vector<String>& args)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// And even if they are, skip . and ..
|
// And even if they are, skip . and ..
|
||||||
if (name == "." || name == "..")
|
if (name == "." || name == "..")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (name.matches(arg, String::CaseSensitivity::CaseSensitive))
|
if (name.matches(arg, String::CaseSensitivity::CaseSensitive))
|
||||||
|
@ -308,50 +308,50 @@ static int run_command(const String& cmd)
|
||||||
auto& subcommand = subcommands[i];
|
auto& subcommand = subcommands[i];
|
||||||
for (auto& redirection : subcommand.redirections) {
|
for (auto& redirection : subcommand.redirections) {
|
||||||
switch (redirection.type) {
|
switch (redirection.type) {
|
||||||
case Redirection::Pipe: {
|
case Redirection::Pipe: {
|
||||||
int pipefd[2];
|
int pipefd[2];
|
||||||
int rc = pipe(pipefd);
|
int rc = pipe(pipefd);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
perror("pipe");
|
perror("pipe");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
subcommand.rewirings.append({ STDOUT_FILENO, pipefd[1] });
|
|
||||||
auto& next_command = subcommands[i + 1];
|
|
||||||
next_command.rewirings.append({ STDIN_FILENO, pipefd[0] });
|
|
||||||
fds.add(pipefd[0]);
|
|
||||||
fds.add(pipefd[1]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case Redirection::FileWriteAppend: {
|
subcommand.rewirings.append({ STDOUT_FILENO, pipefd[1] });
|
||||||
int fd = open(redirection.path.characters(), O_WRONLY | O_CREAT | O_APPEND, 0666);
|
auto& next_command = subcommands[i + 1];
|
||||||
if (fd < 0) {
|
next_command.rewirings.append({ STDIN_FILENO, pipefd[0] });
|
||||||
perror("open");
|
fds.add(pipefd[0]);
|
||||||
return 1;
|
fds.add(pipefd[1]);
|
||||||
}
|
break;
|
||||||
subcommand.rewirings.append({ redirection.fd, fd });
|
}
|
||||||
fds.add(fd);
|
case Redirection::FileWriteAppend: {
|
||||||
break;
|
int fd = open(redirection.path.characters(), O_WRONLY | O_CREAT | O_APPEND, 0666);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror("open");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
case Redirection::FileWrite: {
|
subcommand.rewirings.append({ redirection.fd, fd });
|
||||||
int fd = open(redirection.path.characters(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
fds.add(fd);
|
||||||
if (fd < 0) {
|
break;
|
||||||
perror("open");
|
}
|
||||||
return 1;
|
case Redirection::FileWrite: {
|
||||||
}
|
int fd = open(redirection.path.characters(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
subcommand.rewirings.append({ redirection.fd, fd });
|
if (fd < 0) {
|
||||||
fds.add(fd);
|
perror("open");
|
||||||
break;
|
return 1;
|
||||||
}
|
}
|
||||||
case Redirection::FileRead: {
|
subcommand.rewirings.append({ redirection.fd, fd });
|
||||||
int fd = open(redirection.path.characters(), O_RDONLY);
|
fds.add(fd);
|
||||||
if (fd < 0) {
|
break;
|
||||||
perror("open");
|
}
|
||||||
return 1;
|
case Redirection::FileRead: {
|
||||||
}
|
int fd = open(redirection.path.characters(), O_RDONLY);
|
||||||
subcommand.rewirings.append({ redirection.fd, fd });
|
if (fd < 0) {
|
||||||
fds.add(fd);
|
perror("open");
|
||||||
break;
|
return 1;
|
||||||
}
|
}
|
||||||
|
subcommand.rewirings.append({ redirection.fd, fd });
|
||||||
|
fds.add(fd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,6 @@ static int run_command(const String& cmd)
|
||||||
dbgprintf(" %d\n", child);
|
dbgprintf(" %d\n", child);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int wstatus = 0;
|
int wstatus = 0;
|
||||||
int return_value = 0;
|
int return_value = 0;
|
||||||
|
|
||||||
|
@ -452,7 +451,7 @@ static int run_command(const String& cmd)
|
||||||
printf("Shell: %s(%d) exited abnormally\n", child.name.characters(), child.pid);
|
printf("Shell: %s(%d) exited abnormally\n", child.name.characters(), child.pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(errno == EINTR);
|
} while (errno == EINTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Should I really have to tcsetpgrp() after my child has exited?
|
// FIXME: Should I really have to tcsetpgrp() after my child has exited?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue