Welcome to the Simple Shell project, one of the most exciting and challenging projects that will test your programming skills and knowledge acquired so far at ALX SE.
- Programming Fundamentals
- C Programming
- Engineering Thinking
- Group Work
- Learning How to Learn
Before diving into the project, make sure to review the project framework. Pay close attention to the rules, especially the prohibition against looking at other people's code.
The Simple Shell project involves creating a UNIX command-line interpreter. Here are some key points:
- Compile on Ubuntu 20.04 LTS using gcc with specified options.
- Ensure your code follows the Betty style.
- No memory leaks are allowed.
- Group project - work collaboratively with your partner.
By the end of this project, you should be able to explain:
- Designers of the original Unix OS
- Author of the first Unix shell
- Inventor of the B programming language (predecessor to C)
- Basics of how a shell works
- Concepts such as pid, ppid, environment manipulation, etc.
- Editors: vi, vim, emacs
- Use allowed functions and system calls only
- Follow compilation and testing guidelines
Function | Description |
---|---|
_strlen(const char *input) |
Returns the length of a string. |
_strdup(const char *input) |
Duplicates a string. |
_strcpy(char *dest, const char *src) |
Copies a string from source to destination. |
_strcmp(const char *first, const char *second, size_t nbr_bytes) |
Compares two strings up to a specified number of bytes. |
_strcat(char *dest, const char *src) |
Concatenates two strings. |
Function | Description |
---|---|
_atoi(char *string) |
Converts a string to an integer. |
_int_to_string(int number) |
Converts an integer to a string. |
Function | Description |
---|---|
_count_commands(const char *command) |
Counts the number of commands in a string. |
_create_command(const char *command) |
Creates a command from a string. |
Function | Description |
---|---|
_error_handler(char *name, int count, char *command, int status) |
Handles errors and prints relevant information. |
_check_exit(char *full_command) |
Checks if the command is an exit command. |
Function | Description |
---|---|
_execute_command(char **argv, char *command, int count, char **env) |
Executes a command with arguments. |
_free_command(char *full_command) |
Frees memory allocated for a command. |
_get_input(void) |
Gets input from the user. |
_get_path(void) |
Gets the PATH environment variable. |
_print_env(char *env) |
Prints the current environment. |
_print_prompt(void) |
Prints the command prompt. |
_check_path(const char *command) |
Checks if the command is in the PATH. |
Write code that passes the Betty style checks.
Implement a basic UNIX command-line interpreter. Handle simple command lines.
Extend the shell to handle command lines with arguments.
Handle the PATH, and ensure fork is not called if the command doesn’t exist.
Implement the exit built-in to exit the shell.
Implement the env built-in to print the current environment.
Write your own getline function using a buffer.
Handle commands without using strtok.
Handle arguments for the built-in exit.
Implement setenv and unsetenv built-in commands.
Implement the cd built-in to change the current directory.
Handle commands separated by semicolons.
Handle logical operators && and ||.
Implement the alias built-in command.
Handle variable replacement, including special variables like
Handle comments in the shell using #.
Enable the shell to take a file as a command line argument and execute commands from the file.
- Interactive mode:
./hsh
- Non-interactive mode:
echo "/bin/ls" | ./hsh
Read or watch materials on Unix shell, Thompson shell, Ken Thompson, and the provided concept pages.