Search code examples
fish

How to set $argv to an empty list?


I want to manipulate $argv and pass it on to another fish function. It is simple enough to trim it as follows:

switch $value
case a
    set argv $argv[2..-1]
case b
    set argv $argv[3..-1]
end

call_function $argv

But how can I set it to an empty list?

I don't want to set --erase argv because I do actually want to access the variable.

I tried set argv $argv[] but then count $argv returns 1. (And I may rely on count later -- unless there is a better way to test for emptiness?)


Solution

  • set argv
    

    You don't actually need $argv to get to an empty list at all - the empty list is just the absence of arguments.