update_environ()
{
cp ${ENVIRON_FILE} ${ENVIRON_FILE}.old
- grep " $1" ${ENVIRON_FILE}.old
+ grep " $1" ${ENVIRON_FILE}.old > /dev/null
if [ $? -eq 0 ]
then
# if variable is already set, we replace old setting by new one
cat ${ENVIRON_FILE}.old | awk -v var_root_dir=$1 -v path=$2 -v src_root_dir=$3 -v src_dir=$4 '
- $1=="export" && $2 ~ var_root_dir {print "#"$0; $0="export "var_root_dir "=" path}
- $1=="export" && $2 ~ src_root_dir {print "#"$0; $0="export "src_root_dir "=" src_dir}
+ $1=="export" && $2 ~ "^"var_root_dir"=" {print "#"$0; $0="export "var_root_dir "=" path}
+ $1=="export" && $2 ~ "^"src_root_dir"=" {print "#"$0; $0="export "src_root_dir "=" src_dir}
+ $1 ~ "^"var_root_dir"=" {print "#"$0; $0=var_root_dir "=" path}
+ $1 ~ "^"src_root_dir"=" {print "#"$0; $0=src_root_dir "=" src_dir}
{ print $0}' > ${ENVIRON_FILE}
else
echo -e "##\n#------ ${SOURCE_NAME}-Src ------\nexport $3=$4" >> ${ENVIRON_FILE}