Open 7flash opened 1 week ago
Note, in this particular example, its simply solved by adding "-y" flag to skip interactive mode, however i wonder if its even possible to accept user input while running bun shell, as that would open up many possibilities.
Do you gain anything using the Bun shell, over just using Bash or Dash?
Do you gain anything using the Bun shell, over just using Bash or Dash?
Yes, with Bun Shell I can implement complex logic in between the commands, ie
const secret = await $`external-tool-requiring-user-passcode';
await Bun.password.hash(secret);
// ...
The closest I have gotten to this is over here in this related issue https://github.com/oven-sh/bun/issues/14693#issuecomment-2425379770.
Using Bun.spawn for interactive processes seems to work:
const proc = Bun.spawn({
cmd: ["vim"],
stdin: "inherit",
stdout: "inherit",
stderr: "inherit",
});
const exit_code = await proc.exited;
if(exit_code !== 0) {
throw new Error("process exited with code: " + exit_code);
}
Using Bun.spawn for interactive processes seems to work:
const proc = Bun.spawn({ cmd: ["vim"], stdin: "inherit", stdout: "inherit", stderr: "inherit", }); const exit_code = await proc.exited; if(exit_code !== 0) { throw new Error("process exited with code: " + exit_code); }
Thanks, it actually works! Also compatible with gum https://github.com/charmbracelet/gum
const proc = Bun.spawn({
cmd: ["gum", "choose", "fix", "feat"],
stdin: "inherit",
stdout: "inherit",
stderr: "inherit",
});
const exit_code = await proc.exited;
if(exit_code !== 0) {
throw new Error("process exited with code: " + exit_code);
}
What is the problem this feature would solve?
I want to write a server setup script in Bun shell, however I encounter following issue.
What is the feature you are proposing to solve the problem?
bash interactive mode
What alternatives have you considered?
No response