How can I add arguments to a piped script in fish shell?

Viewed 19

I am looking for a way to add arguments to a piped curl script which shall be executed in a fish shell. In my case, this is installation of oh-my-fish via curl.

The command without arguments is:

curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish

But as I want to run this in a non interactive environment, I want to add the arguments --noninteractive and --yes to the downloaded script to get something like

curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish -- --noninteractive --yes

This code is just to express, what I want and does not run.

For bash the equivalent would be

curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | bash -s -- --noninteractive --yes

but I cannot find a way to do this with fish.

1 Answers

Tell fish to source stdin with arguments explicitly:

curl | fish -c 'source - --noninteractive --yes'

The - as the filename stands for stdin, any further arguments to source will be used as the $argv, no -- is necessary.

Alternatively, separate the download and running step:

curl > file
fish file --noninteractive --yes

Fish stops processing its own arguments after the filename so, again, no -- necessary.


Or, for your problem at hand, oh-my-fish reads the variables "NONINTERACTIVE" and "ASSUME_YES", so you can do

curl | NONINTERACTIVE=1 ASSUME_YES=1 fish
Related