woodson2 0 Newbie Poster

Below is a simple script to prompt for user input while suggesting an editable default value at the prompt:

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.