鱼壳中的一个字符串是否包含另一个字符串?

dea*_*han 4 string fish variable

我的工作我的fish.config使用鱼贝

我正在尝试使用 bash 语法比较字符串,但 fish 不接受该语法。显然有另一种方法可以做到这一点。对于像下面的 bash 解决方案一样干净的解决方案有什么建议吗?

if [[ $STRING == *"other_string"* ]]; then
    echo "It contains the string!"
fi
Run Code Online (Sandbox Code Playgroud)

Jef*_*ler 9

在我看来,有一个string用于此目的的函数:

$ set STRING something here
$ string match -q "other_string" $STRING; and echo yes
$ set STRING some other_string here
$ string match -q "other_string" $STRING; and echo yes
yes
Run Code Online (Sandbox Code Playgroud)

或者:

if string match -q "other_string" $STRING
  echo it matches
else
  echo is does not match
end
Run Code Online (Sandbox Code Playgroud)