From 215b4447886ae4f13674ece020ebd09ce339c433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=C3=ADaz?= Date: Wed, 15 Feb 2017 18:56:58 -0600 Subject: automated: sh-test-lib: add create_out_dir() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some error checking and renaming can happen here for all other scripts to peruse. Change-Id: I7286cf2909c59fc41935658d0a970b9c4b7ec795 Signed-off-by: Daniel Díaz Signed-off-by: Milosz Wasilewski --- automated/lib/sh-test-lib | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'automated/lib') diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib index 9030899..299964d 100755 --- a/automated/lib/sh-test-lib +++ b/automated/lib/sh-test-lib @@ -326,3 +326,12 @@ add_repo() { ;; esac } + +create_out_dir() { + [ -z "$1" ] && error_msg "Usage: create_out_dir output_dir" + OUTPUT=$1 + [ -d "${OUTPUT}" ] && + mv "${OUTPUT}" "${OUTPUT}_$(date -r "${OUTPUT}" +%Y%m%d%H%M%S)" + mkdir -p "${OUTPUT}" + [ -d "${OUTPUT}" ] || error_msg "Could not create output directory ${OUTPUT}" +} -- cgit v1.2.3