Project for the end of the first trimester at Holberton School. This project is for us to show what we have learnt in C during these 3 months, the use of loops, conditional, macros, structures, variables, pointers and more, also to test our teamwork skills and our work under pressure.
The _shell() compatible command language interpreter that executes commands read from the standard input or from a file.
In order to run the shell command interpreter, you must install it in your repository by cloning the following (shown below) in your machine running:
git clone direccion del repositorio final
- In order to compile the function you must run the following line in your shell:
gcc -Wall -Werror -Wextra -pedantic *.c -o hsh
Note: there are two ways of using the command interpreter:
$ ./hsh
($) /bin/ls
hsh main.c shell.c
($)
($) exit
$
$ 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
$
- To read the manual you man run:
man ./[FILE]
taking into account the structure, for our case it would beman ./man_hsh
File Name | Description and contents |
---|---|
manpage | This is the manpage for the shell command, this will help us know how to use the shell and the many uses of it, in here we can find examples and the correct sintaxis of the commands. |
_library.h | This is the headers file where we can find all the prototypes of our functions and the structures used. |
_stdio.c | In here we have the puts and putchar function it is used to print characters. |
_stdlib.c | In here we have the atoi function it is used to make integers into characters, the alloc funcction to allocate memory and the freeall function to free the memory allocated when it is not needed anymore. |
_string_0.c | Here we can find the function _strtok that splits a string with a delimiter given, _strcat function that concatenates two strings given, _strncmp compares an amount of characters, _strlen counts the characters in a string and _strdup to duplicate strings. |
_string_1.c | Here we can find the function _strchr that looks for a character in a string and returns a pointer after the match. |
additionalFunctions_0.c | Here we find the function cantCmds that counts commands, parse function that divide a string in different parts, constructor function who calls the execute, print number who prints numbers, execute that executes the command given. |
additionalFunctions_1.c | Here we find the function findpath that looks for the path where the command can be executed, path_concat function that concatenate the path and the command, path_copy function copies the path, help_me this function prints the help for every builtin. |
builtinsFunctions.c | Here we find the function exitF that allows the user to exit, path_concat function that concatenate the path and the command, path_copy function copies the path, help_me this function prints the help for every builtin, unsetF this function is to unset the environment, help function is the one who manage the help print. |
generate-authors.sh | This script generate the authors file. |
helpFunctions.c | This file has the messages for the builtin help. |
main.c | This function has the launch function who starts all the process, the builtin function who calls the builtins, the issame function who compares two strings and the issignals this function is to catch a special key. |
A simple shell must work with the path and without the path
- /bin/ls
- ls
Below you can find use of some commands.
$ ls -a
$ echo Hola
$ pwd
Here are the result of this actions:
Image of the console using the commands above
- C
- Vim
- Vagrant
- Peppermint Need to change to what Kevin is using
- Ubuntu
- GCC 4.8.4 Compiler