0

I have maybe a strange question: is there a way to embed something like the Linux command line in an application? Specifically I'm imagining hacking games like Uplink where there's a command prompt in-game that you interact with. They're sometimes done well but often not, since writing a command line interpreter is a lot of work on top of making a game. If there was a way to leverage actual command line tools that would both cut out a lot of work for the developer and also help with immersion (it's a Unix system, I know this!).

It would need to be something like a sandboxed virtual machine, since you wouldn't want it to interact with the real host machine, just a fake in-universe computer. But it'd still be nice to support things like bash.rc, piping commands, foreground and background tasks, and keyboard shortcuts.

I'm imagining something like how Lua embeds in C, where you'd get callbacks in the host application when the virtual linux machine wanted to interact with the console, read/write files or start up threads.

But I don't know if anything like this exists, or even can exist without more effort than it'd be worth? I'm not even sure exactly what terms to google to start researching this.

Jay Lemmon
  • 1,158
  • 1
  • 8
  • 22
  • You are looking at writing a shell in C. Search this site `"[c] write simple shell"` (replace `[c]` with whatever language you are writing in) Technically, your question is a bit off-topic as it requests a recommendation of software -- but it's a close call. – David C. Rankin Jan 17 '21 at 03:26
  • Are you after something like [this](https://stackoverflow.com/questions/29112349/how-to-use-a-terminal-embedded-in-a-pyqt-gui)? – tink Jan 17 '21 at 04:50
  • @tink that's wrapping a GUI around a terminal, which is sort of the opposite of what I'm trying to do, which is put a terminal in an application – Jay Lemmon Jan 17 '21 at 16:15
  • @DavidC.Rankin The point is I don't want to write a shell, I want to reuse the existing ones from Linux, as whatever I write isn't going to be as good or as thorough as the real ones. – Jay Lemmon Jan 17 '21 at 16:15
  • Have a look at busybox, maybe. – stark Jan 17 '21 at 16:52

0 Answers0