EivindArvesen/prm

does not work with fish shell

omnidan opened this issue · 7 comments

I added the alias as instructed, when running prm, I get the following error:

'case' builtin not inside of switch block
~/dev/notmine/prm/prm.sh (line 15): case "$1" in
                                    ^
from sourcing file ~/dev/notmine/prm/prm.sh
    called on line 151 of file /usr/local/Cellar/fish/2.2.0/share/fish/config.fish

in function '.'
    called on line 1 of file -

in function 'prm'
    called on standard input

source: Error while reading file '/Users/dan/dev/notmine/prm/prm.sh'

Yeah I'm trying to get this working on fish too. I'm afraid it won't work :(

Since all the prm scripts are ran from bash, as soon as this exits and you're back in fish, all the cd-ing and whatnot you did won't matter, as it was in a different shell.

I might port this to fish someday, but it'll have to be a different implementation with fish functions (unless someone as a better idea, I'm far from being an expert at fish scripting).

EDIT: Fyi 'sourcing' the prm script inside fish won't work as it's written for bash.

@FredDeschenes alright, keep me updated here if you ever develop a fish port :)

@FredDeschenes is completely right.

As I don't have much experience with fish, I don't know the details of the compatibility-issues between it and bash.

However (and I'm just spitballing here):
Wouldn't making the hashbang directives (in prm as well as the generated scripts) more ambiguous (i.e. sh instead of bash) and/or removing it from prm entirely if fish is not bourne-compatible, and changing the case in @omnidan's original comment to if-tests make the script fish-compatible?

@eivind88 Well compatibility-wise, fish just cannot source bash scripts, their scripts being so different.
You can make prm run in fish by adding a 'prm' function

function prm
    bash /path/to/prm $argv
end

but this runs the script in a different shell, so it's basically a noop.

Also, since the scripts are sourced inside bash, they have to be bash scripts themselves, so we can't use any fish functionality with them.

EDIT : To get an idea of how different they are.

I was thinking more in the vein of (something like) fish prm.sh and not explicitly sourcing other scripts in bash (i.e. leaving it ambiguous so that whatever shell is used is tried), but I've since discovered that there are some major differences in syntax that make them incompatible.

So it indeed appears that prm won't work with fish shell unless it is explicitly ported.

Shameless plug, but I've mostly ported prm for fish here.

Report any issues you might have (or create pull requests for the couple of missing features :P)!

Great job!
I'll add a link to your port in the prm readme.