grahampugh-recipes icon indicating copy to clipboard operation
grahampugh-recipes copied to clipboard

usage of match-version-number-or-higher.bash non numerical version numbers breaks for option "--usingJamf" when version number contains character "b"

Open katidzehnder opened this issue 10 months ago • 3 comments

match-version-number-or-higher.bash is misusing character "b" du substitute | to beak the regex into pieces: maybe replace with "ZZ" or a less common character than b

match-version-number-or-higher.bash:

line 357: 		regex_end=$( /usr/bin/sed "s/|/b/" <<< ${regex_end} )
line 381: 		regexString=$( /usr/bin/awk -F "b" -v divider=$(( aBreak + 1 )) '{ print $divider }' <<< "$dividedRegex" )

example with current Spotify that gets wrong output: ./match-version-number-or-higher.bash -j 1.2.35.663.gb699649e

katidzehnder avatar Apr 22 '24 13:04 katidzehnder

Thanks for that. As these lines were inherited from the source script https://gist.github.com/talkingmoose/2cf20236e665fcd7ec41311d50c89c0e, I've asked about the choice of b in the comments in case there was some specific reason I'm not sure about. I'm not really sure why the | needs to be substituted at all.

grahampugh avatar Apr 23 '24 08:04 grahampugh

This should be fixed now, I substituted b for ±.

% ./match-version-number-or-higher.bash -j -q 1.2.35.663.gb699649e
^(\d{2,}.*|[2-9].*|1\.\d{2,}.*|1\.[3-9].*|1\.2\.\d{3,}.*|1\.2\.[4-9]\d{1,}.*|1\.2\.3[6-9].*|1\.2\.35\.\d{4,}.*|1\.2\.35\.[7-9]\d{2,}.*|1\.2\.35\.6[7-9]\d{1,}.*|1\.2\.35\.66[4-9].*)$
^(1\.2\.35\.663\.gb\d{7,}.*|1\.2\.35\.663\.gb[7-9]\d{5,}.*|1\.2\.35\.663\.gb699[7-9]\d{2,}.*|1\.2\.35\.663\.gb6996[5-9]\d{1,}.*|1\.2\.35\.663\.gb699649e.*)$

grahampugh avatar Apr 23 '24 19:04 grahampugh

thanks a lot. it works now. The b was probably used because the script does only check for numbers and nonnumericals are handled like the number 9. as it is so rare to have characters relevant in version number, it is fine to leave the regex to compare numbers and ignore characters.

katidzehnder avatar Apr 25 '24 12:04 katidzehnder