1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

Shell: Parse and correctly evaluate 'command &' and 'command &&'

This commit adds the InBackground and ShortCircuitOnFailure attributes
to commands, which respectively cause the command to be run in the
background, and abort the command chain with exit status != 0.
This commit is contained in:
AnotherTest 2020-05-24 23:00:46 +04:30 committed by Andreas Kling
parent 143be7234f
commit c23c354779
3 changed files with 70 additions and 5 deletions

View file

@ -45,6 +45,12 @@ struct Token {
Type type;
};
enum Attributes {
None = 0x0,
ShortCircuitOnFailure = 0x1,
InBackground = 0x2,
};
struct Redirection {
enum Type {
Pipe,
@ -71,6 +77,7 @@ struct Subcommand {
struct Command {
Vector<Subcommand> subcommands;
Attributes attributes;
};
class Parser {
@ -89,7 +96,7 @@ private:
};
void commit_token(Token::Type, AllowEmptyToken = AllowEmptyToken::No);
void commit_subcommand();
void commit_command();
void commit_command(Attributes = None);
void do_pipe();
void begin_redirect_read(int fd);
void begin_redirect_write(int fd);