Index: tools/common-includes.sh |
diff --git a/tools/common-includes.sh b/tools/common-includes.sh |
index c7d5bc2d3dc379cf9942f9ffa0e4a89367d97f51..d1b8b01473bd85e536130b7191904a15e2192a20 100644 |
--- a/tools/common-includes.sh |
+++ b/tools/common-includes.sh |
@@ -77,20 +77,27 @@ delete_branch() { |
persist() { |
local VARNAME=$1 |
local FILE="$PERSISTFILE_BASENAME-$VARNAME" |
- echo "${!VARNAME}" > $FILE |
+ local VALUE="${!VARNAME}" |
+ if [ -z "$VALUE" ] ; then |
+ VALUE="__EMPTY__" |
+ fi |
+ echo "$VALUE" > $FILE |
} |
restore() { |
local VARNAME=$1 |
local FILE="$PERSISTFILE_BASENAME-$VARNAME" |
local VALUE="$(cat $FILE)" |
Sven Panne
2012/03/28 11:40:39
I'm just curious: Why is this detour via __EMPTY__
|
+ [[ -z "$VALUE" ]] && die "Variable '$VARNAME' could not be restored." |
+ if [ "$VALUE" == "__EMPTY__" ] ; then |
+ VALUE="" |
+ fi |
eval "$VARNAME=\"$VALUE\"" |
} |
restore_if_unset() { |
local VARNAME=$1 |
[[ -z "${!VARNAME}" ]] && restore "$VARNAME" |
- [[ -z "${!VARNAME}" ]] && die "Variable '$VARNAME' could not be restored." |
} |
initial_environment_checks() { |