A basic command line Unix shell written as an attempt to maximize memory efficiency.
- MESH takes an input line (interactive = "stdin", batch = "File* Stream) dynamically increasing the buffer size until the end of the line.
- MESH then parses the input line into separate c strings for each command.
- MESH next parses the commands into an array of c strings that are separated by each argument.
- MESH finally uses a custom forker to fork and simultaneously execute each command on the original line
- The forker also checks for the exit/quit command and sends a signal back to main program to exit once all commands are executed.
- MESH then loops until "exit","quit", or EOF are called.
- "CTRL+D" is counted by the system as an manual EOF so the program also exits then as well.
- Frees any remaining dynamic pointers and returns "0".
- The dynamic buffers are reallocated once all changes are completed for them, so as to not take any extra space.
- The dynamic buffers act as vectors when resizing themselves, starting at chunks of 8 of specific types.
- "execvp" was used as the executor as to auto include "$PATH" elements.
- incorrect number of arguments for the program indicates, "Too many arguments" and Exits the program.
- empty inputs and extra whitespace are removed at parsing and are not forked or executed.
- As "strtok()" function used in parsing does not declare new dynamic memory they are freed along with original input buffer at exiting program.
Requires preferably POSIX compliant system and gcc
Use the Makefile provided to compile the code to an executable.
makeTo enter 'interactive mode' directly call the executable
./meshTo use 'batch mode' call the executable with a singular file as a argument
./mesh foobarTo exit the program enter into the shell 'exit' or 'quit' as a command
READY > exit- Interactive & Batch Modes
- Multiple Commands via seperators ";","|", and "&"
- Simultaneous execution of multi-commands
- Defensive Programming with multiple error checks
- Unrestricted limit of characters via dynamic memory allocation
- Messages to "stderr" for multiple arguments in execution
- Makefile made.
- Readme created via Github Markdown.
- Runs normally on cs2 server.
When echoing the command line from batch files the last line will print after the commands are executed.