Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call help using msys2 #7113

Closed
malobre opened this issue Jun 13, 2020 · 6 comments
Closed

Cannot call help using msys2 #7113

malobre opened this issue Jun 13, 2020 · 6 comments

Comments

@malobre
Copy link
Contributor

malobre commented Jun 13, 2020

fish version 3.1.2

Msys2 has the cygpath command but no cygstart.

This result in cygpath not being called:

# For Windows (Cygwin and WSL), we need to convert the base help dir to a Windows path before converting it to a file URL
# but only if a Windows browser is being used
if type -q cygpath
and string match -qr cygstart $fish_browser[1]
set page_url file://(cygpath -m $__fish_help_dir)/$fish_help_page

When no browser are set and since it doesn't find cygstart it defaults to cmd.exe however because cygpath is not called the path is wrong which make this : /c/Windows/System32/cmd.exe /c 'start file:///usr/share/doc/fish/index.html' fail.

Instead of exiting with an error it then returns to cmd, typing exit will return to fish:

image

From my understanding this could be resolved by changing the code quoted above to this:

        if type -q cygpath
            and string match -qr 'cygstart|.*cmd\.exe' $fish_browser[1]
            set page_url file://(cygpath -m $__fish_help_dir)/$fish_help_page

I can submit a push request if needed.

Edit: I updated the regex from cygstart|cmd\.exe to cygstart|.*cmd\.exe

@malobre
Copy link
Contributor Author

malobre commented Jun 13, 2020

I found why it doesn't return to fish.

Msys2 convert this:
/c/Windows/System32/cmd.exe /c 'start file:///usr/share/doc/fish/index.html'
to this:
C:/Windows/System32/cmd.exe C:/ 'start file:///usr/share/doc/fish/index.html'

This behavior is documented here.

To prevent this from happening, this:

$fish_browser /c "start $page_url"

could be changed to:

        $fish_browser " /c" "start $page_url"

@zanchey
Copy link
Member

zanchey commented Jun 17, 2020

That's wild.

Does that change actually help? I don't have MSYS2 installed, just the Git for Windows Bash, but when testing with /c/Windows/system32/cmd.exe " /c" "start notepad.exe" I get an error complaining about the quoting. Dropping the quotes around the second argument helps but I'm not sure how that works on other platforms.

@zanchey zanchey added this to the fish-future milestone Jun 17, 2020
@malobre
Copy link
Contributor Author

malobre commented Jun 17, 2020

Old post Yes the quotes makes it work under msys2.

I will look for a solution later today. I think we might be able to check if we're running msys2 with an env variable and then do whatever is necessary.

Edit: I misread your comment, I had also deleted the quotes around the second argument.

@malobre
Copy link
Contributor Author

malobre commented Jun 17, 2020

Old post Nevermind !

I had remove the second pair of quotes, could you test this:
/c/Windows/system32/cmd.exe " /c" start notepad.exe

It works with msys2 and with cmd directly, I think it should work with Git for Windows too.

Edit: I misread your comment.

To summarize, this /c/Windows/system32/cmd.exe " /c" start notepad.exe works with:

  • cmd
  • msys2
  • mingw32 / mingw64
  • Git for Windows Bash
  • PowerShell

@malobre
Copy link
Contributor Author

malobre commented Jun 17, 2020

I also noticed that dots are not escaped at multiple places (.exe instead of \.exe):

and string match -qr '.exe' $fish_browser[1]

and string match -qr '.exe' $fish_browser[1]

if string match -qr 'cmd.exe$' -- $fish_browser[1]

Is this voluntary? Should I update those when I make a PR for the previously mentioned changes ?

@krobelus
Copy link
Member

Should I update those when I make a PR

Sure, that can't hurt.

@faho faho closed this as completed in 94f4473 Jun 24, 2020
@zanchey zanchey modified the milestones: fish-future, fish 3.2.0 Jun 26, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants