aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-11-23 09:19:11 -0500
committerGitHub <noreply@github.com>2020-11-23 09:19:11 -0500
commitb155e6b54c6087fac57ea4278a3431ced7bfc7f6 (patch)
tree2060bc9e28c805bc31fa805334e8ab5139eea4e1 /src/nvim/option.c
parent029b5d036d7eb5a16b8e3a1d37f05f92ecf40499 (diff)
parentdd3583836b80e8eccd483d41125aa24f63d2f038 (diff)
downloadrneovim-b155e6b54c6087fac57ea4278a3431ced7bfc7f6.tar.gz
rneovim-b155e6b54c6087fac57ea4278a3431ced7bfc7f6.tar.bz2
rneovim-b155e6b54c6087fac57ea4278a3431ced7bfc7f6.zip
Merge pull request #11148 from janlazo/vim-8.0.1455
vim-patch:8.0.1455,8.1.{2115,2361}
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 146bce8cc0..6149331763 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -652,7 +652,14 @@ void set_init_1(bool clean_arg)
{
const char *shell = os_getenv("SHELL");
if (shell != NULL) {
- set_string_default("sh", (char *) shell, false);
+ if (vim_strchr((const char_u *)shell, ' ') != NULL) {
+ const size_t len = strlen(shell) + 3; // two quotes and a trailing NUL
+ char *const cmd = xmalloc(len);
+ snprintf(cmd, len, "\"%s\"", shell);
+ set_string_default("sh", cmd, true);
+ } else {
+ set_string_default("sh", (char *)shell, false);
+ }
}
}
@@ -987,10 +994,9 @@ static void set_string_default(const char *name, char *val, bool allocated)
xfree(options[opt_idx].def_val[VI_DEFAULT]);
}
- options[opt_idx].def_val[VI_DEFAULT] = (char_u *) (
- allocated
- ? (char_u *) val
- : (char_u *) xstrdup(val));
+ options[opt_idx].def_val[VI_DEFAULT] = allocated
+ ? (char_u *)val
+ : (char_u *)xstrdup(val);
options[opt_idx].flags |= P_DEF_ALLOCED;
}
}