Created
December 24, 2015 05:45
-
-
Save cworks/4ffc1485cf578fb4e19c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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