Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 993 Bytes

README.md

File metadata and controls

26 lines (18 loc) · 993 Bytes

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.