Skip to content

🚀 Simple replication of the command-line interpreter Shell. All files are written in C language.

Notifications You must be signed in to change notification settings

tatsOre/simple_shell

Repository files navigation

Simple Shell

Simple replication of the command-line interpreter Shell. All files are written in C language.

Overview:

The shell is a command that reads lines from either a file or the terminal, interprets them, and generally executes other commands.  It is the program that is running when a user logs into the system (although a user can select a different shell with the chsh(1) command). The shell implements a language that has flow control constructs, a macro facility that provides a variety of features in addition to data storage, along with built in history and line editing capabilities. dash(1) - Linux man page

Compilation:

Code files must be compiled this way:

$ gcc -Wall -Werror -Wextra -pedantic *.c -o hsh

Usage:

The Simple Shell should work like this in interactive mode (simple commands can be typed directly to the running shell):

$ ./hsh
($) /bin/ls
hsh main.c shell.c
($)
($) exit
$

And also in non-interactive mode (commands can be put into a file and the file can be executed directly):

$ echo "/bin/ls" | ./hsh
hsh main.c shell.c test_ls_2
$
$ cat test_ls_2
/bin/ls
/bin/ls
$
$ cat test_ls_2 | ./hsh
hsh main.c shell.c test_ls_2
hsh main.c shell.c test_ls_2
$

Resources:

Requirements:

  • Allowed editors: vi, vim, emacs
  • All your files will be compiled on Ubuntu 14.04 LTS
  • Your C programs and functions will be compiled with gcc 4.8.4 using the flags -Wall -Werror -Wextra and -pedantic
  • All your files should end with a new line
  • A README.md file, at the root of the folder of the project is mandatory
  • Your code should use the Betty style. It will be checked using betty-style.pl and betty-doc.pl
  • Your shell should not have any memory leaks
  • No more than 5 functions per file
  • All your header files should be include guarded
  • Use system calls only when you need to why?

Libraries:

stdarg.h | signal.h | unistd.h | sys/wait.h | stdlib.h | sys/stat.h

Files:

File Description
simple_shell.h Libraries, declarations.
builtin.c Search and init built-ins
errormessages.c Messages Handlers
execute.c Create and execute processes
freeall.c Free memory
getenv.c Get environment variables
pathappend.c Append program to its path
searchinit.c Execute local programs, redirect commands
searchpathfile.c Search and validate file paths
splitarguments.c Count arguments and breaks them into tokens
str_handlers.c String Handlers Funcs
hsh.c Main Function

Flowcharts:

Flowchart Simple Shell

Authors:

  • Maria Fernanda Crespo Martinez | Github
  • Tatiana Orejuela Zapata | Github
Holberton School - Foundations - Low-level programming & Algorithm  Linux and Unix system programming.
 April, 2020. Cali, Colombia.

About

🚀 Simple replication of the command-line interpreter Shell. All files are written in C language.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages