главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Anderiasch <fa@art-core.org>2018-07-25 10:54:43 +0200
committerFlorian Anderiasch <fa@art-core.org>2018-07-25 10:54:43 +0200
commitbcb6339dd1d59c08d38d0fff6df5b9617898b7ad (patch)
tree35bebcc5ceafe4720f6901ab5c28d6552cf2d422
parenta6de94496a7a808afcde924c813d6ebc606b35e3 (diff)
Replace use of 'cut' with more 'sed'
-rwxr-xr-xechoz.sh10
1 files changed, 5 insertions, 5 deletions
diff --git a/echoz.sh b/echoz.sh
index 766051e..83c01d6 100755
--- a/echoz.sh
+++ b/echoz.sh
@@ -4,11 +4,11 @@ thisdir="$(dirname "$0")"
pipename="${XDG_RUNTIME_DIR:-/tmp}/echoz-$$.pipe"
jid="$1"
password="$2"
-username="$(echo "$jid" | cut -d'@' -f1)"
-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)"
+username="$(echo "$jid" | sed 's/@.*//')"
+domain="$(echo "$jid" | sed 's/.*@//')"
+srv="$( ( dig +short SRV "_xmpp-client._tcp.$domain" || echo "0 0 5222 $domain" ) | sort -n | sed 's/[[:digit:]]\+[[:space:]][[:digit:]]\+[[:space:]]//')"
+host="$(echo "$srv" | sed 's/[[:digit:]]\+[[:space:]]//')"
+port="$(echo "$srv" | sed 's/[[:space:]].*//')"
authstr="$(echo -ne "\0$username\0$password" | base64)"
rm -f "$pipename"
mkfifo "$pipename"