Fish

魚相當於 ${this:-that} 擴展和類似

  • August 11, 2020

嘗試fish,我被困在一些變數擴展的等價物上bash

x=${this:-$that}
x=${this:-that}

我如何在魚中做到這一點?

沒有比 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

(我很高興被證明是錯誤的)

引用自:https://unix.stackexchange.com/questions/603888