grahampugh-recipes
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"
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
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.
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.*)$
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.