Skip to content

Unix shell in C with signal handling and command execution.

Notifications You must be signed in to change notification settings

tonievictor/simple_shell

Repository files navigation

Simple Shell

Overview

A simple Unix shell written in C that supports both interactive and non-interactive modes. It can execute a variety of commands, handle signals, and more.

Features

  • Interactive Mode: Run the shell interactively, accepting user commands in real-time.
  • Non-Interactive Mode: Execute commands from a pipe (file and script support coming soon).
  • Command Execution: Supports a variety of Unix commands.
  • Signal Handling: Properly handles signals to ensure robust execution.

Getting Started

Prerequisites

  • This shell requires a Unix-like operating system.
  • You'd need a C compiler, preferably gcc.

Installation

Clone the repository

git clone https://github.com/Tonie-NG/simple_shell.git

Change directory to the project:

cd simple_shell

Compiling

Compile the shell using the following command:

gcc *.c -o simple_shell

For more strictness, you could use this:

gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o simple_shell

Usage

  1. Interactive Mode:

Simply run the executable, and the shell will start accepting commands.

./simple_shell
  1. Non-Interactive Mode:

Provide a valid command using echo and pipe it to the executable file.

echo "/bin/ls" | ./simple_shell

Examples

  1. Interactive Mode:

To start the shell:

./simple_shell

Provide the command path:

/bin/ls
/bin/ls -l

You can also provide the command, and the shell handles the full path:

ls
pwd
exit
  1. Non-interactive mode:

Provide the command path via pipe:

echo "/bin/ls" | ./simple_shell

Provide the command and the shell handles the path

echo "ls" | ./simple_shell

About

Unix shell in C with signal handling and command execution.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published