aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-10-03 02:52:15 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-11-23 07:45:24 -0500
commit1aae46422242677c6cc23438537b70444436e5ce (patch)
tree6938d321f96d97715fc63f19d1d3d2570b0e8e30 /src/nvim/option.c
parent43ec616414c7f17585e8b4a7e34acaaedfff5121 (diff)
downloadrneovim-1aae46422242677c6cc23438537b70444436e5ce.tar.gz
rneovim-1aae46422242677c6cc23438537b70444436e5ce.tar.bz2
rneovim-1aae46422242677c6cc23438537b70444436e5ce.zip
vim-patch:8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Problem: MS-Windows: shell commands fail if &shell contains a space. Solution: Use quotes instead of escaping. (closes vim/vim#4920) https://github.com/vim/vim/commit/2efc44b3f0b6bd8307cb281af095e08e15ab1c24 Always double-quote &shell if it contains a space. Neovim does not support escaping space with backslash, unlike Vim. N/A patches for version.c: vim-patch:8.0.1455: if $SHELL contains a space then 'shell' is incorrect Problem: If $SHELL contains a space then the default value of 'shell' is incorrect. (Matthew Horan) Solution: Escape spaces in $SHELL. (Christian Brabandt, closes vim/vim#459) https://github.com/vim/vim/commit/4bfa8af14142e54f509048239f4e8596911f56aa vim-patch:8.2.1194: test failure because shell prompt differs Problem: Test failure because shell prompt differs. Solution: Set the shell prompt. https://github.com/vim/vim/commit/a4dc6f92bb29b00783f8945bbe1101e837b6ad3c
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;
}
}