The unset built-in undefines variables or functions.

Syntax

  • unset [-fv] [name…]

Description

The unset built-in removes the definition of the variables or functions specified by operands.

It is not an error if any of the specified variables or functions do not exist; they are silently ignored.

Options

-f
--functions

Undefine functions.

-v
--variables

Undefine variables.

These options are mutually exclusive: only the last specified one is effective. If neither is specified, -v is assumed.

Operands

name

The name of a variable or function to be undefined.

Exit status

The exit status of the unset built-in is zero unless there is any error.

Notes

The unset built-in is a special built-in.

Although yash does not do so, the POSIX standard allows removing a function if neither of the -f and -v options is specified and the specified variable does not exist.

At least one name operand must be specified in the POSIXly-correct mode.