Giter Club home page Giter Club logo

minishell's Introduction

minishell

This project is about creating a Bourne-Again Shell (BASH) replica for the minishell project at Codam. Minishell is therefore a user-mode program that implements a Command Line Interface (CLI).

In general terms what this program does is:

  • Print a prompt
  • Read a line
  • Parse
  • Execute
  • Repeat

Features

options

minishell:~$ pgrm -r -f path/to/file

i/o redirections

minishell:~$ pgrm < infile > outfile
minishell:~$ pgrm < infile >> outfile

pipes

minishell:~$ pgrm | pgrm2 | pgrm3

enviroment variables

minishell:~$ARG=something
minishell:~$ pgrm $ARG

previous foreground exit status

minishell:~$ pgrm $?

single quotes

minishell:~$ pgrm '$ARG $ARG2'

double quotes

minishell:~$ pgrm "$ARG $ARG2"

key bindings

  • arrow up / down for history.
  • ctrl-C displays a new prompt on a new line.
  • ctrl-D exits the shell.
  • ctrl-\ does nothing.

Built-ins

  • 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

Missing

  • scripting control
  • command / filename completion
  • background control
  • initialization / startup files

system calls

  • fork
  • exec
  • exit
  • wait
  • open
  • close
  • read
  • write
  • pipe
  • dup
  • chdir

GETTING STARTED

  1. Clone the repo
git clone https://github.com/Chr-ss/minishell.git
  1. cd into directory
cd minishell
  1. Call the Makefile
make

Other Docs

In addition to the README you're reading right now, there are other documents which describe more about this project:

minishell's People

Contributors

sairutra avatar chr-ss avatar

Stargazers

MrMalloc avatar  avatar

Watchers

 avatar  avatar  avatar

minishell's Issues

Tester potentially cutting spaces?

