#!/bin/bash

# Set up prog to be the path of this script, including following symlinks,
# and set up progdir to be the fully-qualified pathname of its directory.
prog="$0"
while [ -h "${prog}" ]; do
    newProg=`/bin/ls -ld "${prog}"`

    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
    if expr "x${newProg}" : 'x/' >/dev/null; then
        prog="${newProg}"
    else
        progdir=`dirname "${prog}"`
        prog="${progdir}/${newProg}"
    fi
done
oldwd=`pwd`
progdir=`dirname "${prog}"`
cd "${progdir}"
progdir=`pwd`
prog="${progdir}"/`basename "${prog}"`
cd "${oldwd}"

jarfile=aso.jar
libdir="$progdir"
if [ ! -r "$libdir/$jarfile" ]
then
    echo `basename "$prog"`": can't find $jarfile"
    exit 1
fi

if [ "$OSTYPE" = "cygwin" ] ; then
        jarpath=`cygpath -w  "$libdir/$jarfile"`
else
        jarpath="$libdir/$jarfile"
fi

# add current location to path
PATH=$PATH:`pwd`;
export PATH;
exec java -cp "$jarpath" net.dirtybox.util.obfuscation.AndroidStringObfuscator "$@"
