Skip to content

Instantly share code, notes, and snippets.

@cworks
Created December 24, 2015 05:45
Show Gist options
  • Save cworks/4ffc1485cf578fb4e19c to your computer and use it in GitHub Desktop.
Save cworks/4ffc1485cf578fb4e19c to your computer and use it in GitHub Desktop.
#!/bin/bash
get_property() {
local target=$1
local file=$2
#echo target : $target
#echo file : $file
sed '/^\#/d' ${file} | grep ${target} | sed -e 's/ //g' |
while read LINE
do
local KEY=`echo $LINE | cut -d "=" -f 1`
local VALUE=`echo $LINE | cut -d "=" -f 2`
[ ${KEY} == ${target} ] && {
local UNKNOWN_NAME=`echo $VALUE | grep '\${.*}' -o | sed 's/\${//' | sed 's/}//'`
if [ $UNKNOWN_NAME ];then
local UNKNOWN_VALUE=`get_property ${UNKNOWN_NAME} ${file}`
echo ${VALUE} | sed s/\$\{${UNKNOWN_NAME}\}/${UNKNOWN_VALUE}/
else
echo $VALUE
fi
return
}
done
return
}
if [ $2 ];then
get_property $1 $2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment