Skip to content

Ahish9009/ash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bb1e39c · Aug 22, 2020
Jul 15, 2020
Jul 17, 2020
Aug 22, 2020
Aug 22, 2020
Jul 10, 2020
Jul 13, 2020
Jul 17, 2020

Repository files navigation

as̶h

Custom shell in low level C for Linux & Mac.

shell ss

Contents

S. No Topic
1 Usage
2 Features
3 Built-In Commands
4 File Structure
5 Naming of the Shell
6 To-Do
7 Author(s)

Usage

  • Clone the repo
    git clone https://github.com/Ahish9009/ash/
  • Navigate into it
    cd ash
  • Generate the binary executable
    on Linux: make linux
    on MacOS: make mac or make
  • Execute
    ./ash
  • Clean
    make clean

Features

  • Set of self-written custom built-in commands
    • Self written and customized
    • Run within the shell's process itself
    • The list of built-in commands can be found here
  • Supports semi-colon separated commands
    • Eg. ls ; cd ..; echo
  • Supports multiple piping
    • Eg. ls | cat | tail -3
  • Supports input & output redirection
    • Eg. cat < inp > out
  • Allows job control/process management
    • Jobs can be run in the foreground or background
    • Background jobs can be brought to the foreground and vice versa
    • Process exit status is displayed on termination of a background job
  • Stores command history
  • Handles/traps signals
    • CTRL-Z sends the job(s) in the foreground to the background
    • CTRL-C terminates the current foreground job
  • Previous commands can be recalled using the up arrow key
    • The nth command can be recalled by pressing the up arrow key n times and hitting enter

Built In Commands

The following self-written commands are built into the shell:

Usage

ls -[al] [path/to/dir]

Description
  • Lists files in the specified directory
  • Lists files of the current directory if no path is specified
Options
  • -l : list in long format with more details
  • -a : display hidden files (those starting with '.')

Usage

cd [path/to/dir]

Description
  • Changes working directory to the path specified
  • Accepts both absolute and relative paths
Options
  • cd - : switches to the previous working directory
  • cd : switches to the root directory

Usage

pwd

Description
  • returns the name of the current working directory

Usage

echo -[n] [string ...]

Description
  • write arguments to the standard output
Options
  • -n : does not print the trailing newline character

Usage

jobs

Description
  • display status of jobs in the current session

Usage

kjob <signal number> [pid ...]

Description
  • send the specified signal to the specified processes
  • Multiple pids can be passed

Usage

history [n]

Description
  • displays the history of commands
  • passing a number n as argument displays the last n entries

Usage

fg [job id]

Description
  • runs the job specified by <job id> in the foreground
  • <job id> can be found using jobs

Usage

bg [job id]

Description
  • run the job specified by <job id> in the background
  • <job id> can be found using jobs

overkill [MacOS] [Linux]

Usage

overkill

Description
  • kill all background processes

Usage

ps [pid]

Description
  • shows information on the process specified by the pid
  • shows shell process information if no argument is passed

Usage

set_env [name] [value]

Description
  • sets the environment variable name to have the specified value

unset_env [MacOS] [Linux]

Usage

unset_env [name]

Description
  • unsets the environment variable name

Usage

cronjob -c [command] -t [time] -p [period]

Description
  • executes command every time seconds for period duration

File Structure

.
├── HEADERS
│   ├── bg.h
│   ├── cd.h
│   ├── cronjob.h
│   ├── echo.h
│   ├── env.h
│   ├── exec.h
│   ├── fg.h
│   ├── help.h
│   ├── history.h
│   ├── jobs.h
│   ├── kjob.h
│   ├── ls.h
│   ├── overkill.h
│   ├── parse.h
│   ├── pcwd.h
│   ├── ps.h
│   ├── processes.h
│   ├── prompt.h
│   ├── redirect.h
│   ├── signals.h
│   ├── sort.h
│   └── utils.h
│
└── SOURCE FILES
    ├── bg.c
    ├── cd.c
    ├── cronjob.c
    ├── echo.c
    ├── env.c
    ├── exec.c
    ├── fg.c
    ├── help.c
    ├── history.c
    ├── jobs.c
    ├── kjob.c
    ├── ls.c
    ├── overkill.c
    ├── parse.c
    ├── pcwd.c
    ├── ps.c
    ├── processes.c
    ├── prompt.c
    ├── redirect.c
    ├── shell.c
    ├── signals.c
    ├── sort.c
    └── utils.c

Naming of the Shell

The s in ash is to emphasize the absence of an 's' before the first 'h' in Ahish 😛
The shell is named using the "<initial>SH" convention

To-Do

  • Wildcard substitution
  • Memory leaks 😛
  • Test linux more

Author(s)

Ahish Deshpande

About

as̶h: Custom shell in low level C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published