From 9235fdb306e24ff72eafdbecc8ccb14003f5fd41 Mon Sep 17 00:00:00 2001
From: Victor Carvalho <contato@victorcarvalho.pt>
Date: Sat, 13 Jan 2018 16:20:17 +0000
Subject: [PATCH] fix to array parsing issue

Glob_check was incorporating one element arrays into globs. The fix simply checks if the b']' is not succeeded by another character, which would make it a glob
---
 src/lib/parser/shell_expand/words/mod.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lib/parser/shell_expand/words/mod.rs b/src/lib/parser/shell_expand/words/mod.rs
index 86e1aedf..ac7ff371 100644
--- a/src/lib/parser/shell_expand/words/mod.rs
+++ b/src/lib/parser/shell_expand/words/mod.rs
@@ -574,8 +574,11 @@ impl<'a, E: Expander + 'a> WordIterator<'a, E> {
                 b' ' | b'"' | b'\'' | b'$' | b'{' | b'}' => break,
                 b']' => {
                     // If the glob is less than three bytes in width, then it's empty and thus
-                    // invalid.
-                    if !(moves <= 3 && square_bracket == 1) {
+                    // invalid. If it's not adjacent to text, it's not a glob.
+                    let next_char = iter.clone().next();
+                    if !(moves <= 3 && square_bracket == 1)
+                        && (next_char != None && next_char != Some(b' '))
+                    {
                         glob = true;
                         break;
                     }
-- 
GitLab