aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/uzbl/scripts/download.sh
diff options
context:
space:
mode:
Diffstat (limited to 'examples/data/uzbl/scripts/download.sh')
-rwxr-xr-xexamples/data/uzbl/scripts/download.sh20
1 files changed, 12 insertions, 8 deletions
diff --git a/examples/data/uzbl/scripts/download.sh b/examples/data/uzbl/scripts/download.sh
index d87335f..aa1ca09 100755
--- a/examples/data/uzbl/scripts/download.sh
+++ b/examples/data/uzbl/scripts/download.sh
@@ -1,15 +1,19 @@
-#!/bin/bash
+#!/bin/sh
# just an example of how you could handle your downloads
# try some pattern matching on the uri to determine what we should do
-# Some sites block the default wget --user-agent...
-WGET="wget --user-agent=Firefox"
+# Some sites block the default wget --user-agent..
+GET="wget --user-agent=Firefox"
-if [[ $8 =~ .*(.torrent) ]]
+dest="$HOME"
+url="$8"
+
+test "x$url" = "x" && { echo "you must supply a url! ($url)"; exit 1; }
+
+# only changes the dir for the $get sub process
+if echo "$url" | grep -E '.*\.torrent' >/dev/null;
then
- cd $HOME
- $WGET $8
+ ( cd "$dest"; eval "$GET" "$url")
else
- cd $HOME
- $WGET $8
+ ( cd "$dest"; eval "$GET" "$url")
fi