Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to spawn a new shell since 8.2.0 #1081

Closed
lzm0 opened this issue Jan 15, 2025 · 2 comments
Closed

Unable to spawn a new shell since 8.2.0 #1081

lzm0 opened this issue Jan 15, 2025 · 2 comments

Comments

@lzm0
Copy link

lzm0 commented Jan 15, 2025

In [email protected], it is possible to spawn a subshell with this command

npx [email protected] --eval 'await $`bash`.stdio("inherit", "inherit", "inherit")'

However, since [email protected], this is no longer possible. Running

npx [email protected] --eval 'await $`bash`.stdio("inherit", "inherit", "inherit")'

will not give the user a new shell.

@antongolub
Copy link
Collaborator

antongolub commented Jan 15, 2025

relates #931

In short, we have 2 3 options:

// preconfiguration
await $({stdio: 'stdio'})`bash`

// postconfiguration
await $({halt: true})`bash`.stdio('inherit', 'inherit', 'inherit').run()

A portion of black magic, which I strongly do not recommend:

import {$, ProcessPromise} from 'zx'

const run = ProcessPromise.prototype.run
ProcessPromise.prototype.run = function () { setImmediate(run.bind(this)) }

await $`echo foo`.stdio('inherit', 'inherit', 'inherit')

@lzm0
Copy link
Author

lzm0 commented Jan 15, 2025

Thanks for the workaround. I decided to go with the postconfiguration approach which worked nicely.

@lzm0 lzm0 closed this as completed Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants