hackerb9 / lsix

Like "ls", but for images. Shows thumbnails in terminal using sixel graphics.
GNU General Public License v3.0
3.97k stars 129 forks source link

✨ add a GitHub Action for shellcheck'ing on every PR and push to master branch + shellcheck'ed script #75

Open thomasmerz opened 1 month ago

thomasmerz commented 1 month ago

shellcheck was complaining:

$ docker run --rm -v "$PWD:/mnt" koalaman/shellcheck:stable -Calways -S warning lsix

In lsix line 196:
    for x in ${!MAPFILE[@]}; do
                 ^------------^ SC2068 (error): Double quote array expansions to avoid re-splitting elements.

In lsix line 208:
        (cd "$arg"; $lsix)
                 ^-------^ SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

Did you mean:
        (cd "$arg" || exit; $lsix)

In lsix line 218:
    resize="[${tilewidth}x${tileheight}]"
    ^----^ SC2034 (warning): resize appears unused. Verify use (or export if used externally).

In lsix line 237:
    while [ $# -gt 0  -a  $# -gt $goal ]; do
                          ^-- SC2166 (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2034 -- resize appears unused. Verify use...
  https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |...

This PR fixed this and I tested it:

image

My GitHub Action's Run can be found here.

thomasmerz commented 1 month ago

@hackerb9 , I have rebased and my PR is ready for your assessment…
It should be clear which shellcheck warnings and errors are fixed (I didn't care about infos and style) and that this PR introduces a free of charge GitHub Action that will shellcheck every push to master or any PR.