shopt -s lastpipe
-if [[ "$2" = gnunet://* ]]; then
- echo "${2:9}"
-else
- echo "$2"
-fi | awk '
+case "$2" in
+gnunet://*) echo "${2:9}" ;;
+*) echo "$2" ;;
+esac | awk '
match($0, /(([^@]*)@)?([^/]*)(\/.*)?/, a) { printf "%s\n%s\n%s\n", a[2], a[3], a[4] }
' | { read -r username && read -r gnsname && read -r path && ! grep '.'; }
if test "$?" != "0"; then
case "$cmd" in
capabilities) printf '%s\n' 'connect' '' ;;
connect) break ;;
- *) echo >&2 "Error: Git remote helper protocol."; exit 1 ;;
+ *) echo >&2 "Error: Git remote helper protocol failure."; exit 1 ;;
esac
done
echo;
cat "$fifo" -;
} | socat stdio tcp4:"$ip":9418 | {
- { if test "" != "$username"; then
- read -r cyphertext
- case "$cyphertext" in
+ { while read -r line; do
+ case "$line" in
"Error: "*)
- echo >&2 "$cyphertext"
+ echo >&2 "$line"
rm "$fifo"
exit 1
;;
"Key:"*)
- plaintext="$(gnunet-identity -e "$username" -R "${cyphertext:4}")" || { rm "$fifo"; exit 1; }
+ plaintext="$(gnunet-identity -e "$username" -R "${line:4}")" || { rm "$fifo"; exit 1; }
printf '%s\n' "$plaintext" | sha256sum
;;
+ "") break ;;
+ *) echo >&2 "Error: Git/GNUnet handler protocol failure."; exit 1 ;;
esac;
- fi; } > "$fifo";
+ done; } > "$fifo";
+ echo '';
cat;
}
rm "$fifo"