Here is a working function that's similar to your test function.
function testvarz
switch (count $argv)
case 0
echo 'zero'
case 1
echo "one $argv[1]"
case 2
echo "two $argv[1] $argv[2]"
case '*'
echo 'else'
end
end
You can use a similar structure for your connect
function.
By the way, you should similarly use $#
in your Bash function instead of trying to rely on $2
being null. You can also use a case
statement in Bash.