
を試してみるとfish
、 からの変数展開のいくつかに相当するものが見つかりませんbash
:
x=${this:-$that}
x=${this:-that}
魚でそれをするにはどうすればいいですか?
答え1
POSIX シェル変数の展開ほど短いものはありません。
if set -q this; or test -z $this
set x $that
else
set x $this
end
または「簡潔な」バージョン
begin; set -q this; or test -z $this; end; and set x $that; or set x $this
(この点については私が間違っていることが証明されれば嬉しいです)