From 0a79f1e836d6096ec67deabca8105f60b124cbbe Mon Sep 17 00:00:00 2001 From: Mark Ingalls Date: Mon, 9 Nov 2015 14:34:47 -0700 Subject: [PATCH 1/3] make this work in the git-for-windows SDK Added an option for the msys value of $OSTYPE --- lib/functions.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/functions.zsh b/lib/functions.zsh index ec6f37214..1623df2bd 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -23,6 +23,7 @@ function open_command() { darwin*) open_cmd="open" ;; cygwin*) open_cmd="cygstart" ;; linux*) open_cmd="xdg-open" ;; + msys*) open_cmd="start" ;; *) echo "Platform $OSTYPE not supported" return 1 ;; From afdfe2391eeab13f2480a88514af895ce660d30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 30 Nov 2015 21:08:40 +0100 Subject: [PATCH 2/3] Add empty string parameter to start command Otherwise `start` will confuse the first parameter as the title of a new command prompt if the parameter contains whitespace. That is because the command to be run will be: start "abc def" which opens a new command prompt window with the title "abc def". With the added empty string we force the start command to interpret the passed parameter as the file / command: start "" "abc def" which will be interpreted like `""` is the title and the rest is the file or command to start. ------- **NOTE:** this wouldn't be necessary if the start script in msys was defined differently; that is, if it had the empty string already incorporated in the script (/usr/bin/start), like so: ```diff -cmd //c start "${@//&/^&}" +cmd //c start "" "${@//&/^&}" ``` Notice however that this would make it impossible to use start setting a different title, so it's probably best to leave it as is. More info: http://sourceforge.net/p/msys2/tickets/14/ ------- The change `${(z)open_cmd}` is necessary to force zsh to split the variable by the spaces and interpret it as separate words. More info: http://zsh.sourceforge.net/FAQ/zshfaq03.html#l17 --- lib/functions.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 1623df2bd..bbdbea5cb 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -23,7 +23,7 @@ function open_command() { darwin*) open_cmd="open" ;; cygwin*) open_cmd="cygstart" ;; linux*) open_cmd="xdg-open" ;; - msys*) open_cmd="start" ;; + msys*) open_cmd="start \"\"" ;; *) echo "Platform $OSTYPE not supported" return 1 ;; @@ -33,7 +33,7 @@ function open_command() { if [[ "$OSTYPE" == darwin* ]]; then $open_cmd "$@" &>/dev/null else - nohup $open_cmd "$@" &>/dev/null + nohup ${(z)open_cmd} "$@" &>/dev/null fi } From 584e0a6ef9ade95cf68dab4f2026d2bd5954fe33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 30 Nov 2015 21:18:27 +0100 Subject: [PATCH 3/3] Use shwordsplit in open_command() --- lib/functions.zsh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index bbdbea5cb..f9d4a9717 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -16,14 +16,17 @@ function take() { } function open_command() { + emulate -L zsh + setopt shwordsplit + local open_cmd # define the open command case "$OSTYPE" in - darwin*) open_cmd="open" ;; - cygwin*) open_cmd="cygstart" ;; - linux*) open_cmd="xdg-open" ;; - msys*) open_cmd="start \"\"" ;; + darwin*) open_cmd='open' ;; + cygwin*) open_cmd='cygstart' ;; + linux*) open_cmd='xdg-open' ;; + msys*) open_cmd='start ""' ;; *) echo "Platform $OSTYPE not supported" return 1 ;; @@ -33,7 +36,7 @@ function open_command() { if [[ "$OSTYPE" == darwin* ]]; then $open_cmd "$@" &>/dev/null else - nohup ${(z)open_cmd} "$@" &>/dev/null + nohup $open_cmd "$@" &>/dev/null fi }