Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Unix Shell in C

A POSIX-style shell built from scratch in C that supports command execution, built-in commands, PATH resolution, tokenization, and I/O redirection. Designed as an exercise in Unix process management and systems programming.

Technical Highlights

  • Process model: fork/execvp/waitpid for child process lifecycle management
  • I/O redirection: dup2-based fd swapping for stdout/stderr, supporting both overwrite and append modes
  • PATH resolution: manual $PATH traversal with stat to locate and validate executables
  • Tokenizer: hand-rolled parser handling single quotes, double quotes, and backslash escaping with correct precedence
  • Built-ins: cd, pwd, echo, type, exit implemented natively without spawning child processes

Build

make

Requires GCC. Compiled with -Wall -Wextra -g.

Usage

./shell
$ echo "hello world"
hello world
$ ls 2> errors.txt
$ cat file.txt >> log.txt
$ exit

Redirection

Operator Effect
> / 1> Redirect stdout (overwrite)
2> Redirect stderr (overwrite)
>> / 1>> Redirect stdout (append)
2>> Redirect stderr (append)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages