Fail gracefully when no files to sign 31/6931/2
authorThanh Ha <thanh.ha@linuxfoundation.org>
Tue, 17 Oct 2017 02:14:01 +0000 (22:14 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Tue, 17 Oct 2017 19:42:09 +0000 (15:42 -0400)
Fixes issue where if there are no files to sign detected the script just
hangs indefinitely. Instead if the files_to_sign array is empty then
exit 1 and inform user.

Change-Id: I82a5957faedfe739800305a8224fed67d2c74801
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
shell/sign

index 4000bbf..1839546 100755 (executable)
@@ -66,6 +66,11 @@ sign_dir() {
                                     ! -name "maven-metadata-local.xml" \
                                     ! -name "maven-metadata.xml"))
 
+    if [ "${#files_to_sign[@]}" -eq 0 ]; then
+        echo "ERROR: No files to sign. Quitting..."
+        exit 1
+    fi
+
     if hash parallel 2>/dev/null; then
         echo "Signing in parallel..."
         parallel --jobs 200% --halt now,fail=1 "$GPG_BIN --batch -abq {}" ::: ${files_to_sign[*]}