Tweak METAR. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit cad8a5b2dba5c57467da56bcb34bb6826aa7b62b DIR parent e3433aaa403accf2277a80e9fa6ac5ceaef6b933 HTML Author: eidolon <?> Date: Fri, 25 Oct 2024 13:43:42 -0400 Tweak METAR. Signed-off-by: Annna Robert-Houdin <annna@bitreich.org> Diffstat: M metar | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- DIR diff --git a/metar b/metar @@ -5,12 +5,13 @@ iata2icao() { } printart() { - awk 'BEGIN { RS = ""; srand() } { a[NR] = $0 } END { print a[int(rand()*length(a))] }' "$txt" + awk 'BEGIN { RS = ""; srand() } { if (rand() < 1 / ++n) out = $0 } END { print out }' "$txt" } dromeinfo() { awk -v aerodrome="$1" --csv ' - BEGIN { aerodrome = toupper(aerodrome) } NR == 1 { split($0, header) } + BEGIN { aerodrome = toupper(aerodrome) } + NR == 1 { split($0, header) } $1 == aerodrome || $10 == aerodrome { for (i = 1; i <= NF; i++) if ($i) @@ -23,7 +24,7 @@ dromeinfo() { END { if (!s) exit; print s }' "$csv" } -if ! id=$(printf '%s\n' "$1" | grep '^[A-Za-z]\{3,4\}$'); then +if ! id=$(printf '%s\n' "$1" | grep '^[A-Za-z0-9]\{3,4\}$'); then printf '%s\n' "invalid IATA/ICAO code." exit 1 fi