RE: How to read out plist information and compare version number?
RE: How to read out plist information and compare version number?
- Subject: RE: How to read out plist information and compare version number?
- From: "Riffel, Allen" <email@hidden>
- Date: Thu, 13 Nov 2008 09:22:09 -0800
- 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: email@hidden
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=email@hidden
[mailto:installer-dev-bounces+ariffel=email@hidden] On
Behalf Of Adam Peck
Sent: Thursday, November 13, 2008 9:05 AM
To: David Schara; email@hidden
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" <email@hidden>
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 (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
h.com
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden