在bash脚本中,我需要启动用户Web浏览器。似乎有很多方法可以做到这一点:
$BROWSER
xdg-open
gnome-open
在GNOME上www-browser
x-www-browser
有没有一种更为标准的方法可以在大多数平台上运行,或者我应该这样做:
#/usr/bin/env bash
if [ -n $BROWSER ]; then
$BROWSER 'http://wwww.google.com'
elif which xdg-open > /dev/null; then
xdg-open 'http://wwww.google.com'
elif which gnome-open > /dev/null; then
gnome-open 'http://wwww.google.com'
# elif bla bla bla...
else
echo "Could not detect the web browser to use."
fi
相似问题