FreeCalypso > hg > fc-sim-tools
changeset 77:3fe1954f5dec
fc-simtool batch stdin mode implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 09 Apr 2021 02:46:01 +0000 |
parents | 526193acfb3f |
children | f6d5cff989d6 |
files | simtool/main.c |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/simtool/main.c Fri Apr 09 02:01:47 2021 +0000 +++ b/simtool/main.c Fri Apr 09 02:46:01 2021 +0000 @@ -11,7 +11,7 @@ { extern int optind; char command[512]; - int rc; + int rc, batch_stdin; parse_global_options(argc, argv); launch_backend(); @@ -29,13 +29,18 @@ printf("ATR: %s\n", be_atr_string); if (be_extra_info[0]) puts(be_extra_info); + batch_stdin = !isatty(0); for (;;) { - if (isatty(0)) { + if (!batch_stdin) { fputs("simtool> ", stdout); fflush(stdout); } if (!fgets(command, sizeof command, stdin)) good_exit(); - simtool_dispatch_cmd(command, 0); + if (batch_stdin) + printf("Stdin command: %s", command); + rc = simtool_dispatch_cmd(command, 0); + if (batch_stdin && rc) + exit(1); } }