
634
|
Chapter 6: The Bash Shell and Korn Shell
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Functions may have local variables, and they may be recursive. The syntax
used to define a function is irrelevant.
•Inksh88, all functions have their own traps and local variables, and may be
recursive.
•Inksh93, name () functions share traps with the “parent” shell and may not
be recursive.
•Inksh93, function functions have their own traps and local variables, and
may be recursive. Using the . command with a function function gives it
POSIX shell semantics (i.e., shared traps and variables).
Variables
This section describes the following:
• Variable substitution
• Built-in shell variables
• Other shell variables
• Arrays
• Discipline functions (ksh93 only)
• Special prompt strings
Variable Substitution
ksh93 provides structured variables, such as pos.x and pos.y. To create either
one, pos must already exist, and braces must be used to retrieve their values.
Names beginning with .sh are reserved for use by ksh.
No spaces should be used in the following expressions. The colon (:) is optional;
if it’s included, var must be nonnull, as well as set.
Variableexpression Description
var=value … Set each variable var to a value.
${var} Use value of var; braces are optional if var is separated from the following text. They are
required for array variables, and ...