A "Shell" made in Rust

Overview

Ironclad-shell

A "shell" command interpreter made in rust.

First things first

This is my first time posting to reddit and my first time using rust (also worth noting that english is not my main language), so please any constructive criticism is well seen.

A little background

I'm a graduate student in computer science and for my OS (Operating Systems) classes my teacher told us to create a "shell" in C/C++, but as I was fascinated by Rust as asked him if i could do it in Rust and for my surprise he said yes. Now, one would think that doing an assignment in a programming language that i have no experience would be a bad call.

It's!

But I decided to go for it!

It doesn't implement all the required operations asked by my teacher but, I thought it would be nice to share it and receive some tips since no teacher or person I know knows Rust.

But what does it do?

It's really simple it has and can do the following things:

  • It has it's own PS1 variable you can set;
  • It has it's own PATH called MYPATH, it copies the original system path and you can later change it;
  • It can pipe (|) commands this was incredibly hard to do;
  • It can redirect stdout (>) and stderr(2>);
  • It can read an stdin file (<);
  • It can run path commands and same directory programs;
  • It sort of can run programs in the background (&) but offers no control;
  • It captures Ctrl+C and it's associated signal, so you can't exit the program with it;
  • It can only be exited by the exit command and by the use of Ctrl+D;
  • It has the set command to see all env variables;
  • It has the exportcommand to set new env variables;
  • It stores the history of the commands in the current dir in a .history file, until it reaches 50 lines. I just realized that if you changed dir it starts writing the .history file again
  • It unfortunately does not have the capability do pipe shell commands with path commands;

I think that it's all, at least that I can remember.

Important points

Now there are two things that I think that are important for me to say before anyone sees the code.

  1. I tried to write the code using OOP, since the codes that my teacher showed us were all in C++ and we're written using OOP.
  2. I believe that I commited alot of mistakes and/or "bad usage of" when writing the code in regards of types and if statements.

"So what, do you have any plans for it now?"

Yes! Firstly I want to fix some of the points that do not follow my teacher points, like correct implementation of background processes, usage of the fg, bg and kill (not the /bin/kill one) commands that weren't implemented.

Implement more POSIX commands, and buffer control.

Add some colors to the PS1 and change it from the one ordered by my teacher.

Add the possibility to pipe shell commands and processes.

Fix any issues pointed by the people that see the code.

Final regards

This my first time having any experience with Rust, and one thing that I learned is, I really liked this language, I work with Typescript daily and have experience with Flutter, Java and C/C++. I always wanted to learn Rust and now I want to learn it even more, I don't know if I should work on other projects, start with stuff that is easier instead of starting with a "shell" implementation. I hope that in the future I end up working with this language.

This is the same .md posted to reddit as i'm doing this at 11:30 PM in my local time, hope you don't mind 😉

You might also like...
🐢 Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands
🐢 Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands

Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, it provides optional and fully encrypted synchronisation of your history between machines, via an Atuin server.

A shell for research papers

Reason: A Shell for Research Papers Did I ever read this paper? Which OSDI 2021 papers did I read? Which ones have the word 'Distributed' in their tit

Explore from the safety of your shell
Explore from the safety of your shell

turtlescan Explore from the safety of your shell Installation: cargo install turtlescan tui Starts a little tui which connects to your JSON-RPC server

dune - A shell by the beach!
dune - A shell by the beach!

dune - A shell by the beach!

A command-line shell like fish, but POSIX compatible.
A command-line shell like fish, but POSIX compatible.

A command-line shell like fish, but POSIX compatible.

Zash - A Zuper Awesome Shell
Zash - A Zuper Awesome Shell

Zash - A Zuper Awesome Shell Welcome to zash, its activily being developed and is not near a stable release. Installation Arch: yay -S zash Paru seem

A very opinionated, zero-configuration shell prompt
A very opinionated, zero-configuration shell prompt

A very opinionated, zero-configuration shell prompt

An interactive shell environment for exploring the p2panda protocol
An interactive shell environment for exploring the p2panda protocol

An interactive shell environment for exploring the p2panda protocol. Uses a mock node and clients to simulate network logic.

Self-contained template system with Handlebars and inline shell scripts

Handlematters Self-contained template system with Handlebars and inline shell scripts Introduction Handlematters is a template system that combines Ha

Owner
Leonardo Kazuyoshi
I'm a CS graduate just trying to learn more, one piece at a time. "It is what it is"
Leonardo Kazuyoshi
A Rust-based shell script to create a folder structure to use for a single class every semester. Mostly an excuse to use Rust.

A Rust Course Folder Shell Script PROJECT IN PROGRESS (Spring 2022) When completed, script will create a folder structure of the following schema: [ro

Sebastián Romero Cruz 1 Apr 10, 2022
a cute shell thingy that written in rust

a cute shell thingy that written in rust

奥田 龍馬 12 Dec 29, 2021
A Unix shell written and implemented in rust 🦀

vsh A Blazingly fast shell made in Rust ?? Installation Copy and paste the following command and choose the appropriate installtion method for you. Yo

XMantle 89 Dec 18, 2022
A command line interface meant to bridge the gap between Rust and shell scripting

clawbang A command line interface meant to bridge the gap between Rust and shell scripting. Intended for use with HEREDOCs and shebangs: $ clawbang <<

Chris Dickinson 52 Mar 25, 2022
Toy Shell Written in Rust

This is a simple toy shell written in Rust language with porpose of learning system programmim, and in a specific theme, process management.

Júlio César de Brito Gardona 4 May 22, 2022
Safe Unix shell-like parameter expansion/variable substitution via cross-platform CLI or Rust API

Safe Unix shell-like parameter expansion/variable substitution for those who need a more powerful alternative to envsubst but don't want to resort to

Isak Wertwein 4 Oct 4, 2022
A unix shell written in rust

rust-shell a unix shell written in rust Features Main features has .rc file (in ~/.rstshrc) has syntax highlighting fish-like autosuggestion emacs edi

matan h 4 Jan 10, 2023
🍬 shell-candy is a library that wraps Rust's `std::process::Command`

?? shell-candy is a library that wraps Rust's `std::process::Command`, providing a functional mechanism for handling stdout/stderr streams of spawned tasks..

Avery Harnish 6 Oct 25, 2022
Shell scripting that will knock your socks off

atom Shell scripting that will knock your socks off. NOTE: Click the image above for a video demonstration.

adam mcdaniel 256 Dec 14, 2022
A new type of shell

A new type of shell

Nushell Project 22.5k Jan 8, 2023