Repository: xonsh/xonsh

Issue:
conda init error
Hi! Xonsh is super cool! I'm happy every time I'm writing xonshrc!

Today I tried to install master and got an error with conda init:

```bash
pip install -U git+https://github.com/xonsh/xonsh
xonfig
+------------------+----------------------+
| xonsh            | 0.9.21.dev31         |
| Git SHA          | d42b4140             |
```
```
cat ~/.xonshrc
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
import sys as _sys
from types import ModuleType as _ModuleType
_mod = _ModuleType("xontrib.conda",
                   "Autogenerated from $(/opt/miniconda/bin/conda shell.xonsh hook)")
__xonsh__.execer.exec($("/opt/miniconda/bin/conda" "shell.xonsh" "hook"),
                      glbs=_mod.__dict__,
                      filename="$(/opt/miniconda/bin/conda shell.xonsh hook)")
_sys.modules["xontrib.conda"] = _mod
del _sys, _mod, _ModuleType
# <<< conda initialize <<<
```
```
xonsh
Traceback (most recent call last):
  File "/opt/miniconda/lib/python3.8/site-packages/xonsh/proc.py", line 1737, in wait
    r = self.f(self.args, stdin, stdout, stderr, spec, spec.stack)
  File "/opt/miniconda/lib/python3.8/site-packages/xonsh/proc.py", line 1232, in proxy_two
    return f(args, stdin)
  File "/opt/miniconda/lib/python3.8/site-packages/xonsh/aliases.py", line 583, in source_alias
    print_color(
  File "/opt/miniconda/lib/python3.8/site-packages/xonsh/tools.py", line 1768, in print_color
    builtins.__xonsh__.shell.shell.print_color(string, **kwargs)
AttributeError: 'NoneType' object has no attribute 'shell'
xonsh> 
```

How I can fix this?
Thanks!

## For community
⬇️  **Please click the 👍 reaction instead of leaving a `+1` or 👍  comment**



Discussion:
Hi @anki-code - this error seems unrelated to the `conda init` section.  This is because the error is in a `print_color()` line and that is not called in the xonshrc at all here
@scopatz I think the error with `print_color` is the result of another error. I dive deeper:

Here is current master. It works without rc:
![Screenshot_20200916_091710](https://user-images.githubusercontent.com/1708680/93299236-6adee300-f7fd-11ea-971a-83b7811f1c3a.png)

But the error with default conda init:

![Screenshot_20200916_091847](https://user-images.githubusercontent.com/1708680/93299389-a2e62600-f7fd-11ea-84f9-a89a0a5466a2.png)

@laloch please take a look on error:
```
SyntaxError: $(/opt/miniconda/bin/conda shell.xonsh hook):51:39: ('code: shell',)
    __xonsh__.execer.exec($($CONDA_EXE shell.xonsh activate @(env_name_or_prefix)),
                                       ^
```
Could it be related to #3745 ?

Yeah, you're right. You have a syntax error on that line. Correct Xonsh syntax would be `$XONSH_SHOW_TRACEBACK=True $XONSH_DEBUG=1 xonsh --rc ~/.xonshrc_conda`.
@laloch please look deeper :) The error is not about how I run xonsh in bash (there is no error). The error when conda init try to run command `__xonsh__.execer.exec($($CONDA_EXE shell.xonsh activate @(env_name_or_prefix))` and I assume that the error related to your cool new feature #3745 with setting env before command because the code `$CONDA_EXE shell.xonsh activate` could be interpreted as "has environment variable" :) The error appears on master branch.
Oops, I see, sorry!
You are right. It seems to be a regression caused by #3745. I don't understand, why the parser doesn't backtrack if it can't find a `=` sign following the variable name. I'll fix this ASAP.

Resolving patch:
diff --git a/xonsh/parsers/base.py b/xonsh/parsers/base.py
--- a/xonsh/parsers/base.py
+++ b/xonsh/parsers/base.py
@@ -3325,11 +3325,7 @@ def p_subproc_arg_part(self, p):
         p[0] = ast.Str(s=p1.value, lineno=p1.lineno, col_offset=p1.lexpos)
 
     def p_envvar_assign_left(self, p):
-        """envvar_assign_left : dollar_name_tok EQUALS
-                              | dollar_name_tok WS EQUALS
-                              | dollar_name_tok EQUALS WS
-                              | dollar_name_tok WS EQUALS WS
-        """
+        """envvar_assign_left : dollar_name_tok EQUALS"""
         p[0] = p[1]
 
     def p_envvar_assign(self, p):


Test patch:
diff --git a/tests/test_parser.py b/tests/test_parser.py
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -2240,6 +2240,10 @@ def test_bang_ls_envvar_listval():
     check_xonsh_ast({"WAKKA": [".", "."]}, "!(ls $WAKKA)", False)
 
 
+def test_bang_envvar_args():
+    check_xonsh_ast({"LS": "ls"}, "!($LS .)", False)
+
+
 def test_question():
     check_xonsh_ast({}, "range?")
 
@@ -2502,7 +2506,7 @@ def test_ls_quotes_3_space():
 
 
 def test_leading_envvar_assignment():
-    check_xonsh_ast({}, "![$FOO= 'foo' $BAR =2 echo r'$BAR']", False)
+    check_xonsh_ast({}, "![$FOO='foo' $BAR=2 echo r'$BAR']", False)
 
 
 def test_echo_comma():