Introduction
Introduction Statistics Contact Development Disclaimer Help
Spruce METAR. - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 4b9dce6013820f08b1fda84acd9603a9f56817c2
parent 906b16d25a5f76b1d4032aab59fbc5752ea1d712
Author: eidolon <?>
Date: Thu, 10 Oct 2024 06:24:54 -0400
Spruce METAR.
Signed-off-by: Annna Robert-Houdin <[email protected]>
Diffstat:
M metar | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/metar b/metar
@@ -1,16 +1,20 @@
#!/bin/sh
-if ! id=$(printf '%s\n' "$1" | grep '^[A-Za-z]\{4\}$'); then
- if ! id=$(printf '%s\n' "$1" | grep '^[A-Za-z]\{3\}$'); then
- printf '%s\n' "invalid ICAO 7910 airport code."
- exit 1
- fi
- id="$(grep ",${1}," /home/annna/bin/modules/airport-codes/data/airport-cod…
- | head -n 1 \
- | cut -d',' -f 1)"
- if [ -z "${id}" ]; then
- printf '%s\n' "invalid ICAO 7910 airport code."
- exit 1
+iata2icao() {
+ csv="/home/annna/bin/modules/airport-codes/data/airport-codes.csv"
+ awk -v IATA="$1" --csv 'BEGIN { IATA = toupper(IATA) } $10 == IATA { print…
+}
+
+if ! id=$(printf '%s\n' "$1" | grep '^[A-Za-z]\{3,4\}$'); then
+ printf '%s\n' "invalid IATA/ICAO code."
+ exit 1
+fi
+
+if [ "${#id}" = 3 ]; then
+ id=$(iata2icao "$id")
+ if [ -z "$id" ]; then
+ printf '%s\n' "invalid IATA code."
+ exit 1
fi
fi
@@ -24,4 +28,3 @@ if [ -z "$metar" ]; then
fi
printf '%s\n' "$metar"
-
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.