Discipline Functions (ksh93 Only)
Along with structured variables, ksh93 introduces discipline
functions . These are special functions that are called
whenever a variable’s value is accessed or changed. For a shell
variable named x, you can define
the following functions:
|
|
Called when |
|
|
Called when |
|
|
Called when |
Within the discipline functions, special variables provide information about the variable being changed:
|
|
The name of the variable being changed. |
|
|
The subscript of the array element being changed. |
|
|
The value of the variable being assigned or returned. Changing it within the discipline function changes the value that is actually assigned or returned. |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access