Fisher: Snippets 2.3.0+ compatibility

Created on 7 Feb 2017  ·  15Comments  ·  Source: jorgebucaran/fisher

As an example, conf.d/ snippets were introduced in fish v2.3.0.

If plugins start using snippets, but the user is still on v2.2.0 - like a lot of Ubuntu users - the plugin will stop working silently.

Are there any solutions for fisherman to warn the user about incompatibilities like this, or does every plugin need to check the installed fish version and print a warning.

Most helpful comment

Don't see a reason to use anything else besides brew upgrade fish

All 15 comments

I think the title is misleading. What you are asking is for a way to patch users that can't upgrade fish to at least 2.3 correct?

Anyway, for snippet support in <=2.2, simply append the following code to your ~/.config/fish/config.fish.

for file in ~/.config/fish/conf.d/*.fish
    source $file
end

I presume you can't patch users automatically, in that case its more about making them aware.

@aristidesfl We could, but they'd have to run fisherman at least once. But that'd be hacky.

There's no simple way to do it because of how fisherman is first introduced in the user system. As you may know, fisherman has no installer or curl | sh kind of stuff.

So, no code actually runs on behalf of fisherman until the user enters fisher and that's the normal behavior.

That sounds better than having each plugin deal with it. A simple warning stating fish is out of date and 2.3.0 is required for some plugins. Fisherman already throws exceptions for fish <2.2.0.

I believe this issue is about how to handle snippet support in <2.2.0?

The way we handle general support for <2.2.0 would be better discussed somewhere else.

I'm not too worried about 2.2.2 TBH, fish is already 2.5 and counting. Ubuntu better upgrade soon.

The point would be improve the warnings which are being printed for <2.2.0 to include warnings about <2.3.0.

I see, right. Fisherman used to work well with 2.2, since it was created around the time (before) 2.3 was released, but I guess it's not so much the case anymore?

Adding warnings for 2.3 seems like a fairly simple change.

Do you want to do it?

Sure

function __fisher_log doesn't work in fish <2.2.0 so the warning message is currently broken. Should we replace __fisher_log with a simple echo in this case? https://github.com/fisherman/fisherman/blob/master/fisher.fish#L19

$ fisher list
fish: Could not expand string '' function okay(s) { printf("'"$okay"'%s'"$nc"' %s\n", "OK", s) } function info(s) { printf("%s\n", s) } function error(s) { printf("'"$error"'%s'"$nc"' %s\n", "!", s) } {
sub(/^[ ]+/, "") gsub("``", " ") if (/&[^&]+&/) { n = match($0, /&[^&]+&/) if (n) { sub(/&[^&]+&/, "'"$$log"'" substr($0, RSTART + 1, RLENGTH - 2) "'"$nc"'", $0) } } s[++len] = $0 } END { for (i = 1; i <=
len; i++) { if ((i == 1 || i == len) && (s[i] == "")) { continue } if (s[i] == "") { print } else { '"$log"'(s[i]) } } } ''
/Users/user/.config/fish/functions/fisher.fish (line 1365):     printf "%s\n" "$message" | command awk '
                                                                                                       ^
in function '__fisher_log',
    called on line 19 of file '/Users/user/.config/fish/functions/fisher.fish',
    with parameter list 'error You need fish &2.2.0& or higher to use fisherman.'

in function 'fisher',
    called on standard input,
    with parameter list 'list'

command: Unknown option 'brew'
/Users/user/.config/fish/functions/fisher.fish (line 21):             if command -s brew > /dev/null
                                                                      ^
in function 'fisher',
    called on standard input,
    with parameter list 'list'


       command − command ‐ run a program


command ‐ run a program
   Synopsis
       command COMMANDNAME [OPTIONS...]

   Description
       command forces the shell to execute the program COMMANDNAME and ignore
       any functions or builtins with the same name.

   Example
       command ls causes fish to execute the ls program, even if an ’ls’
       function exists.

fish: Could not expand string '' function okay(s) { printf("'"$okay"'%s'"$nc"' %s\n", "OK", s) } function info(s) { printf("%s\n", s) } function error(s) { printf("'"$error"'%s'"$nc"' %s\n", "!", s) } {
sub(/^[ ]+/, "") gsub("``", " ") if (/&[^&]+&/) { n = match($0, /&[^&]+&/) if (n) { sub(/&[^&]+&/, "'"$$log"'" substr($0, RSTART + 1, RLENGTH - 2) "'"$nc"'", $0) } } s[++len] = $0 } END { for (i = 1; i <=
len; i++) { if ((i == 1 || i == len) && (s[i] == "")) { continue } if (s[i] == "") { print } else { '"$log"'(s[i]) } } } ''
/Users/user/.config/fish/functions/fisher.fish (line 1365):     printf "%s\n" "$message" | command awk '
                                                                                                       ^
in function '__fisher_log',
    called on line 24 of file '/Users/user/.config/fish/functions/fisher.fish',
    with parameter list 'info
                    Refer to your package manager documentation for
                    instructions on how to upgrade your fish build.
                '

in function 'fisher',
    called on standard input,
    with parameter list 'list'

@aristidesfl Sounds good to me!

Any special reason the warning suggests using brew upgrade fish with --HEAD?

@aristidesfl No idea, I really don't know how to use brew other than the basic stuff. What would be a better recommendation?

Don't see a reason to use anything else besides brew upgrade fish

LGTM

Was this page helpful?
0 / 5 - 0 ratings