diff --git a/importexp b/importexp index 8b54514a4a4c73eb6415ec5b438d1cbe66d9e0c6..9c632d821f243ec3f1833a44f6fa5d94dd6bd06c 100755 --- a/importexp +++ b/importexp @@ -47,10 +47,13 @@ then TMPDIR=$PWD export TMPDIR fi -$DEBUG || trap 'rm -rf $RUN_FILE $LOG_FILE $WORK_DIR' 0 -RUN_FILE=$(mktemp) -LOG_FILE=$(mktemp) -WORK_DIR=$(mktemp -d) +$DEBUG || trap 'rm -rf $MKTEMP_DIR' 0 +MKTEMP_DIR=$(mktemp -d) +RUN_FILE=$MKTEMP_DIR/run +LOG_FILE=$MKTEMP_DIR/log +WORK_DIR=$MKTEMP_DIR/work +SCRIPT_DIR=$MKTEMP_DIR/scripts +mkdir $WORK_DIR $SCRIPT_DIR for RUN_SCRIPT do @@ -129,11 +132,11 @@ done\ sed -r ' s@^(\s*)(cat\s+\$thisscript)@\1: \2@ 2 i\ -cd '$WORK_DIR' +cd '$SCRIPT_DIR' /^\s*#.*start\s+experiment/ i'"$SHOW_HERE_DOCS"' s:^(\s*)(set\s+\+x\s*$|(set\s+\+\w+)x):\1\3: '"${REMOVE_ERROR_FLAG_SH-}"' - s:^(\s*)SCRIPT_DIR=.*$:\1SCRIPT_DIR='$WORK_DIR': + s:^(\s*)SCRIPT_DIR=.*$:\1SCRIPT_DIR='$SCRIPT_DIR': s:^(\s*)experiments_dir=.*$:\1experiments_dir='$WORK_DIR': s:^(\s*)BUILD_DIR=.*$:\1BUILD_DIR='$BUILD_DIR': s:^(\s*)EXPDIR=.*$:\1EXPDIR='$WORK_DIR': @@ -164,10 +167,20 @@ cd '$WORK_DIR' if [ "x$RESTART" != x ] # Try to mimic restart logic then - restart="$RESTART" + restart=".$RESTART." export restart fi + if [ "x$RESTART" = xtrue ] + # Also, create date file for mkexp based scripts + then + eval "$(perl -lne '/^\s*(?:export\s)?\s*( + EXPNAME | + initial_date + )(=.*)$/x and print($1, $2)' $RUN_FILE)" + echo "$initial_date" > $SCRIPT_DIR/$EXPNAME.date + fi + echo "Running '$RUN_SCRIPT'" >&2 ${COMMAND:-/bin/sh} -x $RUN_FILE > $LOG_FILE 2>&1