Cocoshell

   Following the suggestive name, this project was about making our own version of a shell.

   As mentioned in the previous project, I attended the 42 Lisbon coding school, which follows a learning by doing and peer-to-peer learning methodology. The syllabus consists of a series of challenges, and some of them are group projects, which was the case of “minishell”. In pairs, we ought to recreate a simplified version of BASH, in C. Our “minishell” was called “Cocoshell”.

   This was our first group assignment. My work partner and I proved to be a good team: we both were organised, believed in the importance of documenting the code well (and in the value of emojis in writing good documentation), were interested in coding different parts of the project, enjoyed reviewing and discussing each other’s additions in pull requests, and we were bound by friendship. As she once put it, coding with someone is accepting their OCDs (over-normalising and generalising the meaning of OCD) and we accepted each other’s pickiness on how to name functions and variables (the true challenges of coding) without blinking.

   The two biggest tasks of this project were to build the parser and the executer: my partner took the first challenge while I took the later. There were other smaller tasks to take into consideration, such as rewriting some commands like “cd”, “pwd” or “echo” (the idea being that if these commands were called our built-in version should be used, while if other commands were called the system version should be used), managing environment variables or handling signals. She started with the parser while I moved on with the built-in commands – this came in handy, as we were able to align on how the information ought to be transmitted from her part to mine. Then the moment came to face the executor. I had spoken with some friends at school, I had thought about the challenge, and an idea was formed and running in the back of my mind, in a smooth and organic way. So when I sit down to finally code the skeleton of the executor, in one afternoon the idea was turned into code. The description of this blissful moment is not here for show off (I do not even consider it worth showing off) – it is here because it was honestly one of my favourite moments while coding. This was just the structure, taking into consideration pipes and redirections. Other versions came along, more robust, taking into consideration the order of execution, error codes, waiting for parent processes and terminating child processes properly, incorporating heredocs – but the initial structure remained the same, proving to be a scalable and neat approach. For more technical details, check our read me and code in our GitHub repository.

   After multiple rounds of looking for edge cases, testing and increasing our shell’s resilience, we were very happy with our “Cocoshell”.

Continue exploring my projects