Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xterm/x11 strategy failing due to xterm which parses arguments badly argument parsing #343

Open
simlei opened this issue Jul 29, 2023 · 1 comment

Comments

@simlei
Copy link

simlei commented Jul 29, 2023

Hi tpope,

I encountered today a confusing behavior of the x11 dispatch strategy. The upside is, it's rather not the fault of vim-dispatch. The bad news is, this is the xterm delivered by default to my Ubuntu 20.04 (yeah I need to upgrade ^_^).

The rundown:

I'm configuring dispatch like this, so that spawn chooses X11 as strategy.

let g:dispatch_terminal_exec="xterm"
let g:dispatch_no_tmux_spawn=1
let g:dispatch_no_job_spawn=1
let g:dispatch_no_terminal_spawn=1
let g:dispatch_no_gnuscreen_spawn=1

I do :Spawn env.

Nothing happens but an :echo telling me the process was spawned.

I trace down this behavior; I'm arriving at vim-dispatch/autoload/dispatch/x11.vim / function! dispatch#x11#spawn. It has a system(...) call at the end. I inspect the argument to that system call. It is:

xterm /bin/bash -c 'printf '\''\033]1;%s\007\033]2;%s\007'\'' newvim '\''/home/snuc/sandbox/vimrefactor/layer-simlei-base/vim-bin/newvim -c '\''\'\'''\''Messages'\''\'\'''\'''\''; echo $$ > /tmp/nvim.snuc/k2Rzj2/2.pid; sync; perl -e "select(undef,undef,undef,0.1)" 2>/dev/null; /home/snuc/sandbox/vimrefactor/layer-simlei-base/vim-bin/newvim -c '\''Messages'\''; test $? = 0 -o $? = 130 || (printf '\''^[[1m--- Press ENTER to continue ---^[[0m\n'\''; exec head -1); touch /tmp/nvim.snuc/k2Rzj2/2.complete' &

I run this command manually in a terminal. It's output is:

snuc@snuc-NUC8i7BEH:~$ xterm: ambiguous option "-cr" vs "-cc"
xterm: bad command line option "/bin/bash"

usage:  xterm [-/+132] [-C] [-Sccn] [-T string] [-/+ah] [-/+ai] [-/+aw]
    [-b number] [-baudrate rate] [-/+bc] [-bcf milliseconds]
    [-bcn milliseconds] [-bd color] [-/+bdc] [-bg color] [-bw number] [-/+cb]
    [-cc classrange] [-/+cjk_width] [-class string] [-/+cm] [-/+cn] [-cr color]
    [-/+cu] [-/+dc] [-display displayname] [-e command args ...] [-fa pattern]
    [-fb fontname] [-/+fbb] [-/+fbx] [-fd pattern] [-fg color] [-fi fontname]
    [-fn fontname] [-fs size] [-/+fullscreen] [-fw fontname] [-fwb fontname]
    [-fx fontname] [%geom] [#geom] [-geometry geom] [-help] [-/+hm] [-/+hold]
    [-iconic] [-/+ie] [-/+im] [-into windowId] [-/+itc] [-/+j] [-/+k8]
    [-kt keyboardtype] [-/+l] [-/+lc] [-lcc path] [-leftbar] [-lf filename]
    [-/+ls] [-/+maximized] [-/+mb] [-mc milliseconds] [-/+mesg] [-/+mk_width]
    [-ms color] [-n string] [-name string] [-nb number] [-/+nul] [-/+pc]
    [-/+pob] [-report-charclass] [-report-colors] [-report-fonts]
    [-report-icons] [-report-xres] [-rightbar] [-/+rv] [-/+rvc] [-/+rw] [-/+s]
    [-/+samename] [-/+sb] [-selbg color] [-selfg color] [-/+sf] [-sh number]
    [-/+si] [-/+sk] [-sl number] [-/+sm] [-/+sp] [-/+t] [-ti termid]
    [-title string] [-tm string] [-tn name] [-/+u8] [-/+uc] [-/+ulc] [-/+ulit]
    [-/+ut] [-/+vb] [-version] [-/+wc] [-/+wf] [-xrm resourcestring]
    [-ziconbeep percent]

and it's not terminating by itself, i.e. I have to <C-c> to get to my prompt. weird.

XTerm version:

snuc@snuc-NUC8i7BEH:~$ xterm -v
XTerm(353)
xterm is already the newest version (353-1ubuntu1.20.04.2).

I inspect the xterm man page. It says, it inspects /etc/shells to see whether one leading non-option argument is in it. In this case, it should find /bin/bash, stop trying to read options and pass the following arguments to it.
However, that's not what it does according to it's output; it seems to try to match the -c to it's list of option flags.

A shame :(
Just want to report this. I'm working around this myself now by writing the argument to the system(...) call to a temporary executable file and telling xterm to run that.
Let me know if you're interested in a pull request of that workaround.

Cheers,
a fan.

simlei added a commit to simlei/vim-dispatch that referenced this issue Jul 29, 2023
simlei added a commit to simlei/vim-dispatch that referenced this issue Jul 29, 2023
@simlei
Copy link
Author

simlei commented Jul 29, 2023

Here is what I've done and what now works for me:
simlei@c580099

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant