Skip to content
jeromebergPublic

About

Shell written in C, inspired by Bash. Handles pipes and redirections, environment variables and builtin commands.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minishell

C 42 Grade: 100%

A shell written in C, inspired by Bash.

Features

  • Parsing, expansion, and command execution
  • Pipes and redirections
  • Signal handling
  • Environment variables
  • Builtin commands: cd, echo, env, exit, export, pwd, unset

Use

Pipes and redirections

# input redirection
cat < infile

# output redirection
echo hello > outfile

# output redirection (append)
echo world >> outfile

# pipe
env | grep PATH

# heredoc
cat << EOF
line 1
line 2
EOF

cd

# go home
cd

# go to path
cd /tmp

echo

# print environment variable
echo $HOME

# no newline
echo -n hello

export

# print exported variables (sorted)
export

# set variable
export USERNAME=jerome

# create key without value
export EMPTY_KEY

# check exported value
env | grep USERNAME

env

# print set environment variables
env

pwd

# print working directory
pwd

unset

export TEST_VAR=42
env | grep TEST_VAR

# unset variable
unset TEST_VAR

env | grep TEST_VAR

exit

# exit minishell
exit

# exit with code
exit 42

Build

Prerequisites

  • OS: Linux or macOS
  • make
  • cc
  • readline (macOS: brew install readline)
  • valgrind (for make valgrind)

Quick start

# compile
make

# launch shell
./minishell

Commands

make            # compile
make clean      # remove objects
make fclean     # remove objects and executable
make re         # clean and recompile
make valgrind   # run valgrind

Resources

About

Shell written in C, inspired by Bash. Handles pipes and redirections, environment variables and builtin commands.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages