Skip to content

Commit ad2a946

Browse files
committed
skip /K if /D switch is present
This allows to bypass autoexec with F5/F8, even if it was passed via /K.
1 parent e56abc6 commit ad2a946

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/command.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4614,7 +4614,7 @@ int main(int argc, const char *argv[], const char *envp[])
46144614
shell_permanent = 1;
46154615
}
46164616

4617-
if (strnicmp(argv[a], "/E:", 3) == 0)
4617+
else if (strnicmp(argv[a], "/E:", 3) == 0)
46184618
{
46194619
unsigned new_size, old_size = get_env_size();
46204620

@@ -4631,17 +4631,17 @@ int main(int argc, const char *argv[], const char *envp[])
46314631
}
46324632
}
46334633

4634-
if (stricmp(argv[a], "/D") == 0)
4634+
else if (stricmp(argv[a], "/D") == 0)
46354635
{
46364636
disable_autoexec = 1;
46374637
}
46384638

4639-
if (stricmp(argv[a], "/Y") == 0)
4639+
else if (stricmp(argv[a], "/Y") == 0)
46404640
{
46414641
stepping = 1;
46424642
}
46434643

4644-
if (strnicmp(argv[a], "/M", 2) == 0)
4644+
else if (strnicmp(argv[a], "/M", 2) == 0)
46454645
{
46464646
int opt = 1;
46474647
char copt[2];
@@ -4667,15 +4667,18 @@ int main(int argc, const char *argv[], const char *envp[])
46674667
}
46684668

46694669
// check for command in arguments
4670-
if (stricmp(argv[a], "/K") == 0)
4670+
else if (stricmp(argv[a], "/K") == 0)
46714671
{
4672-
shell_mode = SHELL_STARTUP_WITH_CMD;
46734672
a++;
4674-
strncat(cmd_line, argv[a], MAX_CMD_BUFLEN-1);
4675-
parse_cmd_line();
4673+
if (!disable_autoexec)
4674+
{
4675+
shell_mode = SHELL_STARTUP_WITH_CMD;
4676+
strncat(cmd_line, argv[a], MAX_CMD_BUFLEN-1);
4677+
parse_cmd_line();
4678+
}
46764679
}
46774680

4678-
if (stricmp(argv[a], "/C") == 0)
4681+
else if (stricmp(argv[a], "/C") == 0)
46794682
{
46804683
int cmd_buf_remaining;
46814684

0 commit comments

Comments
 (0)