28,7 → 28,7 |
#include <stdlib.h> |
#include <string.h> |
|
#include "svarlang.lib/svarlang.h" |
#include <process.h> |
|
#include "cmd.h" |
#include "env.h" |
153,16 → 153,9 |
/* FALLTHRU */ |
case 'k': /* /K = execute command and keep running */ |
case 'K': |
cmdline++; |
while (*cmdline == ' ') cmdline++; |
cfg->execcmd = cmdline; |
break; |
cfg->execcmd = cmdline + 1; |
return; |
|
case 'y': /* /Y = execute batch file step-by-step (with /P, /K or /C) */ |
case 'Y': |
cfg->flags |= FLAG_STEPBYSTEP; |
break; |
|
case 'd': /* /D = skip autoexec.bat processing */ |
case 'D': |
cfg->flags |= FLAG_SKIP_AUTOEXEC; |
191,7 → 184,6 |
nls_outputnl(1,4); /* "/P Makes the new command interpreter permanent and run AUTOEXEC.BAT" */ |
nls_outputnl(1,5); /* "/C Executes the specified command and returns" */ |
nls_outputnl(1,6); /* "/K Executes the specified command and continues running" */ |
nls_outputnl(1,7); /* "/Y Executes the batch program step by step" */ |
exit(1); |
break; |
|
464,7 → 456,6 |
|
/* fill the newly allocated batctx structure */ |
_fstrcpy(newbat->fname, cmdfile); /* truename of the BAT file */ |
newbat->flags = flags & FLAG_STEPBYSTEP; |
/* explode args of the bat file and store them in rmod buff */ |
cmd_explode(buff, cmdline, NULL); |
_fmemcpy(newbat->argv, buff, sizeof(newbat->argv)); |
845,12 → 836,10 |
flags &= ~DELETE_STDIN_FILE; |
} |
|
/* skip user input if I have a command to exec (/C or /K or /P) */ |
/* skip user input if I have a command to exec (/C or /K) */ |
if (cfg.execcmd != NULL) { |
cmdline = cfg.execcmd; |
cfg.execcmd = NULL; |
/* */ |
if (cfg.flags & FLAG_STEPBYSTEP) flags |= FLAG_STEPBYSTEP; |
goto EXEC_CMDLINE; |
} |
|
873,11 → 862,6 |
while (*cmdline == ' ') cmdline++; |
/* skip batch labels */ |
if (*cmdline == ':') continue; |
/* step-by-step execution? */ |
if (rmod->bat->flags & FLAG_STEPBYSTEP) { |
if (*cmdline == 0) continue; /* skip empty lines */ |
if (askchoice(cmdline, svarlang_str(0,10)) != 0) continue; |
} |
/* output prompt and command on screen if echo on and command is not |
* inhibiting it with the @ prefix */ |
if ((rmod->flags & FLAG_ECHOFLAG) && (cmdline[0] != '@')) { |
936,6 → 920,7 |
cmdres = cmd_process(rmod, *rmod_envseg, cmdline, BUFFER, sizeof(BUFFER), &redirprops, flags & DELETE_STDIN_FILE); |
if ((cmdres == CMD_OK) || (cmdres == CMD_FAIL)) { |
/* internal command executed */ |
continue; |
} else if (cmdres == CMD_CHANGED) { /* cmdline changed, needs to be reprocessed */ |
goto EXEC_CMDLINE; |
} else if (cmdres == CMD_CHANGED_BY_CALL) { /* cmdline changed *specifically* by CALL */ |
945,6 → 930,7 |
} else if (cmdres == CMD_NOTFOUND) { |
/* this was not an internal command, try matching an external command */ |
run_as_external(BUFFER, cmdline, *rmod_envseg, rmod, &redirprops, flags); |
flags &= ~CALL_FLAG; /* reset callflag to make sure it is processed only once */ |
|
/* is it a newly launched BAT file? */ |
if ((rmod->bat != NULL) && (rmod->bat->nextline == 0)) goto SKIP_NEWLINE; |
951,15 → 937,12 |
/* run_as_external() does not return on success, if I am still alive then |
* external command failed to execute */ |
nls_outputnl(0,5); /* "Bad command or file name" */ |
} else { |
continue; |
} |
|
/* I should never ever land here */ |
outputnl("INTERNAL ERR: INVALID CMDRES"); |
} |
|
/* reset one-time only flags */ |
flags &= ~CALL_FLAG; |
flags &= ~FLAG_STEPBYSTEP; |
|
/* repeat unless /C was asked - but always finish running an ongoing batch |
* file (otherwise only first BAT command would be executed with /C) */ |
} while (((rmod->flags & FLAG_EXEC_AND_QUIT) == 0) || (rmod->bat != NULL)); |