From f0b33915ceced4100b0d935ce0a3951744d0d598 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Thu, 14 Mar 2024 16:54:51 +0100
Subject: [PATCH] restore edge case: single dump in backup folder

---
 localdump.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/localdump.sh b/localdump.sh
index bbdbc4c..ea0f732 100755
--- a/localdump.sh
+++ b/localdump.sh
@@ -551,6 +551,11 @@ EOH
             h2 "Select a specific dump for that database"
             showSelectAndInput "$(listBackupedDBs $fileprefix)" "Backupset to import"
             dbfile="$LASTINPUT"
+
+            # if there is a single dump in backup folder: 
+            # '-rw-r--r-- 1 root root 481 Mar 13 12:27 ahcrawler__20240313-1227.sql.gz'
+            # --> take the last part behind the last space to get a filename
+            grep "^-[rwxsSt\-]* " <<< "$LASTINPUT" && dbfile="$(rev <<< \'"$LASTINPUT"\' | cut -d ' ' -f 1 | rev)"
             echo
   
             sTargetDb=$(guessDB ${dbfile})
-- 
GitLab