Enable or disable shell builtins
enable [-a] [-dnps] [-f filename] [name ...]
-a Print all builtin commands, whether disabled or not.
-d removes built-in commands loaded from dynamic libraries.
-n Disables built-in commands or displays disabled built-in commands.
-p Print in reusable format.
-s displays only posix standard built-in commands in the startup state.
-f loads built-in commands into the dynamic library.
-ns prints disabled POSIX standard built-in commands.
-as Print POSIX standard built-in commands, whether disabled or not.
filename: dynamic library file name.
name (optional): built-in command, can be multiple.
enable returns success unless name is not a built-in command or an error occurs.
# posix special builtin
# Assuming no built-in commands are disabled
# Disable two posix standard built-in commands
enable -n set source
# Print the disabled posix standard built-in commands
enable -ns
# Print POSIX standard built-in commands, whether disabled or not.
enable -as
# Print the enabled posix standard built-in commands
enable -s
# Assuming no built-in commands are disabled
# Disable one or more built-in commands
enable -n echo pwd
# Print all built-in commands, whether disabled or not.
enable -a
# Print enabled built-in commands
enable
# Print disabled built-in commands
enable -n
# Enable one or more built-in commands
enablepwd
Q: What about the demonstration of -f
, -d
and -p
?
A: To explain, -f
and -d
are limited to personal abilities and no suitable examples have been found. If you have better examples, please provide PR;
After I verified that there seems to be no difference whether the -p
option is used, you can compare the difference between enable -p|cat -A
and enable|cat -A
. (Note: cat -A
is used to display invisible characters)
Q: Is it possible to disable enable
itself? Can I still disable or enable built-in commands later?
A: Yes; no.
$PATH
. Find the command to be executed. It looks like there is no way to write user's own commands to replace the shell builtin commands. Fortunately, with the enable
command we can do just that.