This project is about creating a simple shell in C.
make
./minishell
Or,
make
./minishell [command]
to run a command directly through minishell
- $HOME is initialized as the $PWD (= the path) of the projet's root directory
The command prompt is composed of:
[$LOGNAME]@[$NAME / $SESSION_MANAGER]:[PATH]$
- $NAME or $SESSION_MANAGER is used, depending on the system
- Unsetting $LOGNAME or $NAME/$SESSION_MANAGER does not change the concerned part
- When $HOME is unset, the current abosulte path is used.
- If the current directory's path is equal to $HOME, the path is replaced by a tilde ('~')
- If the current directory's position is lower than $HOME, the tilde does not appear
- If the current directory is the root directory of all the system files, only "\$" is shown
- The cd command updates $PWD and the path of the command prompt when the directory is changed
- "cd .." works, as chdir() understands ".." as an argument
- cd returns an error if it comes with more than a single argument
- "cd" alone gets to $HOME
- Any argument is ignored
- Every argument is exported to the minishell's envp, unless it is invalid.
- An argument is invalid when:
- The first character of the variable's name is a digit.
- At least one of the characters in the variable's name is not alphanumeric, except for the underscore character ('_').
- The argument begins with the assigning equal character ('=').
- There is at least one space character before the equal character.
- Unsetting $PATH and requesting a command throws and error except when running the following implemented commands: cd, echo, exit, export, unset. This behavior is similar in bash.
- Every argument is unset from the minishell's envp, unless the variable is not found, or is invalid.
- An argument is invalid when:
- The first character of the variable's name is a digit.
- At least one of the characters in the variable's name is not alphanumeric, except for the underscore character ('_').
- When $PWD is unset, the pwd command will print the current absolute path, using getcwd().
- Every argument will be printed, separated by a space, unless it begins with "-n", which will activate the -n option.
- The character '\' is not echoed, as in bash.
- Any argument is ignored
- It prints all the environment variables that are active within minishell.
To check all kinds of leaks while ignoring the onces dued to readline(), create a file with the following content:
{
ignore_readline_leaks
Memcheck:Leak
...
obj:/lib/x86_64-linux-gnu/libreadline.so.7.0
}
You can name this file anything you want.
On the last line, replace what follows "obj:" with the path corresponding to your own system.
The path appears inside the valgrind reports.
Then, run the following command:
valgrind --leak-check=full --show-leak-kinds=all --track-fds=yes --suppressions=ignore_readline_leaks ./minishell
Here, the part following "--suppressions=" corresponds to the name of the file mentionned above.