/simple_shell

Low-level programming & Algorithm ― Linux and Unix system programming

Primary LanguageC

Simple Shell

Description

This is a simple UNIX command line interpreter that replicates functionalities of the shell.

Installation

  1. Clone this repository in your terminal.

  1. Compile with the following flags:
simple_shell$ gcc -Wall -Werror -Wextra -pedantic *.c -o hsh
  1. Run program.
simple_shell$ ./hsh

After successful compilation, the shell is launched and ready for both interactive and non-interactive executions.

Interactive Mode

Run program and wait for the prompt $ to appear. From there, type desired commands. Exit program with the exit command or Ctrl+D.

Non-Interactive Mode

From command line, use echo command and pipe into the program like so:

simple_shell$ echo "command" | ./hsh

Built-ins Supported

Command Name Description Sypnosis
exit Cause normal process termination exit
env Run a program in a modified environment env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
help Retrieve informational text on how use builtin [-dms] [pattern ...]

Examples

$ /bin/pwd
/home/vagrant/simple_shell
$ env
*prints whole environment*
$ ls -l
-rw-rw-r-- 1 vagrant vagrant   158 Aug 28 16:35 directory_1
-rw-rw-r-- 1 vagrant vagrant  2139 Aug 29 02:29 directory_2
$ help exit
exit the shell.

Files

File Name Description
coolshell.h Header file with function prototypes, structs and standard libraries.
coolshell_buf_process.c Functions that read, tokenize and count user input.
coolshell_builtins.c Functions that check built-ins, print environments and exit shell.
coolshell_handle_cmd.c Functions that handle command with or without PATH directory strings and execute commands.
coolshell_helpers_1.c Functions that duplicate and concatenate strings and fill memory with a constant bytes.
coolshell_helpers_2.c Functions that return length and turn integers into a string and write characters to standard output.
coolshell_main.c Main Function that executes command line operations.
coolshell_path_process.c Functions that gets, tokenizes, counts, and concatenates an environmental variable string as well as checking the status of a file.
man_1_simple_shell Simple Shell man page

About

This program was created by:

  • Pierre Beaujuge

GitHub: pierrebeaujuge | Medium: pierre.beaujuge | Email: pierre.beaujuge@gmail.com

  • Joan Cruz

GitHub: joancruzz | LinkedIn: Joan Cruz | Email: joan.cruz95@gmail.com