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

MiShell

  • 3 Devlogs
  • 16 Total hours

Today we're building a UNIX shell. Not the greatest, not the fastest ... just whatever we can get out of my C programming skills (just started btw).

Ship #1

MiShell

I tried to implement a basic UNIX shell as an introductory project to C. It supports only piping and got some builtins. That’s all I could do without having to write a lexer/parser myself. Prior to that the most impressive thing I did with C was checking if a string is palindrome or not.

Challenges encountered:

Manual memory allocation:

As someone used from the simplicity of Python, it was quite the hassle but I did learn awesome strategies to manage memory namely arena and lifetime. I’m kinda proud my code doesn’t explicitly use malloc and that Valgrind confirmed it was leak-less. Even tho nobody will use it (and I know there are bugs), I can see that I progressed. I would love to explore more memory management techniques later.

Segfault:

Even with ton of flags I couldn’t escape those. I kinda convince some of them are still waiting for me, there, in one of my function call.

Manpages:

There are just so confusing. I understand better now why Stackoverflow is goated.

Git:

I didn’t even knew there was an hygiene for good commit. Know I think I know a little more? I will probably need to work on that too.

How to test my project:

Just download the latest release on Github. You should be able to run it on Linux and windows (via WSL). Mac I don’t know. But OS X is Unix-based so perhaps it will works too ? If it crash, …

let’s not talk about such sad things.

  • 3 devlogs
  • 16h
  • 5.98x multiplier
  • 96 Stardust
Try project → See source code →
Open comments for this post

5h 55m 11s logged

Final Devlog:

My shell now started to look like something, although I know that it’s not even close to be prod ready. I did my best to hack together something usable i.e that compiles. If I were to add more than that and I would need to create a whole programming language. Even tho I would love to, that’ll be for another day…

Oh, concerning new features, I added the GNU readline library (same used by other shell) so keyboard navigation actually works like a real shell.

I also used another library to handle the parsing instead of my custom parser (it served me well) and finally I customized the prompt to make it less generic.

Now Mishell also support basic piping.

😮‍💨 Took me soooo long just because I didn’t google enough. It was a good learning experience.

Now, I can finally sleep …


….
I can sleep now right ?

“C is quirky, flawed, and an enormous success.”
- Dennis M. Ritchie.

0
0
7
Open comments for this post

7h 39m 3s logged

Diary of a masoschistic perfectionist C noob:

Hello everyone. Hope you’re enjoying the event. On my end things got a little be nasty for the past days.

Truthfully, the challenge was not that hard but you know how it goes:

man gotta invent lemons just because he can right :)

I fell down the C rabbit whole so bad: macros, pointers, errno, free, linking, … The hardest part was obviously managing memory. I was conditioned so much by Youtube to be scared of memory leaks that I had to rewrite an allocator just so to not use malloc. The other challenge I created for myself was to copy-paste random compile flags from everywhere to ensure my code would be mEmORy SaFe:

Spoiler: didn’t even work :(

I dearly missed Python simplicity. I will just have to fix my skill issues.

Anyway, next challenge will be to improve allocation (again) and add more features to the shell. I’ll probably be done (mostly) after this devlog since the purpose of the shell (interact with cli tools) is accomplished.

Now I can finally sleep.

If debugging is the process of removing software bugs, then programming must be the process of putting them in.

0
0
6
Open comments for this post

2h 26m 2s logged

MiShell is a very simple and dumb shell. It got some builtins commands
and … that’s all. I plan to improve it later (if I find time)

0
0
14

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…