diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-12-28 16:18:38 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-12-28 16:18:38 -0800 |
commit | 0f9de11a67a5bbf3fe0c3be7f55cb25a7987ed4d (patch) | |
tree | 40c6c53ac7b94969823ecb73c145862f9d617723 /tokenizer.cpp | |
parent | 715823a6665a63df5a7ae6e5a9adcbe287626c1c (diff) |
Fix issues related to redirections and block level IO with new parser
Diffstat (limited to 'tokenizer.cpp')
-rw-r--r-- | tokenizer.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tokenizer.cpp b/tokenizer.cpp index 0b003283..4e2b402c 100644 --- a/tokenizer.cpp +++ b/tokenizer.cpp @@ -535,6 +535,23 @@ enum token_type redirection_type_for_string(const wcstring &str, int *out_fd) return mode; } +int fd_redirected_by_pipe(const wcstring &str) +{ + /* Hack for the common case */ + if (str == L"|") + { + return STDOUT_FILENO; + } + + enum token_type mode = TOK_NONE; + int fd = 0; + read_redirection_or_fd_pipe(str.c_str(), &mode, &fd); + /* Pipes only */ + if (mode != TOK_PIPE || fd < 0) + fd = -1; + return fd; +} + int oflags_for_redirection_type(enum token_type type) { switch (type) |