Improve regex for redirections (#356)

This commit is contained in:
Vincent Ollivier 2022-06-17 20:22:28 +02:00 committed by GitHub
parent b16f5fc9fd
commit 629e254a51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -285,13 +285,13 @@ pub fn exec(cmd: &str, env: &mut BTreeMap<String, String>) -> ExitCode {
let mut is_thin_arrow = false;
let mut left_handle;
if Regex::new("<=+").is_match(args[i]) { // Redirect input stream
if Regex::new("^<=+$").is_match(args[i]) { // Redirect input stream
is_fat_arrow = true;
left_handle = 0;
} else if Regex::new("\\d*=+>").is_match(args[i]) { // Redirect output stream(s)
} else if Regex::new("^\\d*=+>$").is_match(args[i]) { // Redirect output stream(s)
is_fat_arrow = true;
left_handle = 1;
} else if Regex::new("\\d*-*>\\d*").is_match(args[i]) { // Pipe output stream(s)
} else if Regex::new("^\\d*-*>\\d*$").is_match(args[i]) { // Pipe output stream(s)
is_thin_arrow = true;
left_handle = 1;
// TODO: right_handle?