git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] web--browse: Use powershell on Windows
@ 2014-02-16  7:22 Steven Penny
  2014-02-16 16:07 ` Eric Sunshine
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Penny @ 2014-02-16  7:22 UTC (permalink / raw)
  To: git; +Cc: Steven Penny

On Windows you can have either MinGW or Cygwin. As has been shown in this script
MinGW uses "start" while Cygwin uses "cygstart". The "cygstart" command is
robust but the "start" command breaks on certain URLs

    $ git web--browse 'http://wikipedia.org/wiki/Key_&_Peele'
    '_Peele' is not recognized as an internal or external command,
    operable program or batch file.

An alternative is to use PowerShell. PowerShell is a component of Windows and
will work with both MinGW and Cygwin.

Signed-off-by: Steven Penny <svnpenn@gmail.com>
---
 Documentation/git-web--browse.txt |  3 +--
 git-web--browse.sh                | 19 ++++++++-----------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index 2de575f..02cccf9 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -33,8 +33,7 @@ The following browsers (or commands) are currently supported:
 * lynx
 * dillo
 * open (this is the default under Mac OS X GUI)
-* start (this is the default under MinGW)
-* cygstart (this is the default under Cygwin)
+* powershell (this is the default under Windows)
 * xdg-open
 
 Custom commands may also be specified.
diff --git a/git-web--browse.sh b/git-web--browse.sh
index ebdfba6..72fbe32 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -34,7 +34,7 @@ valid_tool() {
 	firefox | iceweasel | seamonkey | iceape | \
 	chrome | google-chrome | chromium | chromium-browser | \
 	konqueror | opera | w3m | elinks | links | lynx | dillo | open | \
-	start | cygstart | xdg-open)
+	powershell | xdg-open)
 		;; # happy
 	*)
 		valid_custom_tool "$1" || return 1
@@ -124,13 +124,10 @@ if test -z "$browser" ; then
 	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"
+	# OS indicates Windows
+	if test -n "$OS"
+	then
+		browser_candidates="powershell $browser_candidates"
 	fi
 
 	for i in $browser_candidates; do
@@ -179,11 +176,11 @@ konqueror)
 		;;
 	esac
 	;;
-w3m|elinks|links|lynx|open|cygstart|xdg-open)
+w3m|elinks|links|lynx|open|xdg-open)
 	"$browser_path" "$@"
 	;;
-start)
-	exec "$browser_path" '"web-browse"' "$@"
+powershell)
+	"$browser_path" saps "'$@'"
 	;;
 opera|dillo)
 	"$browser_path" "$@" &
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] web--browse: Use powershell on Windows
  2014-02-16  7:22 [PATCH] web--browse: Use powershell on Windows Steven Penny
@ 2014-02-16 16:07 ` Eric Sunshine
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Sunshine @ 2014-02-16 16:07 UTC (permalink / raw)
  To: Steven Penny; +Cc: Git List

On Sun, Feb 16, 2014 at 2:22 AM, Steven Penny <svnpenn@gmail.com> wrote:
> On Windows you can have either MinGW or Cygwin. As has been shown in this script
> MinGW uses "start" while Cygwin uses "cygstart". The "cygstart" command is
> robust but the "start" command breaks on certain URLs
>
>     $ git web--browse 'http://wikipedia.org/wiki/Key_&_Peele'
>     '_Peele' is not recognized as an internal or external command,
>     operable program or batch file.
>
> An alternative is to use PowerShell. PowerShell is a component of Windows and
> will work with both MinGW and Cygwin.
>
> Signed-off-by: Steven Penny <svnpenn@gmail.com>
> ---
> diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
> index 2de575f..02cccf9 100644
> --- a/Documentation/git-web--browse.txt
> +++ b/Documentation/git-web--browse.txt
> @@ -33,8 +33,7 @@ The following browsers (or commands) are currently supported:
>  * lynx
>  * dillo
>  * open (this is the default under Mac OS X GUI)
> -* start (this is the default under MinGW)
> -* cygstart (this is the default under Cygwin)
> +* powershell (this is the default under Windows)
>  * xdg-open
>
>  Custom commands may also be specified.
> diff --git a/git-web--browse.sh b/git-web--browse.sh
> index ebdfba6..72fbe32 100755
> --- a/git-web--browse.sh
> +++ b/git-web--browse.sh
> @@ -34,7 +34,7 @@ valid_tool() {
>         firefox | iceweasel | seamonkey | iceape | \
>         chrome | google-chrome | chromium | chromium-browser | \
>         konqueror | opera | w3m | elinks | links | lynx | dillo | open | \
> -       start | cygstart | xdg-open)
> +       powershell | xdg-open)
>                 ;; # happy
>         *)
>                 valid_custom_tool "$1" || return 1
> @@ -124,13 +124,10 @@ if test -z "$browser" ; then
>         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"
> +       # OS indicates Windows
> +       if test -n "$OS"
> +       then
> +               browser_candidates="powershell $browser_candidates"
>         fi

Doesn't this penalize users who don't have powershell installed?

>         for i in $browser_candidates; do
> @@ -179,11 +176,11 @@ konqueror)
>                 ;;
>         esac
>         ;;
> -w3m|elinks|links|lynx|open|cygstart|xdg-open)
> +w3m|elinks|links|lynx|open|xdg-open)
>         "$browser_path" "$@"
>         ;;
> -start)
> -       exec "$browser_path" '"web-browse"' "$@"
> +powershell)
> +       "$browser_path" saps "'$@'"
>         ;;
>  opera|dillo)
>         "$browser_path" "$@" &
> --
> 1.8.5.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-16 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-16  7:22 [PATCH] web--browse: Use powershell on Windows Steven Penny
2014-02-16 16:07 ` Eric Sunshine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).