Code Monkey home page Code Monkey logo

simple_shell's Introduction

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

simple_shell's People

Contributors

petehwu avatar sumin3 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.