Print commands as they're read from a file.

When using the "read" command, all commands executed are printed first,
so you can see what goes wrong, if anything.
This commit is contained in:
Daniel Beer 2010-10-12 11:53:46 +13:00
parent 4f1502d198
commit 6d888fff25
4 changed files with 9 additions and 4 deletions

2
main.c
View File

@ -327,7 +327,7 @@ static void process_rc_file(void)
snprintf(text, sizeof(text), "%s/.mspdebug", home);
if (!access(text, F_OK))
process_file(text);
process_file(text, 0);
}
static int add_fet_device(void *user_data, const struct fet_db_record *r)

View File

@ -187,7 +187,7 @@ int process_command(char *cmd)
return do_command(cmd, 0);
}
int process_file(const char *filename)
int process_file(const char *filename, int show)
{
FILE *in;
char buf[1024];
@ -211,6 +211,9 @@ int process_file(const char *filename)
if (*cmd == '#')
continue;
if (show)
printc("\x1b[1m=>\x1b[0m %s", cmd);
if (do_command(cmd, 0) < 0) {
printc_err("read: error processing %s (line %d)\n",
filename, line_no);

View File

@ -51,8 +51,10 @@ void reader_exit(void);
/* Commands can be fed directly to the processor either one at a time,
* or by specifying a file to read from.
*
* If show is non-zero, commands will be printed as they are executed.
*/
int process_command(char *cmd);
int process_file(const char *filename);
int process_file(const char *filename, int show);
#endif

View File

@ -240,7 +240,7 @@ int cmd_read(char **arg)
return -1;
}
return process_file(filename);
return process_file(filename, 1);
}
int cmd_exit(char **arg)