[Slackbuilds-users] Possible typo in python3.SlackBuild
Christoph Willing
chris.willing at iinet.net.au
Sat Jan 10 04:18:20 UTC 2015
On 01/10/2015 04:45 AM, 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:
>>
>>> On 01/09/2015 04:35 PM, Niki Kovacs wrote:
>>>> Hi,
>>
>>>> I just noticed a strange line in python3.SlackBuild:
>>
>>>> PYVER=${VERSION::3}
>>
>>>> I only know this kind of notation:
>>
>>>> PYVER=${VERSION:-3}
>>
>>>> Is this an error or some special syntax I don't know?
>>
>>> From the Parameter Expansion section of the bash manpage:
>>
>>> ${parameter:offset:length}
>>> Substring Expansion. Expands to up to length characters of the
>>> value of parameter starting at the character specified by off-set.
>>
>>> 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[*]:
>
> My current expectation is that Python 4.0 will merely be "the release
> that comes after Python 3.9". <...>
>
> At the current rate of language feature releases (roughly every 18
> months), that means we would likely see Python 4.0 some time in 2023,
> rather than seeing Python 3.10.
>
> But I'm still going to future-proof the code by changing the offending
> line to
>
> PYVER=$(cut -d. -f1,2 <<< "$VERSION")
>
> unless someone has a better suggestion.
That would work but, just for fun, also:
PYVER=${VERSION%.*}
chris
More information about the SlackBuilds-users
mailing list