set_env_var () {You may then use the function set_env_var to set both bash and environment.plist entries. For example,
eval export $1=\""$2"\"
set_plist_var "$1" "$2"
}
set_plist_var () {
# Check current value of plist var
local current=`PlistBuddy -c 'Print :'"$1" ~/.MacOSX/environment.plist`
if [ `expr "$current" : 'Print.* Not Exist'` = "0" ]
then # Variable exists
# Is the current value changing?
if [ X"$current" != X"$2" ]; then
PlistBuddy -c 'Set :'"$1"' "'"$2"'"' ~/.MacOSX/environment.plist
fi
else # Variable does not exist
echo $current
PlistBuddy -c 'Add :'"$1"' string "'"$2"'"' ~/.MacOSX/environment.plist
fi
}
set_env_var M2_HOME "/usr/share/maven"
set_env_var M2 "$M2_HOME/bin"
set_env_var HTML_TIDY "$HOME/.tidy"