examples: format and run shellcheck

~~~
shfmt -i 2 -ci -w examples
shellcheck examples/*
~~~
master
Michael Santos 4 years ago
parent 11ee1c92f4
commit 25d8272656

@ -17,11 +17,11 @@ TMPDIR=$(mktemp -d)
in="$TMPDIR/stdin"
out="$TMPDIR/stdout"
mkfifo $in
mkfifo $out
mkfifo "$in"
mkfifo "$out"
cleanup() {
rm -rf $TMPDIR
rm -rf "$TMPDIR"
}
decode() {
@ -33,15 +33,16 @@ bot() {
while IFS=: read stanza type from to body; do
case "$stanza" in
m) ;;
p) decode "$stanza:$type:$from:$to" 1>&2
p)
decode "$stanza:$type:$from:$to" 1>&2
echo 1>&2
continue
;;
*) continue ;;
esac
USER="$(decode ${from#*/})"
MSG="$(decode ${body})"
USER="$(decode "${from#*/}")"
MSG="$(decode "$body")"
case $MSG in
*"has set the subject to:"*) ;;
@ -72,8 +73,8 @@ bot() {
fi
;;
esac
done < $out
done <"$out"
}
bot > $in &
xmppipe "$@" <$in >$out
bot >"$in" &
xmppipe "$@" <"$in" >"$out"

@ -25,10 +25,11 @@ TMPDIR=$(mktemp -d)
out=$TMPDIR/out
atexit() {
rm -rf $TMPDIR
rm -rf "$TMPDIR"
}
decode() {
# shellcheck disable=SC2034
while IFS=: read stanza type from to body; do
case "$stanza" in
m) printf '%b' "${body//%/\\x}" ;;
@ -39,12 +40,13 @@ decode() {
server() {
CONNECT=0
xmppipe -e -r server -o $1 -b 1024 -x < /dev/null | \
xmppipe -e -r server -o "$1" -b 1024 -x </dev/null |
while IFS=: read stanza rest; do
case "$stanza" in
p)
CONNECT=$((CONNECT + 1))
if [ "$CONNECT" -gt "1" ]; then
# shellcheck disable=SC2068
exec "$PROGNAME" session $@
fi
;;
@ -54,16 +56,19 @@ server() {
}
session() {
mkdir -p $TMPDIR
mkdir -p "$TMPDIR"
trap atexit 0
mkfifo $out
mkfifo "$out"
nc $2 $3 < $out | xmppipe -P 100 -r session -o $1 -x -s | decode > $out
nc "$2" "$3" <"$out" |
xmppipe -P 100 -r session -o "$1" -x -s |
decode >"$out"
}
client() {
xmppipe -P 100 -r client -o $1 -x -s | decode
xmppipe -P 100 -r client -o "$1" -x -s | decode
}
# shellcheck disable=SC2068
$@

Loading…
Cancel
Save