0

Is it possible to have the output of a bash program returned to the command-line interface so that by pressing Enter the output is executed as a command?

I mean something like:

>> cat example.sh
special_echo "ls -l"
>> ./example.sh
>> ls -l

Where special_echo replaces the function I am looking for.

Edgar Derby
  • 2,543
  • 4
  • 29
  • 48
  • 1
    There is no general way for a script to populate the next bash prompt, no. Some hacks are possible, but it's generally better to work with the system than against it, and just say "Press enter to run this command" without returning it to the prompt first – that other guy Feb 18 '18 at 18:43
  • 2
    You seem to be looking for `eval` but remember, `eval` is evil. – tripleee Feb 18 '18 at 18:48
  • Also see [Populate command line from script](https://superuser.com/questions/1023185/populate-command-line-from-script) on superuser. – Charles Duffy Feb 18 '18 at 19:14

0 Answers0