Skip to content

Commit

Permalink
Don't run "kde-open" and "gnome-open" under Unix (#6426)
Browse files Browse the repository at this point in the history
  • Loading branch information
konqoro authored and Araq committed Nov 19, 2017
1 parent 784d2e8 commit aac94e0
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions lib/pure/browsers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,18 @@ proc openDefaultBrowser*(url: string) =
## opens `url` with the user's default browser. This does not block.
##
## Under Windows, ``ShellExecute`` is used. Under Mac OS X the ``open``
## command is used. Under Unix, it is checked if ``gnome-open`` exists and
## used if it does. Next attempt is ``kde-open``, then ``xdg-open``.
## Otherwise the environment variable ``BROWSER`` is used to determine the
## default browser to use.
## command is used. Under Unix, it is checked if ``xdg-open`` exists and
## used if it does. Otherwise the environment variable ``BROWSER`` is
## used to determine the default browser to use.
when defined(windows):
when useWinUnicode:
var o = newWideCString("open")
var u = newWideCString(url)
discard shellExecuteW(0'i32, o, u, nil, nil, SW_SHOWNORMAL)
else:
discard shellExecuteA(0'i32, "open", url, nil, nil, SW_SHOWNORMAL)
var o = newWideCString("open")
var u = newWideCString(url)
discard shellExecuteW(0'i32, o, u, nil, nil, SW_SHOWNORMAL)
elif defined(macosx):
discard execShellCmd("open " & quoteShell(url))
else:
const attempts = ["gnome-open ", "kde-open ", "xdg-open "]
var u = quoteShell(url)
for a in items(attempts):
if execShellCmd(a & u) == 0: return
if execShellCmd("xdg-open " & u) == 0: return
for b in getEnv("BROWSER").string.split(PathSep):
try:
# we use ``startProcess`` here because we don't want to block!
Expand Down

0 comments on commit aac94e0

Please sign in to comment.