Hacker News new | ask | show | jobs
by csours 817 days ago
Scripts should be commented with intent. (I can figure out what it is doing, but I have no clue WHY)

Scripts should be testable.

Scripts should use functions with appropriately scoped variables. (This really helps with testability)

Scripts should list assumptions.

Scripts should CHECK assumptions.

Scripts should call commands with --long-style-options instead of -L, especially uncommon options.

---

As someone who migrated a couple hundred shell scripts over the past year, I'd rather have these done before I ask someone to write a script in C.

edit: and for ${deity} sake, use shellcheck.

2 comments

I think you mean "${deity}" in case of spaces ...
> Scripts should call commands with --long-style-options instead of -L, especially uncommon options.

Too bad `getopts` only supports single-char options. :p

I'm not a fan of getopts

And to be more specific - I meant when the script calls someone else, not how it handles options.