Skip to content

ayushcodes1729/zoro-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to Zoro Shell

Zoro Shell is a simple POSIX shell written in C language.

How to Use

Note: This shell won't work on windows, since POSIX.

Download the binaries I released, the one compatible for your system

OR

  1. Compile the shell:

    gcc src/main.c -o zoro
  2. Run it:

    ./zoro
  3. Type a command(help) at the > prompt and press Enter.

  4. Use exit to leave the shell.

A little sneek peek of working

  • Interactive command prompt using >.
  • Reads user input line by line.
  • Splits commands and arguments by whitespace.
  • Runs external programs available in your system path.
  • Uses fork() to create a child process for commands.
  • Uses execvp() to execute external commands.
  • Waits for child processes to finish before showing the next prompt.
  • Includes basic built-in commands.
  • Handles end-of-file input cleanly.
  • Reports errors for failed reads, forks, and command execution.

Built-in Commands

  • cd <path>: Changes the current working directory.
  • help: Shows shell usage information and available built-ins.
  • exit: Stops the shell.

How It Works

Zoro Shell runs a loop that prints a prompt, reads input, parses it into arguments, and decides whether the command is built in or external.

Built-in commands are handled directly by the shell process. This is required for commands like cd, because changing directories must affect the running shell itself.

For external commands, the shell creates a child process with fork(). The child process calls execvp() to replace itself with the requested program, while the parent process waits until the child exits or is signaled.

Why I named Zoro?

Because I am a One Piece fanboy ;)

Example

>help
>cd src
>ls
>exit

Notes

  • Commands are separated by spaces, tabs, and newlines.
  • Quoting, pipes, redirects, and environment variable expansion are not currently implemented.
  • This project is intended as a small educational shell implementation.

About

A simple shell created in C

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages