Skip to content

πŸš€ Build your own Bourne Shell Command-line Interpreter.

Notifications You must be signed in to change notification settings

viajeradelaluz/simple_shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation



hsh

A simple shell implementation


This project is an implementation of a simple UNIX Command Line Interpreter. It includes the basic functionality of the standard functions and system calls, in the tradition of the first shell written by Ken Thompson.

Overview

Holberton School teaches Full-Stack Software Engineering with a project-based approach. Simple Shell is the final project of the first trimester that covers the Low-level programming of Software Engineering.

Requirements

To run the hsh shell you need to download the code files by clicking Download simple_shell. Or by cloning this repository with the following command in your command terminal. The result will be the same regardless of the option you choose.

~$ git clone https://github.com/viajeradelaluz/simple_shell.git

Enter the folder simple_shell and compile all *.c files using GNU Compiler Collection (GCC) and run under Linux environments like Ubuntu 20.04 LTS.

Invocation

GCC command to compile:

~/simple_shell$ gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh

Run the shell in interactive mode:

~/simple_shell$ ./hsh

Or run the shell in non-interactive mode:

~/simple_shell$ echo "ls -l" | ./hsh

The magic of Makefile:

You can compile and run the hsh shell with the Makefile using the command below. Note: This only works for the interactive mode.

~/simple_shell$ make hsh
($) 

After you finish testing the hsh shell, you can clean up the unnecessary files in the folder with the following command:

~/simple_shell$ make clear
rm hsh .simple_shell_history

Usage

Execute commands in a similar manner to sh. However hsh shell has more limited functionality. It's development is ongoing.

Interactive mode:

~/simple_shell$ ./hsh
($) cd simple_shell
($) pwd
/home/simple_shell
($) ls -go
total 76
-rwxrwxrwx 1     9 Dec  7 12:53 AUTHORS
-rwxrwxrwx 1  1122 Dec  7 12:35 README.md
-rwxrwxrwx 1   900 Dec  7 09:08 _strtok.c
-rwxrwxrwx 1  2154 Dec  7 23:48 builtins.c
-rwxrwxrwx 1  2756 Dec  7 19:15 execute.c
-rwxrwxrwx 1   453 Dec  7 18:42 history.c
-rwxrwxrwx 1 40832 Dec  8 01:52 hsh
-rwxrwxrwx 1  1343 Dec  7 23:43 main.h
-rwxrwxrwx 1   256 Dec  7 19:17 makefile
-rwxrwxrwx 1  1229 Dec  7 18:42 man_1_simple_shell
-rwxrwxrwx 1  1812 Dec  7 12:28 parse.c
-rwxrwxrwx 1  1360 Dec  8 01:49 read.c
-rwxrwxrwx 1   696 Dec  7 23:09 shell.c
-rwxrwxrwx 1  2002 Dec  8 01:09 strings.c
drwxrwxrwx 1  4096 Dec  8 01:57 test
($) exit
~/simple_shell$

Non-interactive mode:

~/simple_shell$ echo "cat AUTHORS" | ./hsh
# This file lists all indivual contributions to the repository.
# It is generated using the `test/generate-authors.sh` script.

Johanna Alfonso <[email protected]>
Cesar Molina <[email protected]>
pipeleon <[email protected]>
~/simple_shell$

File Description

  • AUTHORS β€” Contributions to the repository.
  • README.md β€” Project's description.
  • _strtok.c β€” Implementation of strtok function.
  • builtins.c β€” Parse if a command should be execute as a built-in function: _cd, _help, __exit, _env.
  • execute.c β€” Main track process of the shell. Where the input line is read, the arguments are parsed and the commands are executed.
  • history.c β€” Implementation of the history built-in
  • main.h β€” Main libraries that allow the compilation of the program.
  • makefile β€” Script to compile and run the shell.
  • man_1_simple_shell β€” Man page of the program.
  • parse.c β€” Functions behind of parsing the line and arguments.
  • read.c β€” Functions behind of getting the PATH and working with strings.
  • shell.c β€” Main program of the shell.
  • strings.c β€” Functions behind of working with strings.
  • test β€” Folder with background exercises to prepare the shell project.

Authors

Johanna Alfonso, Cesar Molina, Felipe LeΓ³n.

More information

Holberton School

About

πŸš€ Build your own Bourne Shell Command-line Interpreter.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •