Skip to content

AAx13/simple_shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Shell Project

Usage

Run make and then ./simple_shell or make run in console.

man simple_shell

exit or Ctrl + D to exit shell.

Other Make Commands

  • make gdb - Compile for gdb debugging.
  • make run-v - Run with valgrind -v (verbose).
  • make run-m - Run with valgrind for memory leak checks.
  • make run-e - Run with valgrind for error checks.
  • make clean - Clean up binary, unnecessary files, and man page.

Functions

putchar.c

/* _putchar - writes a character to stdout. */
int _putchar(char c);

atoi.c

/* _atoi - function to turn an ascii representation of a number to int */
int _atoi(char *str);

memset.c

/* _memset - fills memory with a constant byte */
void _memset(void *s, int c, size_t n);

strlen.c

/* _strlen - gets the length of a string excluding the null byte. */
size_t _strlen(char *str);

strdup.c

/* _strdup - duplicate a string. */
char *_strdup(char *str);

strcpy.c

/* _strcpy - copies the string (src) to the string (dest). */
char *_strcpy(char *dest, char *src);

strcat.c

/* _strcat - concatenates two strings. */
char *_strcat(char *dest, char *src);

strcmp.c

/* _strcmp - compares two strings. */
int _strcmp(const char *s1, const char *s2);

strncmp.c

/* _strncmp - compares (n) amount of characters of two strings. */
int _strncmp(const char *s1, const char *s2, size_t n);

putstr.c

/* putstr - writes a string to stdout. */
int putstr(char *str);

getenv.c

/* _getenv - Gets the value of an environment variable. */
char *_getenv(char *name);

prompt.c

/* prompt - prints the shell prompt */
void prompt(char **env);

read.c

/* _read - function to retreive the string (command) from stdin. */
char *_read(void);

parse.c

/* parse - function that splits the line from stdin. */
char **parse(char *line);

exec.c

/* exec - function to execute commands from stdin. */
int exec(char **tokens, char *line);

path_cmd.c

/* path_cmd - function will search directories in $PATH environment variable */
int path_cmd(char **tokens);

build_cmd.c

/* b_cmd - builds full command path from command name. */
char *b_cmd(char *token, char *value);

built_in.c

/* built_in - handles built-in programs. */
int built_in(char **tokens, char *line);

env.c

/* print_env - prints the current environment to stdout. */
int print_env(void);

cd.c

/* _cd - handles the change directory built-in function. */
int _cd(char **tokens);

getcwd.c

/* _getcwd - gets the current working directory. */
char *_getcwd(char **env);

setenv.c

/* _setenv - updates or adds an environment variable. */
int _setenv(char *name, char *value);

unsetenv.c

/* _unsetenv - remove an environment variable. */
int _unsetenv(char *name);

build_var.c

/* build_var - builds a full environment variable from given name and value. */
char *build_var(char *name, char *value);

cd_home.c

/* cd_home - changes directory to home as well as updates environment vars. */
int cd_home(void);

cd_prev.c

/* cd_prev - change to previous directory and update environment variables. */
int cd_prev(void);

free_env.c

/* free_env - frees an array of strings containing env variables. */
void free_env(char **env);

exit_shell.c

/* exit_shell - exits shell with arguments. */
int exit_shell(char **tokens);

About

A simple implementation of a command line interpreter.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors