The static analysis tool shellcheck is quite useful for finding bugs, potential future problems, and compatibility/portability issues in shell scripts.
In a codebase that deals with (for example) both *nix and darwin it can be very helpful because it finds word-splitting bugs that won't commonly show up on a linux host but will mysteriously appear on a mac because of how often mac file paths have spaces in them.
So, I was wondering:
1. Are you open to a sizeable PR implementing the minimal fixes suggested by shellcheck?
Currently there a 22 files that would be changed (and one separate but related github action update):
$ find . -iname '*.sh' -print0 | xargs -0 shellcheck -f json | jq -r '.[].file' | sort --uniq
./.ci/dockerfiles/deb-sbuild/setup-chroot.sh
./cardcomm/minidriver/build32debug.sh
./cardcomm/minidriver/build32release.sh
./cardcomm/minidriver/build64debug.sh
./cardcomm/minidriver/build64release.sh
./cardcomm/tokend/buildtokend.sh
./cardcomm/tokend/buildtokend2.sh
./installers/eid-mw/mac/create_package.sh
./installers/eid-mw/mac/create_uninst_package.sh
./plugins_tools/xpi/build.sh
./scripts/build-aux/cleanup.sh
./scripts/build-aux/fed-rel.sh
./scripts/build-aux/genver.sh
./scripts/build-aux/suse-rel.sh
./scripts/mac/create-vers.sh
./scripts/mac/export-mac.sh
./scripts/mac/export-viewer.sh
./scripts/mac/make-BEIDToken.sh
./scripts/mac/make-mac.sh
./scripts/mac/make-viewer.sh
./scripts/mac/set_eidmw_version.sh
./scripts/mac/sign-viewer.sh
Here's an example diff from that last item:
$ shellcheck -f diff ./scripts/mac/sign-viewer.sh
--- a/./scripts/mac/sign-viewer.sh
+++ b/./scripts/mac/sign-viewer.sh
@@ -13,5 +13,5 @@
codesign -s "Developer ID Application" "/Volumes/eID Viewer/eID Viewer.app/Contents/Frameworks/BeidView.framework/Versions/A/Frameworks/libbeidpkcs11.$REL_VERSION.dylib"
codesign -s "Developer ID Application" "/Volumes/eID Viewer/eID Viewer.app/Contents/Frameworks/BeidView.framework"
codesign -s "Developer ID Application" "/Volumes/eID Viewer/eID Viewer.app"
-hdiutil detach $DEVNAME
+hdiutil detach "$DEVNAME"
hdiutil convert tmp-eidviewer.dmg -format UDBZ -o "eID Viewer-$REL_VERSION-signed.dmg"
It just puts quotations around the $DEVNAME argument to prevent word-splitting. In this case the script controls the content DEVNAME (assuming a non-hostile PATH) so adding the quotes maybe just gives a bit more protection (probably a better failure) if apple changes the output formatting of the hdiutil command. I just mention this because there are many times where the changes are just belt-and-suspenders precautions, rather fixing a proper bug.
2. Are you open to a PR which updates your gitlab or github workflows to include a shellcheck test?
There are official github actions from the shellcheck maintainer, but integrating it into an existing ci script is also easy, provided you have the binary (it's an open source haskell codebase).
The static analysis tool shellcheck is quite useful for finding bugs, potential future problems, and compatibility/portability issues in shell scripts.
In a codebase that deals with (for example) both *nix and darwin it can be very helpful because it finds word-splitting bugs that won't commonly show up on a linux host but will mysteriously appear on a mac because of how often mac file paths have spaces in them.
So, I was wondering:
1. Are you open to a sizeable PR implementing the minimal fixes suggested by shellcheck?
Currently there a 22 files that would be changed (and one separate but related github action update):
Here's an example diff from that last item:
It just puts quotations around the
$DEVNAMEargument to prevent word-splitting. In this case the script controls the content DEVNAME (assuming a non-hostilePATH) so adding the quotes maybe just gives a bit more protection (probably a better failure) if apple changes the output formatting of the hdiutil command. I just mention this because there are many times where the changes are just belt-and-suspenders precautions, rather fixing a proper bug.2. Are you open to a PR which updates your gitlab or github workflows to include a shellcheck test?
There are official github actions from the shellcheck maintainer, but integrating it into an existing ci script is also easy, provided you have the binary (it's an open source haskell codebase).