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: AclFsgNhtjpMUhTJQfe6plC1h6UG8QAANszA Thread-topic: How to read out plist information and compare version number? You might try using command substitution: VERSION=$(defaults read "/Applications/My.app/Contents/Info" <key> <value>) Allen Riffel C.M. Engineer Extensis http://www.extensis.com/ phone: 503.274.2020 x116 email: ariffel@extensis.com Font and Creative Assets Management Software. Trusted by Millions. To learn more about Extensis Solutions, visit: http://www.extensis.com/en/solutions/index.jsp Notice: This communication may contain privileged or other confidential information. If you are not the intended recipient, or believe that you have received this communication in error, please do not print, copy, retransmit, disseminate, or otherwise use the information. Also, please indicate to the sender that you have received this email in error, and delete the copy you received. Thank you. -----Original Message----- From: installer-dev-bounces+ariffel=extensis.com@lists.apple.com [mailto:installer-dev-bounces+ariffel=extensis.com@lists.apple.com] On Behalf Of Adam Peck Sent: Thursday, November 13, 2008 9:05 AM To: David Schara; installer-dev@lists.apple.com Subject: Re: How to read out plist information and compare version number? 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%40smarttec h.com
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/ariffel%40extensis. com This email sent to ariffel@extensis.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)
-
Riffel, Allen