Re: Bash "read" command: want to preload some data

2011-10-09 Thread au2by2
Apologies, line wrapping messed up my previous reply, corrected here (I hope). Won't this do what you want? It obviously works on "old" bash. echo -n "prompt:"; writevt -t `tty` -T "default"; read a; For example: testuser@bartlett:~$ echo -n "prompt:"; writevt -t `tty` -T "default"; read

Re: Re: Bash "read" command: want to preload some data

2011-10-09 Thread au2by2
Won't this do what you want? It obviously works on "old" bash. echo -n "prompt:"; writevt -t `tty` -T "default"; read a; For example: testuser@bartlett:~$ echo -n "prompt:"; writevt -t `tty` -T "default";\ > read a; declare -p a BASH_VERSION prompt:default declare -- a="default" declare --

Re: Bash "read" command: want to preload some data

2010-03-08 Thread A. Costa
On Mon, 8 Mar 2010 17:27:22 +, Bob Cox wrote: > > (Debian's minimal 'dash' also has a 'read -i', so for > > current Debian, the '-i' is universal. Earlier versions, > > or other *nixs might not though.) > > Not so sure that is correct about dash... Whoops, you're right, it seems I did a 'man

Re: Bash "read" command: want to preload some data

2010-03-08 Thread Bob Cox
On Sun, Mar 07, 2010 at 21:11:29 -0500, A. Costa (agco...@gis.net) wrote: > Bash isn't strictly needed, plain Bourne shell works, using parameter > substitution [...] Thank you for you time and trouble. As it happens, I did in fact upgrade this lenny box to use bash version 4.1-1 and all is n

Re: Bash "read" command: want to preload some data

2010-03-07 Thread A. Costa
Bash isn't strictly needed, plain Bourne shell works, using parameter substitution man sh | grep -A 2 -i "parameter:-" ${parameter:-word} Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is

Re: Bash "read" command: want to preload some data

2010-03-06 Thread Bob Cox
On Sat, Mar 06, 2010 at 09:44:13 -0600, Boyd Stephen Smith Jr. (b...@iguanasuicide.net) wrote: > PROMPT="stuff" > DEFAULT="path" > > printf '%s [%s] ?' "$PROMPT" "$DEFAULT" > read FILEPATH > if [ -z "$FILEPATH" ]; then > FILEPATH="$DEFAULT" > fi Boyd and André - thank you both for your s

Re: Bash "read" command: want to preload some data

2010-03-06 Thread Boyd Stephen Smith Jr.
In <20100306124710.gb25...@bobcox.com>, Bob Cox wrote: >On Sat, Mar 06, 2010 at 06:21:27 -0600, Ron Johnson (ron.l.john...@cox.net) wrote: >> On 2010-03-06 04:28, Bob Cox wrote: >>> - >>> Example: ask for a path with a default value. >>> Note: The -i option was introduced with

Re: Bash "read" command: want to preload some data

2010-03-06 Thread André Berger
* Bob Cox (2010-03-06): [...] > - > Example: ask for a path with a default value. > Note: The -i option was introduced with Bash 4. > read -e -p "Enter the path to the file: " -i "/usr/local/etc/" FILEPATH > The user will be prompted, he can just accept the default, or edit it.

Re: Bash "read" command: want to preload some data

2010-03-06 Thread Ron Johnson
On 2010-03-06 06:47, Bob Cox wrote: On Sat, Mar 06, 2010 at 06:21:27 -0600, Ron Johnson (ron.l.john...@cox.net) wrote: On 2010-03-06 04:28, Bob Cox wrote: What I am trying to do is "preload" a bash read command with a value which can be accepted, edited or changed by the user. Some googling s

Re: Bash "read" command: want to preload some data

2010-03-06 Thread Bob Cox
On Sat, Mar 06, 2010 at 06:21:27 -0600, Ron Johnson (ron.l.john...@cox.net) wrote: > On 2010-03-06 04:28, Bob Cox wrote: >> What I am trying to do is "preload" a bash read command with a value >> which can be accepted, edited or changed by the user. Some googling >> shows that this is dead easy

Re: Bash "read" command: want to preload some data

2010-03-06 Thread Ron Johnson
On 2010-03-06 04:28, Bob Cox wrote: What I am trying to do is "preload" a bash read command with a value which can be accepted, edited or changed by the user. Some googling shows that this is dead easy to with the -i option which appeared in bash version 4 - I have found this: -