13 | echo "aspas -> ' "
mini output = (aspas -> ')
bash output = (aspas -> ' )
15 | echo 'aspas -> " '
mini output = (aspas -> ")
bash output = (aspas -> " )

export error code wrong

minishell:$export 123
minishell: export: not a valid identifier
minishell:
$echo $?
0
minishell:~$
==37927==
==37927== HEAP SUMMARY:
==37927== in use at exit: 208,182 bytes in 223 blocks
==37927== total heap usage: 542 allocs, 319 frees, 232,255 bytes allocated
==37927==
==37927== 2 bytes in 1 blocks are definitely lost in loss record 1 of 64
==37927== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==37927== by 0x407FE5: ft_calloc (in /home/crasche/github/minishell/minishell)
==37927== by 0x407A75: ft_itoa (in /home/crasche/github/minishell/minishell)
==37927== by 0x403675: expand_exit_code (expansion.c:19)
==37927== by 0x403555: expand_copy (expansion.c:74)
==37927== by 0x403408: expand (expansion.c:94)
==37927== by 0x4066A7: input_handling (input_handling.c:29)
==37927== by 0x4065FD: main (main.c:25)
==37927==
==37927== LEAK SUMMARY:
==37927== definitely lost: 2 bytes in 1 blocks
==37927== indirectly lost: 0 bytes in 0 blocks
==37927== possibly lost: 0 bytes in 0 blocks
==37927== still reachable: 0 bytes in 0 blocks
==37927== suppressed: 208,180 bytes in 222 blocks
==37927==
==37927== For lists of detected and suppressed errors, rerun with: -s

cd error behavior

minishell:$cd 123123
cd
minishell:
$bash
crasche@f1r6s10:/github/minishell$ cd 123123
bash: cd: 123123: No such file or directory
crasche@f1r6s10:
/github/minishell$ cd $PWD hi
bash: cd: too many arguments
crasche@f1r6s10:/github/minishell$
exit
minishell:
$cd $PWD hi
too many arguments
cd
minishell:~$

new flags for tester

track FDs in vlagrind:
--track-fds=yes
track leaks in child process in valgrind:
--trace-children=yes

cd leaks when not given valid path

==37262==
cminishell:$cd 123132
cd
minishell:
$
==37262==
==37262== HEAP SUMMARY:
==37262== in use at exit: 208,189 bytes in 223 blocks
==37262== total heap usage: 598 allocs, 375 frees, 232,974 bytes allocated
==37262==
==37262== 9 bytes in 1 blocks are definitely lost in loss record 3 of 64
==37262== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==37262== by 0x407FE5: ft_calloc (in /home/crasche/github/minishell/minishell)
==37262== by 0x4075AA: ft_strjoin (in /home/crasche/github/minishell/minishell)
==37262== by 0x404BC5: cd_parse_dso (cd_parse.c:23)
==37262== by 0x404FF4: cd_parse (cd_parse.c:127)
==37262== by 0x4052B0: cd (cd.c:105)
==37262== by 0x402A5E: execute_check_builtin (execution.c:130)
==37262== by 0x402DE2: execute (execution.c:203)
==37262== by 0x406760: input_handling (input_handling.c:45)
==37262== by 0x4065FD: main (main.c:25)
==37262==
==37262== LEAK SUMMARY:
==37262== definitely lost: 9 bytes in 1 blocks
==37262== indirectly lost: 0 bytes in 0 blocks
==37262== possibly lost: 0 bytes in 0 blocks
==37262== still reachable: 0 bytes in 0 blocks
==37262== suppressed: 208,180 bytes in 222 blocks
==37262==
==37262== For lists of detected and suppressed errors, rerun with: -s
==37262== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Export single value without equals sign

export abc

bash:
declare -x XDG_SESSION_TYPE="x11"
declare -x XMODIFIERS="@im=ibus"
declare -x YAD_PID="157837"
declare -x ZDOTDIR="/home/spenning"
declare -x abc

minishell:
declare -x YAD_PID=157837
declare -x ZDOTDIR=/home/spenning
declare -x _=./minishell
declare -x abc=

expand exit code leaks

minishell:$export 123
minishell: export: not a valid identifier
minishell:
$echo $?
0
minishell:~$
==37927==
==37927== HEAP SUMMARY:
==37927== in use at exit: 208,182 bytes in 223 blocks
==37927== total heap usage: 542 allocs, 319 frees, 232,255 bytes allocated
==37927==
==37927== 2 bytes in 1 blocks are definitely lost in loss record 1 of 64
==37927== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==37927== by 0x407FE5: ft_calloc (in /home/crasche/github/minishell/minishell)
==37927== by 0x407A75: ft_itoa (in /home/crasche/github/minishell/minishell)
==37927== by 0x403675: expand_exit_code (expansion.c:19)
==37927== by 0x403555: expand_copy (expansion.c:74)
==37927== by 0x403408: expand (expansion.c:94)
==37927== by 0x4066A7: input_handling (input_handling.c:29)
==37927== by 0x4065FD: main (main.c:25)
==37927==
==37927== LEAK SUMMARY:
==37927== definitely lost: 2 bytes in 1 blocks
==37927== indirectly lost: 0 bytes in 0 blocks
==37927== possibly lost: 0 bytes in 0 blocks
==37927== still reachable: 0 bytes in 0 blocks
==37927== suppressed: 208,180 bytes in 222 blocks
==37927==
==37927== For lists of detected and suppressed errors, rerun with: -s

Tester expanding "*", even with expanding unsure why this is not matching

16 | echo "> >> < * ? [ ] | ; [ ] || && ( ) & # $ \ <<"
mini output = (> >> < cases e2e.sh files files_temp interactive.sh logs README.md util xdotool ? [ ] | ; [ ] || && ( ) & # $ \ <<)
bash output = (> >> < cases e2e.sh files files_temp interactive.sh logs README.md util xdotool ? [ ] | ; [ ] || && ( ) & # $ \ <<)
17 | echo '> >> < * ? [ ] | ; [ ] || && ( ) & # $ \ <<'
mini output = (> >> < cases e2e.sh files files_temp interactive.sh logs README.md util xdotool ? [ ] | ; [ ] || && ( ) & # $ \ <<)
bash output = (> >> < cases e2e.sh files files_temp interactive.sh logs README.md util xdotool ? [ ] | ; [ ] || && ( ) & # $ \ <<)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.