6

There are some command line programs that take input from the user, but do not provide editing capabilities, like sh (alias dash), or nslookup and others.

There is a way to force such applications to provide editing capabilities to correct the current line or recall previous lines?

2 Answers 2

4

There are at least three tool to obtain what is required, these are:

  • rlwrap -- readline feature command line wrapper
  • rlfe -- a front-end using readline to "cook" input lines for other programs
  • ledit -- line editor for interactive programs

You can use each of them simpy prepeding to command to wrap, as in

rlwrap sh

The first, rlwrap, seems the best, because the second make the line in bold, and the third fails to show the prompt with sh, nevertheless it works.

2

The ubiquitous technology to learn is readline, because programs that have been compiled with readline support already have this capability - in whatever Linux distribution and in whatever Unix GNU utilities. (Most GNU programs have been done this way, and it's "painful" when they have not - enough for me that I would recompile them if they didn't get done "right.") It's a lot like learning the vi editor - once it's "in you" it never leaves; and, it makes working with the various programs much more proficient and enjoyable. The readline support behaves the same in whichever program was compiled with that library. How readline was implemented in an individual software program was up to the programmer(s) of that program, so mileage may vary.

For example, in BASH, the up arrow key recalls the previous line, and in almost any console program, [CTRL]+[U] erases everything left of the cursor while [ALT]+[F] moves forward one word and [ALT]+[B] moves backward one word, and many more...

Nslookup does have this, and sh/dash - but they are minimal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .