Skip to content

Commit

Permalink
skip /K if /D switch is present
Browse files Browse the repository at this point in the history
This allows to bypass autoexec with F5/F8, even if it was passed
via /K.
  • Loading branch information
stsp committed Jan 15, 2025
1 parent e56abc6 commit ad2a946
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -4614,7 +4614,7 @@ int main(int argc, const char *argv[], const char *envp[])
shell_permanent = 1;
}

if (strnicmp(argv[a], "/E:", 3) == 0)
else if (strnicmp(argv[a], "/E:", 3) == 0)
{
unsigned new_size, old_size = get_env_size();

Expand All @@ -4631,17 +4631,17 @@ int main(int argc, const char *argv[], const char *envp[])
}
}

if (stricmp(argv[a], "/D") == 0)
else if (stricmp(argv[a], "/D") == 0)
{
disable_autoexec = 1;
}

if (stricmp(argv[a], "/Y") == 0)
else if (stricmp(argv[a], "/Y") == 0)
{
stepping = 1;
}

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

// check for command in arguments
if (stricmp(argv[a], "/K") == 0)
else if (stricmp(argv[a], "/K") == 0)
{
shell_mode = SHELL_STARTUP_WITH_CMD;
a++;
strncat(cmd_line, argv[a], MAX_CMD_BUFLEN-1);
parse_cmd_line();
if (!disable_autoexec)
{
shell_mode = SHELL_STARTUP_WITH_CMD;
strncat(cmd_line, argv[a], MAX_CMD_BUFLEN-1);
parse_cmd_line();
}
}

if (stricmp(argv[a], "/C") == 0)
else if (stricmp(argv[a], "/C") == 0)
{
int cmd_buf_remaining;

Expand Down

0 comments on commit ad2a946

Please sign in to comment.