google / zx

A tool for writing better scripts
https://google.github.io/zx/
Apache License 2.0
42.92k stars 1.09k forks source link

.lines() function outputs array with an empty string instead of the actual output #911

Open floriangeorgi opened 5 days ago

floriangeorgi commented 5 days ago

Expected Behavior

#!/usr/bin/env zx
import {$} from 'zx'
console.log($.sync`echo -e "Item1\nItem2\nItem3"`.lines());

This code should output: [ 'Item1', 'Item2', 'Item3' ] This is at least the behavior in version 8.1.4.

Actual Behavior

It outputs an array with an empty string: [ '' ]

Steps to Reproduce

  1. Create a new node project, install zx and add index.mjs.
    
    // index.mjs

!/usr/bin/env zx

import {$} from 'zx' console.log($.syncecho -e "Item1\nItem2\nItem3".lines());


2. Make it executable. `chmod +x index.mjs`
3. Run it with `zx index.mjs`

### Specifications

- zx version:  8.1.8
- Platform: ~~windows~~ / ~~macos~~ / linux
- Runtime: node / ~~deno~~ / ~~bun~~
antongolub commented 5 days ago

@floriangeorgi,

Thanks for the report. The fix is on the way.