r/programming • u/[deleted] • Jan 16 '15
Tutorial - Write a Shell in C
http://stephen-brennan.com/2015/01/16/write-a-shell-in-c/
28
Upvotes
5
u/exneo002 Jan 17 '15
We did something just like this in OS class. We got as far as pipes and redirects.
1
u/kennydude Jan 17 '15
People in my OS class did not get that far. Enough people struggled just to get commands + arguments to work
1
u/exneo002 Jan 17 '15
Our professor was kind enough to walk us through it. He also gave us some starter code amd all the includes we'd need. Made learning the shell much easier.
1
u/erkz78 Jan 18 '15
Minor bug with that malloc call:
char **tokens = malloc(bufsize * sizeof(char));
This should be:
char **tokens = malloc(bufsize sizeof(char))
2
u/[deleted] Jan 16 '15
I wrote this myself and I wanted to see what people thought of it (hope that's not against the rules!). Let me know what you think.