главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
path: root/echoz.sh
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2018-07-24 18:03:03 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2018-07-24 18:03:03 +0200
commit4cf1debf9e1e92a2a391eda44857d5939f16d5ff (patch)
tree4f3a672bcd105cdea14e32dcdc8d192c6a5a7aca /echoz.sh
parent8c6f5e195e9c67962dc21dde006fb77bfb91e0b6 (diff)
Make echoz.sh POSIX-compliant
Diffstat (limited to 'echoz.sh')
-rwxr-xr-xechoz.sh8
1 files changed, 4 insertions, 4 deletions
diff --git a/echoz.sh b/echoz.sh
index e5b8321..9d9f94c 100755
--- a/echoz.sh
+++ b/echoz.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
set -euf
thisdir="$(dirname $0)"
pipename="${XDG_RUNTIME_DIR:-/tmp}/echoz-$$.pipe"
@@ -9,11 +9,11 @@ domain="$(echo "$jid" | cut -d'@' -f2)"
srv="$( ( dig +short SRV "_xmpp-client._tcp.$domain" || echo "0 0 5222 $domain" ) | sort -n)"
host="$(echo "$srv" | cut -d' ' -f4)"
port="$(echo "$srv" | cut -d' ' -f3)"
-authstr="$(echo -ne "\0$username\0$password" | base64)"
+authstr="$(printf '\0%s\0%s' "$username" "$password" | base64)"
rm -f "$pipename"
mkfifo "$pipename"
DEBUG_PATH=${DEBUG_PATH:-}
-if [[ "x$DEBUG_PATH" != "x" ]]; then
+if [ "x$DEBUG_PATH" != "x" ]; then
debug_recv="${DEBUG_PATH}recv.xml"
debug_sent="${DEBUG_PATH}sent.xml"
rm -f "$debug_sent" "$debug_recv"
@@ -28,7 +28,7 @@ stdbuf -i0 -o0 \
-connect "$host:$port" \
-quiet \
< "$pipename" \
- | (echo -ne "$jid $authstr\n"; \
+ | (printf '%s %s\n' "$jid" "$authstr"; \
stdbuf -o0 tr '>\n' '\n\001') \
| stdbuf -o0 tee "$debug_recv" \
| stdbuf -o0 "$thisdir/echoz.sed" \