Re: How to read out plist information and compare version number?
site_archiver@lists.apple.com Delivered-To: installer-dev@lists.apple.com Thread-index: AclFsgNhtjpMUhTJQfe6plC1h6UG8Q== Thread-topic: How to read out plist information and compare version number? User-agent: Microsoft-Entourage/12.14.0.081024 Hi, You cannot compare versions as strings because this will almost never work as intended. You must split them into their parts and compare those. This perl snippet should give you some idea on what should be done: # Versions are compared fist on MajorVersion then Minor then Build and then Patc h number. sub versionCmp { my @verA = split(/\./, $_[0]); my @verB = split(/\./, $_[1]); for my $i (0 .. scalar(@verA)-1) { return 1 if ($verA[$i] < $verB[$i]); return -1 if ($verB[$i] < $verA[$i]); } return 0; } On 13/11/08 9:59 AM, "David Schara" <David.Schara@Native-Instruments.de> wrote:
Hi,
I tried to create a bash file that should be able to read out an application version number which is located in a plist and compare it to a different version number. Both version numbers have the same appearance: x.y.zzz
This is my code: ______ #!/bin/sh # postflight
VERSION_NEW="0.5.002"
VERSION=defaults read "/Applications/My.app/Contents/Info" "CFBundleShortVersionString"
echo $VERSION
if[$VERSION_NEW -lt $VERSION]; then echo "Version is bigger" else echo "Version is smaler" fi ______ I know there must be something wrong with the if-clause because I try to compare two Strings , but I have no clue how to treat a version number correctly. Also I get a strange error message (read: `/Applications/Maschine.app/Contents/Info': not a valid identifier). What is wrong there?
THX _______________________________________________ Do not post admin requests to the list. They will be ignored. Installer-dev mailing list (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/adampeck%40smarttech.co...
This email sent to adampeck@smarttech.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Installer-dev mailing list (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Adam Peck