2020-09-15 10:59 Budi <budikus...@gmail.com>:
> simply run a readline function among lines codes of bash script such
> a menu-complete, or previous-history repeated thrice, or etc

What is not clear is not how you call the readline function, but what
kind of ``script'' do you assume?

a. If it is the normal executable script which can be used as
  `./script.sh', the question doesn't make sense because there is no
  command line and no readline.  Readline is only enabled in an
  interactive session of Bash.  So one can guess that you are either
  asking how to enable the readline in a script, or talking about some
  other type of scripts that you haven't explained.

b. If you want to enable readline and accept user inputs, you can use
  `read -e' as Greg wrote.  If you want to control the detailed
  behavior of `read -e' (i.e., how it behaves for each keystroke) by
  Bash scripts, the answer is it's impossible.

c. Maybe you are thinking of sourcing a script in an interactive
  shell, such as

  $ source script.sh

  In this case, it is still unclear what you want to do because the
  readline is inactive on the command execution.  There is no prompt
  or command line when the user command is executed.

d. Another possibility is that you are talking about the shell
  commands executed in `bind -x '"keyseq":unix-command''.  In this
  case, it is impossible to invoke a readline function directly from
  the shell commands.  But some limited class of mixed operations can
  be implemented by combining the `bind '"...":"..."'` macro.

e. Or maybe you are thinking of a completely different type of
  ``script''?

--
Koichi

Reply via email to