Skip to content

Conversation

@lauguillier
Copy link

Use bash in shebang
Fix shellcheck errors and warning
Fix a bug in semverLT:

There was a bug in semverLT(), when both versions
have a special field, semverLT would just compare
that special field if majorA > majorB

Before fix:
./semver.sh 8.4.2-12 6.90.5-13
8.4.2-12 -> M: 8 m:4 p:2 s:-12
6.90.5-13 -> M: 6 m:90 p:5 s:-13
8.4.2-12 == 6.90.5-13 -> 1.
8.4.2-12 < 6.90.5-13 -> 0. <- Offending result!
8.4.2-12 > 6.90.5-13 -> 1. <- Side effect because GT uses LT

After fix:
./semver.sh 8.4.2-12 6.90.5-13
8.4.2-12 -> M: 8 m:4 p:2 s:-12
6.90.5-13 -> M: 6 m:90 p:5 s:-13
8.4.2-12 == 6.90.5-13 -> 1.
8.4.2-12 < 6.90.5-13 -> 1. <- Correct
8.4.2-12 > 6.90.5-13 -> 0.

Laurent Guillier added 2 commits November 30, 2023 09:31
Use bash in shebang
use [[ ]] for tests
remove 'function' keyword
Fix shellcheck errors and warnings
There was a bug in semverLT(), when both versions
have a special field, semverLT would just compare
that special field if majorA > majorB

Before fix:
./semver.sh 8.4.2-12 6.90.5-13
8.4.2-12 -> M: 8 m:4 p:2 s:-12
6.90.5-13 -> M: 6 m:90 p:5 s:-13
8.4.2-12 == 6.90.5-13 -> 1.
8.4.2-12 < 6.90.5-13 -> 0.     <- Offending result!
8.4.2-12 > 6.90.5-13 -> 1.     <- Side effect because GT uses LT

After fix:
./semver.sh 8.4.2-12 6.90.5-13
8.4.2-12 -> M: 8 m:4 p:2 s:-12
6.90.5-13 -> M: 6 m:90 p:5 s:-13
8.4.2-12 == 6.90.5-13 -> 1.
8.4.2-12 < 6.90.5-13 -> 1.      <- Correct
8.4.2-12 > 6.90.5-13 -> 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant