savannah-hackers-public
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Savannah-hackers-public] [PATCH 2/2] Add --keep-tmp long option.


From: Bruno Félix Rezende Ribeiro
Subject: [Savannah-hackers-public] [PATCH 2/2] Add --keep-tmp long option.
Date: Sat, 26 Sep 2015 04:49:36 -0300

It keeps temporary files for further inspection.
---
 gsv-eval-remote.sh | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/gsv-eval-remote.sh b/gsv-eval-remote.sh
index 55cfb07..e84ac63 100755
--- a/gsv-eval-remote.sh
+++ b/gsv-eval-remote.sh
@@ -50,6 +50,7 @@ on the download files, and produce an HTML file named 
OUTPUT-HTML.
 
 Options:
  -h, --help              = show this help screen.
+     --keep-tmp          = keep temporary files
 
 Examples:
 
@@ -163,31 +164,33 @@ process_package() {
     esac
 }
 
-GETOPT=$(getopt -oh -lhelp -n $(basename "$0") -- "$@") \
+GETOPT=$(getopt -oh -lhelp,keep-tmp -n $(basename "$0") -- "$@") \
   || { echo "error: cannot parse command line" >&2; exit 1; }
 eval set -- "$GETOPT"
 
 while [ $1 != "--" ]; do
     case "$1" in
        -h|--help) usage;;
+        --keep-tmp) KEEP_TMP=1; shift;;
        *) echo "error: getopt inconsistency --- report this bug!"; exit 1;;
     esac
 done
 shift
 
-test -z "$OUTPUT_HTML" \
+test -z "$1" \
     && die "missing OUTPUT-HTML parameter. See -h for help."
-test -z "$PROJECT_NAME" \
+test -z "$2" \
     && die "missing PROJECT-NAME parameter. See -h for help."
-test -z "$SOURCE" \
+test -z "$3" \
     && die "missing SOURCE-URL parameter. See -h for help."
-touch "$OUTPUT_HTML" \
-    || die "failed to create output file '$OUTPUT_HTML'"
 
 OUTPUT_HTML=$(realpath $1)
 PROJECT_NAME=$2
 SOURCE=$3
 
+touch "$OUTPUT_HTML" \
+    || die "failed to create output file '$OUTPUT_HTML'"
+
 ## From here on, we can at least log the errors into the output HTML file
 OUTPUT_FILE="$OUTPUT_HTML"
 
@@ -208,7 +211,7 @@ test -e "$CSS_FILE" \
 ##
 DIRECTORY=$(mktemp -d /tmp/gnu_eval.XXXXXX) \
     || die "failed to create temporary directory"
-trap "cd /tmp ; rm -rf $DIRECTORY" INT TERM EXIT
+trap "test -z $KEEP_TMP && cd /tmp && rm -rf $DIRECTORY" INT TERM EXIT
 
 cd "$DIRECTORY" || die "failed to CD to '$DIRECTORY'"
 
-- 
2.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]