I am trying to test for the length of $argv or the value of the first $argv[1] element in a function like follows:
function do-something
if test (count $argv) -lt 2 -o $argv[1] = "--help"
echo Usage ...
end
end
However, I am getting the following error:
⟩ do-something
test: Missing argument at index 6
The issue is with the string comparison, but I am not sure how to get this working. I have also tried -o [ $argv[1] = "--help" ], but this fails with another error.
Note also that this works if I include an argument, so it seems fish is evaluating the second condition even if the first fails. Is this a bug?