[Slackbuilds-users] Possible typo in python3.SlackBuild

Audrius Kažukauskas audrius at neutrino.lt
Fri Jan 9 18:45:30 UTC 2015


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.

[*] http://opensource.com/life/14/9/why-python-4-wont-be-python-3

-- 
Audrius Kažukauskas
http://neutrino.lt/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.slackbuilds.org/pipermail/slackbuilds-users/attachments/20150109/03deb33c/attachment.asc>


More information about the SlackBuilds-users mailing list