You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Cameron Fieber <ca...@fieber.ca> on 2004/05/07 15:05:33 UTC

another patch to merlinx script

This patch fixes a bug where the default value wouldn't get returned if 
one of the files existed but didn't have the property set.  Also the 
function keyword is bash specific so I removed that and it now runs in 
cygwin.

-Cameron
Index: merlinx
===================================================================
RCS file: /home/cvspublic/avalon/merlin/cli/src/bin/merlinx,v
retrieving revision 1.2
diff -u -r1.2 merlinx
--- merlinx     6 May 2004 18:56:03 -0000       1.2
+++ merlinx     7 May 2004 13:03:09 -0000
@@ -8,14 +8,19 @@
 # respectively.
 #

-#usage VARIABLE=`find_maven_repo "property_file" "property_name" 
"default_value"`
-function find_property()
+#usage VARIABLE=`find_property "property_file" "property_name" 
"default_value"`
+find_property()
 {
-       VAL=${3}
-       if [ -f ${1} ] ; then
-               VAL=`cat ${1} | grep ^${2} | cut -d= -f2`
+       VAL=
+       if [ -f "${1}" ] ; then
+               VAL=`cat "${1}" | grep "^${2}" | cut -d= -f2`
+       fi
+
+       if [ "${VAL}" = "" ] ; then
+               echo "${3}"
+       else
+               echo "${VAL}"
        fi
-       echo ${VAL}
 }

 #

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org