{"thread":{"id":"25974","subject":"[PATCHv3 1/6] web--browse: coding style","startedAt":"2010-12-06T17:49:44Z","lastAt":"2010-12-08T07:38:11Z","messageCount":13,"participants":["Giuseppe Bilotta","Jonathan Nieder","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"157418","messageId":"1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com","threadId":"25974","inReplyTo":null,"subject":"[PATCHv3 0/6] web--browse cleanup and extensions","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-06T17:49:44Z","receivedAt":"2010-12-06T17:49:44Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Differences from the previous revision of this patchset:\n\n* the CodingGuidelines patch was dropped, since it's merged in next\n* the chromium support patch had some stylistic changes suggested by Junio\n* the *www-browser patch adds support for detecting konqueror and kfmclient,\n  which required some changes to the version string retrieval code; also,\n  readlink is only used if available.\n\nGiuseppe Bilotta (6):\n  web--browse: coding style\n  web--browse: split valid_tool list\n  web--browse: support opera, seamonkey and elinks\n  web--browse: better support for chromium\n  web--browse: use *www-browser if available\n  web--browse: look at the BROWSER env var\n\n Documentation/git-web--browse.txt |   10 ++\n git-web--browse.sh                |  302 ++++++++++++++++++++++++++-----------\n 2 files changed, 225 insertions(+), 87 deletions(-)\n\n-- \n1.7.3.2.664.g294b8.dirty\n"},{"id":"157412","messageId":"1291657790-3719-2-git-send-email-giuseppe.bilotta@gmail.com","threadId":"25974","inReplyTo":"1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 1/6] web--browse: coding style","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-06T17:49:45Z","receivedAt":"2010-12-06T17:49:45Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Retab and deindent choices in case statements.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n git-web--browse.sh |  166 ++++++++++++++++++++++++++--------------------------\n 1 files changed, 83 insertions(+), 83 deletions(-)\n\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\nindex 3fc4166..7c4568f 100755\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -31,11 +31,11 @@ valid_custom_tool()\n \n valid_tool() {\n \tcase \"$1\" in\n-\t\tfirefox | iceweasel | chrome | google-chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)\n-\t\t\t;; # happy\n-\t\t*)\n-\t\t\tvalid_custom_tool \"$1\" || return 1\n-\t\t\t;;\n+\tfirefox | iceweasel | chrome | google-chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)\n+\t\t;; # happy\n+\t*)\n+\t\tvalid_custom_tool \"$1\" || return 1\n+\t\t;;\n \tesac\n }\n \n@@ -46,139 +46,139 @@ init_browser_path() {\n \n while test $# != 0\n do\n-    case \"$1\" in\n+\tcase \"$1\" in\n \t-b|--browser*|-t|--tool*)\n-\t    case \"$#,$1\" in\n+\t\tcase \"$#,$1\" in\n \t\t*,*=*)\n-\t\t    browser=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n-\t\t    ;;\n+\t\t\tbrowser=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n+\t\t\t;;\n \t\t1,*)\n-\t\t    usage ;;\n+\t\t\tusage ;;\n \t\t*)\n-\t\t    browser=\"$2\"\n-\t\t    shift ;;\n-\t    esac\n-\t    ;;\n+\t\t\tbrowser=\"$2\"\n+\t\t\tshift ;;\n+\t\tesac\n+\t\t;;\n \t-c|--config*)\n-\t    case \"$#,$1\" in\n+\t\tcase \"$#,$1\" in\n \t\t*,*=*)\n-\t\t    conf=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n-\t\t    ;;\n+\t\t\tconf=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n+\t\t\t;;\n \t\t1,*)\n-\t\t    usage ;;\n+\t\t\tusage ;;\n \t\t*)\n-\t\t    conf=\"$2\"\n-\t\t    shift ;;\n-\t    esac\n-\t    ;;\n+\t\t\tconf=\"$2\"\n+\t\t\tshift ;;\n+\t\tesac\n+\t\t;;\n \t--)\n-\t    break\n-\t    ;;\n+\t\tbreak\n+\t\t;;\n \t-*)\n-\t    usage\n-\t    ;;\n+\t\tusage\n+\t\t;;\n \t*)\n-\t    break\n-\t    ;;\n-    esac\n-    shift\n+\t\tbreak\n+\t\t;;\n+\tesac\n+\tshift\n done\n \n test $# = 0 && usage\n \n if test -z \"$browser\"\n then\n-    for opt in \"$conf\" \"web.browser\"\n-    do\n-\ttest -z \"$opt\" && continue\n-\tbrowser=\"`git config $opt`\"\n-\ttest -z \"$browser\" || break\n-    done\n-    if test -n \"$browser\" && ! valid_tool \"$browser\"; then\n-\techo >&2 \"git config option $opt set to unknown browser: $browser\"\n-\techo >&2 \"Resetting to default...\"\n-\tunset browser\n-    fi\n+\tfor opt in \"$conf\" \"web.browser\"\n+\tdo\n+\t\ttest -z \"$opt\" && continue\n+\t\tbrowser=\"`git config $opt`\"\n+\t\ttest -z \"$browser\" || break\n+\tdone\n+\tif test -n \"$browser\" && ! valid_tool \"$browser\"; then\n+\t\techo >&2 \"git config option $opt set to unknown browser: $browser\"\n+\t\techo >&2 \"Resetting to default...\"\n+\t\tunset browser\n+\tfi\n fi\n \n if test -z \"$browser\" ; then\n-    if test -n \"$DISPLAY\"; then\n-\tbrowser_candidates=\"firefox iceweasel google-chrome chrome chromium konqueror w3m links lynx dillo\"\n-\tif test \"$KDE_FULL_SESSION\" = \"true\"; then\n-\t    browser_candidates=\"konqueror $browser_candidates\"\n+\tif test -n \"$DISPLAY\"; then\n+\t\tbrowser_candidates=\"firefox iceweasel google-chrome chrome chromium konqueror w3m links lynx dillo\"\n+\t\tif test \"$KDE_FULL_SESSION\" = \"true\"; then\n+\t\t\tbrowser_candidates=\"konqueror $browser_candidates\"\n+\t\tfi\n+\telse\n+\t\tbrowser_candidates=\"w3m links lynx\"\n \tfi\n-    else\n-\tbrowser_candidates=\"w3m links lynx\"\n-    fi\n-    # SECURITYSESSIONID indicates an OS X GUI login session\n-    if test -n \"$SECURITYSESSIONID\" \\\n-\t    -o \"$TERM_PROGRAM\" = \"Apple_Terminal\" ; then\n-\tbrowser_candidates=\"open $browser_candidates\"\n-    fi\n-    # /bin/start indicates MinGW\n-    if test -x /bin/start; then\n-\tbrowser_candidates=\"start $browser_candidates\"\n-    fi\n-\n-    for i in $browser_candidates; do\n-\tinit_browser_path $i\n-\tif type \"$browser_path\" > /dev/null 2>&1; then\n-\t    browser=$i\n-\t    break\n+\t# SECURITYSESSIONID indicates an OS X GUI login session\n+\tif test -n \"$SECURITYSESSIONID\" \\\n+\t\t-o \"$TERM_PROGRAM\" = \"Apple_Terminal\" ; then\n+\t\tbrowser_candidates=\"open $browser_candidates\"\n \tfi\n-    done\n-    test -z \"$browser\" && die \"No known browser available.\"\n+\t# /bin/start indicates MinGW\n+\tif test -x /bin/start; then\n+\t\tbrowser_candidates=\"start $browser_candidates\"\n+\tfi\n+\n+\tfor i in $browser_candidates; do\n+\t\tinit_browser_path $i\n+\t\tif type \"$browser_path\" > /dev/null 2>&1; then\n+\t\t\tbrowser=$i\n+\t\t\tbreak\n+\t\tfi\n+\tdone\n+\ttest -z \"$browser\" && die \"No known browser available.\"\n else\n-    valid_tool \"$browser\" || die \"Unknown browser '$browser'.\"\n+\tvalid_tool \"$browser\" || die \"Unknown browser '$browser'.\"\n \n-    init_browser_path \"$browser\"\n+\tinit_browser_path \"$browser\"\n \n-    if test -z \"$browser_cmd\" && ! type \"$browser_path\" > /dev/null 2>&1; then\n-\tdie \"The browser $browser is not available as '$browser_path'.\"\n-    fi\n+\tif test -z \"$browser_cmd\" && ! type \"$browser_path\" > /dev/null 2>&1; then\n+\t\tdie \"The browser $browser is not available as '$browser_path'.\"\n+\tfi\n fi\n \n case \"$browser\" in\n-    firefox|iceweasel)\n+firefox|iceweasel)\n \t# Check version because firefox < 2.0 does not support \"-new-tab\".\n \tvers=$(expr \"$($browser_path -version)\" : '.* \\([0-9][0-9]*\\)\\..*')\n \tNEWTAB='-new-tab'\n \ttest \"$vers\" -lt 2 && NEWTAB=''\n \t\"$browser_path\" $NEWTAB \"$@\" &\n \t;;\n-    google-chrome|chrome|chromium)\n+google-chrome|chrome|chromium)\n \t# Actual command for chromium is chromium-browser.\n \t# No need to specify newTab. It's default in chromium\n \teval \"$browser_path\" \"$@\" &\n \t;;\n-    konqueror)\n+konqueror)\n \tcase \"$(basename \"$browser_path\")\" in\n-\t    konqueror)\n+\tkonqueror)\n \t\t# It's simpler to use kfmclient to open a new tab in konqueror.\n \t\tbrowser_path=\"$(echo \"$browser_path\" | sed -e 's/konqueror$/kfmclient/')\"\n \t\ttype \"$browser_path\" > /dev/null 2>&1 || die \"No '$browser_path' found.\"\n \t\teval \"$browser_path\" newTab \"$@\"\n \t\t;;\n-\t    kfmclient)\n+\tkfmclient)\n \t\teval \"$browser_path\" newTab \"$@\"\n \t\t;;\n-\t    *)\n+\t*)\n \t\t\"$browser_path\" \"$@\" &\n \t\t;;\n \tesac\n \t;;\n-    w3m|links|lynx|open)\n+w3m|links|lynx|open)\n \teval \"$browser_path\" \"$@\"\n \t;;\n-    start)\n-        exec \"$browser_path\" '\"web-browse\"' \"$@\"\n-        ;;\n-    dillo)\n+start)\n+\texec \"$browser_path\" '\"web-browse\"' \"$@\"\n+\t;;\n+dillo)\n \t\"$browser_path\" \"$@\" &\n \t;;\n-    *)\n+*)\n \tif test -n \"$browser_cmd\"; then\n-\t    ( eval $browser_cmd \"$@\" )\n+\t\t( eval $browser_cmd \"$@\" )\n \tfi\n \t;;\n esac\n-- \n1.7.3.2.664.g294b8.dirty\n"},{"id":"157413","messageId":"1291657790-3719-3-git-send-email-giuseppe.bilotta@gmail.com","threadId":"25974","inReplyTo":"1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 2/6] web--browse: split valid_tool list","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-06T17:49:46Z","receivedAt":"2010-12-06T17:49:46Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"It was getting too long, and we want to add some more.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n git-web--browse.sh |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\nindex 7c4568f..e48e30d 100755\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -31,7 +31,8 @@ valid_custom_tool()\n \n valid_tool() {\n \tcase \"$1\" in\n-\tfirefox | iceweasel | chrome | google-chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)\n+\tfirefox | iceweasel | chrome | google-chrome | chromium |\\\n+\tkonqueror | w3m | links | lynx | dillo | open | start)\n \t\t;; # happy\n \t*)\n \t\tvalid_custom_tool \"$1\" || return 1\n-- \n1.7.3.2.664.g294b8.dirty\n"},{"id":"157416","messageId":"1291657790-3719-4-git-send-email-giuseppe.bilotta@gmail.com","threadId":"25974","inReplyTo":"1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 3/6] web--browse: support opera, seamonkey and elinks","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-06T17:49:47Z","receivedAt":"2010-12-06T17:49:47Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"The list of supported browsers is also updated in the documentation.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n Documentation/git-web--browse.txt |    6 ++++++\n git-web--browse.sh                |   14 +++++++-------\n 2 files changed, 13 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt\nindex 51e8e0a..5d3ae07 100644\n--- a/Documentation/git-web--browse.txt\n+++ b/Documentation/git-web--browse.txt\n@@ -20,8 +20,14 @@ The following browsers (or commands) are currently supported:\n \n * firefox (this is the default under X Window when not using KDE)\n * iceweasel\n+* seamonkey\n+* iceape\n+* chromium\n+* google-chrome\n * konqueror (this is the default under KDE, see 'Note about konqueror' below)\n+* opera\n * w3m (this is the default outside graphical environments)\n+* elinks\n * links\n * lynx\n * dillo\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\nindex e48e30d..48e5a28 100755\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -31,8 +31,8 @@ valid_custom_tool()\n \n valid_tool() {\n \tcase \"$1\" in\n-\tfirefox | iceweasel | chrome | google-chrome | chromium |\\\n-\tkonqueror | w3m | links | lynx | dillo | open | start)\n+\tfirefox | iceweasel | seamonkey | iceape | chrome | google-chrome | chromium |\\\n+\tkonqueror | opera | w3m | elinks | links | lynx | dillo | open | start)\n \t\t;; # happy\n \t*)\n \t\tvalid_custom_tool \"$1\" || return 1\n@@ -104,12 +104,12 @@ fi\n \n if test -z \"$browser\" ; then\n \tif test -n \"$DISPLAY\"; then\n-\t\tbrowser_candidates=\"firefox iceweasel google-chrome chrome chromium konqueror w3m links lynx dillo\"\n+\t\tbrowser_candidates=\"firefox iceweasel google-chrome chrome chromium konqueror opera seamonkey iceape w3m elinks links lynx dillo\"\n \t\tif test \"$KDE_FULL_SESSION\" = \"true\"; then\n \t\t\tbrowser_candidates=\"konqueror $browser_candidates\"\n \t\tfi\n \telse\n-\t\tbrowser_candidates=\"w3m links lynx\"\n+\t\tbrowser_candidates=\"w3m elinks links lynx\"\n \tfi\n \t# SECURITYSESSIONID indicates an OS X GUI login session\n \tif test -n \"$SECURITYSESSIONID\" \\\n@@ -140,7 +140,7 @@ else\n fi\n \n case \"$browser\" in\n-firefox|iceweasel)\n+firefox|iceweasel|seamonkey|iceape)\n \t# Check version because firefox < 2.0 does not support \"-new-tab\".\n \tvers=$(expr \"$($browser_path -version)\" : '.* \\([0-9][0-9]*\\)\\..*')\n \tNEWTAB='-new-tab'\n@@ -168,13 +168,13 @@ konqueror)\n \t\t;;\n \tesac\n \t;;\n-w3m|links|lynx|open)\n+w3m|elinks|links|lynx|open)\n \teval \"$browser_path\" \"$@\"\n \t;;\n start)\n \texec \"$browser_path\" '\"web-browse\"' \"$@\"\n \t;;\n-dillo)\n+opera|dillo)\n \t\"$browser_path\" \"$@\" &\n \t;;\n *)\n-- \n1.7.3.2.664.g294b8.dirty\n"},{"id":"157414","messageId":"1291657790-3719-5-git-send-email-giuseppe.bilotta@gmail.com","threadId":"25974","inReplyTo":"1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 4/6] web--browse: better support for chromium","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-06T17:49:48Z","receivedAt":"2010-12-06T17:49:48Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Debian-based distributions, Chromium the browser is available under\nthe name chromium-browser rather than chromium, to prevent conflicts\nwith the Chromium B.S.U. game.\n\nLook for chromium-browser first when setting the path for chromium, and\nalso add chromium-browser as a supported browser name. Document the\ndual-name support, and mention the dual-name support for\n(google-)chrome too.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n Documentation/git-web--browse.txt |    4 ++--\n git-web--browse.sh                |   12 ++++++++----\n 2 files changed, 10 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt\nindex 5d3ae07..c0416e5 100644\n--- a/Documentation/git-web--browse.txt\n+++ b/Documentation/git-web--browse.txt\n@@ -22,8 +22,8 @@ The following browsers (or commands) are currently supported:\n * iceweasel\n * seamonkey\n * iceape\n-* chromium\n-* google-chrome\n+* chromium (also supported as chromium-browser)\n+* google-chrome (also supported as chrome)\n * konqueror (this is the default under KDE, see 'Note about konqueror' below)\n * opera\n * w3m (this is the default outside graphical environments)\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\nindex 48e5a28..b2fc3b4 100755\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -31,7 +31,8 @@ valid_custom_tool()\n \n valid_tool() {\n \tcase \"$1\" in\n-\tfirefox | iceweasel | seamonkey | iceape | chrome | google-chrome | chromium |\\\n+\tfirefox | iceweasel | seamonkey | iceape |\\\n+\tchrome | google-chrome | chromium | chromium-browser |\\\n \tkonqueror | opera | w3m | elinks | links | lynx | dillo | open | start)\n \t\t;; # happy\n \t*)\n@@ -42,6 +43,10 @@ valid_tool() {\n \n init_browser_path() {\n \tbrowser_path=$(git config \"browser.$1.path\")\n+\tif test -z \"$browser_path\" -a \"$1\" = chromium &&\n+\t   type chromium-browser > /dev/null 2>&1 ; then\n+\t\tbrowser_path=chromium-browser\n+\tfi\n \ttest -z \"$browser_path\" && browser_path=\"$1\"\n }\n \n@@ -104,7 +109,7 @@ fi\n \n if test -z \"$browser\" ; then\n \tif test -n \"$DISPLAY\"; then\n-\t\tbrowser_candidates=\"firefox iceweasel google-chrome chrome chromium konqueror opera seamonkey iceape w3m elinks links lynx dillo\"\n+\t\tbrowser_candidates=\"firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo\"\n \t\tif test \"$KDE_FULL_SESSION\" = \"true\"; then\n \t\t\tbrowser_candidates=\"konqueror $browser_candidates\"\n \t\tfi\n@@ -147,8 +152,7 @@ firefox|iceweasel|seamonkey|iceape)\n \ttest \"$vers\" -lt 2 && NEWTAB=''\n \t\"$browser_path\" $NEWTAB \"$@\" &\n \t;;\n-google-chrome|chrome|chromium)\n-\t# Actual command for chromium is chromium-browser.\n+google-chrome|chrome|chromium|chromium-browser)\n \t# No need to specify newTab. It's default in chromium\n \teval \"$browser_path\" \"$@\" &\n \t;;\n-- \n1.7.3.2.664.g294b8.dirty\n"},{"id":"157415","messageId":"1291657790-3719-6-git-send-email-giuseppe.bilotta@gmail.com","threadId":"25974","inReplyTo":"1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 5/6] web--browse: use *www-browser if available","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-06T17:49:49Z","receivedAt":"2010-12-06T17:49:49Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Debian and derivatives have an alternatives-based default browser\nconfiguration that uses the /usr/bin/gnome-www-browser,\n/usr/bin/x-www-browser and /usr/bin/www-browser symlinks.\n\nWhen no browser is selected by the user and the Debian alternatives are\navailable, try to see if they are one of our recognized selection and\nin the affermative case use it. Otherwise, warn the user about them\nbeing unsupported and move on with the previous detection logic.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n Documentation/git-web--browse.txt |    4 ++\n git-web--browse.sh                |   84 +++++++++++++++++++++++++++++++++++-\n 2 files changed, 85 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt\nindex c0416e5..157738a 100644\n--- a/Documentation/git-web--browse.txt\n+++ b/Documentation/git-web--browse.txt\n@@ -36,6 +36,10 @@ The following browsers (or commands) are currently supported:\n \n Custom commands may also be specified.\n \n+If no default browser is specified, and /usr/bin/gnome-www-browser\n+(under GNOME), /usr/bin/x-www-browser (under X) or /usr/bin/www-browser\n+is present, they are used to determine the browser to use.\n+\n OPTIONS\n -------\n -b <browser>::\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\nindex b2fc3b4..b496b6c 100755\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -50,6 +50,63 @@ init_browser_path() {\n \ttest -z \"$browser_path\" && browser_path=\"$1\"\n }\n \n+# check if a given executable is a browser we like\n+valid_browser_executable() {\n+\ttestexe=\"$1\"\n+\n+\t# check the executable name first, trying to follow symlinks if possible\n+\tif type readlink > /dev/null 2>&1 ; then\n+\t\tbasename=\"$(basename $(readlink -f \"$testexe\"))\"\n+\telse\n+\t\tbasename=\"$(basename \"$testexe\")\"\n+\tfi\n+\tif valid_tool \"$basename\" ; then\n+\t\tbrowser=\"$basename\"\n+\t\tbrowser_path=\"$testexe\"\n+\t\treturn 0\n+\tfi\n+\n+\t# if the linked executable doesn't match a browser name we know about,\n+\t# look at the version string\n+\n+\t# even though most browsers (and applications, in fact) will show their\n+\t# name and version on the first line of the --version output, this is\n+\t# not true in particular for the KDE apps (e.g. konqueror and kfmclient),\n+\t# which display their name and version on the LAST line. So we cannot\n+\t# clip the version string at the first line when retrieving it. Rather,\n+\t# we keep it whole and then limit it when we know what we're dealing with.\n+\n+\tverstring=\"$(\"$testexe\" --version 2> /dev/null)\"\n+\tbrowser=\"$(echo \"$verstring\" | head -n 1 | cut -f1 -d' ' | tr A-Z a-z)\"\n+\tcase \"$browser\" in\n+\t\tmozilla)\n+\t\t\tverstring=\"$(echo \"$verstring\" | head -n 1)\"\n+\t\t\tbrowser=\"$(echo \"$verstring\" | cut -f2 -d' ' | tr A-Z a-z)\"\n+\t\t\t;;\n+\t\tgoogle)\n+\t\t\tverstring=\"$(echo \"$verstring\" | head -n 1)\"\n+\t\t\tbrowser=\"google-chrome\"\n+\t\t\t;;\n+\t\tqt:)\n+\t\t\t# konqueror, kfmclient or other KDE app\n+\t\t\tverstring=\"$(echo \"$verstring\" | tail -n 1)\"\n+\t\t\tbrowser=\"$(echo \"$verstring\" | cut -f1 -d:)\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\tverstring=\"$(echo \"$verstring\" | head -n 1)\"\n+\t\t\t;;\n+\n+\tesac\n+\tif valid_tool \"$browser\" ; then\n+\t\tbrowser_path=\"$i\"\n+\t\treturn 0\n+\tfi\n+\n+\techo >&2 \"$testexe (detected as $browser) is not a supported browser, skipping\"\n+\tbrowser=\"\"\n+\treturn 1\n+}\n+\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -107,6 +164,26 @@ then\n \tfi\n fi\n \n+# Debian and derivatives use gnome-www-browser, x-www-browser or www-browser to\n+# set the default browser for the system. If the user did not specify a tool and\n+# we detect that one of the *www-browser links to a supported one, we pick it.\n+# Otherwise, we warn the user about them being unsupported and proceed to look\n+# for a supported browser.\n+if test -z \"$browser\" ; then\n+\twwwbrowser=\"/usr/bin/www-browser\"\n+\tif test -n \"$DISPLAY\"; then\n+\t\twwwbrowser=\"/usr/bin/x-www-browser $wwwbrowser\"\n+\t\tif test -n \"$GNOME_DESKTOP_SESSION_ID\"; then\n+\t\t\twwwbrowser=\"/usr/bin/gnome-www-browser $wwwbrowser\"\n+\t\tfi\n+\tfi\n+\tfor i in $wwwbrowser; do\n+\t\tif test -x $i && valid_browser_executable $i ; then\n+\t\t\tbreak\n+\t\tfi\n+\tdone\n+fi\n+\n if test -z \"$browser\" ; then\n \tif test -n \"$DISPLAY\"; then\n \t\tbrowser_candidates=\"firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo\"\n@@ -134,7 +211,7 @@ if test -z \"$browser\" ; then\n \t\tfi\n \tdone\n \ttest -z \"$browser\" && die \"No known browser available.\"\n-else\n+else if test -z \"$browser_path\"; then\n \tvalid_tool \"$browser\" || die \"Unknown browser '$browser'.\"\n \n \tinit_browser_path \"$browser\"\n@@ -142,12 +219,13 @@ else\n \tif test -z \"$browser_cmd\" && ! type \"$browser_path\" > /dev/null 2>&1; then\n \t\tdie \"The browser $browser is not available as '$browser_path'.\"\n \tfi\n-fi\n+fi fi\n \n case \"$browser\" in\n firefox|iceweasel|seamonkey|iceape)\n \t# Check version because firefox < 2.0 does not support \"-new-tab\".\n-\tvers=$(expr \"$($browser_path -version)\" : '.* \\([0-9][0-9]*\\)\\..*')\n+\ttest -z \"$verstring\" && verstring=\"$($browser_path -version)\"\n+\tvers=$(expr \"$verstring\" : '.* \\([0-9][0-9]*\\)\\..*')\n \tNEWTAB='-new-tab'\n \ttest \"$vers\" -lt 2 && NEWTAB=''\n \t\"$browser_path\" $NEWTAB \"$@\" &\n-- \n1.7.3.2.664.g294b8.dirty\n"},{"id":"157417","messageId":"1291657790-3719-7-git-send-email-giuseppe.bilotta@gmail.com","threadId":"25974","inReplyTo":"1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 6/6] web--browse: look at the BROWSER env var","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-06T17:49:50Z","receivedAt":"2010-12-06T17:49:50Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"The BROWSER environment variables is used in Debian-based systems to set\nthe user-preferred browser(s).\n\nIt contains a colon-separate list of commands to (try to) execute\nto open a web page. Each item in the list is allowed to have a %s\nplaceholder to be replaced by the URL, in which case we try to run the\ncommand as is. If no placeholder is found, we only look at the command\nname to see if it matches one of our known browsers.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n git-web--browse.sh |   45 +++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 45 insertions(+), 0 deletions(-)\n\ndiff --git a/git-web--browse.sh b/git-web--browse.sh\nindex b496b6c..da36ca4 100755\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -164,6 +164,51 @@ then\n \tfi\n fi\n \n+# Debian and derivatives provide a sensible-brower script that tries to\n+# invoke the user or system preferred browser most appropriate for the\n+# current situation (X or no X, GNOME or other/no DE).\n+# We do not use the sensible-browser script directly since it doesn't\n+# allow us to open pages in a new tab, but we can use the underlying\n+# infrastructure to find the browser to use if the user didn't choose\n+# one. This is done by looking at the BROWSER environment variable\n+# first, and at the *www-browser links if the first search is\n+# unsuccesful.\n+\n+# The BROWSER environment variable is a colon-separate list of commands\n+# to (try and) execute to launch the browser. sensible-browser allows\n+# each BROWSER entry to contain a %s placeholder that will be replaced\n+# by the URL to be opened.\n+# If an entry contains a %s we run it as-is, without doing any detection, on\n+# the premise that it represents the exact way the user expects the browser to\n+# be called. If the execution fails, we do not bail out, since the\n+# failure might be due to the entry being for a graphical browser and\n+# the GUI not being available, which is the reason why multiple entries\n+# can be specified in BROWSER in the first place.\n+# An entry without a %s is only taken as indication of the preferred\n+# browser, so we proceed with our usual detection logic.\n+if test -z \"$browser\" -a -n \"$BROWSER\"; then\n+\tOLDIFS=\"$IFS\"\n+\tIFS=:\n+\tfor i in $BROWSER; do\n+\t\tcase \"$i\" in\n+\t\t\t*sensible-browser*)\n+\t\t\t\t;; # skip\n+\t\t\t*%s*)\n+\t\t\t\tIFS=\"$OLDIFS\"\n+\t\t\t\tcmd=$(printf \"$i\\n\" \"$*\")\n+\t\t\t\t$cmd && exit 0\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tprog=$(which \"$i\" 2> /dev/null)\n+\t\t\t\tif test -n \"$prog\" -a -x \"$prog\" && valid_browser_executable \"$prog\" ; then\n+\t\t\t\t\tbreak\n+\t\t\t\tfi\n+\t\t\t\t;;\n+\t\tesac\n+\tdone\n+\tIFS=\"$OLDIFS\"\n+fi\n+\n # Debian and derivatives use gnome-www-browser, x-www-browser or www-browser to\n # set the default browser for the system. If the user did not specify a tool and\n # we detect that one of the *www-browser links to a supported one, we pick it.\n-- \n1.7.3.2.664.g294b8.dirty\n"},{"id":"157420","messageId":"20101206175914.GD6272@burratino","threadId":"25974","inReplyTo":"1291657790-3719-7-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCHv3 6/6] web--browse: look at the BROWSER env var","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-12-06T17:59:14Z","receivedAt":"2010-12-06T17:59:14Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Giuseppe Bilotta wrote:\n\n> The BROWSER environment variables is used in Debian-based systems to set\n> the user-preferred browser(s).\n\nI _thought_ BROWSER was not Debian-specific, but I cannot find any\nevidence of that online.  See:\n\n http://www.catb.org/~esr/BROWSER/\n http://www.dwheeler.com/browse/secure_browser.html\n\nAt least xdg-open implements a variant on it, and I had assumed\napps preceding xdg-utils did, too.\n"},{"id":"157421","messageId":"AANLkTikEzh2HJEKq-pF8-kfzrjHg4wJcMx3ChP8vEgg9@mail.gmail.com","threadId":"25974","inReplyTo":"20101206175914.GD6272@burratino","subject":"Re: [PATCHv3 6/6] web--browse: look at the BROWSER env var","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-06T18:28:17Z","receivedAt":"2010-12-06T18:28:17Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Mon, Dec 6, 2010 at 6:59 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Giuseppe Bilotta wrote:\n>\n>> The BROWSER environment variables is used in Debian-based systems to set\n>> the user-preferred browser(s).\n>\n> I _thought_ BROWSER was not Debian-specific, but I cannot find any\n> evidence of that online.  See:\n>\n>  http://www.catb.org/~esr/BROWSER/\n>  http://www.dwheeler.com/browse/secure_browser.html\n>\n> At least xdg-open implements a variant on it, and I had assumed\n> apps preceding xdg-utils did, too.\n\nIIRC, RedHat's sensible-browser equivalent, htmlview, used to use\nBROWSER. The package is now obsolete, though, and I'm not even sure it\nused BROWSER at all in its latest incarnations.\n\nxdg-open _does_ use BROWSER though. So maybe I should clear the\nDebian-specificity of this patch.\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"},{"id":"157554","messageId":"7vaakhnok7.fsf@alter.siamese.dyndns.org","threadId":"25974","inReplyTo":"1291657790-3719-6-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCHv3 5/6] web--browse: use *www-browser if available","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-07T23:36:08Z","receivedAt":"2010-12-07T23:36:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:\n\n> +\t# if the linked executable doesn't match a browser name we know about,\n> +\t# look at the version string\n> +\n> +\t# even though most browsers (and applications, in fact) will show their\n> +\t# name and version on the first line of the --version output, this is\n> +\t# not true in particular for the KDE apps (e.g. konqueror and kfmclient),\n> +\t# which display their name and version on the LAST line. So we cannot\n> +\t# clip the version string at the first line when retrieving it. Rather,\n> +\t# we keep it whole and then limit it when we know what we're dealing with.\n\nI'd be more worried about the ones that do not understand --version and\nspawn a new window.\n\n> +\tverstring=\"$(\"$testexe\" --version 2> /dev/null)\"\n> +\tbrowser=\"$(echo \"$verstring\" | head -n 1 | cut -f1 -d' ' | tr A-Z a-z)\"\n> +\tcase \"$browser\" in\n> +\t\tmozilla)\n\nWhat was the first patch in this series about again ;-)?\n\n> +\t\t\tverstring=\"$(echo \"$verstring\" | head -n 1)\"\n> +\t\t\tbrowser=\"$(echo \"$verstring\" | cut -f2 -d' ' | tr A-Z a-z)\"\n> +\t\t\t;;\n> +\t\tgoogle)\n> +\t\t\tverstring=\"$(echo \"$verstring\" | head -n 1)\"\n> +\t\t\tbrowser=\"google-chrome\"\n> +\t\t\t;;\n> +\t\tqt:)\n> +\t\t\t# konqueror, kfmclient or other KDE app\n> +\t\t\tverstring=\"$(echo \"$verstring\" | tail -n 1)\"\n> +\t\t\tbrowser=\"$(echo \"$verstring\" | cut -f1 -d:)\"\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\tverstring=\"$(echo \"$verstring\" | head -n 1)\"\n> +\t\t\t;;\n> +\n> +\tesac\n> +\tif valid_tool \"$browser\" ; then\n> +\t\tbrowser_path=\"$i\"\n> +\t\treturn 0\n> +\tfi\n> +\n> +\techo >&2 \"$testexe (detected as $browser) is not a supported browser, skipping\"\n> +\tbrowser=\"\"\n> +\treturn 1\n> +}\n\nSorry, but I simply do not think it is worth this ugliness to get slight\ncustomization between -new-tab, newTab, and nothingness.\n"},{"id":"157556","messageId":"7vy681m9w5.fsf@alter.siamese.dyndns.org","threadId":"25974","inReplyTo":"1291657790-3719-5-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCHv3 4/6] web--browse: better support for chromium","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-07T23:38:18Z","receivedAt":"2010-12-07T23:38:18Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Up to this point of the series, I think v3 is a regression compared to\nwhat is queued on 'pu'.\n"},{"id":"157579","messageId":"AANLkTinhRUTy6pSiPZnkpj-pSA57VodFVCALfxe8UCH8@mail.gmail.com","threadId":"25974","inReplyTo":"7vy681m9w5.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 4/6] web--browse: better support for chromium","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-08T07:21:08Z","receivedAt":"2010-12-08T07:21:08Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Wed, Dec 8, 2010 at 12:38 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Up to this point of the series, I think v3 is a regression compared to\n> what is queued on 'pu'.\n\nOuch. Including or excluding this one? (Unless I did a mistake, the\nonly difference here was the merging of the conditionals when\npath-checking chromium)\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"},{"id":"157580","messageId":"AANLkTimP+yLLH+arKeg-VHZ4OH5_JgKmdv90j3wGTVUk@mail.gmail.com","threadId":"25974","inReplyTo":"7vaakhnok7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 5/6] web--browse: use *www-browser if available","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2010-12-08T07:38:11Z","receivedAt":"2010-12-08T07:38:11Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Wed, Dec 8, 2010 at 12:36 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:\n>\n>> +     # if the linked executable doesn't match a browser name we know about,\n>> +     # look at the version string\n>> +\n>> +     # even though most browsers (and applications, in fact) will show their\n>> +     # name and version on the first line of the --version output, this is\n>> +     # not true in particular for the KDE apps (e.g. konqueror and kfmclient),\n>> +     # which display their name and version on the LAST line. So we cannot\n>> +     # clip the version string at the first line when retrieving it. Rather,\n>> +     # we keep it whole and then limit it when we know what we're dealing with.\n>\n> I'd be more worried about the ones that do not understand --version and\n> spawn a new window.\n\nThat's indeed a potential issue (although I _do_ wonder if there are\nbrowsers that act like that; the only one I couldn't try, on Linux,\nwas dillo).\n\n>> +     verstring=\"$(\"$testexe\" --version 2> /dev/null)\"\n>> +     browser=\"$(echo \"$verstring\" | head -n 1 | cut -f1 -d' ' | tr A-Z a-z)\"\n>> +     case \"$browser\" in\n>> +             mozilla)\n>\n> What was the first patch in this series about again ;-)?\n\nOh my! LOL. Ok, I can fix that 8-D\n\n>> +                     verstring=\"$(echo \"$verstring\" | head -n 1)\"\n>> +                     browser=\"$(echo \"$verstring\" | cut -f2 -d' ' | tr A-Z a-z)\"\n>> +                     ;;\n>> +             google)\n>> +                     verstring=\"$(echo \"$verstring\" | head -n 1)\"\n>> +                     browser=\"google-chrome\"\n>> +                     ;;\n>> +             qt:)\n>> +                     # konqueror, kfmclient or other KDE app\n>> +                     verstring=\"$(echo \"$verstring\" | tail -n 1)\"\n>> +                     browser=\"$(echo \"$verstring\" | cut -f1 -d:)\"\n>> +                     ;;\n>> +             *)\n>> +                     verstring=\"$(echo \"$verstring\" | head -n 1)\"\n>> +                     ;;\n>> +\n>> +     esac\n>> +     if valid_tool \"$browser\" ; then\n>> +             browser_path=\"$i\"\n>> +             return 0\n>> +     fi\n>> +\n>> +     echo >&2 \"$testexe (detected as $browser) is not a supported browser, skipping\"\n>> +     browser=\"\"\n>> +     return 1\n>> +}\n>\n> Sorry, but I simply do not think it is worth this ugliness to get slight\n> customization between -new-tab, newTab, and nothingness.\n\nI personally don't have a particular feeling for forcing the opening\nin a new tab (and I might have over-engineered it, although it's not\nreally much more complex than the previous versions of this patchset,\nit's just refactored.\n\nIf this requirement is relaxed, the patch becomes much simpler, and we\ncan include direct support for xdg-open, sensible-browser, htlmview &\nso forth.\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"}]}