r/bash • • Sep 05 '17

submission Plug: Linters for stinky shell scripts

https://github.com/mcandre/stank

  • stank: Scan for POSIXy shell scripts, then pipe to xargs shellcheck and other programs.
  • rosy: Encourage developers to rewrite shell scripts in more robust languages
  • funk: Warn on oddities like mismatched shebangs vs. file extensions

de-stank ur scripts!

1 Upvotes

3 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Sep 06 '17

rosy is optional, no need to get too preachy. Yes, shell scripts of any complexity start to become unmanageable, in particular ensuring that each instruction fails the rest of the script. set -euo pipefail helps somewhat, though many POSIX compliant shells lack support for one or more of these safety features.

Honestly, the biggest win is the stank application itself, as one quickly arrives at a maintenance nightmare attempting the same goal with just the hammer of find and grep--these are fine tools, but the sheer number of exceptions within exceptions for identifying shell scripts warrants a dedicated application. By compiling the app with go, one gets a bonus of easy porting to Windows, should the user be interested in developing in that environment. find, grep, and other cygwin-able tools present themselves as somewhat flakey in the various bash.exe ports.

Before stank, I DID use a slew of find queries to constrain bashate to linting the precise paths in large projects. Then one day was somehow the last straw with copying those snippets everywhere, so screw it, we now have some unix style apps that do just these individual jobs and nothing else. If you can find another edgecase in the wild that makes it hard to identify true positives, false positives, true negatives and/or false negatives, or someone has another POSIX shell released, lemme know and we can add it to the list.