From c6fb8ccb5ae58d132a853037e39249be07d56965 Mon Sep 17 00:00:00 2001
From: Evan Lloyd New-Schmidt <evan@new-schmidt.com>
Date: Tue, 26 Sep 2023 13:42:54 -0400
Subject: [PATCH] Improve script warnings/errors

- Warn on unexpected file extensions
- Move filename to end of errors

Signed-off-by: Evan Lloyd New-Schmidt <evan@new-schmidt.com>
---
 download.sh |  2 +-
 run.sh      | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/download.sh b/download.sh
index 70876e0..ee0e63e 100755
--- a/download.sh
+++ b/download.sh
@@ -79,7 +79,7 @@ if [ -n "${1:-}" ]; then
 fi
 
 if [ ! -d "$DUMP_DIR" ]; then
-    echo "DUMP_DIR '$DUMP_DIR' does not exist" >&2
+    echo "DUMP_DIR does not exist: '$DUMP_DIR'" >&2
     exit 1
 fi
 
diff --git a/run.sh b/run.sh
index 3345119..1ce6147 100755
--- a/run.sh
+++ b/run.sh
@@ -53,24 +53,31 @@ fi
 BUILD_DIR=$(readlink -f -- "$1")
 shift
 if [ ! -d "$BUILD_DIR" ]; then
-    echo "BUILD_DIR '$BUILD_DIR' does not exist or is not a directory" >&2
+    echo "BUILD_DIR does not exist or is not a directory: '$BUILD_DIR'" >&2
     exit 1
 fi
 
 OSM_FILE=$(readlink -f -- "$1")
 shift
 if [ ! -f "$OSM_FILE" ]; then
-    echo "OSM_FILE '$OSM_FILE' does not exist or is not a file" >&2
+    echo "OSM_FILE does not exist or is not a file: '$OSM_FILE'" >&2
     exit 1
 fi
 
+if [ "${OSM_FILE: -4}" != ".pbf" ]; then
+    echo "WARN: OSM_FILE does not end in .pbf: '$OSM_FILE'" >&2
+fi
+
 DUMP_FILES=()
 while (( $# > 0 )); do
     dump_file="$(readlink -f -- "$1")"
     if [ ! -f "$dump_file" ]; then
-        echo "DUMP_FILE '$dump_file' does not exist or is not a file" >&2
+        echo "DUMP_FILE does not exist or is not a file: '$dump_file'" >&2
         exit 1
     fi
+    if [ "${dump_file: -12}" != ".json.tar.gz" ]; then
+        echo "WARN: DUMP_FILE does not end in .json.tar.gz: '$dump_file'" >&2
+    fi
     DUMP_FILES+=("$dump_file")
     shift
 done
-- 
2.45.3