#!/usr/bin/luajit local lpeg = require 'lpeg' local P,C,Cs,R = lpeg.P, lpeg.C, lpeg.Cs, lpeg.R local cnum = C(R("09")^1) local cword = C(R("AZ","az","09","__")^1) local bugpat = (P"bgo#" * cnum) / "http://bugzilla.gnome.org/show_bug.cgi?id=%1" + (P"bko#" * cnum) / "http://bugzilla.kernel.org/show_bug.cgi?id=%1" + (P"bmo#" * cnum) / "http://bugzilla.mozilla.org/show_bug.cgi?id=%1" + (P"boo#" * cnum) / "http://bugzilla.opensuse.org/show_bug.cgi?id=%1" + (P"bsc#" * cnum) / "http://bugzilla.suse.com/show_bug.cgi?id=%1" + (P"gh#" * C((1 - P"#")^1) * P"#" * cword) / "https://github.com/%1/issues/%2" + (P"lp#" * cnum) / "https://launchpad.net/bugs/%1" + (P"rh#" * cnum) / "http://bugzilla.redhat.com/show_bug.cgi?id=%1" local pat = Cs((bugpat + P(1))^0) os.execute("xdg-open " .. pat:match(arg[1]))