improve selective status update which makes most preset values unnecessary

This commit is contained in:
2016-12-26 15:10:29 +01:00
parent 1984a70b99
commit 0b871f8099
2 changed files with 7 additions and 5 deletions

View File

@@ -26,7 +26,12 @@ function wtmp {
VAR_NAME=${!i} # variable name
VAR_VAL=${!VAR_NAME} # value of the variable's name
sed -Ei "s/^$VAR_NAME=.*/$VAR_NAME=$VAR_VAL/" $TMP
if [ $(grep -q "^$VAR_NAME=" $TMP; echo $?) == 0 ] ; then # variable already exists in status file
sed -Ei "s/^$VAR_NAME=.*/$VAR_NAME=$VAR_VAL/" $TMP
else
echo "$VAR_NAME=$VAR_VAL" >> $TMP
fi
done
fi