aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-03-05 18:18:25 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-03-05 18:18:25 +1300
commit967d0fd7f02a0f79cec5c0f45234846eff2803c5 (patch)
treea201c088c6bd17d4b57d95735a2ea464f34bf0d3
parentSpecify phony Make targets, reorder (diff)
downloadspsh-967d0fd7f02a0f79cec5c0f45234846eff2803c5.tar.gz
spsh-967d0fd7f02a0f79cec5c0f45234846eff2803c5.zip
More compatible environment passing
-rw-r--r--cmd.c2
-rw-r--r--loop.c4
-rw-r--r--main.c4
-rw-r--r--spsh.h7
4 files changed, 10 insertions, 7 deletions
diff --git a/cmd.c b/cmd.c
index aa29922..b428d58 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,7 +1,7 @@
#include "spsh.h"
/* Process a read line into a command and arguments and try to execute it */
-void cmd(char *line, char **environ) {
+void cmd(char *line) {
char *cmd, *cmd_arg;
pid_t pid;
int status, cmd_argc;
diff --git a/loop.c b/loop.c
index 6d68d50..bf0918c 100644
--- a/loop.c
+++ b/loop.c
@@ -1,7 +1,7 @@
#include "spsh.h"
/* Loop through reading commands until we see an EOF (^D) */
-void loop(char **environ) {
+void loop() {
char *line;
/* Loop until we break */
@@ -13,7 +13,7 @@ void loop(char **environ) {
/* If the line is valid, try to run it as a command */
if (line != NULL) {
if (strlen(line) > 0) {
- cmd(line, environ);
+ cmd(line);
}
}
diff --git a/main.c b/main.c
index a89b1b4..55b8b00 100644
--- a/main.c
+++ b/main.c
@@ -1,13 +1,13 @@
#include "spsh.h"
/* Entry function */
-int main(int argc, char *argv[], char **environ) {
+int main() {
/* Show the banner with the warning */
banner();
/* Start looping through commands */
- loop(environ);
+ loop();
/* If we get to this point, things should be good */
exit(EXIT_SUCCESS);
diff --git a/spsh.h b/spsh.h
index 301ddbc..e915fea 100644
--- a/spsh.h
+++ b/spsh.h
@@ -24,9 +24,12 @@
/* The token used to separate arguments */
#define ARG_DELIM " "
+/* Environment variables for this script */
+extern char **environ;
+
/* Function prototypes to soothe separate files */
void banner();
-void loop(char **environ);
-void cmd(char *line, char **environ);
+void loop();
+void cmd(char *line);
#endif