title: Clean way to launch the web browser from shell script?
body: <p>In a bash script, I need to launch the user web browser. There seems to be many ways of doing this:</p>
  
  <ul>
  <li><code>$BROWSER</code></li>
  <li><code>xdg-open</code></li>
  <li><code>gnome-open</code> on GNOME</li>
  <li><code>www-browser</code></li>
  <li><code>x-www-browser</code></li>
  <li>...</li>
  </ul>
  
  <p>Is there a more-standard-than-the-others way to do this that would work on most platforms, or should I just go with something like this:</p>
  
  <pre><code>#/usr/bin/env bash
  
  if [ -n $BROWSER ]; then
    $BROWSER 'http://wwww.google.com'
  elif which xdg-open &gt; /dev/null; then
    xdg-open 'http://wwww.google.com'
  elif which gnome-open &gt; /dev/null; then
    gnome-open 'http://wwww.google.com'
  # elif bla bla bla...
  else
    echo "Could not detect the web browser to use."
  fi
  </code></pre>