Search code examples
macosterminalfish

How to have argv option in fish shell function?


I need to have my fish function accept option for an argv. Something like,

myProg <command> <options>

Currently i have the following function

function myProg
        java -jar "/Users/username/myProg/myprog-0.2.jar" "$argv"
 end

I need to send the following command from my terminal

myProg vm start

Can you please help with how to rewrite the function to accept the options?

Thanks..


Solution

  • In fish variables like $argv are arrays and when interpolated into a command should not be enclosed in double-quotes unless you want to concatenate the values into a single string. In other words just define your function like this:

    function myProg
        java -jar "/Users/username/myProg/myprog-0.2.jar" $argv
    end