Minishell includes several built-in commands that are executed directly within the shell process. This document describes their usage and behavior.
Changes the current working directory of the shell.
- If no path is provided, it defaults to the
HOMEdirectory. - Updates the
PWDandOLDPWDenvironment variables.
Prints the given strings followed by a newline.
-n: Suppresses the trailing newline.
Displays the current environment variables.
- Lists all variables in the format
NAME=VALUE.
Exits the shell with the specified status.
- If no status is provided, it exits with the status of the last executed command.
- Handles numeric and non-numeric arguments according to
bashstandards.
Adds or updates environment variables.
- If no arguments are provided, it lists all environment variables in alphabetical order, formatted for re-export.
- Supports adding variables with or without values.
Prints the absolute path of the current working directory.
Removes the specified environment variables.
All built-ins are defined in the builtins/ directory. They are dispatched via the exec_builtins function in the execution module. This allows the shell to avoid the overhead of forking processes for these core commands.