Tuesday, April 5, 2022

Using shellcheck With BBEdit

Armin Briegel:

Once you have the shellcheck command installed, you can also invoke from within BBEdit: When you have a script open in BBEdit, verify that the script is recognized as a ‘Unix shell script.’ Then you can select ‘Check Syntax…’ from the ‘#!’ menu (keyboard shortcut ⌘-K). This will open a second window with all the issues shellcheck has found.

Unfortunately, given that Apple is phasing out bash, it doesn’t work with zsh.


Update (2022-04-13): Matt Sephton:

zsh -n $FILENAME and/or zsh -x $FILENAME (non_exec and debug mode respectively) are a reasonable workaround. Not shellcheck good but workable.

1 Comment RSS · Twitter

So true. And it doesn't seem like they plan to support zsh anytime soon (https://github.com/koalaman/shellcheck/issues/809).

I've been using the following workaround using zsh's Bash emulation mode:

# shellcheck shell=bash
emulate -LR bash

Leave a Comment