1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-24 05:11:58 +00:00

open_command: fix and improve command for WSL

- Add double quotes to command so that the next argument isn't
  interpreted as the title for the start command.

- If the first argument is a valid path, convert it to Windows path
  notation. If `wslpath` fails—because it's a path from inside WSL,
  which cannot be converted to Windows path notation— fail with an
  error code.

  This last circumstance will show an error like so:

    wslpath: path: Result not representable
This commit is contained in:
Marc Cornellà 2018-06-29 20:20:56 +02:00
parent 12086593a4
commit f898ada8e3

View file

@ -22,9 +22,10 @@ function open_command() {
case "$OSTYPE" in
darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;;
linux*) [[ $(uname -a) =~ "Microsoft" ]] && \
open_cmd='cmd.exe /c start' || \
open_cmd='xdg-open' ;;
linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || {
open_cmd='cmd.exe /c start ""'
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
} ;;
msys*) open_cmd='start ""' ;;
*) echo "Platform $OSTYPE not supported"
return 1