From 94f4473d3bef58b9e4412e3975690c7748c2cd33 Mon Sep 17 00:00:00 2001 From: Malobre Date: Wed, 24 Jun 2020 18:36:37 +0200 Subject: [PATCH] Fix #7113, correct a few regexes. (#7130) * Fix #7113 (cannot call help using msys2), correct a few regexes. * Use regex instead of glob-style matching * Match `\.exe$` instead of `cmd\.exe$` for WSL * Match `\.exe(\s+|$)` instead of `\.exe$` and `cmd\.exe$` * Fix a few regexes This allows cygstart to be manually set as a browser, with or without arguments --- share/functions/help.fish | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/share/functions/help.fish b/share/functions/help.fish index b06fbd42c..2e027541d 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -80,7 +80,7 @@ function help --description 'Show help for the fish shell' # We use this instead of xdg-open because that's useless without a backend # like wsl-open which we'll check in a minute. if test -f /proc/version - and string match -riq 'Microsoft|WSL' ' >$tmpname set page_url file://$tmpname - # For Windows (Cygwin and WSL), we need to convert the base help dir to a Windows path before converting it to a file URL + # For Windows (Cygwin, msys2 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] + and string match -qr '(cygstart|\.exe)(\s+|$)' $fish_browser[1] set page_url file://(cygpath -m $tmpname) else if type -q wslpath - and string match -qr '.exe' $fish_browser[1] + and string match -qr '\.exe(\s+|$)' $fish_browser[1] set page_url file://(wslpath -w $tmpname) end end end # cmd.exe needs more coaxing. - if string match -qr 'cmd.exe$' -- $fish_browser[1] - $fish_browser /c "start $page_url" - # If browser is known to be graphical, put into background + if string match -qr 'cmd\.exe$' -- $fish_browser[1] + # The space before the /c is to prevent msys2 from expanding it to a path + $fish_browser " /c" start $page_url + # If browser is known to be graphical, put into background else if contains -- $fish_browser[1] $graphical_browsers switch $fish_browser[1] case htmlview x-www-browser @@ -193,7 +194,7 @@ function help --description 'Show help for the fish shell' else # Work around lynx bug where
always has the same formatting as links (unreadable) # by using a custom style sheet. See https://github.com/fish-shell/fish-shell/issues/4170 - if string match -q 'lynx*' -- $fish_browser + if string match -qr '^lynx' -- $fish_browser set fish_browser $fish_browser -lss={$__fish_data_dir}/lynx.lss end $fish_browser $page_url