Before Debian, what Linux distribution you were using ?
Red Hat / Fedora Mandrake Suse Slackware Gentoo LFS Always been with Debian Other ( 75 votes ~ 5 comments )
You are not currently logged in. If you do not have a user account then please consider creating one and logging in before you post your comment. This will allow you to track replies to your comment, and take part in the site much more freely.
To add your comment, fill in all the boxes below and then preview it to make sure you're happy with the way that it looks.
This is the comment you were replying to, attached to the weblog bash read/readline prepopulation questions
#2 Re: bash read/readline prepopulation questions Posted by mcortese (213.70.xx.xx) on Fri 7 Mar 2008 at 11:53 Yes, read cannot do what you need. I suggest you simulate the pre-seeding with the ${x:-y} syntax. myownread() { local x echo >&0 -e "$1$2\e[A" read >&0 -p "$1" x eval "$3='${x:-$2}'" } Then use it like this: # Use: # myownread PROMPT PRESEED VAR myownread "Question? " "yes" aaa echo $aaa The above function works with bash and sh. The only problem is that the \e[A sequence that forces the cursor up one line is terminal-specific (you can find the sequence that fits your term by pressing Control-V then the Up key).
Yes, read cannot do what you need. I suggest you simulate the pre-seeding with the ${x:-y} syntax.
myownread() { local x echo >&0 -e "$1$2\e[A" read >&0 -p "$1" x eval "$3='${x:-$2}'" }
Then use it like this:
# Use: # myownread PROMPT PRESEED VAR myownread "Question? " "yes" aaa echo $aaa
The above function works with bash and sh.
The only problem is that the \e[A sequence that forces the cursor up one line is terminal-specific (you can find the sequence that fits your term by pressing Control-V then the Up key).
Posting Format:
Inappropriate comments will be removed.
Some help on entry formatting is available
Username:
Password:
[ Advanced Login ]
Register Account