Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > gnu.bash.bug > #16887

Re: have read command few first chars. fed by CL

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: have read command few first chars. fed by CL
Date 2020-09-03 10:57 -0400
Message-ID <mailman.2205.1599145108.2469.bug-bash@gnu.org> (permalink)
References <1599144445543-0.post@n7.nabble.com> <20200903145756.GE931@eeg.ccf.org>

Show all headers | View raw


On Thu, Sep 03, 2020 at 07:47:25AM -0700, almahdi wrote:
> 
> is it possible to have the *read* command few first characters in buffer is
> fed by way of script code / CLI

It's a bit unclear what you're really trying to do here, but I'm guessing
you want to pre-populate the user's input for a read command, to provide
a "default" that can be edited.

If you use read with the -e option (to enable readline), you can also use
the -i option.

      -e	use Readline to obtain the line
      -i text	use TEXT as the initial text for Readline

unicorn:~$ read -p 'What is your name? ' -e -i "$LOGNAME" -r name
What is your name? greg_

Where _ represents the cursor.  The string "greg" is pre-populated
from the -i option, and can be backspaced or whatever.

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: have read command few first chars. fed by CL Greg Wooledge <wooledg@eeg.ccf.org> - 2020-09-03 10:57 -0400

csiph-web