Hraesvel / simple_shell

Shell Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0x15. C - Simple Shell

Marsu Shell

Authors

Martin Smith alt text

Susan Su alt text

Table of Context

Introduction

"Simple shell" is a project to recreate shell in C using what we've learned up until now. While we can use a fair amount of pre-existing functions to build our shell most basic function-- such as strlen, strdup, etcetera -- have to be written by us, there are optional tasks to rewrite them.

Including our abilities to write a program in "C" this project is also meant to test our collaborative prowess and work ethic. As such we must work within the same GitHub repository, where communication is critical to avoid merge conflicts. Also, whiteboard and peer programming are also strongly encouraged and from our experience has worked wonders for our progress.


Usage

Basic usage

using Marsu shell in interactive mode.

user@ubuntu:~ $ ./Marsu 
Marsu:~ $
Marsu:~ $ ls -a
.   .bash_history  .bashrc     .lesshst  .profile  .sudo_as_admin_successful  .viminfo  Betty     work
..  .bash_logout   .gitconfig  .local    .ssh      .test_file.swp             .vimrc    dotfiles
Marsu@:~ $ 

using Marsu shell in non-interactive.

user@ubuntu:~ $ echo "/bin/ls -a" | ./Marsu
.   .bash_history  .bashrc     .lesshst  .profile  .sudo_as_admin_successful  .viminfo  Betty     work
..  .bash_logout   .gitconfig  .local    .ssh      .test_file.swp             .vimrc    dotfiles
user@ubuntu:~ $ 

page top


Description

Marsu gets its name from the of the collaborators MARtin and SUsan is so happens to also be the Finnish for guinea pig 😹. The Marsu Shell takes user input in two modes - interactive and non-interactive - and performs the proper course of action. In the interactive mode, commands are taken from the terminal. In the non-interactive mode, commands are piped from a file.

List of allowed functions and system calls
  • access (man 2 access)
  • chdir (man 2 chdir)
  • close (man 2 close)
  • closedir (man 3 closedir)
  • execve (man 2 execve)
  • exit (man 3 exit)
  • fork (man 2 fork)
  • free (man 3 free)
  • stat (__xstat) (man 2 stat)
  • lstat (__lxstat) (man 2 lstat)
  • fstat (__fxstat) (man 2 fstat)
  • getcwd (man 3 getcwd)
  • getline (man 3 getline)
  • kill (man 2 kill)
  • malloc (man 3 malloc)
  • open (man 2 open)
  • opendir (man 3 opendir)
  • perror (man 3 perror)
  • read (man 2 read)
  • readdir (man 3 readdir)
  • signal (man 2 signal)
  • strtok (man 3 strtok)
  • wait (man 2 wait)
  • waitpid (man 2 waitpid)
  • wait3 (man 2 wait3)
  • wait4 (man 2 wait4)
  • write (man 2 write)
  • _exit (man 2 _exit)
  • isatty (man 3 isatty)
  • fflush (man 3 fflush)

page top


Features

Advance task

page top


Modules

Files Description
main.c Main entry point for the Marsu shell.
shell.h header file for the shell containing all the prototypes for the shell.
prompt_util.c Functions that that directly related to the shell basic functionality.
prompt_util2.c More Functions that that directly related to the shell basic functionality.
buildin.c Source for commands that are built into the shell.
strtok.c Susan's implementation of a function that tokenize a string, strtok()
_getline.c TODO

page top


Acknowledgments

page top


About

Shell Project


Languages

Language:C 99.7%Language:Shell 0.3%