zx icon indicating copy to clipboard operation
zx copied to clipboard

repl hangs if command is waiting for input

Open mustafa0x opened this issue 3 years ago • 1 comments

Steps to Reproduce the Problem

zx --repl

await $`mv -i <file> <existing-file>`

Couldn't even find a way to abort (ctrl+c/d/z).

Specifications

  • Version: Latest
  • Platform: Mac

mustafa0x avatar Jan 20 '23 03:01 mustafa0x

const { terminal } = require('terminal-kit')

/**
 * run with kill (Ctrl + C)
 */
function rwk(...args) {
  const p = $(...args)
  const onKeyEvent = (key) => {
    if (key === 'CTRL_C') {
      p.kill()
    }
  }
  terminal.addListener('key', onKeyEvent)
  return p.finally(() => terminal.removeListener('key', onKeyEvent))
}

and then

await rwk`mv -i <file> <existing-file>`

you can interrupt the process with ctrl + c

noih avatar Mar 08 '23 06:03 noih