Hi,
some time ago I fixed a typo in an yast2-packager shell script. After fixing it [1] I remembered that I had looked at the ShellCheck tool in the past. It is a similar tool to Rubocop but designed for shell scripts. There is even an online version if you want to do a quick test without installing it [2]. When I tried to run it on the original script it obviously found the error there. My idea was to run this check also in Travis to avoid similar problems in the future so I created a package in YaST:Head [3] and included it in the Travis image. The package is already available in the Leap 15.0 but the Tumbleweed contains a newer version which reports some more issues so I copied the TW version to YaST:Head and built it also for Leap 15.0. If you want to run ShellCheck for your scripts in Travis see [4] how it was done in the yast2-packager. Last but not least, there is a good documentation (wiki) describing the rationales and how to fix each reported issue, like [5]. So even when you are not a shell expert you should be able to fix the reported issues quite easily. Enjoy! :-) P.S.: An interesting detail I found: Shellcheck looks quite smart, e.g. in foo $bar it complains that you should double quote the unknown $bar value, but with bar=baz foo $bar it does not complain as it is actually not needed. With bar="baz z" foo $bar it correctly complains again. So it does not foolishly complain about double quotes everywhere, it evaluates the context and the real values to avoid false positives. That's really nice! [1] https://github.com/yast/yast-packager/pull/386/files [2] https://www.shellcheck.net/ [3] https://build.opensuse.org/package/show/YaST:Head/ShellCheck [4] https://github.com/yast/yast-packager/blob/465cdbce77c24f008b9e36653abf4dea86da6410/.travis.yml#L17 [5] https://github.com/koalaman/shellcheck/wiki/SC2086 -- Ladislav Slezák YaST Developer SUSE LINUX, s.r.o. Corso IIa Křižíkova 148/34 18600 Praha 8 -- To unsubscribe, e-mail: [email protected] To contact the owner, e-mail: [email protected]
