Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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/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).



> 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://en.wikipedia.org/wiki/Colin_Percival

* https://news.ycombinator.com/user?id=cperciva


I 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.


Hmmm, lots of `for C in $@;` that should be `for C in "$@";` instead.


Hmm. Yup. For example, this is broken:

  # freebsd-update -f "/tmp/path with spaces/freebsd-update.conf" fetch                                                                            
  usage: freebsd-update [options] command ...

  ...


And it's not even setting IFS to the empty string.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: