Skip to content

xDec0de/42minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42minishell Code quality Test coverage Workflow status

42 project "minishell", code follows the norm used at 42. The objective of this project is to create a basic replica of a bash shell, built in C.

Detailed code quality and coverage stats can be found here.

Requirements

This project is designed to work on Linux. Don't expect it to work on Windows unless you are using WSL. That being said, it still has some requirements.

Fast setup

A bash script is provided to install all required dependencies. You can run it with sudo ./setup. This script does require sudo or root privileges to run, as it uses apt to install dependencies. It will also compile the project with make and has two flags to choose from:

Flag Description
-y Automatically accepts installing dependencies
-optional Install optional dependencies too (List below)

If you are just testing the project and not planning to contribute to it, then the recommended command is sudo ./setup -y

List of dependencies

If you prefer a manual install, then here is the list of dependencies:

Required:

  • The project compiles with cc.
  • The readline library. Install it with sudo apt-get install libreadline-dev.
  • Makefile is used for build logic: sudo apt install make.

Optional:

  • Norminette is used for code style validation.
  • Valgrind used for leak testing.
  • lcov, for code coverage reports: sudo apt install lcov

Building, validating and testing the project

As previously stated, 42minishell follows the norm used at 42. This means the norminette program is used in order to validate that the code style of the project is up to standards. To build, validate and test the project we use Makefile. Here is the full table of commands:

Command Description
make norm Executes norminette on the src folder for style validation
make or make all Compiles updated files only
make re Recompiles the whole project (src)
make build make norm and make re
make testonly make fclean and run tests
make covonly Generate coverage report, assuming tests have been done
make test make norm and make testonly
make testcov make testonly and make covonly
make clean Removes any file generated by these commands
make fclean make clean, also removing program executables

Allowed functions

For this rather complex task, we are allowed to use the following table of functions:

Name Library Basic description Used
readline readline/readline.h Get a line from a user with editing
rl_clear_history readline/readline.h Clear history list
rl_on_new_line readline/readline.h Move onto a new line with prompt displayed
rl_replace_line readline/readline.h Replace the contents of the rl_line_buffer
rl_redisplay readline/readline.h Update the display of rl_line_buffer
add_history readline/history.h Place a string at the end of history list
printf stdio.h Formatted output conversion
malloc stdlib.h Allocate dynamic memory
free stdlib.h Free dynamic memory
write unistd.h Write on a file
access unistd.h Check real user's permissions for a file
open fcntl.h Open a file
read unistd.h Read from a file
close unistd.h Close a file descriptor
fork unistd.h Create a child process
wait sys/wait.h Wait for process to change state
waitpid sys/wait.h Wait for process to change state
wait3 sys/wait.h Wait for process to change state, BSD style
wait4 sys/wait.h Wait for process to change state, BSD style
signal signal.h ANSI C signal handling
sigaction signal.h Examine and change a signal action
kill signal.h Send a signal to a process or a group of processes
exit stdlib.h Cause normal process termination
getcwd unistd.h Get current working directory
chdir unistd.h Change working directory
stat unistd.h Get file status
lstat unistd.h Get file status
fstat unistd.h Get file status
unlink unistd.h Delete a name and possibly the file it refers to
execve unistd.h Execute a program
dup unistd.h Duplicate a file descriptor
dup2 unistd.h Duplicate a file descriptor
pipe unistd.h Create pipe
opendir dirent.h Open a directory
readdir dirent.h Read a directory
closedir dirent.h Close a directory
strerror string.h Return string describing error number
perror errno.h Print system error message
isatty unistd.h Test whether a file descriptor refers to a terminal
ttyname unistd.h Return name of a terminal
ttyslot unistd.h Find the slot of the current user's terminal in some file
ioctl sys/ioctl.h Control device
getenv stdlib.h Get an environment variable
tcsetattr unistd.h Set terminal attributes
tcgetattr unistd.h Get terminal attributes
tgetent term.h Load entry
tgetflag term.h Get boolean entry
tgetnum term.h Get numeric entry
tgetstr term.h Get string entry
tgoto term.h Instantiate parameters into a given capability
tputs term.h Retrieve capabilities

About

[42] Our own simple shell based on bash, made in C

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •