# HG changeset patch # User HackBot # Date 1361901713 0 # Node ID 5c453217583bc4d7269a23dce8482be38b9a02fa # Parent b2cc3747ec3678e2d0f671084fdd9f4adec9a7b1 sed -i... -e \'s/grep/timeout 25 grep/\' bin/pastelog diff -r b2cc3747ec36 -r 5c453217583b bin/pastelog --- a/bin/pastelog Tue Feb 26 17:53:02 2013 +0000 +++ b/bin/pastelog Tue Feb 26 18:01:53 2013 +0000 @@ -16,7 +16,7 @@ if expr "$1" + 0 >/dev/null 2>&1; then pasterandom "$1" else - lines=$(grep -P -i -- "$1" ????-??-??.txt | head -n 301) + lines=$(timeout 25 grep -P -i -- "$1" ????-??-??.txt | head -n 301) { echo "$lines" | head -n 300 [ $(echo "$lines" | wc -l) -eq 301 ] && echo "[too many lines; stopping]" diff -r b2cc3747ec36 -r 5c453217583b bin/pastelog... --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/pastelog... Tue Feb 26 18:01:53 2013 +0000 @@ -0,0 +1,28 @@ +#!/bin/sh +cd /var/irclogs/_esoteric + +pasterandom() { + if [ "$1" -gt 150 ]; then + echo "No." + exit + fi + for i in $(seq "$1"); do + file=$(shuf -en 1 ????-??-??.txt) + echo "$file:$(shuf -n 1 $file)" + done | paste +} + +if [ "$1" ]; then + if expr "$1" + 0 >/dev/null 2>&1; then + pasterandom "$1" + else + lines=$(grep -P -i -- "$1" ????-??-??.txt | head -n 301) + { + echo "$lines" | head -n 300 + [ $(echo "$lines" | wc -l) -eq 301 ] && echo "[too many lines; stopping]" + } | paste + fi +else + pasterandom 40 +fi +