On 2014-12-07, Raphael Geissert wrote:
> On Sunday 07 December 2014 09:15:46 Vagrant Cascadian wrote:
>> On 2014-12-06, Raphael Geissert wrote:
>> > I've ran checkbashisms (from the 'devscripts' package) over the whole
>> > archive and I found that your package has a /bin/sh script that uses a
>> > "bashism".
>> > 
>> > checkbashisms' output:
>> >> possible bashism in ./usr/share/initramfs-tools/scripts/local-top/nbd
>> >> line>> 
>> >> 84 ([^] should be [!]):
>> >>     *[^0-9]*)
>> > 
>> > Not using bash (or a Debian Policy compliant shell interpreter that
>> > doesn't provide such an extra feature) as /bin/sh is likely to lead to
>> > errors or unexpected behaviours. Please be aware that dash is the
>> > default /bin/sh.
>> For initramfs-tools/scripts/*, I believe the shell actually used is
>> typically either busybox shell (or klibc shell?), not dash, as these
>> scripts are run from the initramfs environment. Not sure if this
>> actually triggers issues with those shells as well.
>
> Perhaps they should have a proper shebang then?

Not sure what you mean by proper... busybox/klibc sh is installed as
/bin/sh in the initramfs from which it is run.

Because of this, any /bin/sh scripts in
/usr/share/initramfs-tools/scripts/* might not be good targets for
checkbashisms runs...


I did write up a little example, which produced different results for
dash, busybox sh, klibc sh, and bash:

#!/bin/sh

nbdports="/opt/ltsp/ltsp5 /opt/ltsp/i386 /opt/ltsp/amd64 /opt/ltsp/armhf 4535"

for nbdport in $nbdports ; do

echo
echo "testing: $nbdport"
nbdpath=""

case "$nbdport" in
        *[^0-9]*)
                # non-numeric characters, assume a name rather than a port
                nbdpath="$nbdport"
                unset nbdport
                ;;
esac

echo "nbdpath: $nbdpath"
echo "nbdport: $nbdport"

done


Bash and busybox sh produced the same output, which was the correct
output, reporting the solely numeric entries as nbdport, and the other
entries as nbdpath.


Using the suggested alternative match "*[!0-9]*" worked correctly in all
four shells, so the following patch should work correctly (though I
haven't yet tested in the real world):

diff --git a/debian/nbd-client.initrd b/debian/nbd-client.initrd
index 96f89ae..cd1bfe4 100644
--- a/debian/nbd-client.initrd
+++ b/debian/nbd-client.initrd
@@ -81,7 +81,7 @@ case "$nbdroot" in
 esac
 
 case "$nbdport" in
-       *[^0-9]*)
+       *[!0-9]*)
                # non-numeric characters, assume a name rather than a port
                nbdpath="$nbdport"
                unset nbdport



live well,
  vagrant

Attachment: signature.asc
Description: PGP signature

Reply via email to