←back to thread

370 points adriangrigore | 2 comments | | HN request time: 0.637s | source
Show context
packetlost ◴[] No.43558205[source]
I unironically wish there was an enterprise version of Plan 9. I've been writing most of my scripts in `rc` (something my coworkers put up with because we use nix and I can pull it in automatically with dirnev) and it has been great.
replies(3): >>43558552 #>>43559150 #>>43563792 #
1. kristianp ◴[] No.43563792[source]
One benefit of rc is this[1]:

> The most important principle in rc’s design is that it’s not a macro processor. Input is never scanned more than once by the lexical and syntactic analysis code

I worked at a unix shop that deleted most of a working drive because a shell script was modified while it was running. Luckily they kept daily backups on tape. This was about 17 years ago.

[1] https://www.scs.stanford.edu/nyu/04fa/sched/readings/rc.pdf

replies(1): >>43566847 #
2. LukeShu ◴[] No.43566847[source]
Scanning input just is unrelated to the "modified while running" problem. The "modified while running" problem is a read-buffering problem.

For example, consider the following change:

    -echo $x; rm -rf /n/foobar/
    +rm -rf /n/foobar/
     ^^^^^^^^^^^^^^^^
If the shell's first read() reads 16 bytes (indicated above with "^"), then the file is changed, then the shell reads the rest; then the shell will see "echo $x; rm -rf /" regardless of whether or not it scans the input multiple times.

I am unfamiliar with the read-buffering done by either of the 2 main implementations of rc, and so am unable to comment on whether it does things to avoid this problem. But if it does do things to avoid it, those things are orthogonal to the "not a macro processor / input is never scanned more than once" thing.