I am creating a function (below) with which you can provide an argument, a directory. I test if the $argv
is a directory with -d
option, but that doesn’t seem to work, it always return true even if no arguments are supplied. I also tried test -n $argv -a -d $argv
to test is $argv
is empty sting, but that returns test: Missing argument at index 1
error. How should I test if any argument is provided with the function or not? Why is test -d $argv
not working, from my understanding it should be false when no argument is provided, because empty string is not a directory.
function fcd
if test -d $argv
open $argv
else
open $PWD
end
end
Thanks for the help.