Repository: xonsh/xonsh

Issue:
Executing xonsh inside xonsh failed when $UPDATE_OS_ENVIRON = True
<!--- Provide a general summary of the issue in the Title above -->
<!--- If you have a question along the lines of "How do I do this Bash command in xonsh"
please first look over the Bash to Xonsh translation guide: https://xon.sh/bash_to_xsh.html
If you don't find an answer there, please do open an issue! -->

## xonfig

<details>

```
$ xonfig
+------------------+-----------------+
| xonsh            | 0.10.0          |
| Python           | 3.9.6           |
| PLY              | 3.11            |
| have readline    | True            |
| prompt toolkit   | 3.0.20          |
| shell type       | prompt_toolkit  |
| history backend  | json            |
| pygments         | 2.10.0          |
| on posix         | True            |
| on linux         | True            |
| distro           | arch            |
| on wsl           | False           |
| 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            |
| xontrib          | []              |
+------------------+-----------------+
```

</details>

## Expected Behavior
Should not fail

## Current Behavior
<!--- Tell us what happens instead of the expected behavior -->
<!--- If part of your bug report is a traceback, please first enter debug mode before triggering the error
To enter debug mode, set the environment variable `XONSH_DEBUG=1` _before_ starting `xonsh`.
On Linux and OSX, an easy way to to do this is to run `env XONSH_DEBUG=1 xonsh` -->

Xonsh failed to start inside xonsh

### Traceback (if applicable)

<details>

```
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 21333, in main
    args = premain(argv)
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 21273, in premain
    env = start_services(shell_kwargs, args, pre_env=pre_env)
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 21181, in start_services
    execer = Execer(
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 13967, in __init__
    XSH.load(execer=self, ctx=xonsh_ctx)
  File "/usr/lib/python3.9/site-packages/xonsh/built_ins.py", line 557, in load
    self.env = kwargs.pop("env") if "env" in kwargs else Env(default_env())
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 18347, in __init__
    self[key] = val
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 18581, in __setitem__
    deval = detyper(val)
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 5848, in detype
    return x.detype()
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 16979, in detype
    style = self.style
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 17011, in style
    style_name = self.style_name
  File "/usr/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 17002, in style_name
    env_style_name = env.get("XONSH_COLOR_STYLE", "default")
AttributeError: 'NoneType' object has no attribute 'get'
Xonsh encountered an issue during launch
Failback to /bin/fish
```

</details>

## Steps to Reproduce

Add `$UPDATE_OS_ENVIRON = True` to xonsh rc. Start xonsh. Start xonsh inside xonsh.

<!--- Please try to write out a minimal reproducible snippet to trigger the bug, it will help us fix it! -->

## For community
⬇️  **Please click the 👍 reaction instead of leaving a `+1` or 👍  comment**



Discussion:

Resolving patch:
diff --git a/xonsh/environ.py b/xonsh/environ.py
--- a/xonsh/environ.py
+++ b/xonsh/environ.py
@@ -422,7 +422,7 @@ def detype(self):
     @property
     def style_name(self):
         """Current XONSH_COLOR_STYLE value"""
-        env = getattr(XSH, "env", {})
+        env = getattr(XSH, "env", {}) or {}
         env_style_name = env.get("XONSH_COLOR_STYLE", "default")
         if self._style_name is None or self._style_name != env_style_name:
             self._style_name = env_style_name


Test patch: