You are browsing as a guest. Sign up (or log in) to start making projects!

Custom C-Shell

  • 2 Devlogs
  • 12 Total hours

A custom POSIX-compliant Unix shell written entirely in C from scratch. It features a custom lexical analyzer and parser to enforce strict grammar rules, alongside a robust execution engine that handles external $PATH binaries, I/O file redirection (<, >, >>), and complex multi-command piping (|). It also includes natively implemented built-in commands like hop (a persistent directory jumper with a Zoxide-style time-decay frecency algorithm), reveal (a recursive directory scanner), and peek (a memory-efficient file viewer).

Ship #1 Pending review

After 11+ hours of wrestling with C, pointers, and POSIX syscalls, I am shipping my custom Unix shell!

What started as a custom lexer and parser (built entirely from scratch without tools like Yacc) has grown into a fully functional execution environment.

Highlights:

Full Execution Engine: Handles complex pipelines (cmd1 | cmd2 | cmd3) and I/O redirection (<, >, >>) using precise file descriptor management (dup2, pipe, fork).

Zoxide-style Navigation: My hop built-in tracks every directory you visit and uses a time-decaying frecency algorithm so you can jump anywhere using just a substring.

Memory Optimization: Built-ins like peek read files backward chunk-by-chunk using lseek to avoid loading massive files into memory.

Building a shell from the ground up completely changed how I look at the terminal. Source code is linked below, as well as a short demo video!

  • 2 devlogs
  • 12h
Try project → See source code →
Open comments for this post

3h 18m 19s logged

Spent the last 3 hours building the core execution engine for my C-Shell. I implemented external command execution by scanning $PATH and using the fork() and execv() syscalls. The biggest challenge was getting I/O redirection and piping to work correctly. I used dup2() to hijack standard input/output and route them through anonymous temporary files (tmpfile()) to handle multiple file redirections at once.I also ran into a brutal segmentation fault because my built-in commands weren’t expecting redirection operator tokens. I ended up doing a massive architectural refactor to move the entire file descriptor routing to the parent shell level. Now, whether it’s an external binary like ls or my custom peek built-in, they both seamlessly read and write through pipes and files!

0
0
8
Open comments for this post

8h 23m 23s logged

I spent the last 8+ hours building a custom POSIX-compliant C shell from scratch. I built a custom lexer and parser to handle right-linear grammar, quoting, and escaping without using standard parsing tools like Lex/Yacc. I also implemented several complex built-in commands natively without relying on exec system calls, including a custom directory jumper (hop) with a time-decaying frecency algorithm (similar to Zoxide) that persists across sessions, and a custom cat-like tool (peek) that uses lseek to read files in reverse chunk-by-chunk to save memory.

0
0
8

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…