chickadee » augeas » aug-defvar

aug-defvar a name exprprocedure

Defines a variable NAME whose value is the result of evaluating EXPR. If a variable NAME already exists, its name will be replaced with the result of evaluating EXPR. Context will not be applied to EXPR.

If EXPR is NULL, the variable NAME will be removed if it is defined.

Path variables can be used in path expressions later on by prefixing them with $.

On success, returns 0 if EXPR evaluates to anything other than a nodeset, or the number of nodes if EXPR evaluates to a nodeset. On failure, raises an error.


(aug-defvar a "hosts" "/files/etc/hosts")    ;=> 1
(aug-get a "$hosts/1/ipaddr")                ;=> ""
(aug-defvar a "hosts" #f)                    ;=> 0
(aug-get a "$hosts/1/ipaddr")                ;=> undefined variable (exn augeas pathx)