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:
parent
4f1502d198
commit
6d888fff25
2
main.c
2
main.c
|
@ -327,7 +327,7 @@ static void process_rc_file(void)
|
||||||
|
|
||||||
snprintf(text, sizeof(text), "%s/.mspdebug", home);
|
snprintf(text, sizeof(text), "%s/.mspdebug", home);
|
||||||
if (!access(text, F_OK))
|
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)
|
static int add_fet_device(void *user_data, const struct fet_db_record *r)
|
||||||
|
|
5
reader.c
5
reader.c
|
@ -187,7 +187,7 @@ int process_command(char *cmd)
|
||||||
return do_command(cmd, 0);
|
return do_command(cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_file(const char *filename)
|
int process_file(const char *filename, int show)
|
||||||
{
|
{
|
||||||
FILE *in;
|
FILE *in;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
@ -211,6 +211,9 @@ int process_file(const char *filename)
|
||||||
if (*cmd == '#')
|
if (*cmd == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (show)
|
||||||
|
printc("\x1b[1m=>\x1b[0m %s", cmd);
|
||||||
|
|
||||||
if (do_command(cmd, 0) < 0) {
|
if (do_command(cmd, 0) < 0) {
|
||||||
printc_err("read: error processing %s (line %d)\n",
|
printc_err("read: error processing %s (line %d)\n",
|
||||||
filename, line_no);
|
filename, line_no);
|
||||||
|
|
4
reader.h
4
reader.h
|
@ -51,8 +51,10 @@ void reader_exit(void);
|
||||||
|
|
||||||
/* Commands can be fed directly to the processor either one at a time,
|
/* Commands can be fed directly to the processor either one at a time,
|
||||||
* or by specifying a file to read from.
|
* 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_command(char *cmd);
|
||||||
int process_file(const char *filename);
|
int process_file(const char *filename, int show);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue