Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(898)

Unified Diff: src/platform/memento_softwareupdate/memento_updater.sh

Issue 465060: au: Fix octal-looking version number handling in memento_updater.sh. (Closed)
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/memento_softwareupdate/memento_updater.sh
diff --git a/src/platform/memento_softwareupdate/memento_updater.sh b/src/platform/memento_softwareupdate/memento_updater.sh
index 8b7e8b50cceb4c286cf457c743f34f4fc88d1789..9a8c1d08a1786d969d14911e61101a53218835da 100755
--- a/src/platform/memento_softwareupdate/memento_updater.sh
+++ b/src/platform/memento_softwareupdate/memento_updater.sh
@@ -190,11 +190,15 @@ else
exit 1
fi
+# Return 0 if $1 > $2.
+# $1 and $2 are in "a.b.c.d" format where a, b, c, and d are base 10.
function version_number_greater_than {
- # return 0 if $1 > $2
- # Assumes $1, $2 are in "a.b.c.d" format where a, b, c, d are base 10
- EXPANDED_A=$(printf '%020d%020d%020d%020d' $(echo "$1" | sed 's/\./ /g' ))
- EXPANDED_B=$(printf '%020d%020d%020d%020d' $(echo "$2" | sed 's/\./ /g' ))
+ # Replace periods with spaces and strip off leading 0s (lest numbers be
+ # interpreted as octal).
+ REPLACED_A=$(echo "$1" | sed -r 's/(^|\.)0*/ /g')
+ REPLACED_B=$(echo "$2" | sed -r 's/(^|\.)0*/ /g')
+ EXPANDED_A=$(printf '%020d%020d%020d%020d' $REPLACED_A)
+ EXPANDED_B=$(printf '%020d%020d%020d%020d' $REPLACED_B)
# This is a string compare:
[[ "$EXPANDED_A" > "$EXPANDED_B" ]]
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698