bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read portability


From: Dan Douglas
Subject: read portability
Date: Thu, 27 Mar 2014 03:16:56 -0500

As I'm sure everybody knows, Bash is the only shell that supports indexed
arrays but maps the option for reading fields to -a rather than -A. I realize
that "read -A" was an unfortunate, confusing choice in contrast to "typeset
-a", but this is a feature that I use in almost every script, and would "just
work" everywhere if it wasn't for the backwards option. Could we just add it as
an alternate?

A real proper wrapper around read to fix this in a script requires a full-on
option parser to handle both "-a x" and "-ax" forms. Ideally it also has to fix
the collision with the coprocess feature in at least 3 other implementations
and translate between "var?prompt" and "-p prompt". Also "-i default" <->
"var=default; read -v var" (ksh93). I have such a function of course, but don't
care to make every script depend on it.

The -a/-A problem is definitely the most common and annoying of these though
and the -A would be very useful even if left undocumented or marked as
deprecated.

-- 
Dan Douglas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]