running sh scripts through shellcheck
Martin Schwenke
martin at meltin.net
Fri Aug 11 10:27:45 UTC 2017
Hi Rowland,
I've just read your other reply, but will send this anyway given that
I've added some extra explanation. :-)
On Fri, 11 Aug 2017 10:45:58 +0100, Rowland Penny via samba-technical
<samba-technical at lists.samba.org> wrote:
> On Fri, 11 Aug 2017 09:20:33 +0100
> Rowland Penny via samba-technical <samba-technical at lists.samba.org>
> wrote:
>
> >
> > OK, I have got to ctdb/tests/complex/30_nfs_tickle_killtcp.sh where I
> > have found this:
> >
> > echo "Getting MAC address associated with ${test_ip}..."
> > releasing_mac=$(ip neigh show "$test_prefix" | awk '$4 ==
> > "lladdr" {print $5}') [ -n "$releasing_mac" ] || die "Couldn't get
> > MAC address for ${test_prefix}" echo "MAC address is:
> > ${releasing_mac}"
> >
> > So, who doesn't know that 'die' is a perl thing ?
> >
> > There doesn't seem to be a 'die' function.
> >
> > The script is also a 'bash' script instead of a 'sh' script.
> Forget it, found 'die' in ctdb/tests/scripts/common.sh, still think
> calling it 'die' was a bad idea though
Well, you immediately knew what it meant... ;-)
> It still shouldn't be a 'bash' script, it isn't portable, which brings
> me to ctdb/tests/complex/32_cifs_tickle.sh
>
> Changing #!/bin/bash to #!/bin/sh causes this:
>
> In ctdb/tests/complex/32_cifs_tickle.sh line 69:
> if [ "${out/SRC: ${src_socket} /}" != "$out" ] ; then
> ^-- SC2039: #!/bin/sh was specified, but string replacement is not standard.
>
> I will have to find the relevant code, decipher it and re-write it for
> 'sh'
CTDB's public IP address handling isn't portable. It relies on Linux
things like the "ip" command from the "iproute" package. Given that a
significant subset of CTDB's functionality is not portable, it isn't
important to make the tests portable.
While there might me a small number of shellcheck hits in each
individual test, you'll find a lot more in the include file
ctdb/tests/script/integration.bash. It just isn't worth it at this
stage... ;-)
peace & happiness,
martin
More information about the samba-technical
mailing list