diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-04-12 03:21:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-12 03:21:21 +0200 |
commit | dd391bfca1f37093ba556f5da6a7f3eb81147fc0 (patch) | |
tree | 853aea222ea79998c63a0ef2e17e3e44101166e6 /src/nvim/os/env.c | |
parent | 2d72d85b23761383ac7838faed2f7b53bdce8817 (diff) | |
parent | 7c4e5dfd2722b8c25641cbbc66c5b0133d0e2f03 (diff) | |
download | rneovim-dd391bfca1f37093ba556f5da6a7f3eb81147fc0.tar.gz rneovim-dd391bfca1f37093ba556f5da6a7f3eb81147fc0.tar.bz2 rneovim-dd391bfca1f37093ba556f5da6a7f3eb81147fc0.zip |
Merge #6497 from justinmk/win-quot
win: system('...'): special-case cmd.exe
Diffstat (limited to 'src/nvim/os/env.c')
-rw-r--r-- | src/nvim/os/env.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 12c2da6152..ad51e598c1 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -1,11 +1,8 @@ -// env.c -- environment variable access +// Environment inspection #include <assert.h> - #include <uv.h> -// vim.h must be included before charset.h (and possibly others) or things -// blow up #include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/charset.h" @@ -919,3 +916,20 @@ bool os_term_is_nice(void) || NULL != os_getenv("KONSOLE_DBUS_SESSION"); #endif } + +/// Returns true if `sh` looks like it resolves to "cmd.exe". +bool os_shell_is_cmdexe(const char *sh) + FUNC_ATTR_NONNULL_ALL +{ + if (*sh == NUL) { + return false; + } + if (striequal(sh, "$COMSPEC")) { + const char *comspec = os_getenv("COMSPEC"); + return striequal("cmd.exe", (char *)path_tail((char_u *)comspec)); + } + if (striequal(sh, "cmd.exe") || striequal(sh, "cmd")) { + return true; + } + return striequal("cmd.exe", (char *)path_tail((char_u *)sh)); +} |