Skip to main content

Hello everyone,

some of our users use a software called openLCA. As we had some issues with new versions in the past we distribute updates the way the last version stays. So in general they have two versions of this App on their systems.

But my EA only finds (and reports) the wirst version. Can someone tell what is wrong with my code?

Thanks.

 

 

#!/bin/sh
##########################################################################
# A script to collect the Bundle Version of openLCA. #
##########################################################################

PATH_EXPR="/Applications/*/Contents/MacOS/eclipse"
BUNDLE_ID="openLCA"
KEY="CFBundleShortVersionString"

RESULTS=()
IFS=$'\\n'
for BINARY in ${PATH_EXPR}; do
PLIST="$(/usr/bin/dirname "${BINARY}")/../Info.plist"
if [ "$(/usr/bin/defaults read "${PLIST}" CFBundleName 2>/dev/null)" == "${BUNDLE_ID}" ]; then
RESULTS+=($(/usr/bin/defaults read "${PLIST}" "${KEY}" 2>/dev/null))
fi
done
unset IFS

if [ ${#RESULTS[@]} -eq 0 ]; then
/bin/echo "<result></result>"
else
IFS="|"
/bin/echo "<result>|${RESULTS
  • }|</result>"
    unset IFS
    fi

    exit 0

     

     

  • Hello @matthias_bretz  I've created a set of folders to"mimic" the PATH_EXPR path of several "apps".

    I found out the PLIST variable does not resolve the path with /../Info.plist in:

    PLIST="$(/usr/bin/dirname "${BINARY}")/../Info.plist"

    I've changed to:

     

    PLIST="$(/usr/bin/dirname "${BINARY}")/Info.plist"

     and I've got 2 versions as expected.

     

    To double check your script with the real paths set the script to be a a bit more verbose.
    Add

     

    #!/bin/sh
    set -x

    at the beginning of the script and you may find where is failing.

     

    I hope this helps.
    Regards
    Mauricio

    Reply