From 427c89a65345341e8d6b2f548307a38b047e5610 Mon Sep 17 00:00:00 2001 From: Samantha Boyer Date: Mon, 10 Oct 2022 17:16:06 -0500 Subject: [PATCH 1/8] Added last name --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 024bf96..eea36c6 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Pish # # Authors: Gregory -# Samantha +# Samantha Boyer # Readme: README.md # From 0ee8a944c456955ba321eb8ff90d0f30fa558c2d Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Mon, 10 Oct 2022 18:50:32 -0500 Subject: [PATCH 2/8] Cleaned up README file --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index ae5845e..ce7378f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ # Pish A simple bash shell implemented in C. + +# Authors: +Gregory Crawford +Samantha Boyer + + +# Instructions +## Compiling +Run `make` in the base folder +Program is then compiled into bin/ + +## Running +Run `pish` in bin/ to run the program \ No newline at end of file From e314d06c21b14e94c4913d8390477094f8517215 Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Mon, 10 Oct 2022 18:51:12 -0500 Subject: [PATCH 3/8] Moved info to README and removed program autorun --- Makefile | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index eea36c6..019fca5 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,13 @@ -# -# Pish -# -# Authors: Gregory -# Samantha Boyer -# Readme: README.md -# +INC := -I include all: main exec main: - gcc -c -o build/main.o src/main.c + gcc $(INC) -c -o build/main.o src/main.c + gcc $(INC) -c -o build/Pish.o src/Pish.c exec: gcc -o bin/pish build/*.o - ./bin/pish clean: rm build/* From 31b5a5cbb5cf92b238b1d8016dc88cb4dfe5ee7c Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Mon, 10 Oct 2022 18:55:22 -0500 Subject: [PATCH 4/8] Added base Pish from slides and fixed Makefile --- Makefile | 2 +- bin/pish | Bin 15952 -> 0 bytes include/.keep | 0 include/Pish.h | 8 ++++++++ src/Pish.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/main.c | 4 ++-- 6 files changed, 53 insertions(+), 3 deletions(-) delete mode 100755 bin/pish create mode 100644 include/.keep create mode 100644 include/Pish.h create mode 100644 src/Pish.c diff --git a/Makefile b/Makefile index 019fca5..c749080 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ main: gcc $(INC) -c -o build/Pish.o src/Pish.c exec: - gcc -o bin/pish build/*.o + gcc -o bin/pish.out build/*.o clean: rm build/* diff --git a/bin/pish b/bin/pish deleted file mode 100755 index c7013705b65f95be3a4062aa71e49eca16509257..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15952 zcmeHOYit}>6~4QU6Ne=BI!&nKKsR1}8C&EkL4-$KJ8MXdmwG zEU^m(LntC@gN%^c3Xp(btwcfn!4Fpg;VMuH5~z{*5kN>GA}Ez0IHjNfBEva%&bJv4 z>qM#$Ql+`l?sw1QJNM3+JF|Co?)_|fbSNH+DU>?(e#O#M!q=q4u+l9Rf|Tk}yXd=3 z9Z*|I-lBEBJ>>&g{cBIkn<(d%$TP zm-aS052oZFDCt!PbJ^+cu7kNudoEk3EVeK9bhmeRCCkO+A>A> zCx#mVy+4k8!z-fSMk2;CVnrBbAj&|LfhYq}2BHi^8Hh6Q=Fh-in-2WbJoBdp^YQv$ zA5_YGY|V{(ub5|k+;CnWoOk4Fq<+nN*VhS}+7$cGv*oo{fA4wT3d>~uuC@*;Z6~=B zlso@Ca`wW<&9j%yGk;hgn@D%Ab^gpe*ZXsd;_W>}p0Cd)o7%ph+avuFY0Pu=C5EFn z+`ZJbZmv_;wtJVF+Lqbzyde3HX#XSq3=iBi&#s#F%Kb^%9`L zyENO>M*Rez`@h`FW>tC5qf&^YPw4l5lk&9p}{yeZ5rwJCb7$5qAUs z)zf6;K$FCyo@c`Zze>A@s@%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Q z{&-%+P2l`1Lp%k;?S=WjAon02^D|(Vgad^6zYXzC!}kO}2cjUx57bwvLd#F9d$;g> zhy9OXf5^b=#BB=j@%*>ePD(29^QBud^#3LUk6k?XVBU)Ttk}28*B=+~kk{{!j`IgT z=CP{>*_+nY`cVA_AGnpsLB2|fYln|$2LZr?ypzbRL;INDC4?XL=eB~SS=tx(stNpi zs~W!oeh{l;FW}oF0jH#6ZzmhgdaL=vePui8(DwjcJ} +#include +#include +#include +#include "Pish.h" + +// Dummy function for Pish to run +char* getcmd(void) +{ + ; +} + +// Dummy function for Pish to run +void exec(char* command) +{ + ; +} + + + +void Pish(void) +{ + while (1) + { + char *cmd = getcmd(); + int retval = fork(); + if (retval == 0) + { + // This is the child process + // Setup the child's process environment here + // E.g., where is standard I/O, how to handle signals? + exec(cmd); + // exec does not return if it succeeds + printf("ERROR: Could not execute %s\n", cmd); + exit(1); + } else { + // This is the parent process; Wait for the child to finish + int pid = retval; + wait(pid); + } + } +} diff --git a/src/main.c b/src/main.c index 49d012e..3b80286 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ -#include +#include "Pish.h" int main() { - printf("Hello world\n"); + Pish(); } From 0e2f915c5058761b02c6680b25256b83d34f5a87 Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Wed, 19 Oct 2022 21:14:59 -0500 Subject: [PATCH 5/8] Adjusted naming --- src/Pish.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Pish.c b/src/Pish.c index 576a2e7..a1f5d20 100644 --- a/src/Pish.c +++ b/src/Pish.c @@ -5,7 +5,7 @@ #include "Pish.h" // Dummy function for Pish to run -char* getcmd(void) +char* getInput(void) { ; } @@ -22,18 +22,22 @@ void Pish(void) { while (1) { - char *cmd = getcmd(); + char* command = getInput(); int retval = fork(); + // Child if (retval == 0) { // This is the child process // Setup the child's process environment here // E.g., where is standard I/O, how to handle signals? - exec(cmd); + exec(command); // exec does not return if it succeeds - printf("ERROR: Could not execute %s\n", cmd); + printf("ERROR: Could not execute %s\n", command); exit(1); - } else { + } + // Parent + else + { // This is the parent process; Wait for the child to finish int pid = retval; wait(pid); From 098d645eef7b829ef63b739fbecc4d06648df1bb Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Wed, 19 Oct 2022 21:44:28 -0500 Subject: [PATCH 6/8] Added Integrated.c for integrated commands --- include/Integrated.h | 6 ++++++ src/Integrated.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 include/Integrated.h create mode 100755 src/Integrated.c diff --git a/include/Integrated.h b/include/Integrated.h new file mode 100755 index 0000000..fe2509b --- /dev/null +++ b/include/Integrated.h @@ -0,0 +1,6 @@ +#ifndef INTEGRATED_H +#define INTEGRATED_H + +void IntegratedCheck(char* command); + +#endif \ No newline at end of file diff --git a/src/Integrated.c b/src/Integrated.c new file mode 100755 index 0000000..00103c8 --- /dev/null +++ b/src/Integrated.c @@ -0,0 +1,14 @@ +#include +#include "Integrated.h" + +// Checks for commands that are built into Pish +void IntegratedCheck(char* command) +{ + if (command == "exit") + exit(0); + // If there is an argument, change to argument location + // Else, change to home directory + if (command[0] == 'c' && command[1] == 'd') + ; + return; +} \ No newline at end of file From 7cfdc280cfeed37dca48ba990bc1ad6a5a72bc2c Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Wed, 19 Oct 2022 21:45:01 -0500 Subject: [PATCH 7/8] Added Integrated.c to Makefile --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index c749080..ed958b4 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ all: main exec main: gcc $(INC) -c -o build/main.o src/main.c + gcc $(INC) -c -o build/Integrated.o src/Integrated.c gcc $(INC) -c -o build/Pish.o src/Pish.c exec: From f3f0a2cbf21d0ab01e9d7b1ce056bfb689327764 Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Wed, 19 Oct 2022 21:46:44 -0500 Subject: [PATCH 8/8] Adjusted comments and added temporary tests for functions --- src/Pish.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Pish.c b/src/Pish.c index a1f5d20..cac9605 100644 --- a/src/Pish.c +++ b/src/Pish.c @@ -2,28 +2,31 @@ #include #include #include +#include "Integrated.h" #include "Pish.h" -// Dummy function for Pish to run +// Prints a prompt and then reads a command from the terminal char* getInput(void) { - ; + return "echo hello world"; } -// Dummy function for Pish to run +// Executes a command to the system void exec(char* command) { - ; + system(command); } - - +// Main function for Pish program void Pish(void) { + char* command; + int retval; while (1) { - char* command = getInput(); - int retval = fork(); + command = getInput(); + IntegratedCheck(command); + retval = fork(); // Child if (retval == 0) { @@ -42,5 +45,7 @@ void Pish(void) int pid = retval; wait(pid); } + // TODO: Remove break when while loop doesn't break program + break; } }