AmokHuginnsson / replxx

A readline and libedit replacement that supports UTF-8, syntax highlighting, hints and Windows and is BSD licensed.
Other
687 stars 107 forks source link

Possibility to use shell commands #57

Open efferto opened 4 years ago

efferto commented 4 years ago

Hello,

I'm using replxx for an interactive command line application combined with TCLAP. It is nice and easy to use. I was wondering if there is a way to support also system commands. For example on linux if I type ls (dir on windows), send it to the system prompt and get the output back. Do you think there is an easy way? I mean, if the command is not one of the supported (auto-completed) send it to the system?

Thanks a lot.

AmokHuginnsson commented 4 years ago

Hello.

If I understood your question correctly, you are asking for using replxx to implement an interactive system shell for the command line.

It can be achieved, in fact there is already a project that does precisely that: Huginn - a new interactive system shell for both Linux/Unix and Windows systems (Github mirror).
In this project you can see how replxx can be utilized to implement so called "interactive part" of system shell and how much more work is necessary to have fully functioning shell.

If you asked for something simpler than implementing fully fledged system shell so that replxx would do most of the job for you by some method for running system commands and "forwarding" their I/O then unfortunately this would be out of scope for the replxx project.

It is worth mentioning that Linux' ls is implemented completely different than Windows' dir in a sense that ls exists in the system as a standalone program that can be executed by any other process directly while dir on Windows is a cmd's built-in and can be executed only from cmd context.

I hope this answer your question.

efferto commented 4 years ago

@AmokHuginnsson Thanks for your reply. This is exactly what I had in mind. I'll have a look into the huginn project.