How do you compare two strings in Fish (like "abc" == "def"
in other languages)?
So far, I've used a combination of contains
(turns out that contains "" $a
only returns 0
if $a
is the empty string, although that hasn't seemed to work for me in all cases) and switch
(with a case "what_i_want_to_match"
and a case '*'
). Neither of these methods seem particularly... correct, though.
if [ "abc" != "def" ]
echo "not equal"
end
not equal
if [ "abc" = "def" ]
echo "equal"
end
if [ "abc" = "abc" ]
echo "equal"
end
equal
or one liner:
if [ "abc" = "abc" ]; echo "equal"; end
equal