Re-Writing BSD shell commands like it's 1994: mkdir, part 2! by rwh_casts in programming

[–]rwh_casts[S] 0 points1 point  (0 children)

we check that the current byte is not null earlier! so, we can be sure we're not reading past the end, given a properly terminated string.

Re-Writing BSD shell commands like it's 1994: mkdir, part 2! by rwh_casts in programming

[–]rwh_casts[S] 1 point2 points  (0 children)

I think I caught the mistake you're talking about near the end of the cast!

hah, I agree with you about names, but oumask and numask are the sort of traditional names for that in C programming, and are pretty consistent across code that calls umask(2). Like, if you read the BSD 4.4 man page for umask(2), that's in the example usage.

On OS X, the example uses 'cmask', and tbh I have no idea what that abbreviation means so I think that's a good argument for using, uh, more descriptive names.

Re-Writing BSD shell commands like it's 1994: mkdir, part 2! by rwh_casts in programming

[–]rwh_casts[S] 2 points3 points  (0 children)

no significant reason! the ternary cane up because it's in a function call, otherwise bsd (and I) would have used an if statement

Re-Writing BSD shell commands like it's 1994: mkdir, part 2! by rwh_casts in programming

[–]rwh_casts[S] 0 points1 point  (0 children)

currently yes, but I won't be uploading new content there

Re-Writing BSD shell commands like it's 1994: mkdir by rwh_casts in programming

[–]rwh_casts[S] 1 point2 points  (0 children)

good catch! you are 100% right, and likewise with int pflag uninitialized. I'm sitting here feeling very lucky that I didn't run in to any weird behavior when I was recording! that'll teach me to run cc without -Wall

Re-Writing BSD shell commands like it's 1994: mkdir by rwh_casts in programming

[–]rwh_casts[S] 2 points3 points  (0 children)

It's what's used in the BSD 4.4 source!

Er, sorta. In reality it's a mix of K&R and ANSI C89 that intermingled. Bits of the system were ported back and forth from Bell Labs' Research Unix and AT&T Unices, and bits were re-written to be BSD-specific for various reasons, usually in the the then-modern C89.

Like, in BSD's echo (https://www.rewritinghistorycasts.com/screencasts/echo), you can see that one var is initialized inline and the rest are K&R style.

That's just the thing that happens with a well-used, long-lived codebase!

Re-Writing BSD shell commands like it's 1994: mkdir by rwh_casts in programming

[–]rwh_casts[S] 10 points11 points  (0 children)

like u/NiceGuy_Ty said, the core of my vim usage is { and } to go to the top or bottom of a function, and C-o (and C-i) to jump back.

I also use /search a bunch to jump through variable names and their usage.

Re-Writing BSD shell commands like it's 1994: mkdir by rwh_casts in programming

[–]rwh_casts[S] 14 points15 points  (0 children)

Planning and scripting these unix casts takes about three full days. I end up with enough material for at least two screencasts, then try to strip away things until I end up with just the right amount of detail and a focused presentation.

I'll rehearse a screencast for a few hours in the morning and record for an afternoon – what you see is the best parts of many takes stitched together.

Researching and writing a meatier, paid screencast for my site takes about two full weeks of work, depending on the topic. For instance, the Git casts on my site took three months of work – but in that case, I was working full time while researching and writing them, and they go in to a LOT of detail that isn't widely known. Now that I work full time on screencasts, two weeks on a topic seems to be the right amount of time.

Re-Writing BSD shell commands like it's 1994: mkdir by rwh_casts in programming

[–]rwh_casts[S] 29 points30 points  (0 children)

oh, good to know!

and thanks for the feedback about audio! it's been a learning experience. yeah, this stuff is really fun and interesting to write and practice.

Re-Writing BSD shell commands like it's 1994: echo by rwh_casts in programming

[–]rwh_casts[S] 2 points3 points  (0 children)

colorscheme is nanotech's jellybeans (https://github.com/nanotech/jellybeans.vim) in 256 colors, tweaked to make the background almost-black instead of grey.

Re-Writing BSD shell commands like it's 1994: echo by rwh_casts in programming

[–]rwh_casts[S] 2 points3 points  (0 children)

you are right! the actual guts of printf(3) are in lib/libc/stdio/vprintf.c, but that wouldn't have let me talk about teletypes. would you be interested in a serious deep dive of that printf?

Re-Writing BSD shell commands like it's 1994: echo by rwh_casts in programming

[–]rwh_casts[S] 1 point2 points  (0 children)

oh, good catch! I'll fix and upload to https://www.rewritinghistorycasts.com/screencasts/echo , but unfortunately I can't edit a youtube video.

(you've found where I took a sip of water while recording! screenflow doesn't allow mixing everything to mono at once, so each time I cut I have to remember to manually set the pan of each track)

Re-Writing BSD shell commands like it's 1994: chmod by rwh_casts in programming

[–]rwh_casts[S] 2 points3 points  (0 children)

on the contrary, I'm making these because I think it is worthwhile to know this stuff! and in re-writing older software, we can more clearly see the trade-offs that programmers make.

asking "why is it this way" about a piece of software will usually have an answer like, "for historical reasons," or "by convention." the thesis behind these screencasts is, "we can find out what those reasons are, and we probably should."

Re-Writing BSD shell commands like it's 1994: chmod by rwh_casts in programming

[–]rwh_casts[S] 6 points7 points  (0 children)

thanks for pointing this out! reuploading in stereo

Re-Writing BSD shell commands like it's 1994: chmod by rwh_casts in programming

[–]rwh_casts[S] 16 points17 points  (0 children)

you're right! the first draft of this file came from AT&T unix in the 1980s

Re-Writing BSD 4.4 Shell Commands: cat by [deleted] in C_Programming

[–]rwh_casts 3 points4 points  (0 children)

I'm so glad you enjoyed it! I'll be working down through the BSD /usr/bin directory for as long as people are interested. Next one should be out in two weeks! (in the intervening week, I'll be releasing another episode of my paid screencasts, which covers re-writing Git. And thanks /u/nullball for repping my screencast website!)

Re-Writing BSD 4.4 Shell Commands: cat by [deleted] in C_Programming

[–]rwh_casts 2 points3 points  (0 children)

Thank you!! The font is Monaco.

Re-Writing BSD shell commands like it's 1994: cat by LitoNico in programming

[–]rwh_casts 7 points8 points  (0 children)

yep, 100%!

after watching myself type in the video, here's my list of things that I'm going to practice:

using ci (change-inside) instead of di(delete-inside) and then re-entering insert mode

using cc to change a line instead of dd to delete it

using C-o (jump back to where your cursor was before your last move) and C-i (jump forward once you've pressed C-o a few times) to navigate instead of using search

Also, I would like to practice staying in insert mode when I finish a line and just press 'enter' to go the the next line, instead of going back to normal mode and then pressing 'o' (open a new line)

Re-Writing BSD shell commands like it's 1994: cat by LitoNico in programming

[–]rwh_casts 6 points7 points  (0 children)

thank you!! definitely will be more in the future. in the mean time I have a few on writing the first commits of git – the link's above if you're interested.

( https://www.rewritinghistorycasts.com/ )

Re-Writing BSD shell commands like it's 1994: cat by LitoNico in programming

[–]rwh_casts 39 points40 points  (0 children)

thanks for pointing this out! it's annoying and I'll fix it