Repository: xonsh/xonsh

Issue:
![] subprocess comamnd syntax error when there is space

When you run this command (that has a space after '[!' and before 'echo') it errors out 100% of the time

```
> ![ echo "test"]
.
```

You can workaround this by deleting the space. No space after the '[!'

```
> ![echo "test"]
TRACE SUBPROC: (['echo', 'test'],)
test
```

## xonfig

<details>

```
> xonfig
<xonsh-code>:1:0 - xonfig
<xonsh-code>:1:0 + ![xonfig]
TRACE SUBPROC: (['xonfig'],)
+------------------+-----------------+
| xonsh            | 0.9.24          |
| Python           | 3.9.1           |
| PLY              | 3.11            |
| have readline    | True            |
| prompt toolkit   | 3.0.8           |
| shell type       | prompt_toolkit  |
| pygments         | 2.7.3           |
| on posix         | True            |
| on linux         | True            |
| distro           | manjaro         |
| on darwin        | False           |
| on windows       | False           |
| on cygwin        | False           |
| on msys2         | False           |
| is superuser     | False           |
| default encoding | utf-8           |
| xonsh encoding   | utf-8           |
| encoding errors  | surrogateescape |
| on jupyter       | False           |
| jupyter kernel   | None            |
+------------------+-----------------+
```

</details>

## Traceback (if applicable)

<details>

```
cat  /tmp/xonsh-debug-variables
export XONSH_TRACEBACK_LOGFILE=/tmp/xonsh-traceback.log
export XONSH_SHOW_TRACEBACK=True ;
export XONSH_TRACE_SUBPROC=True ;
export XONSH_DEBUG=2
[rado@manjaro ~]$ source  /tmp/xonsh-debug-variables
[rado@manjaro ~]$ xonsh

> ![ echo "test"]
.
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/xonsh/ptk_shell/shell.py", line 238, in _push
    code = self.execer.compile(src, mode="single", glbs=self.ctx, locs=None)
  File "/usr/lib/python3.9/site-packages/xonsh/execer.py", line 135, in compile
    tree = self.parse(input, ctx, mode=mode, filename=filename, transform=transform)
  File "/usr/lib/python3.9/site-packages/xonsh/execer.py", line 95, in parse
    tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
  File "/usr/lib/python3.9/site-packages/xonsh/execer.py", line 238, in _parse_ctx_free
    raise original_error from None
  File "/usr/lib/python3.9/site-packages/xonsh/execer.py", line 219, in _parse_ctx_free
    tree = self.parser.parse(
  File "/usr/lib/python3.9/site-packages/xonsh/parsers/base.py", line 497, in parse
    tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
  File "/usr/lib/python3.9/site-packages/xonsh/ply/ply/yacc.py", line 335, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/usr/lib/python3.9/site-packages/xonsh/ply/ply/yacc.py", line 1203, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/usr/lib/python3.9/site-packages/xonsh/ply/ply/yacc.py", line 194, in call_errorfunc
    r = errorfunc(token)
  File "/usr/lib/python3.9/site-packages/xonsh/parsers/base.py", line 3373, in p_error
    self._parse_error(msg, self.currloc(lineno=p.lineno, column=p.lexpos))
  File "/usr/lib/python3.9/site-packages/xonsh/parsers/base.py", line 639, in _parse_error
    raise err
  File "<string>", line None
SyntaxError: <xonsh-code>:1:2: ('code:  ',)
![ echo "test"]
  ^
```

</details>



Discussion:

Resolving patch:
diff --git a/xonsh/parsers/base.py b/xonsh/parsers/base.py
--- a/xonsh/parsers/base.py
+++ b/xonsh/parsers/base.py
@@ -3104,6 +3104,10 @@ def p_subproc_s2(self, p):
         p1 = p[1]
         p[0] = [self._subproc_cliargs(p1, lineno=self.lineno, col=self.col)]
 
+    def p_subproc_s1(self, p):
+        """subproc : WS subproc"""
+        p[0] = p[2]
+
     def p_subproc_amper(self, p):
         """subproc : subproc amper"""
         p1 = p[1]


Test patch:
diff --git a/tests/test_parser.py b/tests/test_parser.py
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -2180,8 +2180,16 @@ def test_dollar_sub():
     check_xonsh_ast({}, "$(ls)", False)
 
 
-def test_dollar_sub_space():
-    check_xonsh_ast({}, "$(ls )", False)
+@pytest.mark.parametrize(
+    "expr",
+    [
+        "$(ls )",
+        "$( ls)",
+        "$( ls )",
+    ],
+)
+def test_dollar_sub_space(expr):
+    check_xonsh_ast({}, expr, False)
 
 
 def test_ls_dot():
@@ -2246,8 +2254,16 @@ def test_bang_sub():
     check_xonsh_ast({}, "!(ls)", False)
 
 
-def test_bang_sub_space():
-    check_xonsh_ast({}, "!(ls )", False)
+@pytest.mark.parametrize(
+    "expr",
+    [
+        "!(ls )",
+        "!( ls)",
+        "!( ls )",
+    ],
+)
+def test_bang_sub_space(expr):
+    check_xonsh_ast({}, expr, False)
 
 
 def test_bang_ls_dot():