How to use "read" in Busybox v1.1.1 ?

Jody Bruchon jody at jodybruchon.com
Wed May 13 11:56:32 UTC 2015


On 5/13/2015 7:45 AM, Mike Yates wrote:
> read -p "Enter name: " $name
>
> I have found that the "$" is the issue - Busybox will only accept a
> variable name without it, while Bash accepts either, or the null
> variable.
My understanding is that BusyBox does not attempt to support "Bashisms" 
beyond a certain point and generally defers to the POSIX standard:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html

POSIX does not specify a -p option. The correct way to do what you're 
doing and maintain compliance is probably:

echo -n "Enter name: "
read name

Also note that the use of this Bashism results in the opposite of what 
one would expect under POSIX. Here's what happens in BusyBox ash:

$ A=FOO
$ read $A
barbaz
$ set
A='FOO'
FOO='barbaz'

-Jody


More information about the busybox mailing list