I hate bash, and I hate that there is not a standard way of reading property files based on 2 parameters: the property name, and the environment. And we are in 2014...flying people to Mars etc...and still hacking these very basic requirements.
Here is a possible solution:
create a config.sh executable file:
DEV_prop1=bla
PROD_prop1=blu
you have your environment name in a variable ENV
ENV="DEV"
you load all your properties:
. ./config.sh (note the space after the first . !)
then you get the property name with an "indirect referencing":
propertyname=${ENV}_prop1
myvalue="${!propertyname}";
There are many other ways (I hate the cat/grep/awk solution) but they all stink just the same.
Let's face it, bash stinks. Like a skunk.
Monday, February 17, 2014
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment