summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-02-02 16:22:49 +0100
committerFlorian Pritz <bluewind@server-speed.net>2011-02-02 17:21:57 +0100
commit3d9596bab71e36ef2e785d87e7473e10e0d0f22b (patch)
tree9709703c989d96e2b6579874f1f8e97b238265d9
parent09e7b20e91214283be6d484fb201e39d98a76dd0 (diff)
add support for URLs to -g and -d
Try to extract the ID from URLs like http://paste.xinu.at/1234/ Signed-off-by: Florian Pritz <bluewind@server-speed.net>
-rw-r--r--fb.in10
-rw-r--r--fb.pod2
2 files changed, 12 insertions, 0 deletions
diff --git a/fb.in b/fb.in
index 2586667..006d09f 100644
--- a/fb.in
+++ b/fb.in
@@ -84,6 +84,14 @@ read_stdin() {
cat > "$1"
}
+id_from_arg() {
+ if echo "$1" | grep -qE "^https?://"; then
+ echo "$1" | sed -r 's/https?:\/\/[^\/]+\/([^\/]+).*/\1/'
+ else
+ echo "$1"
+ fi
+}
+
help() {
cat <<!
fb-client version $VERSION
@@ -144,10 +152,12 @@ else
else
for i in "$@"; do
if [ "$DELETE" ]; then
+ i=$(id_from_arg "$i")
if ! curl -n -L -A $USERAGENT "$PASTEBIN/file/delete/$i"; then
EXITCODE=1
fi
elif [ "$GET" ]; then
+ i=$(id_from_arg "$i")
if ! curl -s -o - -A $USERAGENT "$PASTEBIN/$i"; then
EXITCODE=1
fi
diff --git a/fb.pod b/fb.pod
index c78a39b..f9aaa76 100644
--- a/fb.pod
+++ b/fb.pod
@@ -30,11 +30,13 @@ If you want to be able to delete files, you have to add the following line to ~/
-d
Delete the IDs. You can no longer upload files in this mode.
+ If the argument is a URL, C<fb> will try to extract the ID.
-g
Download the IDs and output on stdout. Please take care when using this,
as binary data can cause unexpected results when being output directly
to a terminal. You can no longer upload files in this mode.
+ If the argument is a URL, C<fb> will try to extract the ID.
-h
Display a short help message.