diff --git a/create.cgi b/create.cgi
index 6062ab8..f27bbcd 100755
--- a/create.cgi
+++ b/create.cgi
@@ -6,6 +6,7 @@ Cache-Control: no-cache
Content-Type: text/html
END
+
badinput() {
echo "
Bad input, parameter id $@
"
exit
@@ -57,15 +58,14 @@ then
echo Attempting an update
else
- if curl -sI http://api.twitter.com/1/users/lookup.xml?screen_name=${id} |
+ if curl -sI http://api.twitter.com/1/users/lookup.xml?screen_name=${id} |
grep -q "Status: 404 Not Found"
then
echo "$id does not exist on twitter.com :("
exit
fi
- echo Need to create u/$id
- mkdir u/$id
+ mkdir -p u/$id
fi
diff --git a/fetch-tweets.sh b/fetch-tweets.sh
index 4efd62e..ee2e6f6 100755
--- a/fetch-tweets.sh
+++ b/fetch-tweets.sh
@@ -10,14 +10,12 @@ then
exit 1
fi
-# xmlstarlet is often just xml
-if which xmlstarlet >> /dev/null; then
- XMLSTARLET=xmlstarled
-elif which xml >> /dev/null; then
- XMLSTARLET=xml
-else
- echo "xmlstarlet not found :("
- exit 1
+command -v xmlstarlet >/dev/null && XMLSTARLET=xmlstarlet
+command -v xml >/dev/null && XMLSTARLET=xml
+if ! test $XMLSTARLET
+then
+ echo "xmlstarlet not found :("
+ exit 1
fi
twitter_total=$(curl -s "http://api.twitter.com/1/users/lookup.xml?screen_name=$1" |
@@ -98,14 +96,14 @@ do
case $first in
"text") echo "$text"; text="$rest" ;;
"url")
- set -- $(echo $rest)
- finUrl=$2
- domain=$(echo $finUrl | cut -d'/' -f3)
- if [ "$shortDomains" = *$domain* ]
- then
+ set -- $(echo $rest)
+ finUrl=$2
+ domain=$(echo $finUrl | cut -d'/' -f3)
+ if echo $shortDomains | grep -q $domain # TODO might match greedily, e.g. with t.co
+ then
finUrl=$(curl "$finUrl" -s -L -I -o /dev/null -w '%{url_effective}')
- fi
- text=$(echo $text | sed s,$1,$finUrl,g)
+ fi
+ text=$(echo $text | sed s,$1,$finUrl,g)
;;
esac
done
diff --git a/grep.php b/grep.php
index 77c2659..adbb113 100644
--- a/grep.php
+++ b/grep.php
@@ -1,10 +1,15 @@