Thanks for adding the fallback to the $BROWSER environment variable.
However, unlike $PAGER and $EDITOR, $BROWSER doesn't always consist of a single command name that you can run with an URL argument. Quoting man 1 man (one of a few sources fully documenting $BROWSER):
If $BROWSER is set, its value is a colon-delimited list of commands, each of which in turn is used to try to start a web browser for man --html. In each command, %s is replaced by a filename containing the HTML output from groff, %% is replaced by a single percent sign (%), and %c is replaced by a colon (:).
See the documentation for the Python webbrowser module for another explanation of $BROWSER.
So:
- Split
$BROWSER on ':' and loop over each, continuing to the next on failure
- For each one, replace '%s' with the URL, '%c' with a colon, and '%%' with a percent. If and only if it didn't contain '%s', append the URL.
Thanks for adding the fallback to the
$BROWSERenvironment variable.However, unlike
$PAGERand$EDITOR,$BROWSERdoesn't always consist of a single command name that you can run with an URL argument. Quotingman 1 man(one of a few sources fully documenting$BROWSER):See the documentation for the Python webbrowser module for another explanation of
$BROWSER.So:
$BROWSERon ':' and loop over each, continuing to the next on failure