Bash - Enable, disable or print Builtin command

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

1 - About

Enable, disable and print builtin shell commands.

Advertising

3 - Syntax

enable [-adnps] [-f filename] [name ...]
  • -n disable the name; otherwise, names are by default enabled.
  • -f means to load the new builtin command name from shared object filename, on systems that support dynamic loading.
  • -d will delete a builtin previously loaded with -f.
  • -p alon with a and s print a list of shell builtins. See list

3.1 - Return value

The return value is 0 unless a name is not a shell builtin or there is an error loading a new builtin from a shared object.

4 - Management

4.1 - Enable

For example, to use the test binary found via the PATH instead of the shell builtin version, run enable -n test.

4.2 - Disable

Disabling a builtin allows a disk command which has the same name as a shell builtin to be executed without specifying a full pathname, even though the shell normally searches for builtins before disk commands.

4.3 - List

If no name arguments are given, or if the -p option is supplied, a list of shell builtins is printed.

  • With no other option arguments, the list consists of all enabled shell builtins.
  • If -n is supplied, only disabled builtins are printed.
  • If -a is supplied, the list printed includes all builtins, with an indication of whether or not each is enabled.
  • If -s is supplied, the output is restricted to the POSIX special builtins.
Advertising