Live data from Hacker News

A Bourne-style shell built from scratch in 35 minutes [video]

destroyallsoftware.com

11–20 of 71 posts

Re: A Bourne-style shell built from scratch in 35 minutes [video]

#12
post #3

There is more to writing a shell than simply reading commands and executing them after fork()ing. TTY handling must be done right¹ and interrupt and signal handling is rather tricky to get right as well². (Not to mention, of course, that a Unix shell is very cumbersome to use without pipes and redirection. EDIT: Pipes are implemented, but not redirection?) 1. http://www.linusakesson.net/programming/tty/ 2. https://ww…

If the implementation done in less than an hour is not featureful enough for you, obviously you don't have to use it. Doesn't reflect the value in this type of post on HN.

If it was insufficiently pedagogical, or failed to give people the impression that shells are just software and They Can Do It Too, then I would understand the critique more, as those are clearly the goals.

Re: A Bourne-style shell built from scratch in 35 minutes [video]

#13
post #5

On this note, I need to build my own Terminal multiplexer - does anyone have a favorite primer of theirs for all the escape codes? Not only do I need to use them myself, but I need to handle them of child processes to restrict term sizes etc. I can Google like ya'll - I'm just asking if there are any favorite resources :) Thanks

There are no such things as “ the ” escape codes. Any terminal could have any codes. You would have to look at the TERM environment variable and use codes appropriate for that terminal. There are, of course, libraries to do this for you, such as terminfo and ncurses. But never output raw escape codes yourself - all the world is not a VT100 or Linux terminal.

I think the original poster does not want to output escape codes, he wants to build a terminal that will accept escape codes like a xterm. This way, he won't need to create a new terminal type with all the terminfo or ncurses configuration.

Re: A Bourne-style shell built from scratch in 35 minutes [video]

#14

Was expecting more guns, car chases, exotic city backgrounds, and slightly-above-average women from the new Bourne shell. Turns out it's just a command line interpreter. Two stars.

Funny, but the shell's namesake is pretty badass himself https://en.wikipedia.org/wiki/Stephen_R._Bourne

Re: A Bourne-style shell built from scratch in 35 minutes [video]

#15

On this note, I need to build my own Terminal multiplexer - does anyone have a favorite primer of theirs for all the escape codes? Not only do I need to use them myself, but I need to handle them of child processes to restrict term sizes etc. I can Google like ya'll - I'm just asking if there are any favorite resources :) Thanks

The xterm document pointed to elsewhere in the thread ( http://invisible-island.net/xterm/ctlseqs/ctlseqs.html ) is the canonical reference, but I'd suggest using something like libvterm rather than writing that part yourself.

Re: A Bourne-style shell built from scratch in 35 minutes [video]

#17

On this note, I need to build my own Terminal multiplexer - does anyone have a favorite primer of theirs for all the escape codes? Not only do I need to use them myself, but I need to handle them of child processes to restrict term sizes etc. I can Google like ya'll - I'm just asking if there are any favorite resources :) Thanks

Not strictly answering your question, but years ago I worked on a job which comprised a group of us sitting in a room, each with a VT100 connected to a Unix box in the corner, cranking out C. We weren't massively overworked, so one clever bugger wrote his own terminal multiplexer on the side, enabling him to flip between sessions using function keys. Another guy wrote a shell - in Bourne shell. It had, errm, a few issues, but, crucially, gave us command line editing and history (that was otherwise lacking in the vanilla sh we had, and none of us fancied csh much).

Re: A Bourne-style shell built from scratch in 35 minutes [video]

#20
post #14

Was expecting more guns, car chases, exotic city backgrounds, and slightly-above-average women from the new Bourne shell. Turns out it's just a command line interpreter. Two stars.

Funny, but the shell's namesake is pretty badass himself https://en.wikipedia.org/wiki/Stephen_R._Bourne

“[…] at one time Bell Labs had two Stephen R. Bournes with offices along the same hallway.”¹

— Eric Allman

1. http://www.sendmail.org/~ca/email/README.cf.8.8.html

Post reply on HN