[Surfraw-devel] Bug with DuckDuckGo elvi

Manolo Martínez manolo at austrohungaro.com
Thu Jun 28 15:14:30 UTC 2012


On 06/27/12 at 04:50pm, Ivy Foster wrote:
> You're quite right; thanks for reporting this bug. As it
> turns out, duckduckgo defined -p as a short version of
> -safe. Since it seems most likely that safe search will be
> turned on or off in the config rather than on every command
> line, I've removed -p from duckduckgo, resolving the issue.
> 

Happy to help:) I stumbled upon the bug because I use sr -p in a little
script that allows using surfraw searches from within elinks. I attach
it herein in case someone might find it useful. The script should be
saved as (part of) ~/.elinks/hooks.lua

Cheers,
Manolo
-------------- next part --------------
-- Using surfraw from elinks. To search using an elvi from the Go to URL dialog box, use the xyntax "!elvi your search terms". E.g., to search for 
-- Wargames torrents in piratebay, type "!piratebay wargames" in the Go to URL dialog box.
-- You need to have surfraw installed, obviously, and your lua install should have io.popen.

function match (prefix, url)
    return string.sub (url, 1, string.len (prefix)) == prefix
end

function tosurfraw (str)
    return "surfraw -p " .. str .. " 2>/dev/null"
end

function goto_url_hook (url, current_url)
    if match ("!", url) then
        sr = tosurfraw (string.sub (url, 2))
        urlfile = io.popen (sr)
        finalurl = urlfile:read('*all')
        urlfile:close()
        return finalurl

    else
        return url
    end
end


More information about the Surfraw-devel mailing list