diff options
author | Scott Prager <splinterofchaos@gmail.com> | 2015-05-02 10:30:30 -0400 |
---|---|---|
committer | Scott Prager <splinterofchaos@gmail.com> | 2015-05-02 10:30:30 -0400 |
commit | 1c2c90ab0720784473805d20c359499a2d3d2ccf (patch) | |
tree | 8c4e587c91bbf91748c7ace6338aa3f609eaec0f /src/nvim/ex_docmd.c | |
parent | 205466830207a920c62146b7b689fac2e395431a (diff) | |
parent | 1eb33969220b267cf45adb286f0b7b6d14805eff (diff) | |
download | rneovim-1c2c90ab0720784473805d20c359499a2d3d2ccf.tar.gz rneovim-1c2c90ab0720784473805d20c359499a2d3d2ccf.tar.bz2 rneovim-1c2c90ab0720784473805d20c359499a2d3d2ccf.zip |
Merge pull request #2424 from splinterofchaos/term-no-sh
use an argument vector for termopen() / unify jobstart, termopen, and system
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index e81f99ccea..9ff19521b6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9410,9 +9410,22 @@ static void ex_folddo(exarg_T *eap) static void ex_terminal(exarg_T *eap) { - char cmd[512]; - snprintf(cmd, sizeof(cmd), ":enew%s | call termopen('%s') | startinsert", - eap->forceit==TRUE ? "!" : "", - strcmp((char *)eap->arg, "") ? (char *)eap->arg : (char *)p_sh); - do_cmdline_cmd((uint8_t *)cmd); + // We will call termopen() with ['shell'] if not given a {cmd}. + char *name = (char *)p_sh; + char *lquote = "['"; + char *rquote = "']"; + if (*eap->arg != NUL) { + name = (char *)vim_strsave_escaped(eap->arg, (char_u *)"\"\\"); + lquote = rquote = "\""; + } + + char ex_cmd[512]; + snprintf(ex_cmd, sizeof(ex_cmd), + ":enew%s | call termopen(%s%s%s) | startinsert", + eap->forceit==TRUE ? "!" : "", lquote, name, rquote); + do_cmdline_cmd((uint8_t *)ex_cmd); + + if (name != (char *)p_sh) { + xfree(name); + } } |