LinuxCommandLibrary

unsetopt

TLDR

List all currently unset options (use setopt to list set options)

$ unsetopt
copy

Unset a specific option
$ unsetopt [option_name]
copy

Unset multiple options at once
$ unsetopt [option_name1 option_name2 ...]
copy

SYNOPSIS

unsetopt [ {+|-}options | {+|-}o option_name ] [ name ... ]

PARAMETERS

-m
    Treat subsequent arguments as shell‑pattern strings; any option whose name matches a pattern is unset.

+|-
    A leading plus or minus can be used before an option name to explicitly enable (+) or disable (‑) it; with unsetopt the minus form is typical.

o
    Indicates that the next argument is a single option name (useful when the name begins with ‘+’ or ‘‑’).

option_name / name
    The exact name of the shell option to be unset. Multiple names may be supplied.

DESCRIPTION

The unsetopt command is a built‑in of shells such as zsh and ksh that removes one or more shell options from the current environment. It accepts option names directly, or it can operate on patterns when the -m flag is used. When invoked without arguments it lists all options that are currently unset, making it useful for debugging a shell’s configuration. The command respects the same naming rules as setopt: option names are case‑insensitive, underscores are ignored, and a leading no can be used to invert the sense of an option (e.g., unsetopt beep is equivalent to setopt No_Beep). Because it is a shell builtin, it does not affect subshells or external programs, and it cannot unset options that are marked as readonly by the shell implementation.

CAVEATS

Only available in shells that implement it (e.g., zsh, ksh); it does not affect options in child processes. Read‑only options cannot be unset. Pattern matching with -m requires quoting to prevent the shell from expanding the patterns before unsetopt sees them.

TYPICAL USAGE

Unset a single option: unsetopt beep
Unset multiple options: unsetopt noclobber ignoreeof
Unset options matching a pattern: unsetopt -m 'no*hist*'

INTERACTION WITH <B>SETOPT</B>

Because setopt and unsetopt share the same option names, you can toggle an option by using setopt to enable it and unsetopt to disable it. The no prefix works with both commands (e.g., setopt No_Beepunsetopt beep).

HISTORY

The unsetopt builtin originated in the KornShell (ksh) as a counterpart to setopt. When zsh was created, it adopted the same syntax and extended it with pattern‑matching via -m. Over time the command has remained largely unchanged, serving as the primary way to clear shell options in interactive and script contexts.

SEE ALSO

setopt(1), shopt(1), unset(1), set(1)

Copied to clipboard