Tahler / shellfix

Make shell scripts more robust by following advice from the Shellcheck linter.

Repository from Github https://github.comTahler/shellfixRepository from Github https://github.comTahler/shellfix

Shellfix

Make shell scripts more robust by following advice from the Shellcheck linter.

Automatically fixes:

Running

  1. Install Shellcheck.
  2. Run find . -name '*.sh' | xargs /path/to/main.py.

Implementation

This program uses a naive approach of rewriting the file for each rule.

It does, however, take advantage of the fact that rules can appear in cascading fashion. For example, with the expression x=$(ls), SC2034 suggests exporting the variable. However, after the fix (now export x=$(ls)), on a second run it'll suggest declaring and assigning separately SC2155. Fixing rules iteratively in the same respective order avoids this issue.

About

Make shell scripts more robust by following advice from the Shellcheck linter.

License:GNU General Public License v3.0


Languages

Language:Python 100.0%