This repository contains the source code and documentation for MyShell, a simple Linux shell developed using C programming language.
- Introduction
- Features
- Installation
- Usage
- Commands
- Implementation Details
- Makefile
- Contributing
- Release Notes:
- License
- Contact
- Co-Authors
MyShell is a simple command line interpreter that mimics the functionality of a standard Linux shell. It supports several internal commands and introduces a unique custom command for additional functionality.
MyShell supports the following internal commands:
mycd <directory>
: Change the current directory to<directory>
. Reports the current directory if<directory>
is not provided. Reports an error if the directory does not exist.myclr
: Clears the screen.mydir <directory>
: Lists the contents of<directory>
.myenviron
: Lists all environment strings.myecho <comment>
: Displays<comment>
followed by a new line.myhelp
: Displays the user manual using the standardmore
filter.mypause
: Pauses the shell until 'Enter' is pressed.myquit
: Quits the shell.myone
: A custom command providing unique functionality not found in standard Linux commands.
Additionally, the command line prompt contains the pathname of the current directory.
To install MyShell,navigate to your desired directory in Linux and follow these steps:
- Clone the repository:
git clone https://github.com/Lite30/linux-shell-c.git cd linux-shell-c
- Compile the source code using the provided Makefile by entering:
make
- To use the shell simply enter
./myshell
in the terminal and a welcome screen should appear.
Internal Commands
mycd <directory>
- Changes the current directory to .
- If is not provided, it reports the current directory.
- Reports an error if the directory does not exist. -Changes the PWD environment variable accordingly.
myclr
- Clears the terminal screen.
mydir <directory>
- Lists the contents of .
myenviron
- Lists all the environment variables.
myecho <comment>
- Displays followed by a new line. Reduces multiple spaces/tabs to a single space.
myhelp
- Displays the user manual using the standard
more
filter.
mypause
- Pauses the shell until 'Enter' is pressed.
myquit
- Exits the shell.
myone
- A unique command that provides functionality not offered by standard Linux commands. Detailed description and usage instructions for myone are provided below.
Implementation Details
mycd <directory>
- Uses the
chdir
system call to change the directory.. - Updates the
PWD
environment variable.. - Reports an error if the directory does not exist. -Changes the PWD environment variable accordingly.
myclr
- Uses ANSI escape codes to clear the screen..
mydir
- Uses
opendir
,readdir
, andclosedir
functions to list directory contents.
myenviron
-
Iterates through the environment variables using the
environ
pointer.myecho
-
Prints the arguments to the standard output, ensuring multiple spaces/tabs are reduced to a single space..
myhelp
- Uses the
more
filter to display the user manual, typically found in a help text file..
mypause
- Pauses the shell until 'Enter' is pressed.
myquit
- Exits the shell using the
exit
system call..
myone
- A unique command that provides functionality not offered by standard Linux commands..
Implementation:
Reads from the /proc/uptime file and displays the system uptime in a human-readable format.
A Makefile is provided to compile the source code. Use the following command to compile:
make
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit them (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a Pull Request.
version 1.0- 28 May 2024
- Initial Release
This project is licensed under the MIT License - see the LICENSE file for details.
Email:
litebohomaseli3@gmail.cominstagram:
litebohomaseli
- Keketso Tolo - @kent_tolo
- Mosiuoa Sello - @mossie_
- Khoase Hashatsi - @fred_hashatsi