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 #4920)
diff --git a/src/option.c b/src/option.c
index 3d40814..75ff3cd 100644
--- a/src/option.c
+++ b/src/option.c
@@ -102,7 +102,26 @@
|| ((p = (char_u *)default_shell()) != NULL && *p != NUL)
#endif
)
+#if defined(MSWIN)
+ {
+ // For MS-Windows put the path in quotes instead of escaping spaces.
+ char_u *cmd;
+ size_t len;
+
+ if (vim_strchr(p, ' ') != NULL)
+ {
+ len = STRLEN(p) + 3; // two quotes and a trailing NUL
+ cmd = alloc(len);
+ vim_snprintf((char *)cmd, len, "\"%s\"", p);
+ set_string_default("sh", cmd);
+ vim_free(cmd);
+ }
+ else
+ set_string_default("sh", p);
+ }
+#else
set_string_default_esc("sh", p, TRUE);
+#endif
#ifdef FEAT_WILDIGN
/*