Loading...

Build your own Shell

Learn about parsing shell commands, executing programs and more

Start Building
shell
C
shell
C#
shell
Go
shell
JavaScript
shell
C++
shell
Elixir
shell
Gleam
shell
Java
shell
Kotlin
shell
PHP
shell
Python
shell
Ruby
shell
Rust
shell
TypeScript
shell
Zig

This challenge requires a CodeCrafters Membership.

You're welcome to study the full challenge structure and stage instructions for free. A membership is needed for submitting code and viewing solutions.

Want to try a free challenge? Try Build your own Kafka — it's free during beta.

A shell is a command-line interface that executes commands and manages processes. In this challenge, you'll build your own POSIX compliant shell that's capable of interpreting shell commands, running external programs and builtin commands like cd, pwd, echo and more.

Along the way, you'll learn about shell command parsing, REPLs, builtin commands, and more.

Base Stages

A shell is a command-line interface that executes commands and manages processes. In this challenge, you'll build your own POSIX compliant shell that's capable of interpreting shell commands, running external programs and builtin commands like cd, pwd, echo and more.

Along the way, you'll learn about shell command parsing, REPLs, builtin commands, and more.

Print a prompt
Very easy
We'd expect a proficient developer to take < 5 minutes to complete this stage.
Handle invalid commands
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
REPL
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
The exit builtin
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
The echo builtin
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
The type builtin: builtins
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
The type builtin: executable files
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Run a program
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

Navigation

In this challenge extension, you'll add directory navigation support by implementing the cd and pwd commands.

Along the way, you'll learn about what the "current working directory" is, how to change it and more.

The pwd builtin
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
The cd builtin: Absolute paths
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
The cd builtin: Relative paths
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
The cd builtin: Home directory
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

Quoting

In this challenge extension, you'll add quoting support to your shell.

Quoting allows you to preserve whitespace and special characters in your shell commands.

Single quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Double quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Backslash outside quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Backslash within single quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Backslash within double quotes
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Executing a quoted executable
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

Redirection

In this challenge extension, you'll add redirection support to your shell.

Redirection allows you to redirect the output of a command to a file or another command.

Redirect stdout
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Redirect stderr
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Append stdout
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Append stderr
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

Autocompletion

In this challenge extension, you'll add programmable completion support to your shell.

Programmable completion allows you to autocomplete commands and executable files.

Builtin completion
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Completion with arguments
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Missing completions
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Executable completion
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Multiple completions
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.
Partial completions
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.

Pipelines

In this challenge extension, you'll add support for pipelines to your shell.

Pipelines allow you to connect multiple commands together, so the output of one command becomes the input of the next command.

Dual-command pipeline
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.
Pipelines with built-ins
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.
Multi-command pipelines
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.

History

In this challenge extension, you'll add support for viewing and recalling previously entered commands using the history builtin.

History allows you to view and recall previously entered commands. Also, use it to re-run previous commands using the UP and DOWN arrow keys.

The history builtin
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Listing history
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Limiting history entries
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Up-arrow navigation
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Down-arrow navigation
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Executing commands from history
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.

History Persistence

In this challenge extension, you'll add support for persisting history to a file.

History persistence allows you to save and load previously entered commands to and from a file.

Read history from file
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Write history to file
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.
Append history to file
Hard
We'd expect a proficient developer to take more than 1 hour to complete this stage.
Read history on startup
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Write history on exit
Easy
We'd expect a proficient developer to take 5-10 minutes to complete this stage.
Append history on exit
Medium
We'd expect a proficient developer to take 30 minutes to 1 hour to complete this stage.