Hi all,
in a script, I have this code:
--8<---------------cut here---------------start------------->8---
if test \( (count (ls -A .)) != "0" \) -a \( -z $argv[2] \)
echo "This should be run in an empty directory."
exit 3
end
--8<---------------cut here---------------end--------------->8---
It errors with:
test: Expected a combining operator like '-a' at index 4
I don't see what's wrong here. Do you?
Of course, feel free to suggest a better way to encode that this script
must be run in an empty directory unless there are at least two
arguments given.
And also I find it strange that the script runs although I get the
(syntax?) error above. With both Bash and ZSH, syntactical nonsense
like
if [[ -a -z 1/1 ]]; then echo Yes; fi; echo Running
does not print Running and returns exit code 2 whereas fish's equivalent
if test -a -z !; echo Yes; end; echo Running
prints Running and returns zero. In this case, I think the Bash/ZSH
behavior is much better. A syntax error should not be treated as simply
a false expression.
I'm running fish 3.0.1.
Thanks,
Tassilo
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users