Register
It is currently Mon Oct 20, 2014 6:34 pm

Using read to prompt for editable user input in Bash 3


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Tue Nov 27, 2012 11:28 am   

Joined: Mon Apr 27, 2009 2:24 pm
Posts: 10
Below is a simple script to prompt for user input while suggesting an editable default value at the prompt:


Code:
shortname=user1

read -e -i $shortname -p "Please enter the username you would like to add: " input
USERNAME="${input:-$shortname}"

Please enter the username you would like to add: user1


The above is the expected and working output in BASH 4

If I try this same code in BASH 3 it doesn't work because this version does not support the "-i" switch.

I need some help getting the same result in BASH 3.
Thanks


Top
 Profile  
 PostPosted: Wed Nov 28, 2012 1:56 pm   
User avatar

Joined: Fri Jul 22, 2011 5:39 pm
Posts: 47
Man,
You are everywhere. :)


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP