Simple shell is a command line interpreter. This shell is part of an exercise issued by Holberton School Medellin and includes basic functionalities of an UNIX like command line interface.
File | Description |
---|---|
AUTHORS | Lists all individuals having contributed content to the repository |
auxiliary_functions.c | Auxiliary functions for strings |
builtins.c | Analyzes and runs the builtins |
environment.c | Gets environment variable |
execute.c | Executes arguments given by parse function |
holberton.h | Header file with prototypes of functions |
man_1_simple_shell | Manpage of our shell |
parse_line.c | Interprets user input with the delimiter " \r\n\t" |
parse_line2.c | Interprets user input with the delimiter ":" |
path.c | Gets the full pathname |
printing_functions.c | Auxiliary functions for printing |
read_line.c | Reads user input |
run.c | Creates process identification |
shell.c | Main function of our shell |
This shell will be compiled this way:
$ gcc -Wall -Werror -Wextra -pedantic *.c -o hsh
This shell should work like this in interactive mode:
$ ./hsh
($) /bin/ls
hsh main.c shell.c
($)
($) exit
$
But also in non-interactive mode:
$ 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
$
Example of error with hsh:
$ echo "qwerty" | ./hsh
./hsh: 1: qwerty: not found
$ echo "qwerty" | ./././hsh
./././hsh: 1: qwerty: not found
$
Run the executable in your terminal after compiling:
root@vagrant-ubuntu-trusty-64:~/simple_shell# ./hsh
#cisfun$ ls-la
./hsh: 1: ls-la: not found
#cisfun$ ls -l
total 84
-rw-r--r-- 1 root root 173 Aug 28 21:02 AUTHORS
-rw-r--r-- 1 root root 2604 Aug 28 21:50 README.md
-rw-r--r-- 1 root root 1768 Aug 28 21:02 auxiliary_functions.c
-rw-r--r-- 1 root root 1085 Aug 28 21:02 builtins.c
-rw-r--r-- 1 root root 390 Aug 28 21:02 environment.c
-rw-r--r-- 1 root root 394 Aug 28 21:02 execute.c
-rw-r--r-- 1 root root 871 Aug 28 21:02 holberton.h
-rwxr-xr-x 1 root root 18763 Aug 28 21:03 hsh
-rw-r--r-- 1 root root 2157 Aug 28 21:02 man_1_simple_shell
-rw-r--r-- 1 root root 471 Aug 28 21:02 parse_line.c
-rw-r--r-- 1 root root 461 Aug 28 21:02 parse_line2.c
-rw-r--r-- 1 root root 828 Aug 28 21:02 path.c
-rw-r--r-- 1 root root 1875 Aug 28 21:02 printing_functions.c
-rw-r--r-- 1 root root 339 Aug 28 21:22 read_line.c
-rw-r--r-- 1 root root 666 Aug 28 21:02 run.c
-rw-r--r-- 1 root root 867 Aug 28 21:02 shell.c
-rw-r--r-- 1 root root 659 Aug 28 21:22 tmp_file_12345
- access (man 2 access)
- execve (man 2 execve)
- exit (man 3 exit)
- fork (man 2 fork)
- free (man 3 free)
- getline (man 3 getline)
- isatty (man 3 isatty)
- malloc (man 3 malloc)
- perror (man 3 perror)
- signal (man 2 signal)
- stat (__xstat) (man 2 stat)
- strtok (man 3 strtok)
- wait (man 2 wait)
- write (man 2 write)