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

Michael Conrad mconrad at intellitree.com
Fri May 15 03:58:04 UTC 2015


On 5/14/2015 12:38 PM, Mike Yates wrote:
> After all, I was only using "read" as a convenient "stop to debug"
> prompt. The ash "arg count" error prevented "read" from stopping the
> script and was almost disastrous!

Ok, so by "works" you mean "stops to wait for a newline".  That was the 
primary point of confusion.

> As I said, Busybox should either make its built-ins Posix Compliant or
> explain prominently why they are not (Almquist) or, better still, give
> a "usage" line on failure.

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

This document says nothing about the variable being optional or any 
reference to the $REPLY variable.  Do you have a link to a document that 
says otherwise?

> I'm sure you will sggest a more reliable method?

If you want the widest compatibility with shells, simply say "read 
REPLY", and/or actually require the value you read to be "yes" or "y" 
before continuing, which is what most people do.

Also, I like to use "set -e" so that any command which fails will exit 
the shell.  The shell's default of continuing after failed commands is 
the dangerous part.


That said, it doesn't seem like a bad idea to add $REPLY support to 
busybox sh if it can be written in a few bytes, which I suspect it can.

-Mike C


More information about the busybox mailing list