How to access remaining arguments in a fish script

In fish, your arguments are contained in the $argv list. Use list slicing to access a range of elements, e.g. $argv[2..-1] returns all arguments from the second to the last.

For example

function loop --description "loop <count> <command>"
  for i in (seq 1 $argv[1])
    eval $argv[2..-1]
  end
end

Usage

$ loop 3 echo hello world
hello world
hello world
hello world

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)