Skip to content

Command shell like GNU Bash or zsh built with C lang

Notifications You must be signed in to change notification settings

xiaoxiaozhu5/42minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minishell - as beautiful as a shell

About

This project is all about creating a simplified shell program that can run binaries, have a working history, builtins functionality like echo or export and more.

Shell capabilities:

  • Have a working History with saving after reboot.
  • Search and launch the right executable (based on the PATH variable or by using relative or absolute path)
  • Implements the builtins:
    • echo with option -n
    • cd with only a relative or absolute path
    • pwd with no options
    • export with no options
    • unset with no options
    • env with no options or arguments
    • exit with no options
  • ' inhibits all interpretation of a sequence of characters.
  • " inhibits all interpretation of a sequence of characters except for $.
  • Redirections:
    • "<" redirect input.
    • ">" redirect output.
    • "<<" read input from the current source until a line containing only the delimiter is seen.
    • ">>" redirect output with append mode.
  • Pipes | the output of each command in the pipeline is connected via a pipe to the input of the next command.
  • Environment variables ($ followed by characters) expands to their values.
  • $? expands to the exit status of the most recently executed foreground pipeline.
  • ctrl-C ctrl-D ctrl-\ works like in bash.
  • When interactive:
    • ctrl-C print a new prompt on a newline.
    • ctrl-D exit the shell.
    • ctrl-\ do nothing.

All functions are created in accordance with Norm - the bunch of rules how code should be formatted.

Project rules

  • Not interpret unclosed quotes or unspecified special characters like \ or ;.
  • Show a prompt when waiting for a new command.

Requirements & usage

Project requires:

  • Readline library
  • C Lang compiler: gcc or clang
  • Possibility to work with Makefile

Tested on:

  • MacOS 10.15
  • Linux Ubuntu 20.04

Run:

$> make install && make
$> ./minishell
42minishell $> echo "Hello world!"
Hello world!

alt text

Makefile commands

  • make / make all / make minishell - compile project
  • make srcs/*.o - compile specific source file
  • make clean - clean all object files
  • make fclean - clean all object files & library
  • make norminette - check that all functions are created in accordance with Norm (you need to have norminette)
  • make install - install readline library (you need to have Homebrew)

About

Command shell like GNU Bash or zsh built with C lang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published