diff --git a/src/lib/parser/shell_expand/words/mod.rs b/src/lib/parser/shell_expand/words/mod.rs
index 86e1aedf8f98e72b1a7a711f51d043a4bfd3863e..ac7ff371ed31abf93a4714f51166aafbcad08dd6 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;
                     }