
嘗試fish
,我陷入了一些變數擴展的等價物bash
:
x=${this:-$that}
x=${this:-that}
我如何在魚中做到這一點?
答案1
沒有什麼比 posix shell 變數擴展更短的了:
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
(我很高興被證明這一點是錯的)