[Slackbuilds-users] Possible typo in python3.SlackBuild

Christoph Willing chris.willing at iinet.net.au
Sun Jan 11 01:37:56 UTC 2015



On 01/11/2015 01:14 AM, Jim Diamond wrote:
> On Fri, Jan  9, 2015 at 20:45 (+0200), Audrius Kažukauskas wrote:
>
>> On Fri, 2015-01-09 at 13:34:03 -0400, Jim Diamond wrote:
>>> On Fri, Jan  9, 2015 at 17:09 (+1000), Christoph Willing wrote:
>
>>>> Its not stated there but I presume a blank offset defaults it to 0,
>>>> therefore for a VERSION of 3.4.2, PYVER would be set to 3.4
>
>>> That is fragile code.  If VERSION got as high as 3.10.x, Bad Things
>>> would happen.
>
>> Agreed, although very unlikely, according to one of Python
>> developers[*]:
>
> Also agreed.
>
> Another problem with having fragile code is that it might propagate
> itself into other Slackbuilds, which could (who knows?) end up with
> that actually being a bug.

If we're looking for something more robust, yet generic, then my 
previously proposed solution:
     PYVER=${VERSION%.*}
is not so great if a version string has extra fields i.e. 
VERSION=3.4.2.5 would become 3.4.2 (rather than the desired 3.4).

To make up for that shortcoming, I offer:
     PYVER=$(sed 's/\.[^\.]*//2g' <<< "$VERSION")

Maybe not as easy to read as Audrius' solution using cut though ...

chris


More information about the SlackBuilds-users mailing list