############################################################################
#
# Copyright (c) 2011 - dsixda (dislam@rocketmail.com)
#
# Android Kitchen is 100% free.  This script file is intended for personal
# and/or educational use only.  It may not be duplicated for monetary
# benefit or any other purpose without the permission of the developer.
#
############################################################################

#
# This script has two parameters:
#
# $1 = parameter in build.prop (mandatory)
# $2 = working folder name (optional)
#

base_dir=`pwd`

if [ "$2" == "" ]
then
  cd WORKING_*
else
  cd $2
fi

if [ ! -e system/build.prop ]
then
  value=UNKNOWN

else

  cd system

  str=^$1=
  grep_str=`grep -c $str build.prop`

  if [ $grep_str == 0 ]
  then
    value=UNKNOWN

  else  
    value=`grep -m 1 $str build.prop \
            | sed 's/'"$1"'=//g'`

    if [ "$value" == "" ]
    then
      value=UNKNOWN
    fi
  fi
fi

cd $base_dir

echo $value

