2
鑑於只有產生輸出給予一定的輸入該驅動程序功能之間的區別:測試命令:-n和-z
function driver -a arg
test $arg = 1; and echo OK
return 0
end
事情工作確定當函數發出輸出:
$ driver 1 | od -c
0000000 O K \n
0000003
$ test -z (driver 1); and echo no output; or echo some output
some output
$ test -n (driver 1); and echo some output; or echo no output
some output
但在無輸出的情況下:
$ driver 0 | od -c
0000000
$ test -z (driver 0); and echo no output; or echo some output
no output
$ test -n (driver 0); and echo some output; or echo no output
some output
這是一個錯誤?
請注意,上述行爲可能會或可能不會很快發生變化:https://github.com/fish-shell/fish-shell/issues/4163 –