aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/shell.c26
-rw-r--r--src/shell.h2
2 files changed, 18 insertions, 10 deletions
diff --git a/src/shell.c b/src/shell.c
index 8bc2e0b..f6f88d9 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -55,7 +55,7 @@ exec_args(int c, char **v)
55} 55}
56 56
57void 57void
58launch() 58launch(bool prompt)
59{ 59{
60 int i, shell_argc; 60 int i, shell_argc;
61 char line[MAXLINELEN], **shell_argv; 61 char line[MAXLINELEN], **shell_argv;
@@ -64,12 +64,15 @@ launch()
64 for (i = 0; i < MAXNTOKENS; i++) 64 for (i = 0; i < MAXNTOKENS; i++)
65 shell_argv[i] = malloc((MAXTOKENLEN+1) * sizeof(char)); 65 shell_argv[i] = malloc((MAXTOKENLEN+1) * sizeof(char));
66 66
67 fprintf(stderr, "Welcome to Nissy "VERSION".\n" 67 if (prompt) {
68 "Type \"commands\" for a list of commands.\n" 68 fprintf(stderr, "Welcome to Nissy "VERSION".\n"
69 ); 69 "Type \"commands\" for a list of commands.\n");
70 }
70 71
71 while (true) { 72 while (true) {
72 fprintf(stdout, "nissy-# "); 73 if (prompt) {
74 fprintf(stdout, "nissy-# ");
75 }
73 if (fgets(line, MAXLINELEN, stdin) == NULL) 76 if (fgets(line, MAXLINELEN, stdin) == NULL)
74 break; 77 break;
75 shell_argc = parseline(line, shell_argv); 78 shell_argc = parseline(line, shell_argv);
@@ -85,10 +88,15 @@ launch()
85int 88int
86main(int argc, char *argv[]) 89main(int argc, char *argv[])
87{ 90{
88 if (argc > 1) 91 if (argc > 1) {
89 exec_args(argc-1, &argv[1]); 92 if (!strcmp(argv[1], "-b")) {
90 else 93 launch(false);
91 launch(); 94 } else {
95 exec_args(argc-1, &argv[1]);
96 }
97 } else {
98 launch(true);
99 }
92 100
93 return 0; 101 return 0;
94} 102}
diff --git a/src/shell.h b/src/shell.h
index a72d136..bb85ba2 100644
--- a/src/shell.h
+++ b/src/shell.h
@@ -8,6 +8,6 @@
8#define MAXNTOKENS 255 8#define MAXNTOKENS 255
9 9
10void exec_args(int c, char **v); 10void exec_args(int c, char **v);
11void launch(); 11void launch(bool prompt);
12 12
13#endif 13#endif

Generated with cgit - Back to sebastiano.tronto.net