mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-25 11:48:06 +00:00
Shell: Implement specifying fds in file redirection
This commit is contained in:
parent
cf7910fc1e
commit
7ed8a468ec
Notes:
sideshowbarker
2024-07-19 10:58:00 +09:00
Author: https://github.com/karolba
Commit: 7ed8a468ec
Pull-request: https://github.com/SerenityOS/serenity/pull/846
Reviewed-by: https://github.com/bugaevc
1 changed files with 23 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
void Parser::commit_token()
|
void Parser::commit_token()
|
||||||
{
|
{
|
||||||
|
@ -102,6 +103,28 @@ Vector<Command> Parser::parse()
|
||||||
m_state = State::InDoubleQuotes;
|
m_state = State::InDoubleQuotes;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (isdigit(ch)) {
|
||||||
|
if (i != m_input.length() - 1) {
|
||||||
|
char next_ch = m_input.characters()[i + 1];
|
||||||
|
if (next_ch == '>') {
|
||||||
|
commit_token();
|
||||||
|
begin_redirect_write(ch - '0');
|
||||||
|
++i;
|
||||||
|
|
||||||
|
// Search for another > for append.
|
||||||
|
m_state = State::InWriteAppendOrRedirectionPath;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (next_ch == '<') {
|
||||||
|
commit_token();
|
||||||
|
begin_redirect_read(ch - '0');
|
||||||
|
++i;
|
||||||
|
|
||||||
|
m_state = State::InRedirectionPath;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
m_token.append(ch);
|
m_token.append(ch);
|
||||||
break;
|
break;
|
||||||
case State::InWriteAppendOrRedirectionPath:
|
case State::InWriteAppendOrRedirectionPath:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue