From 936794a863822878caa29bd7847cd5248796932f Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 14 Dec 2021 16:23:19 +0100 Subject: Better output in batch mode --- nissy | Bin 188520 -> 188520 bytes src/shell.c | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/nissy b/nissy index 4041688..d853e7f 100755 Binary files a/nissy and b/nissy differ diff --git a/src/shell.c b/src/shell.c index f6f88d9..5fb18bc 100644 --- a/src/shell.c +++ b/src/shell.c @@ -55,7 +55,7 @@ exec_args(int c, char **v) } void -launch(bool prompt) +launch(bool batchmode) { int i, shell_argc; char line[MAXLINELEN], **shell_argv; @@ -64,18 +64,27 @@ launch(bool prompt) for (i = 0; i < MAXNTOKENS; i++) shell_argv[i] = malloc((MAXTOKENLEN+1) * sizeof(char)); - if (prompt) { + if (!batchmode) { fprintf(stderr, "Welcome to Nissy "VERSION".\n" "Type \"commands\" for a list of commands.\n"); } while (true) { - if (prompt) { + if (!batchmode) { fprintf(stdout, "nissy-# "); } + if (fgets(line, MAXLINELEN, stdin) == NULL) break; + + if (batchmode) { + printf(">>>\n" + ">>> Executing command: %s" + ">>>\n", line); + } + shell_argc = parseline(line, shell_argv); + if (shell_argc > 0) exec_args(shell_argc, shell_argv); } @@ -90,12 +99,12 @@ main(int argc, char *argv[]) { if (argc > 1) { if (!strcmp(argv[1], "-b")) { - launch(false); + launch(true); } else { exec_args(argc-1, &argv[1]); } } else { - launch(true); + launch(false); } return 0; -- cgit v1.3