fisher/functions/__fisher_plugin_validate.fish
Bret Johnson 8e05f82980 For some reason a \ line continuation followed by a | at the beginning
of the next line has problems, at least on my machine running cygwin.
It produced an error like this:
~/.local/share/fisherman/functions/__fisher_plugin_validate.fish (line
42):                 | sed -E "
^ from sourcing file
~/.local/share/fisherman/functions/__fisher_plugin_validate.fish
called on standard input

This change simply eliminates the \ line continuation and instead
concatenates with the next line.  It seems simple enough and avoids
this problem, making it work on cygwin.
2016-03-28 23:51:33 -04:00

53 lines
1.5 KiB
Fish

function __fisher_plugin_validate -a plugin
if set -q argv[2]
printf "%s\n" "$argv"
return 1
end
switch "$plugin"
case ..\*
printf "%s\n" "../"
return 1
case . ./\* /\*
if test ! -e "$plugin"
printf "%s\n" $plugin
return 1
end
set plugin (
switch "$plugin"
case /\*
printf "%s\n" $plugin
case \*
printf "$PWD/%s/%s" (dirname "$plugin") (basename "$plugin")
end | sed -E 's|[./]*$||; s|/([\./])/+|/|g'
)
printf "%s\n" $plugin
__fisher_plugin_validate (basename $plugin) > /dev/null
case \*
set -l id "[A-Za-z0-9._-]"
if not printf "%s\n" "$plugin" | grep -qE "^(($id+)[:/]*)*\$"
printf "%s\n" "$plugin"
return 1
end
printf "%s\n" "$plugin" | sed -E "
s|^gh[:/]+|https://github.com/|
s|^gl[:/]+|https://gitlab.com/|
s|^bb[:/]+|https://bitbucket.org/|
s|^omf[:/]+|https://github.com/oh-my-fish/|
s|^($id+)/($id+)\$|https://github.com/\1/\2|
s|^(gist\.github\.com.*)|https://\1|
s|^http(s?)[:/]*|http\1://|
s|https://github((.com)?/)?|https://github.com/|
s|/*(\.git/*)*\$||g" | tr "[A-Z]" "[a-z]"
end
end