
私はfish.configを使って作業しています。魚の皮。
Bash構文を使用して文字列を比較しようとしていますが、Fishはその構文を受け入れません。明らかにこれを行う別の方法があります。以下のbashソリューションのようなクリーンなソリューションに関する提案はありますか?
if [[ $STRING == *"other_string"* ]]; then
echo "It contains the string!"
fi
答え1
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
または:
if string match -q "other_string" $STRING
echo it matches
else
echo is does not match
end