← All projects
Systems & concurrency · 2025

42sh

We rebuilt the Unix shell developers type into all day: a tcsh-compatible shell in C that turns each command line into a syntax tree and runs it, with pipes, redirections, subshells, variables, aliases, history and background jobs, checked output for output against the real tcsh.

CPOSIXCriterion
Team
4 people
Context
Epitech project, 1st year
Status
Done
A session: pipes, variables, && / ||, command substitution, subshell and error messages
1 / 2A session: pipes, variables, && / ||, command substitution, subshell and error messages

Context

Epitech's 1st-year Unix programming project: write a shell that behaves like tcsh, with the same output, error messages and exit codes, using only system calls such as fork, execve, pipe and dup2.

What was built

  • Parser that builds a syntax tree by operator precedence: ; and background jobs, then ||, &&, redirections, pipes and parenthesised subshells
  • Expansion of $variables and $?, `command` substitution, aliases, !N history and *?[ ] globbing
  • Built-ins: cd, env, setenv, unsetenv, set, unset, alias, unalias, which, where, repeat, history, jobs, fg, exit
  • Job control with process groups, and a test script that compares every case with tcsh

Results

15built-in commands
44unit tests