0

I would like to write my own interactive shell for Linux.

  • limited set of my own commands
  • no need to execute external binaries

It is not hard to do it, but I would like to do somethimg more user friendly.

  • TAB auto completion
  • interactive line editing
  • history of last commands

Is there some library/framework/minimal shell that can be used for this? So I don't need to write everything myself.

Prefered license is some permissive (MIT, BSD, Apache, ..)

Prefered language is python, c, c++, javascript or sh

j123b567
  • 3,110
  • 1
  • 23
  • 32
  • One might argue this to be a duplicate of http://stackoverflow.com/questions/1883467/is-there-a-simple-alternative-to-readline -- any answer there would also be an acceptable answer here -- though with modern site rules that question would no longer be allowed. – Charles Duffy Jul 08 '15 at 13:44
  • If I knew readline, I would have google it myself. – j123b567 Jul 09 '15 at 14:50
  • Sure -- folks not knowing the right keywords is why we *want* good duplicate questions (that is, duplicates that ask the question in a way that someone who _didn't_ know the keywords would, and in a way that differs significantly from any other ways the same question was previously asked on the site) -- we mark them close-as-duplicate, and then they provide a pointer/signpost to the canonical answer, thus adding value to the knowledge base. – Charles Duffy Jul 09 '15 at 15:52

2 Answers2

0

If you need job control (i.e. backgrounding) you can have a look at the glibc manual on Implementing a Shell.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Sebi
  • 4,262
  • 13
  • 60
  • 116
  • Since the OP specifies "no need to execute external binaries", there's clearly no need to support executing them in the background. Nonetheless, that's an interesting link. – Charles Duffy Jul 08 '15 at 13:42
  • He can also have a look at the sources of bash: https://ftp.gnu.org/gnu/bash/ . A shell that does not need to execute external binaries is quite limited as it lacks any useful functionality(or it can provide it on its own but that wouldn't make it a shell any more(imagine all binaries such as mkdir, cd, ld, ls, cat, touch, file, etc. put together in one)). – Sebi Jul 08 '15 at 13:54
  • 2
    Reading the question in context, the goal is clearly less a shell in the sense that you're thinking of, and more an interactive command line / REPL for a non-shell piece of software. – Charles Duffy Jul 08 '15 at 13:55
0

For Python, the standard-library cmd module does this: https://docs.python.org/2.7/library/cmd.html

For C, you have several options available for managing interactive editing, history, and tab completion:


By the way -- this question is explicitly off-topic; I expect it to be closed.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441