Discipline Functions

Each variable can have zero or more discipline functions associated with it. The shell initially understands the discipline names get, set, and unset but on most systems others can be added at run time via the C programming interface extension provided by the builtin built-in utility. If the get discipline is defined for a variable, it is invoked whenever the given variable is referenced. If the variable .sh.value is assigned a value inside the discipline function, the referenced variable will evaluate to this value instead. If the set discipline is defined for a variable, it is invoked whenever the given variable is assigned a value. The variable .sh.value is given the value of the variable before invoking the discipline, and the variable will be assigned the value of .sh.value after the discipline completes. If .sh.value is unset inside the discipline, then that value is unchanged. If the unset discipline is defined for a variable, it is invoked whenever the given variable is unset. The variable will not be unset unless it is unset explicitly from within this discipline function.

The variable .sh.name contains the name of the variable for which the discipline function is called,.sh.subscript is the subscript of the variable, and .sh.value will contain the value being assigned inside the .set discipline function. For the set discipline, changing .sh.value will change the value that gets assigned.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.226.28