问题描述
为什么在以下示例中 $VARS
不包含 ('testing','second')
:
~ ❯❯❯ /bin/cat t
testing
second
~ ❯❯❯ /bin/cat t | read -L -a VARS
~ ❯❯❯ echo $VARS
testing
~ ❯❯❯
我认为 -L
应该按行拆分,然后将 -a
存储到列表中。然而,fish 似乎在第一行之后停止了。
解决方法
根据文档不清楚为什么这会起作用,但这是解决方案:
~ ❯❯❯ /bin/cat t
testing
second
~ ❯❯❯ /bin/cat t | read -za VARS
~ ❯❯❯ echo $VARS
testing second