Repository: xonsh/xonsh

Issue:
xonsh breaks the argv parsing of sudo du -hs dirname
## xonfig

```
+------------------+-----------------+
| xonsh            | 0.9.4           |
| Python           | 3.7.3           |
| PLY              | 3.11            |
| have readline    | True            |
| prompt toolkit   | 2.0.9           |
| shell type       | prompt_toolkit2 |
| pygments         | 2.4.2           |
| on posix         | True            |
| on linux         | True            |
| distro           | arch            |
| 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 |
+------------------+-----------------+
```

## Expected Behavior
```
bash

$ du -hs ubuntu-disco/
du: cannot read directory 'ubuntu-disco/etc/ssl/private': Permission denied
du: cannot read directory 'ubuntu-disco/root': Permission denied
du: cannot read directory 'ubuntu-disco/var/cache/ldconfig': Permission denied
du: cannot read directory 'ubuntu-disco/var/spool/cron/crontabs': Permission denied
du: cannot read directory 'ubuntu-disco/var/spool/rsyslog': Permission denied
328M	ubuntu-disco/

$ sudo du -hs ubuntu-disco/
328M	ubuntu-disco/
```

## Current Behavior
```
xonsh

$ du -hs ubuntu-disco/                                                                                                                                                           
/usr/bin/du: cannot read directory 'ubuntu-disco/etc/ssl/private': Permission denied
/usr/bin/du: cannot read directory 'ubuntu-disco/root': Permission denied
/usr/bin/du: cannot read directory 'ubuntu-disco/var/cache/ldconfig': Permission denied
/usr/bin/du: cannot read directory 'ubuntu-disco/var/spool/cron/crontabs': Permission denied
/usr/bin/du: cannot read directory 'ubuntu-disco/var/spool/rsyslog': Permission denied
328M	ubuntu-disco/

$ sudo du -hs ubuntu-disco/                                                                                                                                                      
usage: cmd [-h] [-v]
cmd: error: argument -h/--help: ignored explicit argument 's'

$ sudo du -h -s ubuntu-disco/                                                                                                                                                    
328M	ubuntu-disco/
```

## Steps to Reproduce
xonsh somehow breaks or mangles the argv parsing of `sudo du -hs dirname`.

```
env 

BASH_COMPLETIONS=/usr/share/bash-completion/bash_completion
XONSH_VERSION=0.9.4
SHELL=/bin/bash
COLORTERM=truecolor
XDG_MENU_PREFIX=gnome-
TERMINATOR_DBUS_PATH=/net/tenshu/Terminator2
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
DESKTOP_SESSION=gnome
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=gnome
XDG_SESSION_TYPE=wayland
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
GDM_LANG=en_US.UTF-8
LANG=en_US.UTF-8
XDG_CURRENT_DESKTOP=GNOME
VTE_VERSION=5603
WAYLAND_DISPLAY=wayland-0
GJS_DEBUG_OUTPUT=stderr
XDG_SESSION_CLASS=user
TERM=xterm-256color
DISPLAY=:0
SHLVL=0
XDG_VTNR=2
XDG_SESSION_ID=1
MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
XDG_RUNTIME_DIR=/run/user/1000
XDG_DATA_DIRS=/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
GDMSESSION=gnome
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
HG=/usr/bin/hg
GIO_LAUNCHED_DESKTOP_FILE=/usr/share/applications/terminator.desktop
_=/usr/bin/xonsh
LOADED_RC_FILES=False,False,True
EDITOR=nvim
VISUAL=nvim
DIFFPROG=nvim -d
SUPPRESS_BRANCH_TIMEOUT_MESSAGE=1
VC_BRANCH_TIMEOUT=0.2
VC_HG_SHOW_BRANCH=
SHELL_TYPE=prompt_toolkit2
XONSH_LOGIN=1
XONSH_INTERACTIVE=True
XONSH_DEBUG=0
```

```
cat $HOME/.xonshrc

$EDITOR = 'nvim'
$VISUAL = 'nvim'
$DIFFPROG = 'nvim -d'
$SUPPRESS_BRANCH_TIMEOUT_MESSAGE = True
$VC_BRANCH_TIMEOUT *= 2
$VC_HG_SHOW_BRANCH = False

aliases['ll'] = 'ls -l'
aliases['llh'] = 'ls -lh'
aliases['la'] = 'ls -la'
aliases['lah'] = 'ls -lah'
aliases['rmr'] = 'rm -R --'
aliases['rmrf'] = 'rm -Rf --'
aliases['vim'] = 'nvim'


def _mkcd(args, stdin=None):
    mkdir -p @(args[0]) and cd @(args[0])


aliases['mkcd'] = _mkcd
```


Discussion:
```
$ which du                                                                                                                                                                       
/usr/bin/du

$ file /usr/bin/du                                                                                                                                                               
/usr/bin/du: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=20398eb0cfca2f9f3b7d7fbbf051441695d6a199, stripped

$ which sudo                                                                                                                                                                     
/usr/bin/sudo

$ file /usr/bin/sudo                                                                                                                                                             
/usr/bin/sudo: setuid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=4f1a3bf1a49f6aec7ec0176f2a9c27eab4636edb, stripped
```
Weird, thanks for reporting!

Resolving patch:
diff --git a/xonsh/commands_cache.py b/xonsh/commands_cache.py
--- a/xonsh/commands_cache.py
+++ b/xonsh/commands_cache.py
@@ -380,9 +380,9 @@ def predict_shell(args):
 @lazyobject
 def HELP_VER_PREDICTOR_PARSER():
     p = argparse.ArgumentParser("cmd", add_help=False)
-    p.add_argument("-h", "--help", dest="help", action="store_true", default=None)
+    p.add_argument("-h", "--help", dest="help", nargs="?", action="store", default=None)
     p.add_argument(
-        "-v", "-V", "--version", dest="version", action="store_true", default=None
+        "-v", "-V", "--version", dest="version", nargs="?", action="store", default=None
     )
     return p
 


Test patch: