Merge branch 'bc/blame-crlf-test'
[gitweb.git] / git-web--browse.sh
index 1e827264b4cab04a801804b8d066f9d2cbb85edc..ae152534f5026d50fa32b568d1bdd591629bc59d 100755 (executable)
@@ -32,8 +32,9 @@ valid_custom_tool()
 valid_tool() {
        case "$1" in
        firefox | iceweasel | seamonkey | iceape | \
-       chrome | google-chrome | chromium | chromium-browser |\
-       konqueror | opera | w3m | elinks | links | lynx | dillo | open | start)
+       chrome | google-chrome | chromium | chromium-browser | \
+       konqueror | opera | w3m | elinks | links | lynx | dillo | open | \
+       start | cygstart | xdg-open)
                ;; # happy
        *)
                valid_custom_tool "$1" || return 1
@@ -58,7 +59,7 @@ do
        -b|--browser*|-t|--tool*)
                case "$#,$1" in
                *,*=*)
-                       browser=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+                       browser=$(expr "z$1" : 'z-[^=]*=\(.*\)')
                        ;;
                1,*)
                        usage ;;
@@ -70,7 +71,7 @@ do
        -c|--config*)
                case "$#,$1" in
                *,*=*)
-                       conf=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+                       conf=$(expr "z$1" : 'z-[^=]*=\(.*\)')
                        ;;
                1,*)
                        usage ;;
@@ -99,7 +100,7 @@ then
        for opt in "$conf" "web.browser"
        do
                test -z "$opt" && continue
-               browser="`git config $opt`"
+               browser="$(git config $opt)"
                test -z "$browser" || break
        done
        if test -n "$browser" && ! valid_tool "$browser"; then
@@ -111,7 +112,7 @@ fi
 
 if test -z "$browser" ; then
        if test -n "$DISPLAY"; then
-               browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo"
+               browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo xdg-open"
                if test "$KDE_FULL_SESSION" = "true"; then
                        browser_candidates="konqueror $browser_candidates"
                fi
@@ -119,14 +120,18 @@ if test -z "$browser" ; then
                browser_candidates="w3m elinks links lynx"
        fi
        # SECURITYSESSIONID indicates an OS X GUI login session
-       if test -n "$SECURITYSESSIONID" \
-               -o "$TERM_PROGRAM" = "Apple_Terminal" ; then
+       if test -n "$SECURITYSESSIONID" || test -n "$TERM_PROGRAM"
+       then
                browser_candidates="open $browser_candidates"
        fi
        # /bin/start indicates MinGW
        if test -x /bin/start; then
                browser_candidates="start $browser_candidates"
        fi
+       # /usr/bin/cygstart indicates Cygwin
+       if test -x /usr/bin/cygstart; then
+               browser_candidates="cygstart $browser_candidates"
+       fi
 
        for i in $browser_candidates; do
                init_browser_path $i
@@ -174,7 +179,7 @@ konqueror)
                ;;
        esac
        ;;
-w3m|elinks|links|lynx|open)
+w3m|elinks|links|lynx|open|cygstart|xdg-open)
        "$browser_path" "$@"
        ;;
 start)