]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Force final newline in xmlstarlet
authorJon DeVree <nuxi@vault24.org>
Sat, 3 Feb 2024 17:09:58 +0000 (12:09 -0500)
committerDimitri Papadopoulos Orfanos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Sun, 4 Feb 2024 18:09:34 +0000 (19:09 +0100)
By default xmlstarlet does not include a final newline on the output.
Because POSIX says that all lines must end in a newline, this causes the
final line of output to be skipped by the 'while read ...' loop in bash.
Adding a '-n' after the '-v ...' causes xmlstarlet to include a final
newline at the end of its output.

Signed-off-by: Jon DeVree <nuxi@vault24.org>
trojans/csd-post.sh

index 3c3cc3970226451c6f99f6ff2d36feea4d7c6aed..86837d2b7d1dfeb24a7d56e59a3e6ef72d4a186b 100755 (executable)
@@ -95,7 +95,7 @@ fi
 if [ -n "$XMLSTARLET" ]; then
     URL="https://$CSD_HOSTNAME/CACHE/sdesktop/data.xml"
 
-    curl $PINNEDPUBKEY -s "$URL" | xmlstarlet sel -t -v '/data/hostscan/field/@value' | while read -r ENTRY; do
+    curl $PINNEDPUBKEY -s "$URL" | xmlstarlet sel -t -v '/data/hostscan/field/@value' -n | while read -r ENTRY; do
        # XX: How are ' and , characters escaped in this?
        TYPE="$(sed "s/^'\(.*\)','\(.*\)','\(.*\)'$/\1/" <<< "$ENTRY")"
        NAME="$(sed "s/^'\(.*\)','\(.*\)','\(.*\)'$/\2/" <<< "$ENTRY")"