Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BASH question on getting bundle version...



I suppose there's some way to use a fancy API, or a full XML parser, etc.

However, I did have this need in my project, and I just wrote a script that pulled the information out of the text, using some reasonable method for determining where the data is.

I've included it below. :)

Kevin G.
-----------

#!/bin/sh

# VersionInfo.sh
#
# Parses the built executable's Info.plist file and finds the 5
# major version components, printing them out in order and space-
# delimited.
#
# Kevin Grant (email@hidden)
# June 17, 2004

if [ ! -r ./VersionInfo.sh ] ; then
       echo "$0: run this from the Tools/Application directory"
       exit 1
fi

# config
awk=/usr/bin/awk
grep=/usr/bin/grep
perl=/usr/bin/perl

BIN=`dirname $0`

# extract version components from Info.plist's XML
$grep '<string>.*\..*\..*\..*\..*' ${BIN}/../../Build/Application/MacTelnet.app/Contents/Info.plist | $perl -ne 's/\s*<\/?string>\s*//g; pri
nt' | $awk 'BEGIN { FS = "." } { print $1" "$2" "$3" "$4" "$5 }'



Gang,

First off, sorry if this is an inappropriate question for this list - I scanned the apple lists but didn't see a list that this should obviously to go (feel free to correct me and I'll redirect my question there)...

That said, what is the best way to get the version of a bundled object (.app or .bundle, etc) in a BASH shell script?

I'm pretty new to bash scripting and don't know what is the best approach. Is there a mac specific cmd for auto reading the version info from a bundle's info.plist? Or do I have to manually open the info.plist? If so, are there commands that'll do the xml parsing of the file for me? Or do I need to manually parse for the version info?

I appreciate the feedback of those more savvy than I.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >BASH question on getting bundle version... (From: Ando Sonenblick <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.