| 1 | # Called from spec/ysh-builtins.test.sh |
| 2 | |
| 3 | shopt -s ysh:upgrade # TODO: bad proc error message without this! |
| 4 | |
| 5 | # Set up a file |
| 6 | seq 3 > tmp.txt |
| 7 | |
| 8 | proc read-lines (; out) { |
| 9 | var lines = [] |
| 10 | while read -r line { |
| 11 | append $line (lines) |
| 12 | |
| 13 | # Can also be: |
| 14 | # call lines->append(_reply) |
| 15 | # call lines->push(_reply) # might reame it |
| 16 | } |
| 17 | call out->setValue(lines) |
| 18 | } |
| 19 | |
| 20 | var x |
| 21 | read-lines (&x) < tmp.txt |
| 22 | json write (x) |
| 23 |