7 ms·
Is there a (real) shell whose code is relatively short and self contained and would be valuable to read? This was always something I wanted to do but never quit
by doe88 6mo ago
Is there a (real) shell whose code is relatively short and self contained and would be valuable to read? This was always something I wanted to do but never quite spent time to look for a good one to explore.
- giancarlostoro 6mo agoAlthough not the same... Destroy All Software has videos on building your own shell using Ruby. I watched it to learn and it was a lot of fun to watch him basically building a shell, I'm not really a Ruby guy, but it was easy to grasp. It's not free, you would need a subscription, but its worth the watch otherwise. https://www.destroyallsoftware.com/screencasts/catalog/shell-from-scratch https://www.destroyallsoftware.com/screencasts/catalog/shell...
- epr 6mo agoI think there's a good one if you search around for "xv6 sh.c". Hard to tell immediately from a google search just now since there are many implementations (people do it in school) and github's currently blocking requests from my phone. Also helpful may be running strace on your shell, then reviewing the output line by line to make sure you understand each. This is a VERY instructive exercise to do in general.
- willx86 6mo agohttps://st.suckless.org/ https://st.suckless.org/
- vidarh 6mo agoSt is a terminal, not a shell.
- tame3902 6mo agoIt depends on what you are looking for. My recommendation for learning "how is X done in a shell" is the OpenBSD ksh: https://github.com/ibara/oksh https://github.com/ibara/oksh It's what they use for /bin/sh, it has everything that a complete shell needs (including a mechanism for providing command completions) and has code that is much easier to read than bash or zsh. Something that I also would recommend is the design document for the plan9 rc shell; it is a worthwhile read for anybody interested in shells: https://doc.cat-v.org/plan_9/4th_edition/papers/rc https://doc.cat-v.org/plan_9/4th_edition/papers/rc An implementation is also available if one wants to look at how it could be done: https://github.com/rakitzis/rc https://github.com/rakitzis/rc
- emmelaich 6mo agoI don't know how real you want -- those criteria are probably self contradictory :-) Marc Rochkind's book Avanced UNIX Programming implemented a basic shell, through iterations. You can see the first at e.g. here https://github.com/gmarler/AUPv2/blob/master/c5/sh0.c https://github.com/gmarler/AUPv2/blob/master/c5/sh0.c It might be a bit old too. The book is very good but again, quite old. There seem to be free copies of it on the net. BTW, does anyone know if Marc Rochkind is alive? His site basepath.com seems to be for sale :-(
- deleted 6mo ago[deleted]