On 10/5/17 1:04 PM, Joerg Schilling wrote:
> "Schwarz, Konrad" <[email protected]> wrote:
> 
>> Perhaps I haven't understood the full import, but ksh92 has an additional
>> function syntax (function name { body; }), where "function" is a keyword,
>> that provides local variables declared with typeset.
>>
>> "The New Kornshell" states
>>
>>
>> Because of deficiencies in the POSIX shell standard, there are two
>> types of functions.  POSIX functions [...] do not provide any scoping [...]
>> This makes it hard to write functions that don't have side effects.
> 
> Both types of functions did already exist in ksh88

Both types of function declarations existed in ksh88 (and ksh86), but
functions  declared using the `Posix' syntax did not behave any differently
from functions declared using the orignal ksh `function name' syntax. They
allowed local variables, and scoped traps and options locally.

> 
>> So it seems ksh92's implementation of POSIX functions is for standards 
>> conformance,
>> and the new syntax was introduced to avoid breaking that conformance.
> 
> Since in 1988, there was no POSIX standard for the behavior of commands, this 
> must exist for compatibility with the Bourne Shell.

The `name() { command; }' function declaration syntax was introduced for
Bourne shell compatibility. The behavior change with ksh92-ksh93 was for
Posix conformance.

> 
> The Bourne Shell introduced the function method, that in the 1990s was added 
> to 
> the standard, with it's 1984 release.
> 
> I am sorry, but I cannot verify whether ksh did implement functions before.

ksh had functions dating from the early 1980s in its original incarnation
as a form interpreter. Korn mentions functions as one of the first things
he added to the Bourne shell. I don't know whether ksh-83 had the SVR2
function declaration syntax in addition to `function name', but ksh-86
certainly did.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [email protected]    http://cnswww.cns.cwru.edu/~chet/

Reply via email to