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