k 5 goify: fix extra space bug

This commit is contained in:
lassulus 2017-05-02 20:10:36 +02:00
parent 9afa716800
commit 1a7d62733c

View File

@ -1,17 +1,18 @@
{ pkgs, ... }:
pkgs.writeDashBin "goify" ''
pkgs.writeBashBin "goify" ''
set -euf
GO_HOST=''${GO_HOST:-go}
while read line; do
echo "$line" | sed -E 's|https?://\S*|\n&\n|g' | while read word; do
if echo "$word" | grep -Eq ^https?:; then
${pkgs.curl}/bin/curl -Ss -F uri="$word" http://"$GO_HOST" | tr -d '\r'
echo "$line" | sed 's|https\?://\S*|\n&\n|g' | while read word; do
if echo "$word" | grep -q '^https\?:'; then
${pkgs.curl}/bin/curl -Ss -F uri="$word" http://"$GO_HOST" \
| tr -d '\r'
else
echo "$word";
fi;
done | sed '/^$/d' | tr '\n' ' '; echo;
echo "$word"
fi
done | grep . | tr '\n' ' '; echo
done
''