ensure sole trailing newline in GPX output
authormirabilos <m@mirbsd.org>
Sat, 8 Jun 2019 15:21:28 +0000 (17:21 +0200)
committermirabilos <mirabilos@evolvis.org>
Sat, 8 Jun 2019 15:21:28 +0000 (17:21 +0200)
gpx.sh

diff --git a/gpx.sh b/gpx.sh
index 2754c12..be85a6e 100755 (executable)
--- a/gpx.sh
+++ b/gpx.sh
@@ -1,7 +1,7 @@
 #!/bin/mksh
 #-
-# Copyright © 2007, 2008, 2012, 2013, 2014
-#      Thorsten “mirabilos” Glaser <tg@mirbsd.org>
+# Copyright © 2007, 2008, 2012, 2013, 2014, 2019
+#      mirabilos <m@mirbsd.org>
 #
 # Provided that these terms and disclaimer and all copyright notices
 # are retained or reproduced in an accompanying document, permission
@@ -379,7 +379,7 @@ if [[ $wptype = oc ]]; then
        i=$("${fetch[@]}" "http://www.opencaching.de/search.php?searchbywp=1&showresult=1&output=GPX&f_inactive=0&f_ignored=0&wp=$wp" \
            2>/dev/null)
        [[ $i = *'<wpt'* ]] || exit 1
-       print -nr -- "$i"
+       print -r -- "$i"
        exit 0
 fi
 
@@ -583,7 +583,7 @@ case $wptype {
 
 typeset -u wpcode
 
-rv=<<EOF
+sed $'s/$/\r/' <<EOF
 <?xml version="1.0" encoding="utf-8"?>
 <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0" creator="MirKarte by mirabilos - https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=useful-scripts/mirkarte.git" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak.com/cache/1/0/1 http://www.groundspeak.com/cache/1/0/1/cache.xsd" xmlns="http://www.topografix.com/GPX/1/0">
   <name>Waypoint Listing Generated by MirKarte</name>
@@ -624,6 +624,6 @@ rv=<<EOF
       <groundspeak:travelbugs />
     </groundspeak:cache>
   </wpt>
+</gpx>
 EOF
-print -nr -- "${rv//$'\n'/$'\r\n'}</gpx>"
 exit 0