schlomo / rbme

RSYNC BACKUP MADE EASY
GNU General Public License v3.0
35 stars 13 forks source link

shellcheck #9

Closed thomasmerz closed 4 months ago

thomasmerz commented 1 year ago

Hi @schlomo , you really should use some kind of shellcheck for your rbme Shell Script:

rbme|135 col 30 warning| ShellCheck can't follow non-constant source. Use a directive to specify location. [SC1090]
rbme|221 col 8 warning| Prefer mapfile or read -a to split command output (or quote to avoid splitting). [SC2207]
rbme|290 col 12 warning| Prefer mapfile or read -a to split command output (or quote to avoid splitting). [SC2207]
rbme|290 col 14 warning| Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames. [SC2010]
rbme|299 col 3 warning| Variable was used as an array but is now assigned a string. [SC2178]
rbme|305 col 60 warning| Expanding an array without an index only gives the first element. [SC2128]
rbme|319 col 4 warning| Use 'pushd ... || exit' or 'pushd ... || return' in case pushd fails. [SC2164]
rbme|321 col 11 warning| Quote this to prevent word splitting. [SC2046]
rbme|322 col 4 warning| Use 'popd ... || exit' or 'popd ... || return' in case popd fails. [SC2164]
rbme|431 col 44 warning| Use single quotes, otherwise this expands now rather than when signalled. [SC2064]
rbme|488 col 13 warning| Quote expansions in case patterns to match literally rather than as a glob. [SC2254]
rbme|490 col 20 warning| Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. [SC2206]
rbme|496 col 4 warning| Variable was used as an array but is now assigned a string. [SC2178]
rbme|622 col 10 warning| Expanding an array without an index only gives the first element. [SC2128]
rbme|691 col 2 warning| Use 'pushd ... || exit' or 'pushd ... || return' in case pushd fails. [SC2164]
schlomo commented 1 year ago

😃

Thanks a lot for not giving up on teaching me better Bash, I'll take a look at this. I also appreciate your pushing rear to become better.

TBH, I've had already some cases where I really struggled to make shellcheck happy with the way how I like to use Bash. So I remain curious to see how this goes.

thomasmerz commented 1 year ago

It's hard to get used the shellcheck style… Or even the shfmt style (next level!)… But… when you got used to it, you will love it ❤️

thomasmerz commented 1 year ago

If you want I can try a PR for fixing + a fancy GitHub Action for you repo. But I'm not sure if you want "my" solution or the one from the rear repo/PR? 🤷🏼‍♂️

thomasmerz commented 1 year ago

@schlomo , do you have an opinion about this issue? PR or not?

schlomo commented 1 year ago

Shellcheck is haunting me... RBME is very much in a "just works" stage of its life. I'd be happy to accept PRs that improve stuff, especially introducing things that play well with ReaR but I won't find the time to work on this myself now. If I have time then I'd rather spend it on https://chromein.de/ FYI (although RBME might still have more users).

schlomo commented 4 months ago

Let's see what happens, worst case I'll adopt https://github.com/rear/rear/blob/master/.github/workflows/differential-shellcheck.yml instead :-)

thomasmerz commented 4 months ago

This Red Hat Plumber/Dev is doing also a great job 👍🏼 But it is also a little bit oversized for your little small project (but suits perfect for rear - and I'm out of support for this 😃).