The shell project is part of Holberton school curriculum and this custom shell suppose to replicate some of the functionalities of sh
.
The shell should be compiled on Ubuntu 14.04 LTS this way:
gcc -Wall -Werror -Wextra -pedantic *.c -o hsh
This program must have the exact same output as sh as long as the exact same error output.
Clone repository: https://github.com/cnov20/simple_shell.git
Exits with code 0 on "end of file" condition. CTRL + D
. Otherwise the shell will return the exit status of the last command executed, or if the exit builtin is used with a numeric argument, it will return the argument.
Custom functions | Functionality |
---|---|
* _putchar |
output of chars & strings |
* _strcmp |
compares two strings |
* _putstring |
outputs strings |
* _print_env |
print environment |
* _getline |
delimited string input |
* _strncat |
concatenates two strings |
* _strlen |
calculate the length of a string |
shell.h
Contains all function prototypes and function structures used for the program:
char *_getenv_PATH(const char *name);
printing the enviroment of variable PATHint execve(const char *filename, char *const argv[], char *const envp[]);
executes functions in child processvoid _putstring(char *str);
prints a string to standard outputunsigned int _strlen(char *str);
finds the length of a string, excluding the null characterint _putchar(char c);
writes a character to standard outputint _strcmp(char *s1, char *s2);
compares two stringschar *_memcpy(char *dest, char *src, unsigned int n);
function that copies memory areachar *_strdup(char *src);
function that allocates space for and creates copy of given stringvoid shell_exit(int status);
exit the shell when user types exit in promptchar **tokenizer(char *line);
tokenizes the environment by chosen delimetersint execute_cmd(char **argv);
function forks child process, if command is executablechar *_strncat(char *dest, char *src, int n);
concatenates two stringsvoid _print_env(void);
prints the environment
- /bin/ls: prints the content of the current directory and prints new prompt right after the command was executed and the result was printed to standard output.
- /bin/pwd: prints the path of the current working directory to stdandard output and prints the prompt right after - ready for a new command to be entered.
- exit: builtin that terminate the shell
Christopher Novelli: github account, twitter
Ekaterina Kalache: github account, twitter
Public, no copyright protection