bug-bash
[Top][All Lists]
Advanced

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

Re: [PATCH] admit 'typeset' is here to stay


From: Dan Douglas
Subject: Re: [PATCH] admit 'typeset' is here to stay
Date: Sat, 20 Feb 2016 14:55:32 -0600

On Thu, Jan 28, 2016 at 4:36 PM, Martijn Dekker <martijn@inlv.org> wrote:
> In 'help typeset', the 'typeset' builtin is called obsolete and has been
> so since at least bash 2.05b (2002) or possibly earlier. Perhaps it's
> time to just call it a synonym, as indeed the texinfo documentation does.
>
> diff -ur bash-4.4-beta.orig/builtins/declare.def
> bash-4.4-beta/builtins/declare.def
> --- bash-4.4-beta.orig/builtins/declare.def     2015-08-24
> 19:02:28.000000000 +0100
> +++ bash-4.4-beta/builtins/declare.def  2016-01-28 22:32:16.000000000 +0000
> @@ -65,7 +65,7 @@
>  $SHORT_DOC typeset [-aAfFgilnrtux] [-p] name[=value] ...
>  Set variable values and attributes.
>
> -Obsolete.  See `help declare'.
> +Synonym of `declare'.  See `help declare'.
>  $END
>
>  #include <config.h>
>

"typeset" vs. "declare" isn't always a straightforward decision
depending on one's requirements. Bash's "typeset" has always
been there for portability despite being a synonym for "declare",
so I think just calling it a synonym would be counterproductive.
http://thread.gmane.org/gmane.comp.standards.posix.austin.general/8371/focus=8377

It's tricky because the big problems surrounding "typeset" lie in the
details of variable scope and how each option is supported. There are
some good reasons for choosing "typeset" if you're willing to work around
all the subtleties but I think that's a bit beyond a concise description
for the help output.

For the most common requirement: localizing or applying an attribute to
a variable within a single function; "local" and the posix-compatible
declaration builtins are usually what people want. "local" is supported
by every current implementation that also has "typeset" and "declare",
plus a few others like dash (to a limited degree).  Those that are mostly
concerned with bash compatibility usually choose "declare" when not using
"local".



reply via email to

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