summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2004-09-21 12:07:12 +0000
committerPaul Smith <psmith@gnu.org>2004-09-21 12:07:12 +0000
commit704c60cec021d75164c8a7c34bcd667e45f184e3 (patch)
treef910a966cede38013d111434ecf8e08e6547acd3 /main.c
parent9714e501fb356adb043c77a3180a7f8c16c1484d (diff)
downloadgunmake-704c60cec021d75164c8a7c34bcd667e45f184e3.tar.gz
Remove sindex() and replace with strstr().
Windows: allow users to set SHELL to cmd.exe and have it behave as if no UNIX shell were found.
Diffstat (limited to 'main.c')
-rw-r--r--main.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/main.c b/main.c
index 13c3415..5cb387f 100644
--- a/main.c
+++ b/main.c
@@ -699,7 +699,8 @@ int
find_and_set_default_shell (char *token)
{
int sh_found = 0;
- char* search_token;
+ char *search_token;
+ char *tokend;
PATH_VAR(sh_path);
extern char *default_shell;
@@ -708,8 +709,25 @@ find_and_set_default_shell (char *token)
else
search_token = token;
- if (!no_default_sh_exe &&
- (token == NULL || !strcmp(search_token, default_shell))) {
+
+ /* If the user explicitly requests the DOS cmd shell, obey that request.
+ However, make sure that's what they really want by requiring the value
+ of SHELL either equal, or have a final path element of, "cmd" or
+ "cmd.exe" case-insensitive. */
+ tokend = search_token + strlen (search_token) - 3;
+ if (((tokend == search_token
+ || (tokend > search_token
+ && (tokend[-1] == '/' || tokend[-1] == '\\')))
+ && strcmpi (tokend, "cmd"))
+ || ((tokend - 4 == search_token
+ || (tokend - 4 > search_token
+ && (tokend[-5] == '/' || tokend[-5] == '\\')))
+ && strcmpi (tokend - 4, "cmd.exe"))) {
+ batch_mode_shell = 1;
+ unixy_shell = 0;
+ sh_found = 0;
+ } else if (!no_default_sh_exe &&
+ (token == NULL || !strcmp (search_token, default_shell))) {
/* no new information, path already set or known */
sh_found = 1;
} else if (file_exists_p(search_token)) {