Eshell is a basic UNIX shell implemented in C. It provides a prompt where users can enter commands, and the shell will execute them just like traditional shells (e.g., sh
, bash
).
- Custom shell prompt:
(Eshell) $
- Tokenizes and parses user input.
- Locates and executes system commands from the
$PATH
. - Handles basic command execution using
fork()
,execve()
, andwaitpid()
. - Gracefully handles command not found errors.
- Clean memory management.
File | Description |
---|---|
main.c |
Main shell loop: reads input, parses it, and runs commands. |
execmd.c |
Handles forking and executing user commands. |
get_location.c |
Finds the full path of commands based on the $PATH . |
main.h |
Header file containing function prototypes and includes. |
- The shell prints a prompt:
(Eshell) $
- It waits for the user to type a command.
- The input is tokenized into the command and its arguments.
- The shell locates the executable using the
PATH
environment variable. - A child process is forked to execute the command using
execve()
. - The parent shell waits for the child to finish before accepting the next command.
Use gcc
to compile all the source files:
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o eshell