Skip to content

sumin3/simple_shell

Repository files navigation

0x15. C - Simple Shell

A simple shell program to mimic sh shell. It allows the user to execute commands and interact with the kernel.

Features

  • Run commands in $PATH
  • Run commands from standard input

Built-ins:
exit [status]
env (print current environment values)
cd
setenv (sets environment value)
unsetenv (clear environment value)

Getting Started

To use this shell, first download this repository into your local machine by issuing the following command in your local terminal.

git clone https://github.com/sumin3/simple_shell.git

Change directory into the simple_shell directory created by the git clone command and issue the following command to compile the code

gcc -Wall -Werror -Wextra -pedantic *.c -o shell

Once the files are compiled you can run the program by issuing the command

./shell

Alternatively, you can copy the shell executable into the /usr/local/bin directory by issuing

sudo cp shell /usr/local/bin

After the above has been done, you can run the program by issuing the command

shell

Usage Examples

The following example shows how to start the shell and issue a ls command to list the contents of the directory then exit the shell

$ ./shell
$> ls
README.md	shell		shell_error.c		shell_helper1.c
holberton.h	shell.c		shell_get_builtin.c	shell_helper2.c
$> exit
$

You can also use the shell in a non-interactive mode by piping in a command as follows: `` $ echo "/bin/ls" | ./shell README.md shell shell_error.c shell_helper1.c holberton.h shell.c shell_get_builtin.c shell_helper2.c $ `

Output

Command Expected Output
ls lists files in current directory
/bin/ls lists files in current directory
env print out of environment values
ls -l lists files in long format
cd changes directory to home direcotry
cd - displays previous directory and change into tht directory
cd / changes directory to root directory
111 command not found

click here for a more comprehensive list of commands and expected output.

Testing

There is a separate repository for the test suite Here Follow the instructions there to run a more comprehensive test on the simple shell program.

Files

File Desc
AUTHORS Authors file
README.md Readme file
holberton.h header file with prototypes to functions used
man_1_simple_shell man page for the simple shell program
shell.c main entry point for the simple shell program
shell_enviro.c function(s) for popluating the environment values
shell_error.c function(s) for handling error message printing
shell_fork.c function for executing command issued by user
shell_get_builtin.c function(s) for handling the builtin functionality
shell_helper1.c helper functions
shell_helper2.c helper functions
shee_set_env.c function(s) for setting and un-setting environment values

Authors

Sumin Yu
Peter Wu

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages