A shell, also known as a command interpreter, is a program that provides a command-line interface for users to interact with the operating system. It acts as an intermediary between the user and the operating system, interpreting and executing commands entered by the user.
An alx team project where each team are required to create a command line interpreter that takes a text command and execute other program in response to thet command
Name | |
---|---|
Lerato Mgwangqa | ivyratermgwangqa@gmail.com |
Francis Eze | fhrancorey99@gmail.com |
- PID & PPID
- Creating a Simple Shell
- Executing Programs with execve
- Creating Processes with fork
- Synchronizing Processes with wait
- Working with Environment Variables
- Output
- Compilation
- Testing
- Understanding process IDs (PID) and parent process IDs (PPID)
- Retrieving process IDs using system calls
- Implementing a simple shell interpreter based on bash and sh
- Parsing user commands and executing them
- Using the execve system call to execute another program
- Replacing the current process with a new program
- Understanding the fork system call
- Creating child processes from a parent process
- Using the wait system call to suspend the execution of the parent process
- Waiting for child processes to terminate before continuing
- Accessing and manipulating environment variables in shell programs
- Retrieving the environment using the
environ
variable - Modifying environment variables using custom functions
- The shell have exact same output as the
sh
(/bin/sh
) - The only difference is when you print an error, the name of the program must be equivalent to your argv[0] (See below)
$ echo "qwerty" | /bin/sh
/bin/sh: 1: qwerty: not found
$ echo "qwerty" | /bin/../bin/sh
/bin/../bin/sh: 1: qwerty: not found
$
$ echo "qwerty" | ./hsh
./hsh: 1: qwerty: not found
$ echo "qwerty" | ./././hsh
./././hsh: 1: qwerty: not found
$
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
$ ./hsh
($) /bin/ls
hsh main.c shell.c
($)
($) exit
$
$ echo "/bin/ls" | ./hsh
hsh main.c shell.c test_ls_2
$
$ cat test_ls_2
/bin/ls
/bin/ls
$
$ cat test_ls_2 | ./hsh
hsh main.c shell.c test_ls_2
hsh main.c shell.c test_ls_2
$