Table of Contents
Now that I am mostly done with my Final Year Project, I am looking at different projects to learn more about
Go is an open source programming language supported by Google which has concurrency built into it. To run a concurrent program in
Go, we just make use of the keyword
go func() to run it in parallel.
Go also have channels to help with communications between channels using the
chan keyword. This is a very powerful feature of
Go which I will be using in this project.
A good way to learn a new programming language is to make a project using it. I have decided to make a shell in
Go as it is a good way to learn the language and also to learn how to make concurrent programs.
What is a shell? #
A shell is a command line interface that allows us to interact with the operating system. It is a program that takes in commands and executes them. The most common shell is the
bash shell which is the default shell for most Linux distributions.
In this project, we will be making a basic subset of the
bash shell. We will be able to run commands like
exit. If there is additional time, we will add in some other commands for fun.
Goals of the project #
The goal of this project is to practice my
go programming skills to prepare myself for my full time job, which may require me to use
go. I will also be using this project to learn more about
go and how to use it to make concurrent programs.
We will implement the following:
- A basic shell that can run commands.
- Piping between commands.
- Running multiple commands in 1 time.
- Some basic commands for a shell.
Project Structure #
The project will be split into 3 main parts:
- The shell itself
- The commands that the shell will run
- The tests for the shell
To view the full code, you can visit the Github Repository.
The Shell #
As the scope of the project is small, the shall will just do the following:
- The shell will take in a command from the user.
- The shell will parse the command and split it into the command and the arguments.
- The shell will then check if the command is a built-in command.
- If it is a built-in command, the shell will run the command.
- If it is not a built-in command, the shell will check if the command is a valid executable.
- If it is a valid executable, the shell will run the command.
- If it is not a valid command, the shell will print an error message.