Skip to content

AhmadYousif89/simple_shell

Repository files navigation

Simple Shell | UNIX Command Interperter

The gates of shell

Introduction

This repository represents a Holberton School project wherein we undertook the task of crafting a command line interpeter similar to the Shell introduced by the renowned Stephen Bourne, using the C programming language. The challenge involved minimizing reliance on standard library functions, opting instead for our custom functions refined over the low level proramming course of the past couple of months.

The primary objective of this project was to deepen our understanding of shell functionality. Noteworthy aspects of exploration included comprehending the system environment vatiables, distinguishing between functions and system calls, and mastering the creation of processes using fork, execve and many other intricacies.

Getting Started

This project was compiled on Ubuntu 20.04 LTS using the gcc compiler with these flags -Wall -Werror -Wextra -pedantic -std=gnu89.

In order to use this program, you will need to follow these steps :

  • Start by cloning this repository by running this command in your terminal.
git clone https://github.com/AhmadYousif89/simple_shell
cd simple_shell
  • Compile the program with these commands.
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
  • Run the program by executing the compiled file hsh.
simple_shell$ ./hsh
$

STD library custom functions

This list contains some of the custom functions utilized in our project, mirroring the functionality of certain standard C library functions.

Name Functionality
_strlen Gets the length of string.
_strstr Find the first occurrence of the substring.
_strcmp Compare two strings.
_strcat Append a string to another string.
_strcpy Copy string from src to dest.
_strchr Locates a character and return a string from its position.
_strdup Duplicate a string in memory.
_strtok Splits a string into words.
_memcpy Copy number of byte from src to some memory area.
_memset Fill a string with some characters.
_putchar Print to stdout using low level system call (write).

List of functions and system calls

This list contains the already builtin functions and system calls we were allowed to use and utilize in our project.

Name Functionality
chdir Changes the current working directory. man chdir
close Closes the file discriptors. man close
execve Replaces the currently running process with a new process. man execve
exit Terminates the process and return the exit code status. man exit
fork Creates a new process by duplicating the calling process.man fork
free Free allocated memory on demand. man free
getcwd Gets current working directory. man getcwd
getline Reads an entire line from a stream. man getline
getpid Returns the process ID (PID) of the calling process. man getpid
isatty Tests whether a file descriptor refers to a terminal or not. man isatty
malloc Allocates dynamic memory. man malloc
open Opens a file to process. man open
signal Used to handle the Ctrl+C termination signal. man signal
stat Display file or file system status. man stat
wait Suspends execution of the calling thread until one of its children terminates. man wait
write Used to print to stdout, stderr. man write

Author

Ahmad Yousif

Happy Coding 👋

About

ALX | Shell Interpreter - C

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages