//svarcom/trunk/cmd/del.c |
---|
87,7 → 87,7 |
* confirmation set, ask for a global confirmation */ |
if ((confirmflag == 0) && (imatch(buff + pathlimit, "????????.???"))) { |
nls_outputnl(36,5); /* "All files in directory will be deleted!" */ |
if (askchoice(svarlang_str(36,6)/*"Are you sure (Y/N)?"*/, svarlang_str(0,10)/*"YN"*/) != 0) return(CMD_FAIL); |
if (askchoice(svarlang_str(36,6)/*"Are you sure?"*/, svarlang_str(0,10)/*"YN"*/) != 0) return(CMD_FAIL); |
} |
for (i = 0;; i = 1) { |
113,7 → 113,7 |
if (confirmflag) { |
output(buff); |
output(" \t"); |
if (askchoice(svarlang_str(36,7)/*"Delete (Y/N)?"*/, svarlang_str(0,10)) != 0) continue; |
if (askchoice(svarlang_str(36,7)/*"Delete?"*/, svarlang_str(0,10)) != 0) continue; |
} |
/* del found file */ |
//svarcom/trunk/cmd/ver.c |
---|
26,7 → 26,7 |
* ver |
*/ |
#define PVER "2022.1" |
#define PVER "2022.2" |
#define COPYRDATE "2021-2022" |
static enum cmd_result cmd_ver(struct cmd_funcparam *p) { |
//svarcom/trunk/command.c |
---|
28,7 → 28,7 |
#include <stdlib.h> |
#include <string.h> |
#include <process.h> |
#include "svarlang.lib/svarlang.h" |
#include "cmd.h" |
#include "env.h" |
153,9 → 153,16 |
/* FALLTHRU */ |
case 'k': /* /K = execute command and keep running */ |
case 'K': |
cfg->execcmd = cmdline + 1; |
return; |
cmdline++; |
while (*cmdline == ' ') cmdline++; |
cfg->execcmd = cmdline; |
break; |
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; |
184,6 → 191,7 |
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; |
456,6 → 464,7 |
/* 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)); |
836,10 → 845,12 |
flags &= ~DELETE_STDIN_FILE; |
} |
/* skip user input if I have a command to exec (/C or /K) */ |
/* skip user input if I have a command to exec (/C or /K or /P) */ |
if (cfg.execcmd != NULL) { |
cmdline = cfg.execcmd; |
cfg.execcmd = NULL; |
/* */ |
if (cfg.flags & FLAG_STEPBYSTEP) flags |= FLAG_STEPBYSTEP; |
goto EXEC_CMDLINE; |
} |
862,6 → 873,11 |
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] != '@')) { |
920,7 → 936,6 |
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 */ |
930,7 → 945,6 |
} 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; |
937,11 → 951,14 |
/* 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" */ |
continue; |
} else { |
/* I should never ever land here */ |
outputnl("INTERNAL ERR: INVALID CMDRES"); |
} |
/* 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) */ |
//svarcom/trunk/helpers.c |
---|
199,11 → 199,19 |
* in string. keys in c MUST BE UPPERCASE! */ |
unsigned short askchoice(const char *s, const char *c) { |
unsigned short res; |
char cstr[2] = {0,0}; |
char key = 0; |
AGAIN: |
output(s); |
output(" "); |
output("("); |
for (res = 0; c[res] != 0; res++) { |
if (res != 0) output("/"); |
cstr[0] = c[res]; |
output(cstr); |
} |
output(") "); |
_asm { |
push ax |
//svarcom/trunk/history.txt |
---|
3,6 → 3,11 |
=== SvarCOM's history / changelog === |
=== ver 2022.2 (xx.xx.xxxx) ================================================== |
- step-by-step execution of batch files (/Y) |
=== ver 2022.1 (28.02.2022) ================================================== |
- added GOTO support (jumps to a labelled line within a batch file) |
//svarcom/trunk/lang/en-utf8.txt |
---|
15,18 → 15,19 |
0.7:Required parameter missing |
0.8:Invalid destination |
# the message below MUST be a two-letter upper-case string for "Yes/No" keys |
# the message below MUST be a two-letter UPPER-CASE string for "Yes/No" keys |
# that user can press to answer interactive "Yes/No" questions |
0.10:YN |
# SVARCOM HELP SCREEN |
1.0:Starts the SvarCOM command interpreter |
1.1:COMMAND /E:nnn [/[C|K] [/P] [/D] command] |
1.1:COMMAND /E:nnn [/P] [/D] [/Y] [/[C|K] command] |
1.2:/D Skip AUTOEXEC.BAT processing (makes sense only with /P) |
1.3:/E:nnn Sets the environment size to nnn bytes |
1.4:/P Makes the new command interpreter permanent and run AUTOEXEC.BAT |
1.5:/C Executes the specified command and returns |
1.6:/K Executes the specified command and continues running |
1.7:/Y Executes the batch program step by step (only with /P, /K or /C) |
# VARIOUS SVARCOM MESSAGES |
2.0:SVARCOM VERSION CHANGED. SYSTEM HALTED. PLEASE REBOOT YOUR COMPUTER. |
206,8 → 207,8 |
36.3:[drive:][path]filename Specifies the file(s) to delete. |
36.4:/P Prompts for confirmation before deleting each file. |
36.5:All files in directory will be deleted! |
36.6:Are you sure (Y/N)? |
36.7:Delete (Y/N)? |
36.6:Are you sure? |
36.7:Delete? |
# DIR |
37.0:Displays a list of files and subdirectories in a directory. |
//svarcom/trunk/rmodinit.h |
---|
30,12 → 30,15 |
#define FLAG_ECHOFLAG 4 |
#define FLAG_ECHO_BEFORE_BAT 8 |
#define FLAG_SKIP_AUTOEXEC 16 |
#define FLAG_STEPBYSTEP 32 |
/* batch context structure used to track what batch file is being executed, |
* at what line, arguments, whether or not it has a parent batch... */ |
struct batctx { |
char fname[130]; /* truename of batch file being processed */ |
char argv[130]; /* args of the batch call (0-separated) */ |
unsigned char flags; /* used for step-by-step execution */ |
unsigned long nextline; /* offset in file of next bat line to process */ |
struct batctx far *parent; /* parent context if this batch was CALLed */ |
}; |
//svarcom/trunk/todo.txt |
---|
11,7 → 11,6 |
"FOR" command |
IF EXIST on an empty drive should not lead to the 'Abort, Retry, Fail' prompt |
CTRL+C should allow to abort a BAT file running in an infinite loop |
Step-by-step execution of batch programs |
=== MEDIUM PRIORITY ========================================================== |
26,7 → 25,7 |
=== NICE TO HAVE ============================================================= |
respawn COMMAND.COM entirely from memory if it survived last application |
translations could be cached in rmod-owned memory |
translations could be cached in rmod-owned memory (eg. with /P /MSG) |
DIR %DIRCMD% lookup |
COPY /V |
COPY /Y |