Skip to content

Commit

Permalink
Add empty string parameter to start command
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mcornella committed Nov 30, 2015
1 parent 0a79f1e commit afdfe23
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/functions.zsh
Expand Up @@ -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
;;
Expand All @@ -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
}

Expand Down

0 comments on commit afdfe23

Please sign in to comment.