#!/bin/bash

source $ENV_STORE

SCRIPTDIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source $SCRIPTDIR/lib.sh

if [ -f ./rpkg.macros ]; then
    source ./rpkg.macros
fi

function end {
    retcode=$?

    if [ $retcode -eq 0 ]; then
        declare -x > $ENV_STORE
    fi

    exit $retcode
}

trap end EXIT
