Bug#832896: /usr/bin/checkbashisms: checkbashisms fails to detect substring expansion with negative offsets
Antonio Ospite
ao2 at ao2.it
Fri Jul 29 21:22:28 UTC 2016
On Fri, 29 Jul 2016 14:52:54 +0200
Antonio Ospite <ao2 at ao2.it> wrote:
> Package: devscripts
> Version: 2.16.6
> Severity: normal
> File: /usr/bin/checkbashisms
>
> Dear Maintainer,
>
> checkbashisms does not detect substring expansion when negative values
> are used for offset or length.
>
> ------------------------------------------------------------------------------
> #!/bin/sh
>
> STR="0123456789"
>
> # This substring expansion will be detected
> #echo "${STR:1:10}"
>
> # These ones won't
> echo "${STR: -10:1}"
> echo "${STR:0: -9}"
> ------------------------------------------------------------------------------
>
For completeness, let me add that bash allows also parentheses around
negative offset and length values:
------------------------------------------------------------------------------
# Apparently parentheses are valid too
echo "${STR:(-10):1}"
echo "${STR:0:(-9)}"
------------------------------------------------------------------------------
and checkbashisms fails to detect these cases too.
Thanks,
Antonio
--
Antonio Ospite
http://ao2.it
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
More information about the devscripts-devel
mailing list