/usr/lib/surfraw/stack is in surfraw 2.2.8-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #!/bin/sh
# elvis: stack -- Search Stack Overflow
# Author: jason ryan • http://jasonwryan.com
. surfraw || exit 1
w3_config_hook () {
def SURFRAW_stack_categories "$SURFRAW_categories"
def SURFRAW_stack_unix 0
def SURFRAW_stack_results 25
}
w3_usage_hook () {
cat <<EOF
Usage: $w3_argv0 [options] [search-string]
Description:
Search Stack Overflow (http://stackoverflow.com)
Combine search terms (tags) with a "+" eg., "bash+script"
Local options:
-sort=CATEGORIES
-s=CATEGORIES
new | Most recently asked (default)
feat | Questions with open bounties
vote | Questions with most votes
active | Recently active
null | No upvoted answers
faq | Questions with the most links
Default: new
-u | Search Unix & Linux Exchange
Default: no
-num=NUMBER | Number of results per page
Default: $SURFRAW_stack_results
EOF
w3_global_usage
}
w3_parse_option_hook () {
opt="$1"
optarg="$2"
case "$opt" in
-sort=*) setopt SURFRAW_stack_categories $optarg ;;
-s=*) setopt SURFRAW_stack_categories $optarg ;;
-num=*) setopt SURFRAW_stack_results $optarg ;;
-u) setoptyn SURFRAW_stack_unix 1 ;;
*) return 1 ;;
esac
return 0
}
w3_config
w3_parse_args "$@"
# w3_args now contains list of arguments
case "$SURFRAW_stack_categories" in
new) category="newest" ;;
feat) category="featured" ;;
vote) category="votes" ;;
active) category="active" ;;
null) category="unanswered" ;;
faq) category="faq" ;;
*) category="newest" ;;
esac
# Check for Unix & Linux Exchange
if [ "$SURFRAW_stack_unix" = 1 ]; then
url="http://unix.stackexchange.com"
else
url="http://stackoverflow.com"
fi
# No arguments passed
if [ -z "$w3_args" ]; then
w3_browse_url "$url"
else
escaped_args=$(w3_url_of_arg $w3_args)
if [ -n "$SURFRAW_stack_categories" ]; then
w3_browse_url "${url}/questions/tagged/${escaped_args}?sort=${category}&pagesize=${SURFRAW_stack_results}"
else
w3_browse_url "${url}/questions/tagged/${escaped_args}"
fi
fi
|