[Surfraw-commits] [SCM] surfraw - a fast unix command line interface to WWW branch, master, updated. surfraw_2-2-5_1-33-gc548ef3

Ian Beckwith ianb at erislabs.net
Tue Oct 27 05:42:12 UTC 2009


The following commit has been merged in the master branch:
commit c548ef384591202774dedf274719c1f19a6ebf4d
Author: Ian Beckwith <ianb at erislabs.net>
Date:   Tue Oct 27 05:41:01 2009 +0000

    support -o | -o=FILE to dump to stdout or FILE, using curl, wget or GET (from libwww-perl)

diff --git a/ChangeLog b/ChangeLog
index 89f3d02..8d2b360 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,8 @@
 	  and all his other work).
 	* Fixed cia.
 	* Fixed tests: aur, debpts, lastfm.
+	* Added -o | -o=FILE option, to fetch URL and dump to
+	  stdout or FILE.
 	* test/Makefile.am: add debvcsbrowse.test to EXTRA_DIST
 	* Makefile.am: install-data-hook: remove execute flag
 	  from generated files surfraw.conf, elvi.1sr & surfraw.1.
diff --git a/debian/changelog b/debian/changelog
index ecd1ec6..b914eaf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,8 +8,9 @@ surfraw (2.2.6-1) unstable; urgency=low
   * debian/control:
     + update vcs- fields to point to new git repo.
     + Standards-Version: 3.8.3 (No changes).
+    + add Recommends: curl | wget | libwww-perl for -o.
 
- -- Ian Beckwith <ianb at debian.org>  Tue, 27 Oct 2009 02:38:17 +0000
+ -- Ian Beckwith <ianb at debian.org>  Tue, 27 Oct 2009 05:26:27 +0000
 
 surfraw (2.2.5-1) unstable; urgency=low
 
diff --git a/debian/control b/debian/control
index e128e91..4a15fb0 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,7 @@ Homepage: http://surfraw.alioth.debian.org
 Package: surfraw
 Architecture: all
 Depends: lynx | www-browser
-Recommends: surfraw-extra, links | elinks | elinks-lite | w3m
+Recommends: surfraw-extra, links | elinks | elinks-lite | w3m, curl | wget | libwww-perl
 Suggests: screen
 Conflicts: surfaw
 Replaces: surfaw
diff --git a/surfraw.IN b/surfraw.IN
index d1a5cbf..2e8f6c0 100644
--- a/surfraw.IN
+++ b/surfraw.IN
@@ -275,6 +275,7 @@ Global options:
 				Environment: SURFRAW_graphical
   -help				What you're reading now, dude
   -p | -print			Just print search URL, don't pass to browser
+  -o | -o=FILE			Fetch URL and dump to stdout or FILE.
   -quiet=yes|no			I can't enjoy it with you talking all the time
 				Default: $SURFRAW_quiet
 				Environment: SURFRAW_quiet
@@ -332,6 +333,9 @@ w3_parse_option () {
 	-q | -quote)	    setoptyn SURFRAW_quote_args	    	yes	;;
 	-new)		    setoptyn SURFRAW_new_window		yes	;;
 	-new=*)		    setoptyn SURFRAW_new_window		$optarg ;;
+	-o)		    setoptyn SURFRAW_dump		yes	;;
+	-o=*)		    setoptyn SURFRAW_dump		yes
+			    setopt SURFRAW_dump_file		$optarg ;;
 	-t | -text)	    unset DISPLAY
 			    setoptyn SURFRAW_graphical 		no	;;
 	-version)	    echo $surfraw_version; exit 0	    	;;
@@ -384,13 +388,34 @@ w3_parse_args () {
     fi
 }
 
+w3_dump () {
+    if test -z "$SURFRAW_dump_file"; then
+	SURFRAW_dump_file="-"
+    fi
+    if test -x "$(which curl)"; then
+	curl -o "$SURFRAW_dump_file" "$@"
+    elif test -x "$(which wget)"; then
+	wget -q -O "$SURFRAW_dump_file" "$@"
+    elif test -x "$(which GET)"; then
+	if test "$SURFRAW_dump_file" = "-"; then
+	    GET "$@"
+	else
+	    GET "$@" > "$SURFRAW_dump_file"
+	fi
+    else
+	err "No URL fetcher found: install curl, wget or libwww-perl"
+    fi
+}
+
 w3_browse_url () {
    if ok SURFRAW_new_screen && test -n "$STY" && test $mode = text; then
    	screen=yes
    else
    	screen=no
    fi
-    if ok SURFRAW_print; then
+    if ok SURFRAW_dump; then
+	w3_dump "$@"
+    elif ok SURFRAW_print; then
 		echo "$@"
     elif ok screen; then
 	if test $SURFRAW_browser_args = "none"; then
diff --git a/surfraw.conf.IN b/surfraw.conf.IN
index a6a6505..f0c8516 100644
--- a/surfraw.conf.IN
+++ b/surfraw.conf.IN
@@ -79,6 +79,10 @@ defyn SURFRAW_escape_url_args	yes
 # just print search url?
 defyn SURFRAW_print             no
 
+# Fetch and dump url?
+defyn SURFRAW_dump		no
+
 # Language/country (for elvi that support it)
 # Should be a 2-letter iso country code
 def SURFRAW_lang     	  	""
+

-- 
surfraw -  a fast unix command line interface to WWW



More information about the Surfraw-commits mailing list