How to access remaining arguments in a fish script

后端 未结 3 753
失恋的感觉
失恋的感觉 2021-01-31 15:55
my-fish-script a b c d

Say you want to get the all arguments from the second argument onwards, so b c d.

In bash you can use

3条回答
  •  抹茶落季
    2021-01-31 16:11

    You could also use read which is more readable in my opinion:

    function loop
      echo $argv | read -l count command
      for i in (seq 1 $count)
        eval $command
      end
    end
    

    This works better especially when you want to use more than the first argument.

    echo $argv | read -l first second rest
    

提交回复
热议问题