Discussion:
[Help-bash] What was the reason to give declare its name?
D630
2016-12-01 00:48:09 UTC
Permalink
I have been reading a lot about early shell history these days. Can you
remeber, how the built-in command 'declare' got its name? What was the
rationale behind it?
konsolebox
2016-12-01 11:16:29 UTC
Permalink
Post by D630
I have been reading a lot about early shell history these days. Can you
remeber, how the built-in command 'declare' got its name? What was the
rationale behind it?
I'm more interested to know why `declare` was made to declare
variables in the local context by default, when there's already the
`local` builtin. Was it because it was meant to remain compatible with
`typeset`? And even if `local` was added later (if it was added
later), I think it was still early enough for `declare` to be able to
change behavior. We could have enjoyed global declaration of
associative arrays as early as 4.0.
--
konsolebox
Chet Ramey
2016-12-01 16:33:15 UTC
Permalink
Post by konsolebox
I'm more interested to know why `declare` was made to declare
variables in the local context by default, when there's already the
`local` builtin.
Your history is backwards. `declare' predated `local', which only came
in just before 1990 in response to a late draft (D9?) of Posix.2-1992.
Since declare already had the desired semantics, it was easy to add local.
Post by konsolebox
Was it because it was meant to remain compatible with
`typeset`? And even if `local` was added later (if it was added
later), I think it was still early enough for `declare` to be able to
change behavior. We could have enjoyed global declaration of
associative arrays as early as 4.0.
All of this happened before 1990, and there wasn't any inclination to
make bash incompatible with ksh.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://cnswww.cns.cwru.edu/~chet/
Chet Ramey
2016-12-01 16:24:07 UTC
Permalink
Post by D630
I have been reading a lot about early shell history these days. Can you
remeber, how the built-in command 'declare' got its name? What was the
rationale behind it?
It was originally intended to be compatible with the ksh (ksh88 at the
time) `typeset', with the same semantics, but `declare' was a more
descriptive name. "declare variables and give them attributes".
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://cnswww.cns.cwru.edu/~chet/
Loading...