diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-04-12 01:35:17 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-04-12 02:28:43 +0200 |
commit | 7c4e5dfd2722b8c25641cbbc66c5b0133d0e2f03 (patch) | |
tree | 853aea222ea79998c63a0ef2e17e3e44101166e6 /src/nvim/os | |
parent | d31d177a0c2c9997c2cdb04975bc3354b9a23fb8 (diff) | |
download | rneovim-7c4e5dfd2722b8c25641cbbc66c5b0133d0e2f03.tar.gz rneovim-7c4e5dfd2722b8c25641cbbc66c5b0133d0e2f03.tar.bz2 rneovim-7c4e5dfd2722b8c25641cbbc66c5b0133d0e2f03.zip |
win: os_shell_is_cmdexe() + tests
Diffstat (limited to 'src/nvim/os')
-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)); +} |