read_image_version assigns only a single sigit for the patch version
Steps to Reproduce
- Have installed an overleaf image with patch version greater then 9 (ex. 3.5.13)
- Use a script to run the function
read_image_versionfromlib/shared-functions.sh - Read the
$IMAGE_VERSION_PATCHvariable Example code : (the file must be in the toolkit root to work)
#!/bin/bash
TOOLKIT_ROOT="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
source lib/shared-functions.sh
sudo echo 3.5.13 | sudo tee config/version
read_image_version
echo "$IMAGE_VERSION_MAJOR.$IMAGE_VERSION_MINOR.$IMAGE_VERSION_PATCH"
Expected Behaviour
The variable IMAGE_VERSION_PATCH should be the whole number (ex. 13) and not only the last digit (ex. 3)
Observed Behaviour
The variable $IMAGE_VERSION_PATCH contains only the last digit (ex.3)
Context
I was creating a script to automate my upgrade from overleaf version 3.0.1 to the latest (5.2.1).
While doing that i used shared-functions.sh to access it's functions and i needed to check the image version before upgrading to version 4.0.1 (needs image version > 3.5.10)
Technical Info
This is using the latest version of the toolkit
- Operating System and version (desktop or mobile): Ubuntu server 20.04
- Project and/or file: lib/shared-functions.sh
Analysis:
The problem is that the regex used in read_image_version is wrong.
Current regex: ^([0-9]+)\.([0-9]+)\.([0-9])+(-RC[0-9]*)?(-with-texlive-full)?$
Right regex: ^([0-9]+)\.([0-9]+)\.([0-9]+)+(-RC[0-9]*)?(-with-texlive-full)?$
The only difference is the + after the third number's regex.
You can test the regex only using websites like: https://regex101.com/