Repository: xonsh/xonsh

Issue:
Bad documentation or bug: _.rtn does not work
[In the Documentation](https://xon.sh/bash_to_xsh.html) you write that `_.rtn` is the equivalent of the shell `$?` and that it `Returns the exit code, or status, of the previous command.`. Either I understand the documentation wrong or there is a bug:
```
#!/usr/bin/env xonsh
echo "abc"
print(_.rtn)
```
Outputs
```
abc
Traceback (most recent call last):
  File "/home/volker/.local/bin/xonsh", line 8, in <module>
    sys.exit(main())
  File "/home/volker/.local/lib/python3.8/site-packages/xonsh/main.py", line 426, in main
    _failback_to_other_shells(args, err)
  File "/home/volker/.local/lib/python3.8/site-packages/xonsh/main.py", line 373, in _failback_to_other_shells
    raise err
  File "/home/volker/.local/lib/python3.8/site-packages/xonsh/main.py", line 424, in main
    sys.exit(main_xonsh(args))
  File "/home/volker/.local/lib/python3.8/site-packages/xonsh/main.py", line 471, in main_xonsh
    run_script_with_cache(
  File "/home/volker/.local/lib/python3.8/site-packages/xonsh/codecache.py", line 162, in run_script_with_cache
    run_compiled_code(ccode, glb, loc, mode)
  File "/home/volker/.local/lib/python3.8/site-packages/xonsh/codecache.py", line 67, in run_compiled_code
    func(code, glb, loc)
  File "./generateIso.xonsh", line 24, in <module>
    print(_.rtn)
NameError: name '_' is not defined
```


Discussion:

Resolving patch:
diff --git a/xontrib/bashisms.py b/xontrib/bashisms.py
--- a/xontrib/bashisms.py
+++ b/xontrib/bashisms.py
@@ -64,3 +64,86 @@ def alias(args, stdin=None):
 
 aliases["alias"] = alias
 builtins.__xonsh__.env["THREAD_SUBPROCS"] = False
+
+
+def _unset(args):
+    if not args:
+        print("Usage: unset ENV_VARIABLE", file=sys.stderr)
+
+    for v in args:
+        try:
+            __xonsh__.env.pop(v)
+        except KeyError:
+            print(f"{v} not found", file=sys.stderr)
+
+
+aliases["unset"] = _unset
+
+
+def _export(args):
+    if not args:
+        print("Usage: export ENV_VARIABLE=VALUE", file=sys.stderr)
+
+    for eq in args:
+        if "=" in eq:
+            name, val = shlex.split(eq)[0].split("=", 1)
+            __xonsh__.env[name] = val
+        else:
+            print(f"{eq} equal sign not found", file=sys.stderr)
+
+
+aliases["export"] = _export
+
+
+def _set(args):
+    arg = args[0]
+    if arg == "-e":
+        __xonsh__.env["RAISE_SUBPROC_ERROR"] = True
+    elif arg == "+e":
+        __xonsh__.env["RAISE_SUBPROC_ERROR"] = False
+    elif arg == "-x":
+        __xonsh__.env["XONSH_TRACE_SUBPROC"] = True
+    elif arg == "+x":
+        __xonsh__.env["XONSH_TRACE_SUBPROC"] = False
+    else:
+        print(
+            "Not supported in xontrib bashisms.\nPRs are welcome - https://github.com/xonsh/xonsh/blob/master/xontrib/bashisms.py",
+            file=sys.stderr,
+        )
+
+
+aliases["set"] = _set
+
+
+def _shopt(args):
+
+    supported_shopt = ["DOTGLOB"]
+
+    args_len = len(args)
+    if args_len == 0:
+        for so in supported_shopt:
+            onoff = "on" if so in __xonsh__.env and __xonsh__.env[so] else "off"
+            print(f"dotglob\t{onoff}")
+        return
+    elif args_len < 2 or args[0] in ["-h", "--help"]:
+        print(f'Usage: shopt <-s|-u> <{"|".join(supported_shopt).lower()}>')
+        return
+
+    opt = args[0]
+    optname = args[1]
+
+    if opt == "-s" and optname == "dotglob":
+        __xonsh__.env["DOTGLOB"] = True
+    elif opt == "-u" and optname == "dotglob":
+        __xonsh__.env["DOTGLOB"] = False
+    else:
+        print(
+            "Not supported in xontrib bashisms.\nPRs are welcome - https://github.com/xonsh/xonsh/blob/master/xontrib/bashisms.py",
+            file=sys.stderr,
+        )
+
+
+aliases["shopt"] = _shopt
+
+
+aliases["complete"] = "completer list"


Test patch: