2 ms·
> I did some looking at freebsd-update, and it's quite the shell script, which makes it daunting to consider changing. All the forking and whatever doesn't seem
by deaddodo 2y ago
> I did some looking at freebsd-update, and it's quite the shell script, which makes it daunting to consider changing. All the forking and whatever doesn't seem great; using data structures should be a lot simpler!
It doesn't look too crazy:
https://github.com/freebsd/freebsd-src/blob/main/usr.sbin/freebsd-update/freebsd-update.sh https://github.com/freebsd/freebsd-src/blob/main/usr.sbin/fr...
It's fairly well broken down, and pretty well organized. I think the most difficult part is that so much of it relies on shell nice-isms that are a pain to re-implement in something like C (although, I guess you could just call fetch and the like directly via 'exec' or 'system'; rather than using their libraries to manage things directly).
- throw0101d 2y ago> It's fairly well broken down, and pretty well organized. Not surprising given that it's written by Colin Percival, who was the Security Officer for FreeBSD for a while, and who runs/develops Tarsnap: * https://www.tarsnap.com https://www.tarsnap.com * https://en.wikipedia.org/wiki/Colin_Percival https://en.wikipedia.org/wiki/Colin_Percival * https://news.ycombinator.com/user?id=cperciva https://news.ycombinator.com/user?id=cperciva
- kstrauser 2y agoI do have to say that's about the cleanest shell script of that size I've ever seen. cperciva, if you're reading this, that's pretty.
- cryptonector 2y agoHmmm, lots of `for C in $@;` that should be `for C in "$@";` instead.
- ptx 2y agoHmm. Yup. For example, this is broken: # freebsd-update -f "/tmp/path with spaces/freebsd-update.conf" fetch usage: freebsd-update [options] command ... ...
- cryptonector 2y agoAnd it's not even setting IFS to the empty string.