bash 6,000 Q&As Showing 6,000 of 6,187

Bash FAQ & Answers

6000 expert Bash answers researched from official documentation. Every answer cites authoritative sources you can verify.

Jump to section:

Shell Parameters > Shell Variables (151) Invoking Bash > Command-Line Options (133) Bash Builtin Commands > Bourne Shell Builtins (72) Modifying Shell Behavior > Completion and Readline Integration (69) Bash Builtin Commands > Shell Behavior Modification (68) Shell Variables > Interactive Shell Behavior (68) Command Line Editing > History Operations (64) Readline Init File > Key Bindings (64) Shell Expansions > Text Processing Expansions (64) Shell Expansions > Pattern-Based Expansions (62) Bourne Shell Builtins > Variable and Environment Management (58) Interactive Shells > Command Line Editing (56) Installing Bash > Installation Customization (55) Readline Init File > Variable Settings (54) Conditional Constructs > Branching Conditionals (54) Shell Functions > Parameter and Argument Handling (53) Bash Builtin Commands > Bash-Specific Builtins (53) Controlling the Prompt > Terminal Control (51) Command Line Editing > Completion (51) Installing Bash > Build Configuration (51) Shell Expansions > Substitution Expansions (51) Programmable Completion > Completion Source Mechanisms (49) Interactive Shells > Prompting and Display (49) Command Line Editing > Line Editing Basics (49) Bash Builtin Commands > Programmable Completion Builtins (48) Invoking Bash > Argument Handling (48) Readline Interaction > Basic Interaction (48) Job Control > Job Control Commands (47) Shell Variables > Job Control and Process Management (47) Command Line Editing > Cursor Movement (46) Shell Syntax > Compound Commands (46) Conditional Constructs > Expression Evaluation Constructs (46) Job Control > Job Identification and Specification (45) Interactive Shells > History Management (45) History Expansion > Event Designators (45) Using History Interactively > History Modification (45) Bourne Shell Builtins > Signal and Event Handling (43) Modifying Shell Behavior > Job Control and Process Management (43) Major Differences From The Bourne Shell (43) Using History Interactively > History Manipulation Commands (42) Shell Expansions > Path Expansions (42) Bash POSIX Mode (41) Invoking Bash > Shell Execution Modes (41) Executing Commands > Command Expansion and Preparation (41) Readline vi Mode (41) Shell Arithmetic > Conditional Operations (40) Bourne Shell Builtins > Testing and Parsing (40) Redirections > Basic Stream Redirection (40) Using History Interactively > History Expansion Syntax (39) Controlling the Prompt > Location Context (39) Using History Interactively > Word Extraction (38) Shell Scripts (38) Using History Interactively > History Storage and Management (38) Modifying Shell Behavior > History Management (37) Interactive Shells > Error and Exit Behavior (37) Shell Variables > Special Parameters (36) Command Line Editing > Text Manipulation (36) Shell Syntax > Command Structures (36) Bourne Shell Builtins > Directory and Path Management (35) Interactive Shells > Signal Handling (35) Programmable Completion > Result Filtering and Processing (35) Executing Commands > Command Location and Invocation (34) Bourne Shell Builtins > Flow Control (34) Executing Commands > Signal Processing (34) Readline Interaction > Navigation (34) Quoting > Extended Quoting Formats (34) Shell Variables > Execution Context and Debugging (33) Bash Conditional Expressions > File Comparison Tests (33) Redirections > File Descriptor Operations (33) Shell Commands > Compound Commands (32) Shell Functions > Return Values and Exit Status (32) Bash Builtin Commands > Special Builtins (32) Introduction (32) Bindable Readline Commands > Commands For Changing Text (31) Shell Commands > Lists (31) Command Line Editing > Killing and Yanking (31) Bourne Shell Builtins > Command Execution (30) Executing Commands > Exit Status and Return Codes (30) Definitions (30) Job Control > Interactive vs Non-Interactive Behavior (30) Shell Arithmetic > Bitwise Operations (30) Readline Init File > Init File Structure (29) History Expansion > Modifiers (29) Quoting > Basic Quoting Mechanisms (29) Shell Syntax > Shell Processing Mechanics (29) Controlling the Prompt > System Identity (29) Arithmetic Expansion (29) Shell Functions > Function Definition and Syntax (29) Using History Interactively > Event Selection (28) Shell Arithmetic > Arithmetic Operations (28) Modifying Shell Behavior > Debugging and Tracing (28) Bash Builtin Commands > Directory Stack Builtins (28) Filename Expansion > Shell Options for Globbing Behavior (28) Job Control > Execution States (28) Quoting > Character Interpretation Control (28) Shell Arithmetic > Comparison Operations (28) Modifying Shell Behavior > Pathname Expansion and Globbing (28) Conditional Constructs > Pattern Matching Conditionals (27) Interactive Shells > Job Control (27) Filename Expansion > Character Classes and Bracket Expressions (27) Shell Parameters > Positional Parameters (27) Readline Interaction > Text Manipulation (26) Shell Functions > Function Execution and Invocation (26) Controlling the Prompt > Command Context (26) Bourne Shell Builtins > Script Lifecycle (26) Filename Expansion > Extended Pattern Matching (26) Shell Parameter Expansion > Substring Extraction (25) Arrays > Element Access and Retrieval (25) Pipelines (25) Shell Parameters > Special Parameters (25) Readline Interaction > History Search (25) Readline Interaction > Command Modifiers (25) Bash Conditional Expressions > File Permission Tests (24) Bash Builtin Commands > Command History Builtins (24) Shell Commands > Simple Commands (24) Installing Bash > Basic Installation Process (24) Bash Startup Files > File Selection Order (24) Grouping Commands (24) Shell Syntax > Advanced Command Forms (24) Programmable Completion > Completion Specification Management (24) Shell Commands > Reserved Words (24) Shell Variables > History Management (23) Bash Conditional Expressions > Arithmetic Comparison Tests (23) Bash Conditional Expressions > File Type Tests (23) Invoking Bash > Startup File Processing (23) Shell Parameter Expansion > Pattern Removal (22) Shell Commands > Pipelines (22) Lists of Commands (22) Arrays > Array Types and Declaration (22) Process Substitution (21) Executing Commands > Execution Environment Management (21) The Restricted Shell (21) Modifying Shell Behavior > Error Handling and Exit Behavior (21) Bash Startup Files > Shell Invocation Types (21) Bindable Readline Commands > Miscellaneous Commands (21) Arrays > Assignment and Modification (21) Redirections > Here Documents and Here Strings (20) Conditional Constructs > Loop-Based Conditionals (20) Bash Startup Files > Configuration Purpose (20) Shell Parameter Expansion > Case Modification (20) Bash Conditional Expressions > String Comparison Tests (20) Invoking Bash > Security and Privilege Settings (20) Tilde Expansion (20) Conditional Constructs > Interactive Selection Constructs (20) Command Substitution (20) Executing Commands > Environment Variable Handling (20) Command Line Editing > Keyboard Macros and Arguments (20) Bindable Readline Commands > Commands For Moving (20) Bash Startup Files > Execution Lifecycle (20) Shell Parameter Expansion > Pattern Substitution (19) Shell Functions > Variable Scope and Locality (19) Bash Startup Files > Scope of Configuration (19) Looping Constructs > Loop Flow Control (19) Programmable Completion > Completion Variables (19) Shell Variables > Shell Ancestry and Compatibility (19) Filename Expansion > Special Matching Rules (19) Shell Arithmetic > Logical Operations (18) Installing Bash > Multi-Platform Support (18) Bash Builtin Commands > Job Control Builtins (18) The Directory Stack (18) Brace Expansion (18) Bourne Shell Builtins > System Information and Permissions (18) Shell Commands > Coprocesses (18) Bindable Readline Commands > Killing And Yanking (18) Programmable Completion > Completion Action Types (17) Using History Interactively > History Filtering and Control (17) Shell Variables > Locale and Internationalization (16) Interactive Shells > Shell Initialization (16) Word Splitting (16) Shell Parameter Expansion > Name and Key Operations (16) Simple Commands (16) Shell Parameter Expansion > Default and Alternative Values (16) Readline Init File > Conditional Constructs (16) Arrays > Array Manipulation (15) Looping Constructs > Condition-Based Iteration (15) Bindable Readline Commands > Specifying Numeric Arguments (15) Looping Constructs > Iteration by Collection (15) Bindable Readline Commands > Keyboard Macros (15) Shell Parameter Expansion > String Length and Counting (15) Shell Variables > Bash-Specific Extensions (15) Filename Expansion > Basic Wildcard Patterns (15) Shell Arithmetic > Assignment Operations (15) Bash Conditional Expressions > Logical and Negation Operators (13) Bindable Readline Commands > Commands For Completion (12) Controlling the Prompt > Temporal Information (12) Shell Parameter Expansion > Basic Value Access (11) Redirections > Process Substitution (8) Installing Bash > Shared Configuration (8) Bash Conditional Expressions > File Ownership Tests (8) Programmable Completion > Completion Behavior Options (2) Interactive Shells > Interactive Features (1)

Shell Parameters > Shell Variables

151 questions
A

If PROMPT_COMMAND is set, the value is interpreted as a command to execute before the printing of each primary prompt ($PS1).

Sources
95% confidence
A

BASHPID expands to the process id of the current Bash process. This differs from $$ under certain circumstances, such as subshells that do not require Bash to be re-initialized.

Sources
95% confidence
A

A zero-length (null) directory name in the value of PATH indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon.

Sources
95% confidence
A

If set to a number greater than zero, PROMPT_DIRTRIM is used as the number of trailing directory components to retain when expanding the \w and \W prompt string escapes. Characters removed are replaced with an ellipsis.

Sources
95% confidence
A

GROUPS is an array variable containing the list of groups of which the current user is a member.

Sources
95% confidence
A

BASH_SOURCE is an array variable whose members are the source filenames corresponding to the elements in the FUNCNAME array variable.

Sources
95% confidence
A

SHLVL is incremented by one each time a new instance of Bash is started. This is intended to be a count of how deeply your Bash shells are nested.

Sources
95% confidence
A

BASH_REMATCH is an array variable whose members are assigned by the '=~' binary operator to the [[ conditional command. The element with index 0 is the portion of the string matching the entire regular expression. The element with index n is the portion of the string matching the nth parenthesized subexpression.

Sources
95% confidence
A

IGNOREEOF controls the action of the shell on receipt of an EOF character as the sole input. If set, the value denotes the number of consecutive EOF characters that can be read as the first character on an input line before the shell will exit.

Sources
95% confidence
A

LINES is used by the select builtin command to determine the column length for printing selection lists. It is automatically set upon receipt of a SIGWINCH.

Sources
95% confidence
A

BASH_COMMAND is the command currently being executed or about to be executed, unless the shell is executing a command as the result of a trap, in which case it is the command executing at the time of the trap.

Sources
95% confidence
A

MACHTYPE is a string that fully describes the system type on which Bash is executing, in the standard gnu cpu-company-system format.

Sources
95% confidence
A

DIRSTACK is an array variable containing the current contents of the directory stack. Directories appear in the stack in the order they are displayed by the dirs builtin.

Sources
95% confidence
A

FUNCNAME is an array variable containing the names of all shell functions currently in the execution call stack. The element with index 0 is the name of any currently-executing shell function. The bottom-most element is 'main'.

Sources
95% confidence
A

HISTIGNORE is a colon-separated list of patterns used to decide which command lines should be saved on the history list.

Sources
95% confidence
A

HOSTFILE contains the name of a file in the same format as /etc/hosts that should be read when the shell needs to complete a hostname.

Sources
95% confidence
A

histchars contains up to three characters which control history expansion, quick substitution, and tokenization. The first character is the history expansion character (normally '!'), the second is quick substitution (normally '^'), and the optional third is the history comment character (usually '#').

Sources
95% confidence
A

The shell sets BASH_ARGC only when in extended debugging mode (extdebug option to the shopt builtin).

Sources
95% confidence
A

When += is applied to an array variable using compound assignment, the variable's value is not unset (as it is when using '='), and new values are appended to the array beginning at one greater than the array's maximum index for indexed arrays, or added as additional key-value pairs in an associative array.

Sources
95% confidence
A

If set to an integer corresponding to a valid file descriptor, Bash will write the trace output generated when 'set -x' is enabled to that file descriptor.

Sources
95% confidence
A

BASH_CMDS is an associative array variable whose members correspond to the internal hash table of commands as maintained by the hash builtin.

Sources
95% confidence
A

$! expands to the process ID of the job most recently placed into the background, whether executed as an asynchronous command or using the bg builtin.

Sources
95% confidence
A

The shell sets BASH_ARGV only when in extended debugging mode (extdebug option to the shopt builtin).

Sources
95% confidence
A

FIGNORE is a colon-separated list of suffixes to ignore when performing filename completion. A sample value is '.o:~'.

Sources
95% confidence
A

LC_COLLATE determines the collation order used when sorting the results of filename expansion, and determines the behavior of range expressions, equivalence classes, and collating sequences within filename expansion and pattern matching.

Sources
95% confidence
A

COMP_LINE is the current command line. This variable is available only in shell functions and external commands invoked by the programmable completion facilities.

Sources
95% confidence
A

A nameref is a reference to another variable, created using the -n option to declare or local. Whenever the nameref variable is referenced, assigned to, unset, or has its attributes modified, the operation is actually performed on the variable specified by the nameref variable's value.

Sources
95% confidence
A

When HISTCONTROL includes 'erasedups', all previous lines matching the current line are removed from the history list before that line is saved.

Sources
95% confidence
A

GLOBIGNORE is a colon-separated list of patterns defining the set of filenames to be ignored by filename expansion. If a filename matched by a filename expansion pattern also matches one of the patterns in GLOBIGNORE, it is removed from the list of matches.

Sources
95% confidence
A

BASH_LINENO is an array variable whose members are the line numbers in source files corresponding to each member of FUNCNAME.

Sources
95% confidence
A

LC_CTYPE determines the interpretation of characters and the behavior of character classes within filename expansion and pattern matching.

Sources
95% confidence
A

COMP_TYPE is set to an integer value corresponding to the type of completion attempted: TAB for normal completion, '?' for listing completions after successive tabs, '!' for listing alternatives on partial word completion, '@' to list completions if the word is not unmodified, or '%' for menu completion.

Sources
95% confidence
A

A parameter is an entity that stores values. It can be a name, a number, or one of the special characters listed in the Bash documentation.

Sources
95% confidence
A

Each list entry in MAILPATH can specify the message printed when new mail arrives by separating the filename from the message with a '?'.

Sources
95% confidence
A

If HISTTIMEFORMAT is set and not null, its value is used as a format string for strftime to print the timestamp associated with each history entry displayed by the history builtin.

Sources
95% confidence
A

SHELL contains the full pathname to the shell. If it is not set when the shell starts, Bash assigns to it the full pathname of the current user's login shell.

Sources
95% confidence
A

If Bash finds EMACS in the environment when the shell starts with value 't', it assumes the shell is running in an emacs shell buffer and disables line editing.

Sources
95% confidence
A

If set, Bash uses TMPDIR's value as the name of a directory in which Bash creates temporary files for the shell's use.

Sources
95% confidence
A

$$ expands to the process ID of the shell. In a subshell, it expands to the process ID of the invoking shell, not the subshell.

Sources
95% confidence
A

If BASH_ENV is set when Bash is invoked to execute a shell script, its value is expanded and used as the name of a startup file to read before executing the script.

Sources
95% confidence
A

COMPREPLY is an array variable from which Bash reads the possible completions generated by a shell function invoked by the programmable completion facility.

Sources
95% confidence
A

COMP_CWORD is an index into ${COMP_WORDS} of the word containing the current cursor position. This variable is available only in shell functions invoked by the programmable completion facilities.

Sources
95% confidence
A

BASHOPTS is a colon-separated list of enabled shell options. Each word in the list is a valid argument for the -s option to the shopt builtin command.

Sources
95% confidence
A

Namerefs can be unset using the -n option to the unset builtin. Otherwise, if unset is executed with the name of a nameref variable as an argument, the variable referenced by the nameref variable is unset.

Sources
95% confidence
A

COLUMNS is used by the select builtin command to determine the terminal width when printing selection lists. It is automatically set upon receipt of a SIGWINCH.

Sources
95% confidence
A

COMP_WORDS is an array variable consisting of the individual words in the current command line, split as Readline would split it using COMP_WORDBREAKS.

Sources
95% confidence
A

PIPESTATUS is an array variable containing a list of exit status values from the processes in the most-recently-executed foreground pipeline.

Sources
95% confidence
A

BASH_ARGV is an array variable containing all of the parameters in the current bash execution call stack.

Sources
95% confidence
A

BASH_ALIASES is an associative array variable whose members correspond to the internal list of aliases as maintained by the alias builtin.

Sources
95% confidence
A

LC_ALL overrides the value of LANG and any other LC_ variable specifying a locale category.

Sources
95% confidence
A

COMP_POINT is the index of the current cursor position relative to the beginning of the current command. If the current cursor position is at the end of the current command, the value equals ${#COMP_LINE}.

Sources
95% confidence
A

LC_MESSAGES determines the locale used to translate double-quoted strings preceded by a '$' (see Locale Translation).

Sources
95% confidence
A

The default path is system-dependent and is set by the administrator who installs bash. A common value is '/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin'.

Sources
95% confidence
A

In an interactive shell, TMOUT is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after that number of seconds if input does not arrive.

Sources
95% confidence
A

SHELLOPTS is a colon-separated list of enabled shell options. Each word in the list is a valid argument for the -o option to the set builtin command.

Sources
95% confidence

Invoking Bash > Command-Line Options

133 questions
A

bash -O extdebug enables extended debugging mode. This provides additional debugging features: the BASH_ARGC, BASH_ARGV, BASH_SOURCE, and BASH_LINENO variables are set, trap handlers receive additional info, and the DEBUG trap is inherited by shell functions.

Sources
95% confidence
A

bash -O cdable_vars allows cd to treat a variable as a directory name if the directory doesn't exist. For example, if mydir='/home/user/docs', then cd mydir would cd to /home/user/docs. The variable value must be an absolute path.

Sources
95% confidence
A

set -e (errexit) does NOT cause exit on: commands in if/while/until conditions, commands whose exit status is being tested with !, part of && or || chains (except the last), piped commands (unless pipefail is set), or any command in a compound command except the last. The ERR trap also overrides this behavior.

Sources
95% confidence
A

The -x option causes bash to print a trace of simple commands, for commands, case commands, select commands, and arithmetic for commands and their arguments or associated word lists after they are expanded and before they are executed. Equivalent to 'set -x' or 'set -o xtrace'.

Sources
95% confidence
A

An interactive login shell reads /etc/profile first, then looks for ~/.bash_profile, ~/.bash_login, and ~/.profile in order, executing the first one found and ignoring the others. When a login shell exits, it reads ~/.bash_logout if it exists.

Sources
95% confidence
A

bash -O huponexit causes bash to send SIGHUP to all jobs when an interactive login shell exits. This terminates background jobs. Disabled by default.

Sources
95% confidence
A

set -o keyword (or -k) causes all argument assignments to be placed in the environment for a command, not just those before the command name. This allows 'VAR=value command' anywhere in the command line.

Sources
95% confidence
A

bash -O shift_verbose causes the shift builtin to print an error message when the shift count exceeds the number of positional parameters. Without this, silent failure occurs.

Sources
95% confidence
A

set -o allexport (or -a) causes all variable definitions to be automatically exported to the environment of child commands. Any variable assignment or modification will be exported automatically without needing 'export' command.

Sources
95% confidence
A

When bash is invoked as 'sh' or with --posix, and running interactively or with a shell script, it uses the value of ENV variable to name the startup file. Bash expands $ENV and executes commands from that file if it exists and is readable.

Sources
95% confidence
A

Bash starts as a login shell if: invoked with -l or --login option, invoked with argument zero (program name) starting with -, or invoked as a login shell by the system (e.g., from /bin/login). Login shells read /etc/profile and ~/.bash_profile.

Sources
95% confidence
A

The -h option causes bash to remember the location of commands as they are looked up for execution. This is enabled by default and is equivalent to 'set -h' or 'set -o hashall'. It affects command hash table behavior.

Sources
95% confidence
A

The --noprofile option prevents bash from reading the system-wide startup file /etc/profile and any personal startup files (~/.bash_profile, ~/.bash_login, or ~/.profile) for a login shell. This skips all profile initialization.

Sources
95% confidence
A

set -o xtrace (or -x) enables debugging mode where commands are printed after expansion but before execution. Each line is prefixed with PS4 (default: +).

Sources
95% confidence
A

The -f option disables pathname expansion (globbing). This prevents special characters like *, ?, and [...] from being expanded to matching filenames. This is equivalent to 'set -f' or 'set -o noglob'.

Sources
95% confidence
A

bash -O cmdhist causes bash to save multi-line commands in a single history entry. This is enabled by default, allowing easy recall of multi-line commands. Without it, each line is a separate history entry.

Sources
95% confidence
A

set -o noexec (or -n) causes commands to be read but not executed. This is useful for syntax checking scripts. Shell syntax is parsed, but commands are not run.

Sources
95% confidence
A

bash -O dotglob includes filenames beginning with . in the results of pathname expansion. By default, * doesn't match dotfiles. With dotglob, ls * would show .bashrc and other hidden files.

Sources
95% confidence
A

set -o errtrace (or -E) causes ERR traps to be inherited by shell functions, command substitutions, and subshells. Without this, ERR traps only trigger in the main shell, not in these contexts.

Sources
95% confidence
A

-e (errexit) causes bash to exit if any command in a script fails (non-zero exit status), but only checks the last command in a pipeline by default. -o pipefail makes the pipeline exit status be the rightmost non-zero exit, so -e will trigger if any command in the pipe fails.

Sources
95% confidence
A

bash -O expand_aliases enables alias expansion. Aliases are expanded by default in interactive shells but not in non-interactive shell scripts. This option enables alias expansion in scripts if needed.

Sources
95% confidence
A

The -n option causes bash to read commands but not execute them. This is useful for checking shell scripts for syntax errors. Equivalent to 'set -n' or 'set -o noexec'. bash -n script.sh will check syntax without running.

Sources
95% confidence
A

The --login option is equivalent to -l. It makes bash act as if it had been invoked as a login shell, causing it to read and execute login shell startup files like /etc/profile and ~/.bash_profile.

Sources
95% confidence
A

The -T option causes bash to exit if a pipeline command (not just the entire pipeline) returns a non-zero status. This is stronger than set -e which only looks at the last command in a pipeline. Equivalent to 'set -T' or 'set -o pipefail'.

Sources
95% confidence
A

When invoked with -c, bash runs the command string and does NOT read any startup files. It's a non-interactive, non-login shell. However, if BASH_ENV is set and bash is not in POSIX mode, the file specified by BASH_ENV will be sourced before executing the command.

Sources
95% confidence
A

set -o braceexpand enables brace expansion (the default). This allows patterns like {a,b,c} or {1..5} to expand to multiple words. Disabling with +o braceexpand or set +B turns off this feature.

Sources
95% confidence
A

bash -O failglob causes patterns that match no files to cause an error message rather than being left unexpanded. This is useful for catching typos in glob patterns.

Sources
95% confidence
A

Bash processes options in the order they appear on the command line, but certain options like -c affect behavior immediately. Options like -O, -o can set shell options. After option processing, remaining arguments are: if -c was used, the command string and remaining args become $0, $1, etc.; if no -c, the first remaining arg is the script filename, rest become positional parameters.

Sources
95% confidence
A

set -o emacs enables Emacs-style command-line editing in the interactive shell. This uses key bindings similar to Emacs editor (Ctrl+F for forward, Ctrl+B for backward, etc.). This is typically the default.

Sources
95% confidence
A

bash -O lastpipe causes the last command in a pipeline to be executed in the current shell, not a subshell. This allows variables set in the last pipeline command to persist after the pipeline completes. Only works when job control is disabled.

Sources
95% confidence
A

set -o noclobber (or -C) prevents shell redirection from overwriting existing regular files. The > operator will fail if the file exists. Use >| to override.

Sources
95% confidence
A

The -l option makes bash act as if it had been invoked as a login shell. A login shell reads certain startup files like /etc/profile, ~/.bash_profile, ~/.bash_login, or ~/.profile (whichever is found first, the rest are ignored).

Sources
95% confidence
A

When bash is started non-interactively (e.g., to run a shell script), if the environment variable BASH_ENV is set and non-empty, bash expands its value and uses that file as startup file, executing commands from it (like sourcing it). This is similar to ENV in POSIX sh.

Sources
95% confidence
A

bash -O xpg_echo causes the echo builtin to expand backslash escape sequences by default, without requiring -e flag. For example, echo 'hello\nworld' would print an actual newline. Without this option, echo doesn't expand escapes unless -e is used.

Sources
95% confidence
A

bash -O histverify causes the results of history substitution to be shown for review before execution. The substituted command is loaded into readline buffer, requiring Enter to execute. This prevents accidental execution of wrong history substitutions.

Sources
95% confidence
A

bash -O localvar_inherit causes a local variable in a function to inherit the value and attributes of a variable with the same name at the previous scope. Without this, local variables start unset.

Sources
95% confidence
A

The --dump-po-strings option outputs strings in GNU gettext PO format with each translatable string formatted as:
#: filename:line
msgid "original string"
msgstr ""

This creates a valid .po file suitable for translation tools.

Sources
95% confidence
A

bash -O histappend causes the history list to be appended to $HISTFILE when the shell exits, rather than overwriting the file. This preserves history from multiple concurrent shell sessions.

Sources
95% confidence
A

bash -O lithist causes newlines in multi-line commands to be saved in the history with embedded newlines rather than using semicolons. This preserves the visual structure of commands in history.

Sources
95% confidence
A

The -t option causes bash to exit after reading and executing one command. Equivalent to 'set -t' or 'set -o onecmd'. This is useful for single-command execution from a pipe or file.

Sources
95% confidence
A

The --posix option changes bash behavior to match the POSIX standard more strictly. This affects: default value of ENV variable, special variables handling, startup files, disabling non-POSIX extensions, and more. It can also be enabled with 'set -o posix' within a running shell.

Sources
95% confidence
A

bash -O direxpand causes directory names to be expanded during word completion. For example, Tab completion of ~/doc would expand to ~/Documents/ rather than keeping it as ~/doc.

Sources
95% confidence
A

set -o pipefail (or -T) causes a pipeline to return the exit status of the last command in the pipe that exited with a non-zero status, or zero if all commands exited successfully. Without this, the pipeline returns the exit status of the last command only.

Sources
95% confidence
A

bash -O extglob enables extended pattern matching features. This allows patterns like !(pattern) - match anything except pattern, @(pattern1|pattern2) - match exactly one, *(pattern) - match zero or more, +(pattern) - match one or more, ?(pattern) - match zero or one.

Sources
95% confidence
A

bash -O checkwinsize checks the window size after each command and updates LINES and COLUMNS if the window size has changed. This is enabled by default in interactive shells.

Sources
95% confidence
A

bash -O globasciiranges causes range expressions in glob patterns like [a-z] to be interpreted in ASCII alphabetical order rather than using the current locale's collation order. This is the default in POSIX mode.

Sources
95% confidence
A

bash -O cdspell corrects minor spelling errors in directory names for cd command. For example, cd /usr/locl might autocorrect to /usr/local. It only works when the corrected component exists.

Sources
95% confidence
A

Use 'set -o' without arguments to display all current shell options and their settings. Use 'set -o optionname' to enable an option, 'set +o optionname' to disable. Use '+o' to display options in a format that can be re-used as input.

Sources
95% confidence
A

bash -O histreedit causes a failed history substitution to be reloaded into the readline editing buffer for correction. Without this, a failed history substitution (like !$ when no previous command) results in an error.

Sources
95% confidence
A

set -o history enables command history (enabled by default). This allows commands to be saved to the history list and recalled. Disabling with +o history or set +H turns off command history saving.

Sources
95% confidence
A

The -D option causes bash to list all double-quoted strings prefixed with $ to standard output. These are the strings that are subject to language translation when the current locale is not C or POSIX. This does not execute the script but extracts translatable strings.

Sources
95% confidence
A

The -c option causes bash to read and execute commands from the first non-option argument argument (which must be present), then exit. Any remaining arguments after the command string are assigned to positional parameters starting at $0. Example: bash -c 'echo hello' world

Sources
95% confidence
A

The -v option causes shell input lines to be echoed as they are read. This shows each line before it's executed, useful for debugging. Equivalent to 'set -v' or 'set -o verbose'. Different from -x which shows the expanded command.

Sources
95% confidence
A

set -o onecmd (or -t) causes bash to exit after reading and executing a single command. This is useful for processing one command at a time from input.

Sources
95% confidence
A

The -i option specifies that the shell should be interactive. This forces bash to behave as an interactive shell even if standard input is not a terminal. An interactive shell enables job control, reads commands from stdin with readline, and displays primary and secondary prompts.

Sources
95% confidence
A

bash -O progcomp enables programmable completion. This is the default and allows bash to use custom completion functions specified with complete and compgen builtins.

Sources
95% confidence
A

bash -O dirspell attempts spelling correction on directory names during completion. Similar to cdspell but works during tab completion, not just cd command.

Sources
95% confidence
A

set -o errexit (-e) exits if a pipeline command returns non-zero, except when the exit status is being tested (if, while, until, !, ||, &&), part of compound command except last, or part of any command in a && or || list except the last. It's disabled in subshells by default unless ERR trap is set.

Sources
95% confidence
A

set +o without arguments displays all current shell options in a format that can be re-input to the shell to restore the current settings. This is useful for saving and restoring option states.

Sources
95% confidence
A

Use 'shopt' without arguments to display all current shopt options and their settings. Use 'shopt -s optionname' to enable (set) an option, 'shopt -u optionname' to disable (unset). Use 'shopt -p' to display in a reusable format.

Sources
95% confidence
A

The --norc option prevents bash from reading the ~/.bashrc initialization file for an interactive shell. It's equivalent to setting --norc or skipping the standard personal rc file.

Sources
95% confidence
A

set -o noclobber (or -C) prevents redirection from overwriting existing files. Using > file will fail if file exists. To force overwrite, use >| instead. This protects against accidental data loss when redirecting output.

Sources
95% confidence
A

bash -O promptvars enables prompt string variable expansion and command substitution in prompt strings like PS1. This is enabled by default. Disabling treats prompts as literal strings without expanding $ variables.

Sources
95% confidence
A

bash -O hostcomplete enables hostname completion when completing words containing @. Tab completion attempts to complete hostnames from /etc/hosts. This is enabled by default in interactive shells.

Sources
95% confidence
A

set -o noglob (or -f) disables pathname expansion (globbing). Wildcards like *, ?, and [...] are not expanded to matching filenames.

Sources
95% confidence
A

Many bash invocation options can be toggled after startup using the 'set' builtin. For example, 'set -x' enables tracing like -x, 'set +x' disables it. 'set -o errexit' enables -e behavior. However, some options like --norc, --noprofile, --rcfile only affect startup and cannot be changed later.

Sources
95% confidence
A

bash -v (verbose) prints shell input lines as they are read, before any expansion. bash -x (xtrace) prints commands after expansion but before execution. So -v shows what's in the script file, while -x shows what bash will actually execute with variables expanded.

Sources
95% confidence
A

bash -O nullglob causes patterns that match no files to expand to a null string rather than the pattern itself. Without this, echo .nonexistent prints '.nonexistent'; with nullglob it prints nothing.

Sources
95% confidence
A

set -o nounset (or -u) causes unset variables to be treated as an error when performing parameter expansion. An error is printed to stderr and the shell exits.

Sources
95% confidence
A

bash +O optionname disables (unsets) a shopt option. For example, bash +O extglob script.sh disables extended globbing. The + prefix means 'disable' while -O means 'enable'.

Sources
95% confidence
A

The -P option causes bash to not follow symbolic links when executing commands like cd that change the current working directory. It uses the physical directory structure instead. Equivalent to 'set -P' or 'set -o physical'.

Sources
95% confidence
A

set -o vi enables Vi-style command-line editing in the interactive shell instead of Emacs mode. This uses key bindings similar to the vi editor (ESC to enter command mode, i for insert mode, etc.).

Sources
95% confidence
A

set -o functrace (or -T) causes DEBUG and RETURN traps to be inherited by shell functions and command substitutions. This enables debugging in function calls.

Sources
95% confidence
A

The -k option causes all arguments assignment statements to be placed in the environment for a command, not just those preceding the command name. This allows variable assignments anywhere in the command line. Equivalent to 'set -k' or 'set -o keyword'.

Sources
95% confidence
A

The -B option enables brace expansion (equivalent to set -o braceexpand). This is enabled by default and allows patterns like {a,b,c} to expand to 'a b c' or {1..5} to '1 2 3 4 5'.

Sources
95% confidence
A

shopt -q optionname suppresses output and returns exit status 0 if the option is enabled, 1 if disabled. This is useful for testing option state in scripts without printing anything.

Sources
95% confidence
A

The -C option prevents bash from overwriting existing files with > redirection. You can still override this with >| operator. Equivalent to 'set -C' or 'set -o noclobber'. This provides protection against accidental file overwrites.

Sources
95% confidence
A

bash -O checkhash causes bash to check if a command found in the hash table still exists before executing it. If the command has been deleted, it's searched for in PATH again. This is off by default.

Sources
95% confidence
A

When invoked as 'sh', bash reads /etc/profile and then ~/.profile if it's a login shell. For non-interactive shells, it doesn't read any startup files. It does NOT read ~/.bashrc or /etc/bash.bashrc when invoked as sh.

Sources
95% confidence
A

set -o ignoreeof prevents an interactive shell from exiting upon receiving EOF (Ctrl+D). The user must use 'exit' or 'logout' instead. This prevents accidental shell termination from pressing Ctrl+D.

Sources
95% confidence
A

When using bash -c 'command_string', arguments after the command string are assigned to positional parameters starting at $0. For example: bash -c 'echo $0 $1 $2' arg0 arg1 arg2 prints 'arg0 arg1 arg2'. The command string itself is not assigned to any parameter.

Sources
95% confidence
A

When bash is invoked with the name 'sh' (e.g., via a symlink), it tries to mimic the startup behavior of historical versions of sh as closely as possible while conforming to POSIX. In this mode, bash doesn't read ~/.bashrc and looks for ENV variable for its interactive startup file.

Sources
95% confidence
A

The +T option disables the DEBUG and RETURN trap inheritance (disables functrace). This is the opposite of -T which enables it.

Sources
95% confidence
A

set -o huponexit causes bash to send SIGHUP to all jobs when an interactive login shell exits. This terminates background jobs when you log out. Disabled by default.

Sources
95% confidence
A

set -o physical (or -P) causes bash to not follow symbolic links when changing directories with cd. It uses the physical directory structure instead of the logical one with symlinks.

Sources
95% confidence
A

bash -O execfail causes a non-interactive shell to not exit if it cannot execute the file specified as an argument (e.g., the script file doesn't exist or isn't executable). The shell just reports the error and continues. Default is to exit.

Sources
95% confidence
A

bash -O sourcepath enables the source builtin to use PATH to find the file to source. This is enabled by default. If disabled, source only looks in the current directory.

Sources
95% confidence
A

The -p option turns on privileged mode. In this mode, the $BASH_ENV and $ENV files are not processed, shell functions are not inherited from the environment, and SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE are ignored if set in the environment. This is used when bash runs with real/effective UID/GID differences.

Sources
95% confidence
A

The -b option causes bash to report termination status of background jobs immediately, rather than waiting until just before printing the next primary prompt. This is equivalent to 'set -b' or 'set -o notify'.

Sources
95% confidence
A

bash -O nocasematch causes pattern matching in [[ ... ]] and case statements to be case-insensitive. For example, [[ $name == 'test' ]] matches 'test', 'TEST', 'TeSt', etc.

Sources
95% confidence
A

set -o histexpand (or -H) enables history expansion using ! character. This allows !! (last command), !$ (last argument), !n (command number n), etc. Disabling with +o histexpand turns this feature off.

Sources
95% confidence
A

The --debugger option arranges for the debugger profile to be executed before the shell starts. This allows debugging facilities to be enabled at shell startup. It is equivalent to --debugger or -T but with more explicit naming.

Sources
95% confidence
A

The --noediting option prevents bash from using the GNU Readline library for command-line editing when running interactively. This disables command history, line editing, and tab completion in interactive sessions.

Sources
95% confidence
A

bash -O mailwarn causes bash to print a warning message when a mail file is accessed after the shell has first noticed that mail exists in it. This warns if mail was already read.

Sources
95% confidence
A

The -r option makes the shell restricted. A restricted shell cannot: change directories with cd, change the value of SHELL, PATH, ENV, or BASH_ENV, specify command names containing /, redirect output using >, >|, <>, >&, &>, or >>, or turn off restricted mode with set +r or set +o restricted.

Sources
95% confidence
A

set -o hashall (or -h) enables command hashing (default). Bash remembers the location of commands in a hash table to avoid PATH searches. Disabling with +o hashall turns off this optimization.

Sources
95% confidence
A

The -G option causes the pattern '**' to match all files and zero or more directories and subdirectories when used in pathname expansion. This enables recursive globbing (requires globstar).

Sources
95% confidence
A

The +O option disables (unsets) the shopt option named by the following option argument. This is the opposite of -O. Example: bash +O extglob script.sh disables extended pattern matching.

Sources
95% confidence
A

The -- option signals the end of options. All arguments after -- are treated as filenames and arguments, even if they start with -. This allows handling filenames that begin with -. Example: bash -- -x script.sh treats -x as a filename, not an option.

Sources
95% confidence
A

The +E option disables ERR trap inheritance. This is the opposite of -E. When disabled, ERR traps are not inherited by shell functions, command substitutions, or subshell commands.

Sources
95% confidence
A

The --wordexp option causes bash to print the word expansion results and exit. This shows how bash would expand arguments without executing them. This is a debugging option to test brace expansion, tilde expansion, parameter expansion, etc.

Sources
95% confidence
A

The -m option enables job control. This is enabled by default for interactive shells and allows background job control with commands like bg, fg, jobs, etc. Equivalent to 'set -m' or 'set -o monitor'.

Sources
95% confidence
A

shopt -u optionname disables (unsets) a shell option. This is the opposite of -s which sets/enables options. Example: shopt -u dotglob disables dotglob.

Sources
95% confidence
A

set -o monitor (or -m) enables job control. This allows background/foreground jobs, bg, fg, jobs commands. This is on by default for interactive shells.

Sources
95% confidence
A

When an option is prefixed with + instead of -, it disables that option. For example: bash +o posix disables POSIX mode, bash +x disables command tracing. This is the opposite behavior of the - prefix which enables options.

Sources
95% confidence
A

The -e option causes bash to exit immediately if a command exits with a non-zero status (with some exceptions like pipelines with '!', while/until loops, if conditions, etc.). This is equivalent to 'set -e' or 'set -o errexit'.

Sources
95% confidence
A

When used with shopt, -- marks the end of options. After --, all remaining arguments are treated as option names even if they start with -. This allows setting options that look like flags.

Sources
95% confidence
A

The -O option enables (sets) the shopt option named by the following option argument. This allows setting shell options like extglob, dotglob, etc. at invocation time. Example: bash -O extglob script.sh enables extended pattern matching.

Sources
95% confidence
A

The -H option enables ! style history expansion. This is on by default for interactive shells. It allows commands like !!, !$, !n to reference history. Equivalent to 'set -H' or 'set -o histexpand'.

Sources
95% confidence
A

Bash determines if it's interactive by checking: if it's started with -i option, if standard input is a terminal (tty), and if the -c option is NOT present, and if the -s option is present (implying stdin reading). An interactive shell has job control enabled, displays prompts (PS1/PS2), and reads commands with readline.

Sources
95% confidence
A

The -u option causes bash to treat unset variables as an error when performing parameter expansion. An error message will be written to stderr and the shell will exit. Equivalent to 'set -u' or 'set -o nounset'.

Sources
95% confidence
A

bash -O nocaseglob enables case-insensitive pathname matching. When globbing, * matches both uppercase and lowercase files. For example, *.txt matches file.TXT and file.txt. This is a shopt option, not a set option.

Sources
95% confidence
A

The -s option causes bash to read commands from standard input. This allows positional parameters to be set even when reading from stdin. If there are no arguments remaining after option processing, bash reads from stdin. Any remaining arguments are assigned to positional parameters.

Sources
95% confidence
A

bash -O localvar_unset causes unset of a local variable to unset the variable at all higher scopes. Without this, unsetting a local variable only unsets the local scope, revealing the variable from the calling scope.

Sources
95% confidence

Bash Builtin Commands > Bourne Shell Builtins

72 questions
A

The times builtin prints the accumulated user and system times for the shell and for all processes run as children of the shell. It outputs two lines: one for the shell and one for child processes.

Sources
95% confidence
A

The -d option for read specifies the delimiter character that marks the end of input (instead of newline). The first character of delim is used. If delim is empty, read reads until a NUL character.

Sources
95% confidence
A

The : (colon) builtin does nothing and returns a successful exit status (0). It is also known as the null command and is often used for providing side effects like variable assignment or as a placeholder in then/else clauses.

Sources
95% confidence
A

If CDPATH is set, cd searches each colon-separated directory in CDPATH for the target directory. If the directory is found in CDPATH, cd prints the full path of the new directory.

Sources
95% confidence
A

Yes, the cd builtin updates the PWD variable to the new working directory after successfully changing directories. If the -P option is used, $PWD is set to the physical directory path with symbolic links resolved.

Sources
95% confidence
A

Yes, the break builtin accepts an optional argument n, which specifies the number of enclosing loops to exit from. If n is not specified, break exits from the innermost enclosing loop. n must be >= 1.

Sources
95% confidence
A

No, the shift builtin does not accept negative numbers. The shift builtin shifts positional parameters to the left by n (default 1). The number must be a non-negative integer less than or equal to $#.

Sources
95% confidence
A

When invoked with no arguments, the export builtin displays a list of all exported variables in a format that can be reused as input to the shell. Each exported variable is displayed with 'declare -x' prefix.

Sources
95% confidence
A

No, a readonly variable cannot be unset or have its value changed. Attempting to unset a readonly variable or modify its value results in an error.

Sources
95% confidence
A

The help builtin displays help information for shell builtins. When invoked without arguments, it lists all builtins. It cannot be used to display help for external commands.

Sources
95% confidence
A

The continue builtin accepts an optional argument n, which specifies the number of enclosing loops to skip to the next iteration of. If n is not specified, continue continues with the next iteration of the innermost enclosing loop. n must be >= 1.

Sources
95% confidence
A

The set -u option treats unset variables as an error when expanding. If an unset variable is expanded, bash displays an error message and exits (if not interactive). This helps catch typos in variable names.

Sources
95% confidence

Modifying Shell Behavior > Completion and Readline Integration

69 questions
A

COMP_TYPE is set to an integer value corresponding to the type of completion attempted: TAB for normal completion, '?' for listing completions after successive tabs, '!' for listing alternatives on partial word completion, '@' to list completions if the word is not unmodified, or '%' for menu completion.

Sources
95% confidence
A

COMP_WORDS is an array variable consisting of the individual words in the current command line. The line is split into words as readline would split it, using COMP_WORDBREAKS. This variable is available only in shell functions and external commands invoked by the programmable completion facilities.

Sources
95% confidence
A

The compgen builtin displays possible completions depending on the options. It is intended to be used from within a shell function generating possible completions. If the optional WORD argument is supplied, matches against WORD are generated.

Sources
95% confidence
A

The default value is Off. When set to On, this alters the default completion behavior when inserting a single match into the line. It's only active when performing completion in the middle of a word, and readline does not insert characters from the completion that match characters after point.

Sources
95% confidence
A

The default value is unset, which means the number of history entries is not limited. If set to zero, existing history entries are deleted and no new entries are saved. If set to a value less than zero, the number of history entries is not limited.

Sources
95% confidence
A

COMP_POINT is the index of the current cursor position relative to the beginning of the current command. If the current cursor position is at the end of the current command, the value of this variable is equal to ${#COMP_LINE}.

Sources
95% confidence
A

The default value is Off. When set to On, makes readline use a single line for display, scrolling the input horizontally on a single screen line when it becomes longer than the screen width rather than wrapping to a new line. This setting is automatically enabled for terminals of height 1.

Sources
95% confidence
A

The compopt builtin modifies or displays completion options for each NAME, or if no NAMEs are supplied, the completion currently being executed. If no OPTIONs are given, it prints the completion options for each NAME or the current completion specification.

Sources
95% confidence
A

COMP_WORDBREAKS is the set of characters that the readline library treats as word separators when performing word completion. If COMP_WORDBREAKS is unset, it loses its special properties, even if it is subsequently reset.

Sources
95% confidence
A

The -x option causes a shell command to be executed when KEYSEQ is entered. The syntax is: bind '-x keyseq:shell-command'. This allows binding key sequences to shell commands rather than readline functions.

Sources
95% confidence
A

The default value is On. When set to On, readline will convert characters with the eighth bit set to an ASCII key sequence by stripping the eighth bit and prefixing it with an escape character. readline will set it to Off if the locale contains eight-bit characters.

Sources
95% confidence
A

The default value is 500 (milliseconds). This specifies how long readline will wait for a character when reading an ambiguous key sequence. If set to a value less than or equal to zero, or to a non-numeric value, readline will wait until another key is pressed.

Sources
95% confidence
A

COMP_CWORD is an index into COMP_WORDS of the word containing the current cursor position. This variable is available only in shell functions and external commands invoked by the programmable completion facilities.

Sources
95% confidence

Bash Builtin Commands > Shell Behavior Modification

68 questions
A

The set -m option enables monitor mode (job control). This option is on by default for interactive shells on systems that support it. All processes run in a separate process group. When a background job completes, the shell prints a line containing its exit status.

Sources
95% confidence
A

When shopt -s cmdhist is set, bash attempts to save all lines of a multi-line command in the same history entry. This allows easy re-editing of multi-line commands. This option is enabled by default, but only has an effect if command history is enabled.

Sources
95% confidence
A

When set -P is enabled, the shell does not resolve symbolic links when executing commands such as cd that change the current working directory. It uses the physical directory structure instead. By default, bash follows the logical chain of directories when performing commands which change the current directory.

Sources
95% confidence
A

When shopt -s execfail is set, a non-interactive shell will not exit if it cannot execute the file specified as an argument to the exec builtin command. An interactive shell does not exit if exec fails.

Sources
95% confidence
A

Using set -o displays the current shell options in a readable format. Using set +o displays a series of set commands to recreate the current option settings. Using shopt displays all shopt options and their status. Using shopt -p displays them in a reusable format.

Sources
95% confidence
A

When shopt -s force_fignore is set, the suffixes specified by the FIGNORE shell variable cause words to be ignored when performing word completion even if the ignored words are the only possible completions. This option is enabled by default.

Sources
95% confidence
A

When shopt -s failglob is set, patterns which fail to match filenames during pathname expansion result in an expansion error. Without this option, non-matching patterns are either left unchanged (default) or removed (if nullglob is set).

Sources
95% confidence
A

When set -o posix is used, bash changes its behavior where the default operation differs from the POSIX standard to match the standard (posix mode). This affects many aspects of shell behavior to ensure compliance with POSIX.

Sources
95% confidence
A

When shopt -s globasciirange is set, bash uses the traditional POSIX behavior for range expressions in pattern matching. That is, the current locale's collating sequence is not taken into account, so 'b' will not collate between 'A' and 'B', and upper-case and lower-case ASCII characters will collate together.

Sources
95% confidence
A

The shopt -q option suppresses normal output (quiet mode). The return status indicates whether the optname is set or unset. If multiple optname arguments are given with -q, the return status is zero if all optnames are enabled; non-zero otherwise.

Sources
95% confidence
A

When shopt -s nocasematch is set, bash matches patterns in a case-insensitive fashion when executing case or [[ conditional commands, when performing pattern substitution word expansions, or when filtering possible completions as part of programmable completion.

Sources
95% confidence
A

When shopt -s direxpand is set, bash replaces directory names with the results of word expansion when performing filename completion. This changes the contents of the readline editing buffer. If not set, bash attempts to preserve what the user typed.

Sources
95% confidence
A

After expanding each simple command, for command, case command, select command, or arithmetic for command, bash displays the expanded value of PS4, followed by the command and its expanded arguments or associated word list. This is useful for debugging scripts.

Sources
95% confidence
A

When shopt -s expand_aliases is set, aliases are expanded as described under ALIASES. This option is enabled by default for interactive shells. Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt.

Sources
95% confidence
A

The set -e option causes bash to exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command exits with a non-zero status. The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test following the if or elif reserved words, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted with !.

Sources
95% confidence
A

When shopt -s globstar is set, the pattern ** used in a pathname expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a /, only directories and subdirectories match.

Sources
95% confidence
A

When shopt -s histverify is set, and readline is being used, the results of history substitution are not immediately passed to the shell parser. Instead, the expanded line is reloaded into the readline editing buffer for further modification.

Sources
95% confidence
A

When shopt -s nullglob is set, bash allows patterns which match no files to expand to a null string, rather than being left unchanged. Without this option, if no matching filenames are found, the word is left unchanged.

Sources
95% confidence
A

The set -u option treats unset variables and parameters other than the special parameters '@' and '', or array variables subscripted with '@' or '', as an error when performing parameter expansion. If expansion is attempted on an unset variable or parameter, the shell prints an error message, and, if not interactive, exits with a non-zero status.

Sources
95% confidence
A

When set -T is set, any traps on DEBUG and RETURN are inherited by shell functions, command substitutions, and commands executed in a subshell environment. The DEBUG and RETURN traps are normally not inherited in such cases.

Sources
95% confidence
A

The shopt -p option displays all settable options in a form that may be reused as input. With no options or with the -p option, a list of all settable options is displayed with an indication of whether or not each is set.

Sources
95% confidence
A

When set -C is enabled, bash does not overwrite an existing file with the >, >&, and <> redirection operators. This can be overridden when creating output files by using the redirection operator >| instead of >.

Sources
95% confidence
A

The -- option signals the end of options. All remaining arguments are assigned to the positional parameters. The -x and -v options are turned off. If there are no args, the positional parameters remain unchanged.

Sources
95% confidence
A

Setting GLOBIGNORE to a non-null value has the effect of enabling the dotglob shell option, so all filenames beginning with a '.' will match. To get the old behavior of ignoring filenames beginning with a '.', make '.*' one of the patterns in GLOBIGNORE. The dotglob option is disabled when GLOBIGNORE is unset. The filenames '.' and '..' are always ignored when GLOBIGNORE is set and not null.

Sources
95% confidence
A

When set -o pipefail is enabled, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default. Without this option, the return status of a pipeline is the exit status of the last command.

Sources
95% confidence
A

When shopt -s cdspell is set, minor errors in the spelling of a directory component in a cd command will be corrected. The errors checked for are transposed characters, a missing character, and one character too many. If a correction is found, the corrected filename is printed, and the command proceeds. This option is only used by interactive shells.

Sources
95% confidence
A

When shopt -s extglob is set, the extended pattern matching features are enabled. This includes patterns like ?(pattern-list) for zero or one occurrence, *(pattern-list) for zero or more, +(pattern-list) for one or more, @(pattern-list) for one of the given patterns, and !(pattern-list) for anything except the given patterns. The extglob option changes the behavior of the parser, so it must be enabled before parsing constructs containing the patterns.

Sources
95% confidence
A

When shopt -s histappend is set, the history list is appended to the file named by the value of the HISTFILE variable when the shell exits, rather than overwriting the file. By default, the history file is overwritten.

Sources
95% confidence

Shell Variables > Interactive Shell Behavior

68 questions
A

When nocasematch is enabled, Bash performs pattern matching in a case-insensitive fashion during case command and [[ conditional command matching. This affects both pattern matching and regular expression matching with =~.

Sources
95% confidence
A

HISTIGNORE contains a colon-separated list of patterns used to decide which commands should be saved on the history list. Patterns containing '&' are ANDed with previous patterns, and patterns containing '|' are ORed. A pattern is matched against the full command line. An '&' pattern matches the previous line. For example, setting HISTIGNORE='ls:ps:pwd' will prevent those commands from being saved in history.

Sources
95% confidence
A

When globstar is enabled, the ** pattern in a pathname expansion context will match all files and zero or more directories and subdirectories. If followed by a /, it matches only directories and subdirectories. This pattern is recursive and can be very powerful for deep directory searches.

Sources
95% confidence
A

When mail_warn is enabled, Bash displays a warning message before printing the primary prompt if mail has been received since the last time the mail was checked. This option is only available in interactive shells.

Sources
95% confidence
A

When lithist is enabled, and cmdhist is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators where possible. This preserves the visual structure of the command in history.

Sources
95% confidence
A

When histverify is enabled, and readline is being used, the results of history substitution are not immediately passed to the shell parser. Instead, the expanded line is reloaded into the readline editing buffer for further modification.

Sources
95% confidence
A

INPUTRC contains the filename for the readline startup file, overriding the default ~/.inputrc. If unset, readline reads from ~/.inputrc. If that file doesn't exist, it uses /etc/inputrc.

Sources
95% confidence
A

LC_ALL overrides the value of LANG and any other LC_ variable specifying a locale category. It provides a way to set all locale categories to a single locale.

Sources
95% confidence
A

REPLY stores the user's input when the read builtin is called without variable arguments. It is also used by the select command to store the user's selection. This default variable is used when no variable name is supplied to read or select.

Sources
95% confidence
A

When cdspell is enabled, minor errors in the spelling of a directory component in a cd command are corrected. The errors checked for are transposed characters, a missing character, and one character too many. Corrections are only applied if the corrected directory name exists.

Sources
95% confidence
A

When auto_cd is enabled, if a command name is not a valid command but is the name of a directory in the current directory, Bash automatically performs a cd to that directory. This option is only available in interactive shells.

Sources
95% confidence
A

FCEDIT specifies the default editor for the fc builtin command. If not set, the default editor is 'ed'. The fc command is used to list, edit, and re-execute commands from the command history.

Sources
95% confidence
A

TERM specifies the terminal type for readline and other programs that use the terminfo database. Common values include 'xterm-256color', 'vt100', 'screen', etc. It affects display capabilities like color support and cursor movement.

Sources
95% confidence
A

When execfail is enabled, a non-interactive shell will not exit if it cannot execute the file specified as an argument to the exec builtin. An interactive shell does not exit if exec fails. This option is only available in interactive shells.

Sources
95% confidence
A

If set to a value greater than zero, TMOUT is treated as the default timeout for the read builtin (see Bash Builtins). The select command terminates if input does not arrive after TMOUT seconds when input is coming from a terminal. In an interactive shell, if TMOUT is set to a value greater than zero and not equal to the default (60 seconds), bash will terminate after waiting for that number of seconds for input.

Sources
95% confidence
A

HISTCONTROL controls how commands are saved to the history list. It can be set to: 'ignorespace' (lines beginning with a space are not saved), 'ignoredups' (lines matching the last history line are not saved), 'ignoreboth' (both ignorespace and ignoredups), or 'erasedups' (all previous lines matching the current line are removed from the history list before that line is saved).

Sources
95% confidence
A

LINES determines the height of the screen used for displaying select menus and line editing prompts. If not set, Bash attempts to set it automatically based on the terminal size. The value is updated by the checkwinsize option if the window size changes.

Sources
95% confidence
A

DISPLAY contains the X11 display server to connect to for GUI applications. The format is typically 'hostname:display.screen' or ':display' for local displays. Without this variable set, X11 applications cannot open windows.

Sources
95% confidence
A

HOSTFILE contains the name of a file in the same format as /etc/hosts that should be read when the shell needs to complete a hostname. The list of possible hostname completions may be changed while the shell is running; the next time hostname completion is attempted, Bash adds the contents of the new file to the existing list. If HOSTFILE is set but has no value, Bash attempts to read /etc/hosts for hostname completion.

Sources
95% confidence
A

TERM_PROGRAM is set by some terminal emulators to indicate which program is running. For example, Terminal.app sets it to 'Apple_Terminal' and iTerm2 sets it to 'iTerm.app'. This allows shell scripts to detect and adapt to specific terminal features.

Sources
95% confidence
A

FIGNORE contains a colon-separated list of suffixes to ignore when performing filename completion. A filename whose suffix matches one of the entries in FIGNORE is excluded from the list of matched filenames. For example, setting FIGNORE='.o:~' will ignore files ending in .o or ~ during completion.

Sources
95% confidence
A

TIMEFORMAT specifies the format for the time string printed by the time reserved word. The format can include escape sequences like %R (real time), %U (user CPU time), %S (system CPU time), %P (CPU percentage), and more. If not set, Bash acts as if $TIMEFORMAT=$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS' were set. If the value is null, no timing information is displayed.

Sources
95% confidence
A

When restricted_shell is enabled, it indicates the shell is in restricted mode. This is a read-only option that cannot be unset. Restricted mode disables certain operations that could be used to subvert restrictions, such as changing directories, modifying environment variables, or redirecting output.

Sources
95% confidence
A

When compat32 is enabled, Bash changes its behavior to match version 3.2 with respect to the treatment of invalid character classes in bracket expressions used by pattern matching and pathname expansion.

Sources
95% confidence
A

MAILCHECK specifies how often (in seconds) Bash checks for mail in the files specified by the MAILPATH or MAIL variables. The default is 60 seconds. When set to 0, Bash checks for mail before each primary prompt is displayed.

Sources
95% confidence
A

When checkhash is enabled, Bash checks that a command found in the hash table exists before trying to execute it. If a hashed command no longer exists, a normal path search is performed.

Sources
95% confidence
A

IGNOREEOF controls the action of an interactive shell on receipt of an EOF character as the sole input. If set, the value is the number of consecutive EOF characters that must be typed as the first characters on an input line before bash exits. If the variable exists but does not have a numeric value, or has no value, then the default is 10. If the variable does not exist, EOF signifies the end of input to the shell.

Sources
95% confidence
A

When cmdhist is enabled, Bash attempts to save all lines of a multiple-line command in the same history entry. This allows easy re-editing of multi-line commands. This option is enabled by default.

Sources
95% confidence
A

EDITOR specifies the default editor used by various shell commands and programs. When Bash needs to invoke an editor (for example, with fc -e), it uses this variable if VISUAL is not set. Common values include 'vi', 'vim', 'nano', or 'emacs'.

Sources
95% confidence
A

COLUMNS determines the width of the screen used for displaying select menus and line editing prompts. If not set, Bash attempts to set it automatically based on the terminal size. The value is updated by the checkwinsize option if the window size changes.

Sources
95% confidence
A

When xpg_echo is enabled, the echo builtin expands backslash escape sequences by default. This matches the behavior defined by the POSIX standard. Without this option, echo does not expand escape sequences unless the -e option is given.

Sources
95% confidence
A

If HISTTIMEFORMAT is set and not null, its value is used as a format string for strftime(3) to print the timestamp associated with each history entry displayed by the history builtin. If this variable is set, time stamps are written to the history file so they may be preserved across shell sessions.

Sources
95% confidence
A

When promptvars is enabled, prompt strings undergo variable and parameter expansion, command substitution, and arithmetic expansion after being expanded. This option is enabled by default, allowing dynamic prompts using variables like \u, \w, etc.

Sources
95% confidence
A

LANG determines the locale category for any category not specifically selected with a variable starting with LC_. It affects how strings are displayed, sorted, and compared throughout the shell.

Sources
95% confidence
A

When progcomp is enabled, programmable completion facilities are enabled. This option is enabled by default in interactive shells. It allows the use of programmable completion functions with the complete and compgen builtins.

Sources
95% confidence
A

When compat31 is enabled, Bash changes its behavior to match version 3.1 with respect to quoted arguments to the [[ conditional command's =~ operator and locale-specific string comparison when using the [[ conditional command's < and > operators.

Sources
95% confidence
A

When nullglob is enabled, Bash allows filename patterns which match no files to expand to a null string, rather than themselves. This is useful in scripts where you want to gracefully handle the case where no files match a pattern.

Sources
95% confidence
A

When login_shell is enabled, it indicates that the shell is a login shell. This is a read-only option that cannot be modified. It is automatically set by Bash when the shell is started as a login shell.

Sources
95% confidence
A

When histappend is enabled, the history list is appended to the file named by the HISTFILE variable when the shell exits, rather than overwriting the file. This allows multiple shell sessions to share the same history file without losing history from other sessions.

Sources
95% confidence
A

When interactive_comments is enabled, a word beginning with # causes that word and all remaining characters on that line to be ignored in an interactive shell. This option is enabled by default. This allows comments in interactive command lines.

Sources
95% confidence
A

When nocaseglob is enabled, Bash matches filenames in a case-insensitive fashion when performing filename expansion. This is useful on case-sensitive filesystems when you want to match files regardless of case.

Sources
95% confidence
A

MAPFILE is an array variable that holds the text read by the mapfile builtin when no variable name is supplied. The mapfile builtin reads lines from standard input into an array variable.

Sources
95% confidence
A

GLOBIGNORE is a colon-separated list of patterns defining the set of file names to be ignored by filename expansion. If a file name matched by a filename expansion pattern also matches one of the patterns in GLOBIGNORE, it is removed from the list of matches. When this variable is set, dot files do not need to be matched explicitly.

Sources
95% confidence

Command Line Editing > History Operations

64 questions
A

histchars is a 2-3 character string controlling history expansion. The first character is the history expansion character (default '!'), the second is the quick substitution character (default '^'), and the third (if present) is the comment character when history expansion is performed (default '#').

Sources
95% confidence
A

When HISTCONTROL=erasedups, all previous lines matching the current line are removed from the history list before that line is saved. This ensures that each unique command appears only once in the history, keeping only the most recent occurrence.

Sources
95% confidence
A

HISTCONTROL controls which commands are saved in the history list. Common values include: 'ignorespace' (don't save commands starting with space), 'ignoredups' (don't save duplicate commands), 'ignoreboth' (both ignorespace and ignoredups), and 'erasedups' (remove all previous occurrences of a command before saving).

Sources
95% confidence
A

'history -s arg' adds 'arg' to the end of the history list as if it had been entered as a command. This doesn't execute the command, just adds it to history.

Sources
95% confidence
A

HISTFILE specifies the filename where the command history is saved. The default is ~/.bash_history. If unset, the history is not saved when an interactive shell exits.

Sources
95% confidence
A

'history -n' reads the history file and appends its contents to the current history list. This is useful for incorporating history from other concurrent shell sessions.

Sources
95% confidence
A

HISTFILESIZE sets the maximum number of lines to contain in the history file (~/.bash_history) on login. The default is typically 500. Setting it to 0 truncates the history file to zero size.

Sources
95% confidence
A

'history -d offset' deletes the history entry at position 'offset'. If offset is negative, it counts from the end of the history list. The history is renumbered after deletion.

Sources
95% confidence
A

'history -p' performs history expansion on each argument but doesn't execute the result. This displays what the expansion would produce. It's useful for debugging history expansion.

Sources
95% confidence
A

'history -r' reads the history file and appends its contents to the current history list, similar to -n. It's typically used to reload history.

Sources
95% confidence
A

'history -w' writes out the current history list to the history file, overwriting it completely. This differs from -a which only appends new entries.

Sources
95% confidence
A

'fc -s [pat=rep ...] [command]' re-executes a command after substituting 'pat' with 'rep'. 'fc -e editor [first] [last]' opens the commands in an editor for editing before execution. If no editor is specified, the value of FCEDIT is used (defaulting to ed if FCEDIT is unset).

Sources
95% confidence
A

HISTIGNORE is a colon-separated list of patterns determining which commands should not be saved in the history list. Commands matching any pattern are ignored. For example, 'HISTIGNORE="ls:pwd:exit"' would ignore those specific commands.

Sources
95% confidence
A

'fc -l' lists the history commands. The format is 'fc -l [first] [last]' where 'first' and 'last' can be numbers or strings. Without arguments, it lists the last 16 commands.

Sources
95% confidence
A

'history -c' clears the history list by deleting all the entries. This only affects the current shell session's in-memory history, not the history file.

Sources
95% confidence
A

FCEDIT specifies the editor used by the 'fc' builtin command when no editor is specified with -e. If unset, 'ed' is used as the default editor.

Sources
95% confidence

Readline Init File > Key Bindings

64 questions

Shell Expansions > Text Processing Expansions

64 questions
A

If nullglob disabled: word left unchanged. If nullglob enabled: word removed. If failglob enabled: error message printed, command not executed.

Sources
95% confidence
A

The standard form is $(command). The backtick form command is deprecated. Bash performs command substitution by executing command in a subshell and replacing with standard output, with trailing newlines deleted.

Sources
95% confidence
A

The shell scans results of parameter expansion, command substitution, and arithmetic expansion that did NOT occur within double quotes for word splitting.

Sources
95% confidence
A

Brace expansion is a mechanism to generate arbitrary strings that do not need to exist as filenames. It takes the form of an optional preamble, followed by comma-separated strings or a sequence expression between braces, followed by an optional postscript. Brace expansion is performed BEFORE any other expansions, and any characters special to other expansions are preserved in the result. It is strictly textual and Bash does not apply syntactic interpretation to the text between braces.

Sources
95% confidence
A

A sequence expression takes the form {x..y[..incr]}, where x and y are either integers or letters, and incr is an optional increment integer. The default increment is 1 or -1 as appropriate. When integers are prefixed with 0, the shell forces each term to have the same width with zero-padding.

Sources
95% confidence
A

If parameter is null or unset, nothing is substituted. Otherwise, the expansion of word is substituted. The value of parameter itself is not used.

Sources
95% confidence
A

The expression undergoes the same expansions as if within double quotes, but double quotes are not treated specially and are removed. All tokens undergo parameter expansion, command substitution, and quote removal. Arithmetic expansions may be nested.

Sources
95% confidence
A

${parameter,,pattern} converts uppercase letters matching pattern to lowercase. It examines ALL characters and converts each one that matches pattern.

Sources
95% confidence
A

If first character of parameter is ! and not nameref, introduces indirection. Bash uses value formed by expanding rest of parameter as new parameter; this is then expanded. ! must immediately follow left brace.

Sources
95% confidence
A

If offset evaluates to a number less than zero, the value is used as an offset in characters from the END of the value. A negative offset must be separated from the colon by at least one space to avoid confusion with the :- expansion.

Sources
95% confidence
A

If parameter is null or unset, the shell writes the expansion of word (or a message to that effect if word is not present) to standard error and, if the shell is not interactive, exits with a non-zero status. An interactive shell does not exit but does not execute the command.

Sources
95% confidence
A

${parameter,pattern} converts uppercase letters matching pattern to lowercase. It only examines and converts the FIRST character if it matches pattern.

Sources
95% confidence
A

Process substitution allows a process input or output to be referred to using a filename. Forms: <(list) or >(list). Process runs asynchronously, input/output appears as filename passed as argument.

Sources
95% confidence
A

${parameter^pattern} converts lowercase letters matching pattern to UPPERCASE. It only examines and converts the FIRST character if it matches pattern.

Sources
95% confidence
A

If IFS is unset, or its value is exactly (the default), sequences at beginning and end are ignored, other sequences delimit words.

Sources
95% confidence
A

If name is an array variable, ${!name[@]} expands to the list of array indices (keys). When used within double quotes, each key expands to a separate word.

Sources
95% confidence
A

GLOBIGNORE restricts matching filenames. Each matching filename also matching patterns in GLOBIGNORE is removed. Setting to non-null enables dotglob. . and .. always ignored when GLOBIGNORE is set and not null.

Sources
95% confidence
A

Yes. ${var:=word} assigns the expansion of word to parameter if it is unset or null, and the result is the final value. Positional parameters and special parameters cannot be assigned this way.

Sources
95% confidence
A

Bash performs expansions in the following order: 1. Brace expansion, 2. Tilde expansion, 3. Parameter and variable expansion, 4. Arithmetic expansion, 5. Command substitution, 6. Word splitting, 7. Filename expansion.

Sources
95% confidence
A

No, the results of brace expansion are not sorted; left to right order is preserved. For example, echo a{d,c,b}e outputs ade ace abe (not alphabetical).

Sources
95% confidence
A

${parameter@E} expands to the value with backslash escape sequences expanded as with the $'...' quoting mechanism.

Sources
95% confidence
A

${#parameter} substitutes the LENGTH in characters of the value. If parameter is * or @, substitutes number of positional parameters. If parameter is array name, substitutes number of elements.

Sources
95% confidence
A

After word splitting (unless -f option set), Bash scans each word for unquoted *, ?, and [. If one appears, word is replaced with alphabetically sorted list of matching filenames.

Sources
95% confidence
A

${parameter^^pattern} converts lowercase letters matching pattern to UPPERCASE. It examines ALL characters and converts each one that matches pattern.

Sources
95% confidence
A

${parameter@A} expands to a string in the form of an assignment statement or declare command that recreates parameter with its attributes and value.

Sources
95% confidence

Shell Expansions > Pattern-Based Expansions

62 questions
A

When set, range expressions in pattern matching bracket expressions behave as if in the traditional C locale. Pattern matching does not take the current locale's collating sequence into account, so 'b' will not collate between 'A' and 'B', and uppercase and lowercase ASCII characters will collate together.

Sources
95% confidence
A

When dotglob is enabled, the set of filenames includes all files beginning with '.', but '.' and '..' must be matched explicitly. When disabled, the set does not include any filenames beginning with '.' unless the pattern begins with a '.'.

Sources
95% confidence
A

The order of expansions is: 1) brace expansion, 2) tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion), 3) word splitting, and 4) filename expansion.

Sources
95% confidence
A

Bash scans each word for the characters '*', '?', and '['. If one of these characters appears and is not quoted, the word is regarded as a pattern and replaced with an alphabetically sorted list of filenames matching the pattern.

Sources
95% confidence
A

When the globstar shell option is enabled and '' is used in a filename expansion context, two adjacent ''s used as a single pattern match all files and zero or more directories and subdirectories. If followed by a '/', two adjacent '*'s match only directories and subdirectories.

Sources
95% confidence
A

If the login name is the null string, the tilde is replaced with the value of the HOME shell variable. If HOME is unset, the home directory of the user executing the shell is substituted instead.

Sources
95% confidence
A

The sorting order of characters in range expressions and the characters included are determined by the current locale and LC_COLLATE/LC_ALL variables. In the default C locale, '[a-dx-z]' equals '[abcdxyz]', but in dictionary-order locales it may equal '[aBbCcDdxYyZz]'.

Sources
95% confidence
A

Each variable assignment is checked for unquoted tilde-prefixes immediately following a ':' or the first '='. This allows using tildes in assignments to PATH, MAILPATH, and CDPATH. Bash also performs tilde expansion on words satisfying variable assignment conditions when they appear as arguments to simple commands, except in POSIX mode.

Sources
95% confidence
A

Yes, brace expansions may be nested. The results of each expanded string are not sorted; left to right order is preserved.

Sources
95% confidence
A

When a pattern is used for filename expansion, the character '.' at the start of a filename or immediately following a slash must be matched explicitly, unless the shell option dotglob is set. When not matching filenames, the '.' character is not treated specially.

Sources
95% confidence

Bourne Shell Builtins > Variable and Environment Management

58 questions
A

The shift builtin shifts positional parameters. It renames positional parameters $N+1,$N+2... to $1,$2... If N is not given, it is assumed to be 1.

Sources
95% confidence
A

No, readonly variables cannot be unset. The unset command will fail with a non-zero exit status when attempting to unset a readonly variable.

Sources
95% confidence
A

The export builtin marks shell variables for automatic export to the environment of subsequently executed commands. If VALUE is supplied, it assigns VALUE before exporting.

Sources
95% confidence
A

The set - command assigns any remaining arguments to the positional parameters and turns off the -x and -v options.

Sources
95% confidence
A

The local builtin creates local variables within functions. Local variables can only be used within a function and are visible only to the function where they are defined and its children.

Sources
95% confidence
A

The pipefail option causes the return value of a pipeline to be the status of the last command to exit with a non-zero status, or zero if no command exited with a non-zero status.

Sources
95% confidence
A

The readonly builtin marks shell variables as unchangeable. The values of these names may not be changed by subsequent assignment.

Sources
95% confidence
A

The -P option prevents the shell from resolving symbolic links when executing commands such as cd which change the current directory (physical).

Sources
95% confidence
A

The -g option creates global variables when used in a shell function; otherwise it is ignored. This suppresses the local behavior of declare in functions.

Sources
95% confidence
A

The declare builtin declares variables and gives them attributes. If no NAMEs are given, it displays the attributes and values of all variables.

Sources
95% confidence
A

The unset builtin removes values and attributes of shell variables and functions. For each NAME, it removes the corresponding variable or function.

Sources
95% confidence
A

The -k option causes all assignment arguments to be placed in the environment for a command, not just those that precede the command name (keyword).

Sources
95% confidence

Interactive Shells > Command Line Editing

56 questions
A

unset (uses HISTSIZE shell variable). If set to zero, existing history entries are deleted and no new entries are saved. If set to a value less than zero, the number of history entries is not limited. If set to a non-numeric value, it defaults to 500.

Sources
95% confidence
A

emacs. The keymap variable can be set to: emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-command (synonyms: vi or vi-move), and vi-insert. The default value is emacs.

Sources
95% confidence
A

Displays readline variable names and values in such a way that they can be re-read (parseable format).

Sources
95% confidence
A

Displays readline function names and bindings in such a way that they can be re-read (parseable format).

Sources
95% confidence
A

Causes shell-command to be executed whenever keyseq is entered. When executed, the shell sets READLINE_LINE to the contents of the line buffer, and READLINE_POINT and READLINE_MARK to the current location of the insertion point and mark. Numeric arguments are stored in READLINE_ARGUMENT.

Sources
95% confidence

Installing Bash > Installation Customization

55 questions

Readline Init File > Variable Settings

54 questions
A

The default value is 'unset', meaning the number of history entries is not limited. When set to zero, existing history entries are deleted and no new entries are saved. When set to a value less than zero, the number of history entries is not limited.

95% confidence
A

The default value is 'Off'. When set to On, readline will display characters with the eighth bit set directly rather than as a meta-prefixed escape sequence. Readline will set it to On if the locale contains eight-bit characters.

95% confidence

Conditional Constructs > Branching Conditionals

54 questions
A

if list; then list; [ elif list; then list; ] ... [ else list; ] fi - The if list is executed, and if its exit status is zero, the then list is executed. Otherwise, each elif list is executed in turn, and if its exit status is zero, the corresponding then list is executed. If no elif succeeds, the else list (if any) is executed.

Sources
95% confidence

Shell Functions > Parameter and Argument Handling

53 questions
A

When not executing a function, FUNCNAME is unset or has a single element 'main' (depending on Bash version and context). The array only contains meaningful function names when within function call context. In the main script execution, FUNCNAME[0] may not contain a useful value.

Sources
95% confidence
A

The ${parameter:=word} syntax assigns default values. If parameter is unset or null, the expansion of word is assigned to parameter and then substituted. This differs from :- in that it actually assigns the value to the variable, not just uses it for expansion.

Sources
95% confidence
A

FUNCNAME is an array variable containing the names of all shell functions currently in the execution call stack. FUNCNAME[0] is the name of the currently executing function, FUNCNAME[1] is the function that called it, FUNCNAME[2] is the function that called that one, and so on.

Sources
95% confidence
A

The ${parameter:-word} triggers on both unset AND null values, while ${parameter-word} only triggers when parameter is unset (not when it's null/empty). The :- version is more commonly used to handle missing arguments regardless of whether they were passed as empty strings.

Sources
95% confidence
A

While they are often equivalent, ${var} is safer and more versatile. Braces are required for: positional parameters with 2+ digits (${10}), expansion operations (${var:-default}), substring expansion (${var:1:3}), and when the variable name is adjacent to alphanumeric characters (echo ${var}text). Braces make the variable boundaries explicit.

Sources
95% confidence
A

OPTIND is the index of the next argument to be processed by getopts. It is initialized to 1 each time the shell or a shell script is invoked. When an option requires an argument, getopts places that argument in OPTARG and increments OPTIND to point to the next argument.

Sources
95% confidence
A

The local command can create local array variables. For example, local arr=("$@") creates a local array containing all positional parameters. Local arrays hide any global arrays with the same name. However, you cannot use local to make individual array elements local - you must declare the entire array as local.

Sources
95% confidence
A

The ${!name} syntax performs indirect expansion. If name is the name of a variable (e.g., var=foo; foo=bar), then ${!var} expands to the value of the variable whose name is the value of var (so ${!var} gives bar). This allows for dynamic variable references.

Sources
95% confidence
A

Variables declared with local or declare inside a function have local scope and hide variables with the same name in outer scopes (including global variables). The local scope remains in effect until the function returns. Bash uses dynamic scoping for variables.

Sources
95% confidence
A

The ${#parameter} syntax expands to the length in characters of the value of parameter. If parameter is * or @, the result is the number of positional parameters. For example, ${#1} gives the length of the first argument's string value.

Sources
95% confidence
A

Starting with Bash 4.0, shift accepts a negative argument which shifts parameters to the right. For example, shift -2 effectively shifts positional parameters $1 and $2 out of existence and sets $# to $# - 2. This is less commonly used but available for specific manipulation needs.

Sources
95% confidence
A

BASH_ARGC is an array containing the number of parameters in each frame of the current bash execution call stack. BASH_ARGV is an array containing all the parameters in the current bash execution call stack. They are only available in debugging mode (when extdebug is enabled with shopt -s extdebug).

Sources
95% confidence
A

The ${parameter:-} syntax with an empty word expands to nothing if parameter is unset or null, and to the value of parameter otherwise. This is useful for providing a default empty string rather than the literal string 'null' or similar when a parameter is missing.

Sources
95% confidence
A

The set -- command with no arguments clears all positional parameters. When followed by arguments (e.g., set -- arg1 arg2), it sets the positional parameters to those arguments, replacing all existing ones. This is commonly used to reset or reassign $1, $2, etc.

Sources
95% confidence
A

The ${parameter/pattern/string} syntax replaces the first match of pattern with string. To replace all matches, use ${parameter//pattern/string}. If string is omitted (just ${parameter/pattern/}), the matched portions are deleted. If pattern begins with #, it must match at the beginning; if it begins with %, it must match at the end.

Sources
95% confidence
A

The ${!prefix*} and ${!prefix@} syntax expands to the names of variables whose names begin with prefix. The @ form causes the expansion to result in separate words when quoted, while the * form results in a single word. This is useful for enumerating variables with a common prefix.

Sources
95% confidence
A

The return builtin causes a function to exit with the specified exit status value (0-255). If no value is provided, return returns the exit status of the last command executed. Return can only be used within functions and sourced scripts, not in the main script execution.

Sources
95% confidence
A

Some builtin variables like BASH_REMATCH have special behavior when declared local. Declaring BASH_REMATCH as local in a function creates a new variable that shadows the global one but may not behave identically. The official manual warns about potential issues with declaring certain built-in variables as local.

Sources
95% confidence
A

getopts is a builtin that parses positional parameters. Each time it is invoked, it retrieves the next option from the command line, placing it in the variable name specified (typically opt), and the option argument in OPTARG if required. getopts returns true when an option is found, false when the end of options is reached. It silently stops at the first non-option argument unless OPTERR is set to 0.

Sources
95% confidence
A

BASHPID expands to the process ID of the current Bash process. This differs from $$ in subshells: $$ is the PID of the original shell, while BASHPID is the PID of the current shell instance (including subshells). BASHPID is typically the same as $$ unless in a subshell.

Sources
95% confidence
A

When offset is negative in ${parameter:offset:length}, it counts from the end of the value. For example, ${1: -3} gives the last 3 characters of $1. Note that when using negative offsets, a space before the negative number is required to distinguish it from the default value syntax.

Sources
95% confidence

Bash Builtin Commands > Bash-Specific Builtins

53 questions
A

The option can be any of the options accepted by declare. When local is used within a function, it causes the variable name to have a visible scope restricted to that function and its children.

95% confidence
A

The -t option gives each name the trace attribute. Traced functions inherit the DEBUG and RETURN traps from the calling shell. The trace attribute has no special meaning for variables.

95% confidence
A

The -I option causes local variables to inherit the attributes (except the nameref attribute) and value of any existing variable with the same name at a surrounding scope. If there is no existing variable, the local variable is initially unset.

95% confidence
A

The -D option indicates that other supplied options and actions should apply to the 'default' command completion; that is, completion attempted on a command for which no completion has previously been defined.

95% confidence
A

The -P option forces a PATH search for each name, even if 'type -t name' would not return file. If a command is hashed, -p and -P print the hashed value, which is not necessarily the file that appears first in PATH.

95% confidence
A

The return value is true unless an invalid option is supplied, an attempt is made to modify the options for a name for which no completion specification exists, or an output error occurs.

95% confidence
A

If name is -, the set of shell options is made local to the function: shell options changed using the set builtin inside the function are restored to their original values when the function returns. The restore is effected as if a series of set commands were executed to restore the values that were in place before the function.

95% confidence
A

The -n option disables each specified shell builtin. Disabling a builtin allows a disk command with 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. For example, to use the test binary found via PATH instead of the shell builtin version, run 'enable -n test'.

95% confidence
A

The -f option loads a new builtin command name from a shared object filename (on systems that support dynamic loading). Bash uses the value of the BASH_LOADABLES_PATH variable as a colon-separated list of directories to search for filename. The default is system-dependent.

95% confidence
A

The -D option indicates that other supplied options should apply to the 'default' command completion; that is, completion attempted on a command for which no completion has previously been defined.

95% confidence
A

compgen generates possible completion matches for word according to the options, which may be any option accepted by the complete builtin with the exception of -p and -r, and writes the matches to standard output. If word is specified, only those completions matching word will be displayed.

95% confidence
A

The filenames option tells readline that the compspec generates filenames, so it can perform any filename-specific processing (like adding a slash to directory names, quoting special characters, or suppressing trailing spaces). Intended to be used with shell functions.

95% confidence
A

The -I option indicates that other supplied options should apply to completion on the initial non-assignment word on the line, or after a command delimiter such as ; or |, which is usually command name completion.

95% confidence
A

The -n option gives each name the nameref attribute, making it a name reference to another variable. That other variable is defined by the value of name. All references, assignments, and attribute modifications to name, except those using or changing the -n attribute itself, are performed on the variable referenced by name's value. The nameref attribute cannot be applied to array variables.

95% confidence
A

compopt modifies completion options for each name according to the options, or for the currently-executing completion if no names are supplied. If no options are given, it displays the completion options for each name or the current completion.

95% confidence

Controlling the Prompt > Terminal Control

51 questions
A

The default value of convert-meta is 'On', which means readline will convert characters with the eighth bit set to an ASCII key sequence by stripping the eighth bit and prefixing an escape character. Readline sets it to Off if the locale contains eight-bit characters.

Sources
95% confidence
A

PROMPT_DIRTRIM, when set to a number greater than zero, is used as the number of trailing directory components to retain when expanding the \w and \W prompt string escapes. Characters removed are replaced with an ellipsis.

Sources
95% confidence

Command Line Editing > Completion

51 questions
A

The set of characters that the readline library treats as word separators when performing word completion. If unset, it loses its special properties, even if subsequently reset.

Sources
95% confidence
A

match-hidden-files (default: On). When set to On, readline matches files whose names begin with a '.' (hidden files) when performing filename completion. If set to Off, the leading '.' must be supplied by the user in the filename to be completed.

Sources
95% confidence
A

COMP_LINE (current command line), COMP_POINT (index of current cursor position), COMP_KEY (key that invoked completion), COMP_TYPE (type of completion attempted), COMP_WORDS (array of individual words in command line), and COMP_CWORD (index into COMP_WORDS of the word containing the current cursor position).

Sources
95% confidence
A

alias (-a), arrayvar, binding, builtin (-b), command (-c), directory (-d), disabled, enabled, export (-e), file (-f), function, group (-g), helptopic, hostname, job (-j), keyword (-k), running, service (-s), setopt, shopt, signal, stopped, user (-u), variable (-v).

Sources
95% confidence
A

TAB (complete command). When pressed, bash attempts completion treating the text as a variable (if begins with $), username (if begins with ~), hostname (if begins with @), or command (including aliases and functions) in turn. If none of these produces a match, filename completion is attempted.

Sources
95% confidence
A

compopt modifies completion options for each name according to the options, or for the currently-executing completion if no names are supplied. If no options given, displays completion options. Unlike complete, it doesn't define new completions but modifies options for existing ones. Can use +o to turn off an option.

Sources
95% confidence
A

The order is: 1) Actions specified by compspec options (-f, -d, etc.) with FIGNORE filtering. 2) Pathname expansion patterns from -G option. 3) Wordlist from -W option after brace/tilde/parameter/arithmetic expansion. 4) Shell function from -F option. 5) Command from -C option. 6) Filter from -X option. 7) Prefix/suffix from -P/-S options. If no matches and -o dirnames was supplied, directory completion is attempted. If -o plusdirs was supplied, directory matches are added to results.

Sources
95% confidence
A

COMP_TYPE is set to an integer value corresponding to the type of completion attempted: TAB for normal completion, ? for listing completions after successive tabs, ! for listing alternatives on partial word completion, @ to list completions if the word is not unmodified, or % for menu completion.

Sources
95% confidence
A

skip-completed-text (default: Off). When set to On, it alters the default completion behavior when inserting a single match into the line. It's only active when performing completion in the middle of a word. If enabled, readline does not insert characters from the completion that match characters after point in the word being completed, so portions of the word following the cursor are not duplicated.

Sources
95% confidence
A

filterpat is a pattern as used for pathname expansion. It is applied to the list of possible completions generated by the preceding options and arguments, and each completion matching filterpat is removed from the list. A leading ! in filterpat negates the pattern; any completion not matching filterpat is removed. A & in the pattern is replaced with the text of the word being completed.

Sources
95% confidence
A

The word before point is treated as a pattern for pathname expansion, with an asterisk implicitly appended. This pattern is used to generate a list of matching filenames for possible completions.

Sources
95% confidence
A

The wordlist is split using characters in the IFS special variable as delimiters, and each resultant word is expanded using brace expansion, tilde expansion, parameter and variable expansion, command substitution, and arithmetic expansion. The results are prefix-matched against the word being completed, and matching words become possible completions.

Sources
95% confidence
A

First, if the command word is empty, compspecs defined with -E are used. If compspec defined for that command, it's used. If command word is a full pathname, compspec for full pathname is searched first, then portion after final slash. If not found, compspec with -D is used as default. If no default compspec, bash attempts alias expansion and tries to find compspec for expanded command word.

Sources
95% confidence
A

Performs filename completion and inserts the list of possible completions enclosed within braces so the list is available to the shell (for Brace Expansion).

Sources
95% confidence
A

If set, and programmable completion is enabled, bash treats a command name that doesn't have any completions as a possible alias and attempts alias expansion. If it has an alias, bash attempts programmable completion using the command word resulting from the expanded alias.

Sources
95% confidence
A

The default value is 100. It determines when the user is queried about viewing the number of possible completions. If the number of possible completions is greater than or equal to this value, readline will ask whether the user wishes to view them; otherwise they are simply listed. A value of zero means readline should never ask.

Sources
95% confidence
A

-D applies completions to the 'default' command completion (commands with no specific completion defined). -E applies completions to 'empty' command completion (completion attempted on a blank line). -I applies completions to the initial non-assignment word on the line, or after a command delimiter such as ; or | (usually command name completion). If multiple options are supplied, -D takes precedence over -E, and both take precedence over -I.

Sources
95% confidence
A

Tell readline that the compspec generates filenames, so it can perform any filename-specific processing (like adding a slash to directory names, quoting special characters, or suppressing trailing spaces). Intended to be used with shell functions.

Sources
95% confidence
A

The word before point is treated as a pattern for pathname expansion, and the list of matching filenames is inserted, replacing the word. If a numeric argument is supplied, an asterisk is appended before pathname expansion.

Sources
95% confidence
A

Two key variables: 1) show-all-if-ambiguous (default: Off) - if set to On, words with multiple possible completions cause matches to be listed immediately instead of ringing the bell. 2) show-all-if-unmodified (default: Off) - if set to On, words with multiple possible completions without any possible partial completion cause matches to be listed immediately instead of ringing the bell.

Sources
95% confidence
A

The default value is 0. It specifies the length in characters of the common prefix of a list of possible completions that is displayed without modification. When set to a value greater than zero, common prefixes longer than this value are replaced with an ellipsis when displaying possible completions.

Sources
95% confidence
A

The pathname expansion pattern globpat is expanded to generate possible completions. The words generated need not match the word being completed. GLOBIGNORE shell variable is not used to filter matches, but FIGNORE variable is used.

Sources
95% confidence

Installing Bash > Build Configuration

51 questions

Shell Expansions > Substitution Expansions

51 questions
A

If parameter is null or unset, the shell writes the expansion of word (or a message to that effect if word is not present) to the standard error and, if it is not interactive, exits with a non-zero status. An interactive shell does not exit, but does not execute the command associated with the expansion.

Sources
95% confidence
A

It converts matching uppercase letters to lowercase. The ',,' variant examines all characters in the expanded value and converts each one that matches pattern.

Sources
95% confidence
A

The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; and filename expansion. Process substitution is performed simultaneously with tilde, parameter, variable, and arithmetic expansion and command substitution.

Sources
95% confidence
A

It expands to the names of variables whose names begin with prefix, separated by the first character of the IFS special variable. When @ is used and the expansion appears within double quotes, each variable name expands to a separate word.

Sources
95% confidence
A

If the first character following the open brace is a '|', the construct expands to the value of the REPLY shell variable after command executes, without removing any trailing newlines, and the standard output of command remains the same as in the calling shell.

Sources
95% confidence
A

It converts matching uppercase letters to lowercase, but only examines the first character in the expanded value and converts its case if it matches pattern.

Sources
95% confidence

Programmable Completion > Completion Source Mechanisms

49 questions
A

The COMP_TYPE variable indicates the type of completion being attempted. Values include: @ for normal completion (tab), % for successive tab completion (list completions), ! for listing alternatives on partial word completion, and = for menu completion.

Sources
95% confidence
A

The -X filterpat option filters out completions that match filterpat. The pattern is applied to each potential completion and any matches are excluded. This is used to exclude certain patterns from completion results.

Sources
95% confidence
A

The -D option defines a completion for all commands that don't already have a completion specification. It's used to set a default completion function.

Sources
95% confidence
A

The -o option sets completion options. For example: complete -o default mycommand enables default completion after any matches. Common options include default, dirnames, nospace, filenames, plusdirs.

Sources
95% confidence
A

The -o filenames option tells bash that the completion function returns filenames, which causes bash to perform filename-specific processing like de-quoting, adding trailing slashes to directories, and suppressing trailing spaces.

Sources
95% confidence
A

The -E option defines completion for empty command lines (before any command is typed). It's typically used in bash completion frameworks for special empty-line handling.

Sources
95% confidence

Interactive Shells > Prompting and Display

49 questions
A

When checkjobs is enabled, bash lists the status of any stopped and running jobs before exiting an interactive shell. If any jobs are running, exit is deferred until a second exit is attempted without an intervening command.

Sources
95% confidence
A

When lithist is set and the cmdhist option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators where possible.

Sources
95% confidence
A

By default, bash waits until it is about to print a prompt before reporting changes in a job's status. If the -b option to the set builtin command is enabled, bash reports such changes immediately.

Sources
95% confidence
A

If IGNOREEOF exists but does not have a numeric value, or has no value, the default value is 10. This means 10 consecutive EOF characters must be typed as the first characters on an input line before bash exits.

Sources
95% confidence
A

The -m option enables monitor mode (job control). This option is on by default for interactive shells on systems that support it. When a background job completes, the shell prints a line containing its exit status.

Sources
95% confidence
A

PROMPT_DIRTRIM, when set to a number greater than zero, specifies the number of trailing directory components to retain when expanding the \w and \W prompt string escapes. Characters removed are replaced with an ellipsis.

Sources
95% confidence
A

When cdspell is set, minor errors in the spelling of a directory component in a cd command are automatically corrected. Errors checked include transposed characters, a missing character, and one character too many. This option is only used by interactive shells.

Sources
95% confidence
A

The promptvars option, when enabled (which is the default), causes prompt strings to undergo parameter expansion, command substitution, arithmetic expansion, and quote removal after being expanded with backslash-escaped special characters.

Sources
95% confidence

Command Line Editing > Line Editing Basics

49 questions
A

The -m option selects a keymap to use for the duration of the command. Acceptable keymap names are: emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, vi-command, and vi-insert.

Sources
95% confidence

Bash Builtin Commands > Programmable Completion Builtins

48 questions
A

The '-o filenames' option tells readline that the completion function generates filenames. This enables readline to handle things like pathname expansion, directory separators, and adding trailing slashes for directories.

Sources
95% confidence
A

The COMP_TYPE variable contains a value indicating the type of completion attempted. Values include: '!' for normal completion, '@' for menu completion, '%' for menu completion with repeated hits, and '^' for alternate completion.

Sources
95% confidence
A

The COMP_POINT variable contains the index of the current cursor position relative to the beginning of the current command. If the cursor is at the end of the line, its value equals the length of COMP_LINE.

Sources
95% confidence

Invoking Bash > Argument Handling

48 questions
A

The -k option (or set -o keyword) causes all keyword arguments to be placed in the environment for a command, not just those preceding the command name. This allows arguments anywhere in the command line to be exported. Example: FOO=bar command vs command FOO=bar.

Sources
95% confidence
A

The --verbose option is equivalent to -v. It causes Bash to print shell input lines as they are read. Each line is displayed before being parsed or executed. Useful for debugging to see exactly what the shell is reading.

Sources
95% confidence
A

The -x option causes Bash to print commands and their arguments as they are executed. Each command is printed after expansion but before execution, prefixed with PS4 (typically '+'). This is essential for debugging to see what's actually running. Equivalent to 'set -x'.

Sources
95% confidence
A

Bash determines if it's a login shell by: 1) if invoked as -bash (argv[0] starts with -), 2) if the -l option was specified, 3) if invoked with the name 'login' on some systems. Login shells read /etc/profile and the first readable of ~/.bash_profile, ~/.bash_login, or ~/.profile.

Sources
95% confidence
A

Using + instead of - disables the option. For example, +x disables xtrace (debug printing), while -x enables it. This is shorthand for set +x or set -x. Options can be toggled: bash -xev starts with both xtrace and errexit enabled.

Sources
95% confidence
A

The -v option causes Bash to print shell input lines as they are read. This verbose mode shows each line of a script or input before execution, useful for debugging shell scripts. It's equivalent to 'set -v'.

Sources
95% confidence
A

The -e option (or set -o errexit) causes Bash to exit immediately if a command exits with a non-zero status. This fails-fast behavior doesn't apply to commands in certain constructs like while/until loops, if tests, or pipelines where the last command's status is what matters.

Sources
95% confidence
A

For interactive login shells: /etc/profile, then ~/.bash_profile, ~/.bash_login, or ~/.profile (first readable one), then ~/.bashrc (if sourced from profile). For interactive non-login shells: /etc/bash.bashrc (if exists), then ~/.bashrc. The --noprofile and --norc options skip these files.

Sources
95% confidence
A

The -- option signals the end of options. All arguments after -- are treated as filenames and arguments, even if they start with a dash. This prevents filenames beginning with - from being interpreted as options. Example: bash -- script.sh -argument

Sources
95% confidence
A

The --rpm-requires option produces a list of requirements for the script. It outputs shell features and commands used, formatted for RPM packaging systems. This helps RPM packages determine what shell capabilities are needed by a script. Only available when Bash is compiled with RPM support.

Sources
95% confidence
A

The -b option (or set -o notify) causes Bash to report the termination of background jobs immediately, rather than waiting before displaying the next primary prompt. By default, job termination is only reported just before the prompt is displayed.

Sources
95% confidence
A

The -P option (or set -o physical) prevents Bash from following symbolic links when resolving commands. pwd -P and cd use the physical directory structure rather than following symlinks. The $PWD variable reflects the actual path without symlink resolution.

Sources
95% confidence
A

The -l option makes Bash act as a login shell. A login shell reads certain startup files like /etc/profile, ~/.bash_profile, ~/.bash_login, or ~/.profile (whichever is found first and is readable) in that order. The option name stands for 'login'.

Sources
95% confidence
A

The -D option causes Bash to print all double-quoted strings prefixed with $ to standard output. These are strings that may be subject to translation. When used with -n, no commands are executed. This is used for internationalization and creating translation catalogs.

Sources
95% confidence
A

The -i option specifies that the shell should be interactive. An interactive shell runs with job control enabled, reads commands from user input, and displays prompts. Without this option, scripts run non-interactively even if connected to a terminal.

Sources
95% confidence
A

An exit status of 0 indicates successful execution. This is the standard Unix convention where 0 means success and any non-zero value (1-255) indicates failure or an error condition.

Sources
95% confidence
A

The -s option causes Bash to read commands from standard input. This allows reading from a pipe or redirection. If arguments are present after -s, they are assigned to positional parameters ($0, $1, etc.), but the script is still read from stdin. Example: echo 'echo $1' | bash -s hello

Sources
95% confidence
A

The -f option (or set -o noglob) disables pathname expansion (globbing). Wildcards like *, ?, and [...] are treated literally rather than expanded to matching filenames. Useful when working with special characters that shouldn't be expanded.

Sources
95% confidence
A

Arguments after the command string are assigned to positional parameters starting at $0, not $1. Example: bash -c 'echo $0 $1 $2' script_name arg1 arg2 outputs: script_name arg1 arg2. The first argument becomes $0 (script name), second becomes $1, etc.

Sources
95% confidence
A

The -m option (or set -o monitor) enables job control. This allows background and foreground job management, bg/fg commands, and job control signals. It's automatically enabled for interactive shells on systems that support job control.

Sources
95% confidence
A

The --noprofile option prevents Bash from reading system-wide and personal initialization files for login shells. Specifically, it inhibits reading /etc/profile, ~/.bash_profile, ~/.bash_login, and ~/.profile. This provides a clean environment without profile customizations.

Sources
95% confidence
A

The --help option causes Bash to display a brief usage summary and exit successfully. This shows standard options like -c, -i, -l, -r, -s and basic usage information. The output is concise and meant for quick reference.

Sources
95% confidence
A

The --posix option changes Bash's behavior to match the POSIX standard more strictly. It enables POSIX mode, which affects various aspects like default values for environment variables, handling of special characters, and startup file behavior. It makes Bash more compatible with standard Unix shells.

Sources
95% confidence
A

The --noediting option prevents Bash from using the GNU Readline library for command-line editing. This disables interactive editing features like command history, arrow key navigation, and tab completion. Useful when Bash is run by specialized programs.

Sources
95% confidence
A

The -p option (or set -o privileged) turns on privileged mode. When Bash starts as setuid (not recommended), this mode is automatically enabled. It disables reading of user startup files and ignores the ENV file for security. The effective user ID (euid) is not reset to the real user ID.

Sources
95% confidence
A

The -r option makes the shell restricted. A restricted shell cannot: change working directory, change values of SHELL, PATH, ENV, or BASH_ENV, specify command names containing /, redirect output using >, >>, <>, >|, &, >&, >&, and >>&, turn off restricted mode with set +r or set -o restricted. This is for creating controlled environments.

Sources
95% confidence
A

The -C option (or set -o noclobber) prevents redirection from overwriting existing files. Using > file will fail if file exists. Use >| file to force overwrite. This protects against accidental data loss. The +C option re-enables overwriting.

Sources
95% confidence
A

The --version option causes Bash to print version information about this instance of Bash and exit successfully. The output includes the bash version number, release status, and machine type. Example: 'GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)'.

Sources
95% confidence
A

Bash exit status values range from 0 to 255. Exit status values above 255 are wrapped modulo 256. If a script or command returns 256, it becomes 0; 257 becomes 1, etc. The special exit status 128+N indicates termination by signal N.

Sources
95% confidence
A

The --debugger option (equivalent to set -o debug or set -o debugger) enables debugging mode before the script executes. This allows the shell to enter a debugging state where the DEBUG trap is executed before each simple command, enabling debugging behavior.

Sources
95% confidence
A

The -n option causes Bash to read commands but not execute them. This syntax check mode parses the script without running it, useful for checking for syntax errors before execution. It's often combined with -v for comprehensive syntax checking.

Sources
95% confidence
A

The -h option (or set -o hashall) enables automatic hashing of command locations. Bash remembers the full path of each command as it's found, avoiding repeated PATH searches. This is enabled by default. The hash built-in displays or modifies this table.

Sources
95% confidence
A

The -a option (or set -o allexport) causes all variables to be automatically exported to child processes. When set, any variable created or modified is automatically marked for export, equivalent to using 'export' on each assignment.

Sources
95% confidence
A

The -O option enables a shell option upon invocation. It takes an argument which is the option name to enable. Example: bash -O globstar enables the globstar option, which allows ** recursive wildcard expansion. The +O option disables the specified option.

Sources
95% confidence
A

The -t option (or set -o onecmd) causes Bash to exit after reading and executing one command. This is useful for single-command execution where you want the shell to terminate immediately. When used with -c, it's essentially the default behavior.

Sources
95% confidence
A

The --norc option prevents Bash from reading ~/.bashrc for an interactive shell. This provides an interactive shell without personal configuration customizations. System-wide resources from /etc/bash.bashrc may still be read depending on compilation.

Sources
95% confidence
A

The -u option (or set -o nounset) causes Bash to treat unset variables as an error when expanding. Attempting to expand $unset_var results in an error message and exits with status 1 (unless -e is disabled). This helps catch typos and uninitialized variables.

Sources
95% confidence
A

The +O option disables a shell option upon invocation. It takes an argument which is the option name to disable. Example: bash +O histexpand disables history expansion. Unlike -O which enables options, +O turns them off.

Sources
95% confidence
A

When using -c, the first argument after the command string becomes $0, and subsequent arguments become $1, $2, etc. For example: bash -c 'echo $0 $1' myname arg1 outputs 'myname arg1' where $0=myname and $1=arg1. If no additional arguments are provided, $0 is set to the shell's name (often 'bash').

Sources
95% confidence
A

The --dump-po-strings option is similar to -D but outputs in a GNU gettext PO (Portable Object) file format. It extracts all translatable strings prefixed with $ from scripts for translation management. Used for internationalization workflows.

Sources
95% confidence
A

ENV (used in POSIX mode) specifies a file that Bash reads and executes when starting an interactive shell or when invoked as sh. Similar to BASH_ENV but for POSIX compatibility. When Bash is in POSIX mode, ENV is checked for the startup file path.

Sources
95% confidence
A

The --init-file file (or abbreviated as --rcfile file) specifies a file to read instead of ~/.bashrc for an interactive shell. This option only works for interactive shells, not scripts. It allows customizing the startup configuration for a specific shell invocation.

Sources
95% confidence
A

The -c option causes Bash to read and execute commands from the first non-option argument argument after processing options, then exit. Any remaining arguments are assigned to positional parameters starting at $0. Example: bash -c 'echo hello' world sets $0 to 'world'.

Sources
95% confidence
A

The --dump-strings option is equivalent to -D. It prints all double-quoted strings prefixed with $ to standard output. These are strings marked for translation in the script.

Sources
95% confidence

Readline Interaction > Basic Interaction

48 questions
A

The default value is 'unset', which means the number of history entries is not limited. If set to zero, existing entries are deleted and no new entries are saved. If set to a negative value, the number of history entries is not limited.

Sources
95% confidence

Job Control > Job Control Commands

47 questions
A

The current job is the most recent job stopped or placed in the background. It is referred to as %% or %+ in job specifications and is the default job used by fg and bg when no jobspec is provided.

Sources
95% confidence
A

The -h option to disown marks each JOBSPEC so that SIGHUP is not sent to the job if the shell receives a SIGHUP, but does not remove the job from the job table.

Sources
95% confidence
A

The wait command can wait for both individual process IDs and job specifications. When given a job specification, wait waits for all processes in that job's process group to terminate.

Sources
95% confidence
A

No, the fg command accepts only a single job_spec argument. It places that job in the foreground and makes it the current job. Only one job can be in the foreground at a time.

Sources
95% confidence
A

The suspend command suspends the execution of the shell until it receives a SIGCONT signal. This is a job control builtin that allows suspending the shell itself.

Sources
95% confidence
A

The jobs builtin accepts the following options: -l (lists process IDs in addition to normal information), -n (lists only processes that have changed status since the last notification), -p (lists process IDs only), -r (restrict output to running jobs), -s (restrict output to stopped jobs), and -x (runs COMMAND after replacing job specifications with process IDs).

Sources
95% confidence
A

When you run disown on a stopped job, the job is removed from the job table but remains in a stopped state. Unlike disown -r (which only affects running jobs), regular disown affects both running and stopped jobs.

Sources
95% confidence
A

Bash provides the following job control builtins: jobs (list active jobs), bg (resume jobs in background), fg (bring jobs to foreground), disown (remove jobs from job table), wait (wait for jobs to complete), and suspend (suspend the shell).

Sources
95% confidence
A

No, disown does not terminate background jobs. It only removes them from the shell's job table, so the shell no longer tracks them or sends SIGHUP to them when the shell exits. The jobs continue running.

Sources
95% confidence
A

When the shell exits, it sends SIGHUP to all jobs in its job table by default. Jobs that have been disowned (without -h) or started with nohup are not affected. The shell does not send SIGHUP to jobs that were removed from the job table.

Sources
95% confidence
A

The jobs -x option runs a command after replacing job specifications with the process group leader's PID. This is different from normal job expansion which happens within the shell's job control syntax. It's used to pass job PIDs as arguments to external commands.

Sources
95% confidence
A

The disown builtin accepts three options: -a (remove all jobs if JOBSPEC is not supplied), -h (mark each JOBSPEC so that SIGHUP is not sent to the job if the shell receives a SIGHUP), and -r (remove only running jobs).

Sources
95% confidence
A

The suspend command is typically used in interactive shells. In non-interactive shells, job control is usually disabled and suspend may not work as expected. The shell must have job control enabled for suspend to function.

Sources
95% confidence
A

The -n option in the jobs command lists only processes that have changed status since the last notification. This is useful for seeing only new status changes rather than all active jobs.

Sources
95% confidence

Shell Variables > Job Control and Process Management

47 questions
A

exec replaces the current shell with a new command without creating a new process. The new command takes over the same process ID. When used without arguments in a script, it can be used to redirect file descriptors for the remainder of the script.

Sources
95% confidence
A

set -m enables job control. This allows background and foreground jobs, places jobs in separate process groups, and enables job control builtins like fg, bg, and jobs. This is the default for interactive shells.

Sources
95% confidence
A

disown removes jobs from the job table, optionally with options: -h to mark jobs so SIGHUP is not sent on shell exit, -r to remove only running jobs, -a to remove all jobs. This protects jobs from SIGHUP when the shell exits.

Sources
95% confidence
A

Bash assigns job numbers sequentially starting from 1. There is no fixed maximum in Bash documentation; practical limits are determined by system resources and the operating system's process table size.

Sources
95% confidence
A

SIGTTOU (signal number 22 on most systems) is sent to a background process group when it attempts to write to the terminal. By default, this causes the process to stop (suspend) until brought to the foreground, unless TOSTOP is set on the terminal.

Sources
95% confidence
A

SIGQUIT (signal number 3) is the quit signal, typically generated by Ctrl+. It causes the current foreground process to terminate and produce a core dump. Bash handles SIGQUIT specially for certain builtins and commands.

Sources
95% confidence
A

At shell startup, $_ expands to the absolute pathname of the shell or script being executed. After that, it expands to the last argument to the previous command, and also set to the full pathname of each command executed and placed in the environment exported to that command.

Sources
95% confidence
A

checkjobs is not a standard Bash shell option. There is no 'checkjobs' option in the official Bash shopt documentation. Jobs are checked when using the wait command or jobs command.

Sources
95% confidence
A

SIGINT (signal number 2) is the interrupt signal, typically generated by Ctrl+C. It causes the current foreground process to terminate. Bash handles SIGINT specially for certain builtins and commands.

Sources
95% confidence
A

HISTCONTROL is unset by default, meaning all commands are saved to the history list. It can be set to 'ignorespace' (lines beginning with space are not saved), 'ignoredups' (duplicate lines are not saved), 'ignoreboth' (both options), or 'erasedups' (all previous lines matching the current line are removed).

Sources
95% confidence
A

PROMPT_COMMAND, if set, is executed as a command before each primary prompt is displayed. It is typically used to set dynamic information in the prompt or to perform actions before each command.

Sources
95% confidence
A

SIGSTOP (signal number 19 on most systems) stops (suspends) a process's execution. It cannot be caught or ignored by the process. The process can be resumed with SIGCONT or the bg/fg commands.

Sources
95% confidence
A

If set, auto_resume enables job control features. If set to 'exact', the string supplied must match a job name exactly. If set to 'substring', the string supplied needs to match a substring of the job name. The 'substring' option is the default.

Sources
95% confidence
A

If wait is used without arguments, it returns 0 if all jobs exited successfully, or non-zero if any job exited with a non-zero status. If given job/PID arguments, it returns the exit status of the last job waited for.

Sources
95% confidence
A

If TMOUT is set to a value greater than zero, TMOUT is treated as the default timeout for the read builtin. The select command command terminates if input is not entered within TMOUT seconds. In an interactive shell, Bash terminates after waiting for that many seconds if input does not arrive.

Sources
95% confidence
A

CHILD_MAX sets the maximum number of child processes that can be created before the shell considers it too expensive to create additional ones. If set to a value greater than zero, the shell will not create more than this number of child processes.

Sources
95% confidence
A

The job table contains: job number, process group ID, process IDs, current working directory, state (Running/Stopped/Done/etc.), the command that started the job, and whether the job is the current (+) or previous (-) job.

Sources
95% confidence
A

SIGTSTP (signal number 20 on most systems) is the typical stop signal generated from the terminal (usually Ctrl+Z). Unlike SIGSTOP, SIGTSTP can be caught or ignored by the process.

Sources
95% confidence
A

Monitor mode (-m) is enabled by default in interactive shells, but disabled in non-interactive scripts. This can be checked with 'echo $-' - if 'm' appears in the output, monitor mode is active.

Sources
95% confidence
A

Job control allows Bash to switch between multiple process groups (jobs). It enables backgrounding (&), foregrounding (fg), listing jobs (jobs), and controlling process groups. Job control is only available in interactive shells when the operating system supports it.

Sources
95% confidence

Command Line Editing > Cursor Movement

46 questions

Shell Syntax > Compound Commands

46 questions
A

BASH_REMATCH is an array variable that records which parts of the string matched the =~ regex pattern. Index 0 contains the portion matching the entire regex. Substrings matched by parenthesized subexpressions are saved in remaining indices, where index n contains the nth parenthesized subexpression match.

Sources
95% confidence
A

The =~ operator treats the string to the right as a POSIX extended regular expression pattern and matches accordingly using the POSIX regcomp and regexec interfaces.

Sources
95% confidence
A

When used with [[, the == and != operators treat the string to the right as a pattern and match according to Pattern Matching rules, as if the extglob shell option were enabled. The = operator is identical to ==.

Sources
95% confidence
A

Using ';;&' in place of ';;' causes the shell to test the patterns in the next clause, if any, and execute any associated command-list if the match succeeds, continuing as if the pattern list had not matched.

Sources
95% confidence
A

Compound commands are the shell programming language constructs. Each construct begins with a reserved word or control operator and is terminated by a corresponding reserved word or operator. They include looping constructs, conditional commands, and mechanisms to group commands.

Sources
95% confidence

Conditional Constructs > Expression Evaluation Constructs

46 questions
A

The -v varname operator returns true if the shell variable varname is set (has been assigned a value). For indexed arrays subscripted with @ or *, it returns true if the array has any set elements. For associative arrays subscripted with @ or *, it returns true if an element with that key is set.

Sources
95% confidence
A

From highest to lowest precedence: id++ id-- (post-increment/decrement), ++id --id (pre-increment/decrement), - + (unary minus/plus), ! ~ (logical/bitwise negation), ** (exponentiation), * / % (multiplication/division/remainder), + - (addition/subtraction), << >> (bitwise shifts), <= >= < > (comparison), == != (equality/inequality), & (bitwise AND), ^ (bitwise XOR), | (bitwise OR), && (logical AND), || (logical OR), expr ? expr : expr (conditional), = *= /= %= += -= <<= >>= &= ^= |= (assignment), expr1, expr2 (comma).

Sources
95% confidence

Job Control > Job Identification and Specification

45 questions
A

Normally, bash waits until it is about to print a prompt before reporting changes in a job's status so as not to interrupt any other output. If the -b option to the set builtin command is enabled, bash reports such changes immediately. Any trap on SIGCHLD is executed for each child that exits.

95% confidence
A

If an attempt to exit bash is made while jobs are stopped (or, if the checkjobs shell option has been enabled, running), the shell prints a warning message and, if the checkjobs option is enabled, lists the jobs and their statuses. If a second attempt to exit is made without an intervening command, the shell does not print another warning and any stopped jobs are terminated.

95% confidence

Interactive Shells > History Management

45 questions
A

The * word designator refers to all of the words but the zeroth (word 1 through the last word). It is a synonym for '1-$'. If there is only one word in the event, the empty string is returned.

Sources
95% confidence
A

When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps for the following history line. When writing, timestamps are marked with the history comment character to distinguish them from other history lines.

Sources
95% confidence
A

When lithist is set and the cmdhist option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators.

Sources
95% confidence
A

The !?string[?] event designator refers to the most recent command preceding the current position in the history list containing string. The trailing '?' may be omitted if string is followed immediately by a newline.

Sources
95% confidence
A

When histverify is set and readline is being used, the results of history substitution are not immediately passed to the shell parser. Instead, the resulting line is loaded into the readline editing buffer, allowing further modification.

Sources
95% confidence
A

The valid values for HISTCONTROL are: ignorespace (lines beginning with a space are not saved), ignoredups (lines matching the previous history entry are not saved), ignoreboth (shorthand for both ignorespace and ignoredups), and erasedups (all previous lines matching the current line are removed before saving).

Sources
95% confidence
A

When a shell with history enabled exits, the last $HISTSIZE lines are copied from the history list to $HISTFILE. If histappend is enabled, lines are appended; otherwise the history file is overwritten. If HISTTIMEFORMAT is set, timestamps are written to the history file marked with the history comment character, and the file is then truncated to HISTFILESIZE lines.

Sources
95% confidence
A

When histreedit is set and readline is being used, a user is given the opportunity to re-edit a failed history substitution by reloading it into the readline editing buffer.

Sources
95% confidence
A

The histchars variable contains two or three characters: the first is the history expansion character (default '!'), the second is the quick substitution character (default '^'), and the optional third character indicates the remainder of the line is a comment when found as the first character of a word (default '#').

Sources
95% confidence
A

When cmdhist is set, bash attempts to save all lines of a multiple-line command in the same history entry, adding semicolons where necessary to preserve syntactic correctness. This option is enabled by default.

Sources
95% confidence
A

The history -d offset option deletes the history entry at position offset. If offset is negative, it is interpreted as relative to one greater than the last history position, so negative indices count back from the end of the history.

Sources
95% confidence
A

Only backslash () and single quotes can quote the history expansion character (!). Additionally, the history expansion character is treated as quoted if it immediately precedes the closing double quote in a double-quoted string.

Sources
95% confidence

History Expansion > Event Designators

45 questions
A

The !?string[?] event designator refers to the most recent command preceding the current position in the history list containing string. The trailing ? may be omitted if string is followed immediately by a newline.

Sources
95% confidence
A

When the histverify shell option is enabled and readline is being used, history substitutions are not immediately passed to the shell parser. Instead, the expanded line is reloaded into the readline editing buffer for further modification.

Sources
95% confidence
A

The histchars variable contains two or three characters which control history expansion and tokenization. The first character is the history expansion character (default !), the second is the quick substitution character (default ^), and the optional third character indicates the comment character (default #).

Sources
95% confidence
A

When the histreedit shell option is enabled and readline is being used, a failed history substitution will be reloaded into the readline editing buffer for correction.

Sources
95% confidence

Using History Interactively > History Modification

45 questions
A

The :x modifier quotes the substituted words similar to :q, but it breaks the words at whitespace and quotes each word separately. This is useful when you want to split a single argument into multiple quoted arguments.

Sources
95% confidence
A

fc -s re-executes the command without invoking an editor. It's a shortcut to recall and re-run a previous command directly.

Sources
95% confidence
A

When histverify is enabled and history expansion is used, Bash displays the expanded command line for review instead of immediately executing it. You can then modify the line or press Enter to execute it.

Sources
95% confidence
A

fc -l -10 lists the last 10 commands in the history (commands from history position -10 to the current command).

Sources
95% confidence
A

fc is a built-in command that allows you to edit commands from history before executing them, using an editor. The history expansion feature !cmd directly recalls and executes commands from history without editing (though you can use modifiers like :s for substitution). fc is more suitable for complex edits while history expansion is quicker for simple recalls.

Sources
95% confidence

Bourne Shell Builtins > Signal and Event Handling

43 questions
A

If arg is not present and -p has been supplied, then the trap commands associated with each sigspec are displayed. If no arguments are supplied or if only -p is given, trap prints the list of commands associated with each signal.

Sources
95% confidence
A

The ERR trap is not executed if the failed command is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of a command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted using !.

Sources
95% confidence
A

If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP.

Sources
95% confidence
A

If id is not given, wait waits for all running background jobs and the last-executed process substitution, if its process id is the same as $!, and the return status is zero.

Sources
95% confidence
A

The shell exits by default upon receipt of a SIGHUP. Before exiting, an interactive shell resends the SIGHUP to all jobs, running or stopped. Stopped jobs are sent SIGCONT to ensure that they receive the SIGHUP.

Sources
95% confidence
A

When bash is interactive, in the absence of any traps, it ignores SIGTERM (so that kill 0 does not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is interruptible). In all cases, bash ignores SIGQUIT.

Sources
95% confidence
A

If the -n option is supplied, wait waits for a single job from the list of ids or, if no ids are supplied, any job, to complete and returns its exit status.

Sources
95% confidence
A

If a sigspec is ERR, the command arg is executed whenever a pipeline (which may consist of a single simple command), a list, or a compound command returns a non-zero exit status.

Sources
95% confidence
A

An argument of -l lists the signal names. If any arguments are supplied when -l is given, the names of the signals corresponding to the arguments are listed, and the return status is 0.

Sources
95% confidence
A

If a sigspec is RETURN, the command arg is executed each time a shell function or a script executed with the . or source builtins finishes executing.

Sources
95% confidence
A

If the -p option is supplied, the process or job identifier of the job for which the exit status is returned is assigned to the variable varname named by the option argument. The variable will be unset initially, before any assignment. This is useful only when the -n option is supplied.

Sources
95% confidence
A

Supplying the -f option, when job control is enabled, forces wait to wait for id to terminate before returning its status, instead of returning when it changes status.

Sources
95% confidence
A

If a sigspec is DEBUG, the command arg is executed before every simple command, for command, case command, select command, every arithmetic for command, and before the first command executes in a shell function.

Sources
95% confidence

Modifying Shell Behavior > Job Control and Process Management

43 questions
A

SIGINT is signal number 2. It is generated when the user presses Ctrl+C and typically interrupts the current process.

Sources
95% confidence
A

The 'bg' command resumes a suspended job in the background. Syntax: 'bg [job_spec]'. If no job_spec is provided, it uses the current job. The job must have been previously suspended (typically with Ctrl+Z) to be resumed in the background.

Sources
95% confidence
A

Without options, 'disown' removes the specified jobs from the shell's job table. If no job_spec is provided, it disowns the current job. This means the shell will no longer track the job and will not send SIGHUP to it when the shell exits.

Sources
95% confidence
A

SIGHUP is signal number 1. It is typically sent when a controlling terminal is closed and traditionally causes processes to terminate.

Sources
95% confidence
A

SIGSTOP is signal number 19. It stops a process and cannot be caught or ignored. Unlike SIGTSTP (Ctrl+Z), SIGSTOP cannot be handled by the process.

Sources
95% confidence
A

The 'set -o notify' option (equivalent to 'set -b') causes Bash to report the termination status of background jobs immediately, rather than waiting until the next prompt is displayed.

Sources
95% confidence
A

SIGSTOP (signal 19) cannot be caught or ignored by a process, while SIGTSTP (signal 20, typically sent by Ctrl+Z) can be caught and handled by the process. Both signals stop a process, but SIGTSTP gives the process a chance to clean up.

Sources
95% confidence
A

The 'fg' command resumes a suspended job in the foreground, or brings a background job to the foreground. Syntax: 'fg [job_spec]'. If no job_spec is provided, it uses the current job (the last job stopped in the background or started in the background).

Sources
95% confidence
A

The 'suspend' command suspends the execution of the shell until it receives a SIGCONT signal. Syntax: 'suspend [-f]'. The -f option forces the suspend even if the shell is a login shell.

Sources
95% confidence
A

The 'set -m' option enables job control (monitor mode). When enabled, Bash places each pipeline or command in its own process group, allowing job control commands like bg, fg, and jobs to function. This is the default behavior for interactive shells.

Sources
95% confidence
A

The 'set +m' option disables job control. When disabled, background jobs run in the same process group as the shell, and job control features become unavailable.

Sources
95% confidence
A

SIGCONT is signal number 18. It resumes a stopped process. If the process was stopped, this signal causes it to continue execution.

Sources
95% confidence
A

The 'huponexit' option is OFF by default. This means that by default, Bash does NOT send SIGHUP to jobs when an interactive login shell exits. However, the operating system may still send SIGHUP when the terminal closes.

Sources
95% confidence
A

The 'jobs -x' option executes the specified command replacing any job specification found in command arguments with the corresponding process group ID. For example: 'jobs -x kill %1' would replace %1 with the process group ID before executing kill.

Sources
95% confidence
A

The $! variable expands to the process ID (PID) of the most recently executed background (asynchronous) command. This allows you to reference the background job in other commands like 'wait $!' or 'kill $!'.

Sources
95% confidence
A

The 'jobs -p' option displays only the process ID (PID) of the process group leader for each job, without showing the job status or command.

Sources
95% confidence
A

SIGTERM is signal number 15. It is the default signal sent by the kill command and requests a process to terminate gracefully.

Sources
95% confidence
A

The exit status returned by 'wait' can range from 0 to 255. If a job exits with a status greater than 255, the value is truncated modulo 256. Values 128 and above typically indicate the job was terminated by a signal (signal number + 128).

Sources
95% confidence
A

The 'disown -h' option marks each job_spec so that SIGHUP is not sent to the job if the shell receives a SIGHUP (e.g., when the terminal closes). The job remains in the job table but is marked to not receive hangup signals.

Sources
95% confidence

Major Differences From The Bourne Shell

43 questions
A

Bash supports ${var^^} to convert variable contents to uppercase and ${var,,} to convert to lowercase. For example: name='foo'; echo ${name^^} outputs 'FOO'. The Bourne shell does not support this case modification parameter expansion.

Sources
95% confidence
A

Bash supports $'...' quoting which interprets backslash escape sequences within the string. For example: echo $'Hello\nWorld' prints Hello and World on separate lines. The Bourne shell does not support this syntax.

Sources
95% confidence
A

No. The Bourne shell does not maintain command history. Bash maintains a command history list accessible through the history built-in, !! (last command), !n (command number n), and !string (most recent command starting with string).

Sources
95% confidence
A

No. Bash 4.3+ supports nameref variables with declare -n that create a reference to another variable (similar to pointers). For example: declare -n ref=var; ref=value actually assigns to var. The Bourne shell does not support namerefs.

Sources
95% confidence
A

In Bash, the default value of IFS is . However, Bash treats IFS whitespace differently than Bourne shell: when splitting with IFS whitespace, Bash ignores leading/trailing whitespace and consecutive delimiters. The Bourne shell treats each IFS character as a separate delimiter.

Sources
95% confidence
A

No. Bash's read built-in supports -t seconds for timeout, -n chars for character count, -s for silent input, -d delim for custom delimiter, and more. The Bourne shell's read command is more limited and does not support these options.

Sources
95% confidence
A

Bash supports here strings with the <<< operator, allowing a string to be used as standard input. For example: wc -w <<< 'hello world'. The Bourne shell does not support here strings.

Sources
95% confidence
A

Bash supports coprocs with coproc NAME { command; } or coproc command for asynchronous commands that can communicate with the shell. This feature, introduced in Bash 4.0, is not available in the Bourne shell.

Sources
95% confidence
A

No. The Bourne shell does not support arrays. Bash supports both indexed arrays (arr=(element1 element2)) and associative arrays (declare -A arr).

Sources
95% confidence
A

No. Brace expansion, which generates arbitrary strings like {a,b,c} expanding to 'a b c' or file{1,2,3}.txt expanding to 'file1.txt file2.txt file3.txt', is a Bash-specific feature not available in the Bourne shell.

Sources
95% confidence
A

No. The [[ ]] compound command is a Bash-specific feature that provides more powerful conditional testing with support for &&, ||, <, >, and regex matching with =~. The Bourne shell only supports the [ ] test command (which must use -a and -o instead of && and ||).

Sources
95% confidence
A

No. Bash's lastpipe option (set with shopt -s lastpipe) runs the last command of a pipeline in the current shell context, allowing variables set in the last pipeline command to persist. The Bourne shell does not support this option.

Sources
95% confidence

Using History Interactively > History Manipulation Commands

42 questions
A

The history -d start-end option deletes the range of history entries between positions start and end, inclusive. Positive and negative values for start and end are interpreted as offsets from the current command.

Sources
95% confidence
A

The history -s option stores the args in the history list as a single entry. The last command in the history list is removed before the args are added.

Sources
95% confidence
A

If HISTTIMEFORMAT is set and not null, its value is used as a format string for strftime(3) to print the timestamp associated with each history entry displayed by the history builtin. When set, timestamps are written to the history file to be preserved across shell sessions.

Sources
95% confidence
A

The history -n option reads the history lines not already read from the history file into the current history list. These are lines appended to the history file since the beginning of the current bash session.

Sources
95% confidence
A

The history -d offset option deletes the history entry at position offset. If offset is negative, it is interpreted as relative to one greater than the last history position (negative indices count back from the end). An index of -1 refers to the current history -d command.

Sources
95% confidence
A

The history -p option performs history substitution on the following args and displays the result on standard output. It does not store the results in the history list. Each arg must be quoted to disable normal history expansion.

Sources
95% confidence
A

The history -a option appends the 'new' history lines to the history file. These are history lines entered since the beginning of the current bash session, but not already appended to the history file.

Sources
95% confidence
A

HISTIGNORE accepts a colon-separated list of patterns. Each pattern is anchored at the beginning of the line and must match the complete line (no implicit '*' is appended). Patterns are tested after HISTCONTROL checks are applied.

Sources
95% confidence
A

Timestamps are written to the history file marked with the history comment character. When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps for the following history entry.

Sources
95% confidence
A

The fc -s option re-executes a command. Each instance of pat is replaced by rep (if pat=rep is specified), and the command is re-executed without editing.

Sources
95% confidence

Shell Expansions > Path Expansions

42 questions
A

The extglob option changes the behavior of the parser, since the parentheses are normally treated as operators with syntactic meaning. To ensure that extended matching patterns are parsed correctly, make sure that extglob is enabled before parsing constructs containing the patterns, including shell functions and command substitutions.

Sources
95% confidence
A

If a word begins with an unquoted tilde character ('~'), all of the characters up to the first unquoted slash (or all characters if there is no unquoted slash) are considered a tilde-prefix. If none of the characters in the tilde-prefix are quoted, the characters following the tilde are treated as a possible login name.

Sources
95% confidence
A

If the nullglob shell option is set, filename expansion patterns which match no files expand to nothing and are removed, rather than expanding to themselves (the literal pattern string).

Sources
95% confidence
A

Brace expansion is performed before any other expansions. Any characters special to other expansions are preserved in the result. Brace expansion is strictly textual - Bash does not apply any syntactic interpretation to the context of the expansion or the text between the braces.

Sources
95% confidence
A

If the dotglob shell option is set, Bash includes filenames beginning with a '.' in the results of filename expansion. The filenames '.' and '..' must always be matched explicitly, even if dotglob is set.

Sources
95% confidence
A

If the tilde-prefix is '+', the value of the shell variable PWD replaces the tilde-prefix. If the tilde-prefix is '-', the value of the shell variable OLDPWD, if it is set, is substituted.

Sources
95% confidence
A

After word splitting, unless the -f option has been set, Bash scans each word for the characters '*', '?', and '['. If one of these characters appears, and is not quoted, then the word is regarded as a pattern and replaced with an alphabetically sorted list of filenames matching the pattern.

Sources
95% confidence
A

The '' pattern matches any string, including the null string. When the globstar shell option is enabled and '' is used in a filename expansion context, two adjacent '*'s used as a single pattern match all files and zero or more directories and subdirectories.

Sources
95% confidence
A

When integers are supplied in a brace expansion sequence, they may be prefixed with '0' to force each term to have the same width. When either x or y begins with a zero, the shell attempts to force all generated terms to contain the same number of digits, zero-padding where necessary.

Sources
95% confidence
A

Within a bracket expression, character classes can be specified using the syntax [:class:], where class is one of: alnum, alpha, ascii, blank, cntrl, digit, graph, lower, print, punct, space, upper, word, or xdigit. The 'word' character class matches letters, digits, and the character '_'.

Sources
95% confidence
A

The GLOBIGNORE shell variable may be used to restrict the set of file names matching a pattern. If GLOBIGNORE is set, each matching file name that also matches one of the patterns in GLOBIGNORE is removed from the list of matches. The filenames . and .. are always ignored when GLOBIGNORE is set and not null. However, setting GLOBIGNORE to a non-null value has the effect of enabling the dotglob shell option.

Sources
95% confidence
A

If the characters following the tilde in the tilde-prefix consist of a number N, optionally prefixed by a '+' or a '-', the tilde-prefix is replaced with the corresponding element from the directory stack, as it would be displayed by the dirs builtin. If the tilde-prefix, sans the tilde, consists of a number without a leading '+' or '-', '+' is assumed.

Sources
95% confidence
A

Only brace expansion, word splitting, and filename expansion can increase the number of words of the expansion. Other expansions expand a single word to a single word, with the exceptions of "$@" and $* (special parameters), and "${name[@]}" and ${name[*]} (arrays).

Sources
95% confidence
A

If the globstar shell option is set, the pattern '**' used in a filename expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a '/', only directories and subdirectories match.

Sources
95% confidence
A

If the globasciiranges shell option is set, range expressions used in pattern matching bracket expressions behave as if in the traditional C locale when performing comparisons. Pattern matching does not take the current locale's collating sequence into account, so 'b' will not collate between 'A' and 'B', and upper-case and lower-case ASCII characters will collate together.

Sources
95% confidence
A

By default, if no matching filenames are found and the shell option nullglob is disabled, the word is left unchanged. If the nullglob option is set and no matches are found, the word is removed. If the failglob shell option is set and no matches are found, an error message is printed and the command is not executed.

Sources
95% confidence
A

The sorting order of characters in range expressions and the characters included in the range are determined by the current locale and the values of the LC_COLLATE and LC_ALL shell variables. In the default C locale, '[a-dx-z]' is equivalent to '[abcdxyz]'. Many locales sort characters in dictionary order, where '[a-dx-z]' might be equivalent to '[aBbCcDdxYyZz]'.

Sources
95% confidence
A

If the login name after tilde is the null string, the tilde is replaced with the value of the HOME shell variable. If HOME is unset, the home directory of the user executing the shell is substituted instead.

Sources
95% confidence
A

The shell options that control pathname expansion behavior include: dotglob (include filenames beginning with '.'), nocaseglob (case-insensitive matching), nullglob (remove non-matching patterns), failglob (error on non-matching patterns), globstar (enable '**' recursive matching), globskipdots (never match '.' and '..'), and globasciiranges (use C locale for range expressions).

Sources
95% confidence
A

If the failglob shell option is set, patterns which fail to match filenames during filename expansion result in an expansion error (an error message is printed and the command is not executed).

Sources
95% confidence

Bash POSIX Mode

41 questions
A

The local keyword for creating local variables in functions is available in POSIX mode, though it's not part of the POSIX standard—Bash maintains it for compatibility.

Sources
95% confidence
A

In POSIX mode, the read builtin does not support the -e option for readline editing, -u for file descriptors, or other Bash-specific extensions like -a for arrays.

Sources
95% confidence
A

In POSIX mode, function names must be valid shell identifiers and the function keyword is not recognized. Functions must be defined as name() { ... } without the function keyword.

Sources
95% confidence

Invoking Bash > Shell Execution Modes

41 questions
A

Bash is interactive if: (1) it is started without non-option arguments (unless -s is specified) AND without the -c option, AND (2) its standard input and standard error are both connected to terminals (as determined by isatty(3)), OR (3) it was explicitly started with the -i option.

95% confidence
A

The -D option prints a list of all double-quoted strings preceded by $ on standard output. These are strings subject to language translation when the current locale is not C or POSIX. This implies the -n option, so no commands are actually executed.

95% confidence
A

If arguments remain after option processing, and neither -c nor -s was supplied, the first argument is assumed to be the name of a file containing shell commands. $0 is set to the name of the file, and positional parameters are set to remaining arguments. Bash reads and executes commands from this file, then exits. The file is first searched in the current directory, then in PATH if not found.

95% confidence
A

The --debugger option arranges for the debugger profile to be executed before the shell starts and turns on extended debugging mode (extdebug option to shopt builtin). This option must appear on the command line before single-character options to be recognized.

95% confidence
A

The -O shopt_option sets the value of a shell option accepted by the shopt builtin. The +O shopt_option unsets it. If shopt_option is not supplied, the names and values of shell options are printed. If +O is used without shopt_option, output is displayed in a format that may be reused as input.

95% confidence
A

If the -s option is present, or if no arguments remain after option processing, commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell or when reading input through a pipe.

95% confidence
A

If the shell is started with effective user (group) ID not equal to the real user (group) ID, and the -p option is NOT supplied: (1) no startup files are read, (2) shell functions are not inherited from the environment, (3) SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE environment variables are ignored, and (4) the effective user ID is set to the real user ID.

95% confidence
A

If the -c option is present, commands are read from the first non-option argument command_string. If there are arguments after the command_string, the first argument is assigned to $0 and any remaining arguments are assigned to the positional parameters ($1, $2, etc.).

95% confidence
A

In restricted mode, the following are disallowed: (1) changing directories with cd, (2) setting/unsetting SHELL, PATH, HISTFILE, ENV, or BASH_ENV, (3) specifying command names containing /, (4) specifying filenames containing / to ., history, or hash -p builtins, (5) importing function definitions from environment at startup, (6) parsing SHELLOPTS from environment at startup, (7) redirecting output using >, >|, <>, >&, &>, and >> operators, (8) using exec to replace the shell, (9) adding/deleting builtins with enable -f/-d, (10) enabling disabled builtins with enable, (11) using command -p, (12) turning off restricted mode with set +r or shopt -u restricted_shell.

95% confidence

Executing Commands > Command Expansion and Preparation

41 questions
A

GLOBIGNORE restricts the set of filenames matching a pattern. If set, each matching filename that also matches a pattern in GLOBIGNORE is removed from the list. Setting GLOBIGNORE to a non-null value enables the dotglob option.

Sources
95% confidence
A

${parameter:=word} assigns default values. If parameter is unset or null, the expansion of word is assigned to parameter, and the value is then substituted. Positional parameters and special parameters cannot be assigned this way.

Sources
95% confidence
A

There are two forms: $(command) (modern, recommended) and command (legacy/backtick form). Both execute command in a subshell and replace the substitution with standard output, with trailing newlines deleted.

Sources
95% confidence
A

Sequence expressions take the form {x..y[..incr]}, where x and y are integers or single letters, and incr is an optional integer increment. Default increment is 1 or -1. Integers can be prefixed with 0 to force equal width. Example: {1..5} expands to '1 2 3 4 5'.

Sources
95% confidence
A

Brace expansion generates arbitrary strings that need not exist as files. Patterns take the form: optional preamble + {comma-separated strings OR sequence expression} + optional postscript. For example: a{d,c,b}e expands to 'ade ace abe'. Results are not sorted; left-to-right order is preserved.

Sources
95% confidence
A

Braces are required when parameter is a positional parameter with more than one digit (e.g., ${12}), or when parameter is followed by a character that should not be interpreted as part of its name.

Sources
95% confidence
A

The order is: 1) brace expansion; 2) tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done left-to-right); 3) word splitting; 4) pathname expansion. Quote removal occurs after all expansions.

Sources
95% confidence
A

Brace expansion can be disabled with the +B option to the set command, or by starting bash with the +B option. This provides strict compatibility with historical sh versions.

Sources
95% confidence
A

No, if no expansion occurs, no splitting is performed. Word splitting only applies to results of parameter expansion, command substitution, and arithmetic expansion that did not occur within double quotes.

Sources
95% confidence
A

Process substitution allows a process's input or output to be referred to using a filename. It takes the form <(list) for input or >(list) for output. The process list runs asynchronously, and its input/output appears as a filename.

Sources
95% confidence
A

The exclamation point introduces indirect expansion. Bash uses the value formed by expanding the rest of parameter as the new parameter; this is then expanded. For nameref parameters, it expands to the name of the parameter referenced.

Sources
95% confidence
A

After all preceding expansions, all unquoted occurrences of the characters , ', and " that did not result from expansions are removed.

Sources
95% confidence

Readline vi Mode

41 questions
A

Press 'f' followed by a character to move forward to the next occurrence of that character. Press 'F' followed by a character to move backward to the previous occurrence. Press 't' to move forward to just before the character, or 'T' to move backward to just after it.

95% confidence
A

Press 'w' to move forward to the beginning of the next word, or 'b' to move backward to the beginning of the previous word. Press 'e' to move forward to the end of the current word.

95% confidence
A

When set to 'on' in .inputrc, it displays '@' or '+' to indicate insert mode, and ':' or '-' to indicate command mode. The actual characters can be customized with 'vi-ins-mode-string' and 'vi-cmd-mode-string' variables.

95% confidence
A

Run 'set -o vi' in the current shell, or add it to ~/.bashrc for permanent configuration. This switches Readline from the default emacs mode to vi mode.

Sources
95% confidence
A

Press '(' to move backward to the beginning of the previous sentence, or ')' to move forward to the beginning of the next sentence. Sentences are defined as text followed by '.', '!', or '?' followed by a space.

95% confidence

Shell Arithmetic > Conditional Operations

40 questions
A

The expression undergoes the same expansions as if it were within double quotes (tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution, and quote removal), but double quote characters in expression are not treated specially and are removed.

95% confidence
A

The shell performs tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution, and quote removal on words between [[ and ]] (the expansions that would occur if the words were enclosed in double quotes).

95% confidence

Bourne Shell Builtins > Testing and Parsing

40 questions
A

The echo builtin returns 0 (success) if all arguments are successfully written. It returns non-zero only if there's a write error. The return value is not typically checked since echo is used for output, not testing.

Sources
95% confidence
A

The -t option to read builtin causes read to time out and return failure if a complete line of input is not read within TIMEOUT seconds. The timeout value is specified as an integer after -t. If timeout is reached, read returns exit status 1 and the variable is not set.

Sources
95% confidence
A

Parentheses in let builtin expressions are used to group sub-expressions and control operator precedence, just like in C. For example: let 'x = (5 + 3) * 2' evaluates to 16. The parentheses force the addition to happen before multiplication.

Sources
95% confidence
A

The -e option to read builtin enables readline to read the line. This gives the user full line-editing capabilities including command history, cursor movement, and readline editing features similar to interactive shell input. This is only available when bash is compiled with readline support.

Sources
95% confidence
A

The -p option to read builtin displays PROMPT as a prompt before reading input, without a trailing newline. For example: read -p 'Enter name: ' name displays 'Enter name: ' and waits for user input.

Sources
95% confidence
A

The -d option to read builtin changes the delimiter character from newline to the first character of DELIM. The read command reads until the specified delimiter instead of newline. For example: read -d ';' reads input until a semicolon is encountered.

Sources
95% confidence
A

The -u option to read builtin reads input from file descriptor FD instead of standard input. For example: read -u 3 line reads from file descriptor 3. This is useful for reading from files opened with exec commands.

Sources
95% confidence
A

The -E option to echo builtin explicitly disables interpretation of backslash escape sequences. This is actually the default behavior in bash, but -E can be used to override the xpg_echo shell option or to be explicit. Use -e to enable escape interpretation.

Sources
95% confidence
A

The -u option to read builtin causes read to treat backslashes as escape characters only when followed by a valid escape character. Without -u (and with -r), backslashes are treated literally. This option was added in bash 5.1 to provide more precise control over backslash handling.

Sources
95% confidence
A

The -ef (equal files) file test operator returns true if file1 and file2 refer to the same device and inode numbers (i.e., they are hard links to the same file). Usage: [ file1 -ef file2 ].

Sources
95% confidence
A

The =~ operator performs regular expression matching in bash within [[ ]] conditional expressions. The string to the right of =~ is considered an extended regular expression and matched against the string on the left. Captured groups are stored in BASH_REMATCH array. For example: [[ $string =~ ^[0-9]+$ ]] matches if string contains only digits.

Sources
95% confidence
A

The printf builtin provides formatted output similar to C's printf, with format specifiers like %s, %d, %f, etc. It doesn't interpret escape sequences by default (requires explicit format). The echo builtin simply outputs its arguments separated by spaces, with behavior regarding escape sequences (-e/-E options) varying between implementations. printf is more portable and predictable.

Sources
95% confidence
A

The -nt (newer than) file test operator returns true if file1 is newer (has a more recent modification timestamp) than file2, or if file1 exists and file2 does not. Usage: [ file1 -nt file2 ].

Sources
95% confidence
A

The -x file test operator returns true if the file exists and has execute permission. For directories, this tests if the directory can be searched (entered). The check is performed against the current user's effective permissions.

Sources
95% confidence
A

There is no -a or -A option to the echo builtin. The -a option is used with read builtin to read words into an indexed array. The echo builtin has -n (suppress trailing newline), -e (enable backslash escape interpretation), and -E (disable backslash escape interpretation, which is default) options.

Sources
95% confidence
A

The -n option to echo builtin suppresses the trailing newline that echo normally adds to output. This allows multiple echo statements to output on the same line. For example: echo -n 'Prompt: '; read response displays 'Prompt: ' and waits for input on the same line.

Sources
95% confidence
A

The let builtin supports standard C-style comparison operators: < (less than), <= (less than or equal), > (greater than), >= (greater than or equal), == (equal), and != (not equal). These return 1 for true and 0 for false when used in arithmetic expressions.

Sources
95% confidence
A

The -a option to read builtin reads words into an indexed array variable starting at index 0. Each word from the input (split by IFS) becomes an array element. For example: read -a arr reads space-separated words into the arr array.

Sources
95% confidence
A

The single bracket [ is a POSIX builtin command (test), while [[ is a bash keyword that provides enhanced functionality. Within [[ ]], word splitting and pathname expansion are disabled, && and || have higher precedence than -a and -o, and pattern matching with == and != is supported. Variables inside [[ ]] don't require quoting.

Sources
95% confidence
A

The -n test operator returns true if the length of the string is non-zero (not empty). For example: [ -n "$string" ] is true if string is not empty. This is the opposite of -z which returns true if the string has zero length.

Sources
95% confidence
A

The -r option to read builtin prevents backslash from acting as an escape character. This is 'raw mode' which preserves backslashes literally in the input. This is typically recommended for reading input to avoid unexpected behavior with backslashes.

Sources
95% confidence
A

The -L file test operator returns true if the file exists and is a symbolic link. The -h operator is a synonym for -L. Both test for symbolic links, following the link only if the file test operator requires examining the target.

Sources
95% confidence
A

The -ot (older than) file test operator returns true if file1 is older (has an older modification timestamp) than file2, or if file2 exists and file1 does not. Usage: [ file1 -ot file2 ].

Sources
95% confidence
A

The -e option to echo builtin enables interpretation of backslash escape sequences. Recognized escapes include: \a (alert/bell), \b (backspace), \c (truncate output, suppress trailing newline), \e (escape), \f (form feed), \n (newline), \r (carriage return), \t (horizontal tab), \v (vertical tab), \ (backslash), ' (single quote), \nnn (octal byte), \xHH (hex byte).

Sources
95% confidence
A

The -n option to read builtin reads exactly NCHARS characters rather than a full line. After reading N characters, read returns immediately without waiting for a newline. For example: read -n 1 key reads a single keystroke.

Sources
95% confidence
A

When IFS is set to an empty string (IFS=), no word splitting occurs. This is commonly used with read to preserve leading and trailing whitespace: IFS= read -r line reads the entire line exactly as input.

Sources
95% confidence
A

The -eq operator performs integer (numeric) comparison, while = performs string comparison. Use -eq, -ne, -gt, -ge, -lt, -le for numbers, and =, !=, <, > for strings. For example: [ 5 -eq 05 ] is true (numeric), but [ 5 = 05 ] is false (string comparison).

Sources
95% confidence
A

The -z test operator returns true if the length of the string is zero (empty). For example: [ -z "$string" ] is true if string is empty. This is the opposite of -n which returns true if the string has non-zero length.

Sources
95% confidence
A

Both let and (( evaluate arithmetic expressions, but let is a builtin command while (( is a keyword. The let command syntax is: let 'expression', while (( syntax is: (( expression )). The let command returns 1 if the last expression is 0, while (( can be used directly in conditionals. For example: let x++ vs ((x++)). Both perform the same operation but with different syntax.

Sources
95% confidence
A

There is no -N option to the read builtin in standard bash. You may be confusing it with the -n option which reads exactly N characters. The read builtin options are: -a array, -d delim, -e, -i text, -n nchars, -N nchars (bash 5.1+), -p prompt, -r, -s, -t timeout, -u fd.

Sources
95% confidence
A

The -s option to read builtin puts it into silent mode, where input is not echoed to the terminal. This is commonly used for password input: read -s -p 'Password: ' password. The input is still stored in the variable, just not displayed as it's typed.

Sources
95% confidence
A

The -i option to read builtin places the initial text value into the input buffer before reading begins. It requires the -e option (readline mode). For example: read -e -i 'default' var will pre-fill the input buffer with 'default' which the user can then edit.

Sources
95% confidence
A

The -S file test operator returns true if the file exists and is a socket. This is one of the special file type tests along with -f (regular file), -d (directory), -L (symbolic link), -b (block device), -c (character device), and -p (named pipe/FIFO).

Sources
95% confidence

Redirections > Basic Stream Redirection

40 questions
A

Redirects both standard output and standard error to the same file, appending to the file if it exists. This is equivalent to '>> file 2>&1'. Introduced in Bash 4.0.

Sources
95% confidence
A

Redirects standard error (file descriptor 2) to a file, appending to the end of the file if it exists.

Sources
95% confidence
A

A here-string redirects a single string to standard input. It uses '<<<' followed by a string (which can undergo expansion). The string is expanded and supplied to the command's standard input, with a trailing newline automatically appended.

Sources
95% confidence
A

This is a here-document with leading tab removal. All leading tab characters are stripped from input lines before they are processed by the command.

Sources
95% confidence
A

Redirects standard error (file descriptor 2) to the same destination as standard output (file descriptor 1). This merges stderr into stdout.

Sources
95% confidence
A

A here-document is a special form of redirection that allows you to pass multiple lines of input to a command. It uses '<<' followed by a delimiter, then all lines until the delimiter appears on a line by itself become the command's input.

Sources
95% confidence
A

Redirects standard output (file descriptor 1) to the same destination as standard error (file descriptor 2). This merges stdout into stderr.

Sources
95% confidence
A

Duplicates input file descriptor n from the file descriptor specified by 'word'. If 'word' is not a number, it redirects input from that file. If 'word' is '-', file descriptor n is closed.

Sources
95% confidence
A

No, redirections themselves do not affect the exit status of a command. If a redirection fails (e.g., permission denied), the shell will report an error and may not execute the command, but this is separate from the command's exit status.

Sources
95% confidence
A

Duplicates output file descriptor n by redirecting it to the file descriptor specified by 'word'. If 'word' is not a number, it redirects from that file. If 'word' is '-', file descriptor n is closed.

Sources
95% confidence
A

Redirects both standard output and standard error to the same file. This is equivalent to '> file 2>&1'. This operator is specific to Bash 4.0 and later.

Sources
95% confidence

Using History Interactively > History Expansion Syntax

39 questions
A

The :g modifier causes changes to be applied over the entire event line. This is used in conjunction with :s (e.g., :gs/old/new/) or :&. If used with :s, any delimiter can be used in place of /, and the final delimiter is optional if it is the last character of the event line. An a may be used as a synonym for g.

Sources
95% confidence
A

The history -p option performs history substitution on the following args and displays the result on standard output. Does not store the results in the history list. Each arg must be quoted to disable normal history expansion.

Sources
95% confidence
A

The :s/old/new/ modifier substitutes new for the first occurrence of old in the event line. Any character may be used as the delimiter in place of /. The final delimiter is optional if it is the last character of the event line. The delimiter may be quoted in old and new with a single backslash. If & appears in new, it is replaced by old. A single backslash will quote the &. If old is null, it is set to the last old substituted, or, if no previous history substitutions took place, the last string in a !?string[?] search. If new is null, each matching old is deleted.

Sources
95% confidence
A

Use the +H option to the set builtin command (e.g., set +H). This disables history expansion for interactive shells. Non-interactive shells do not perform history expansion by default.

Sources
95% confidence
A

When histverify is enabled and readline is being used, history substitutions are not immediately passed to the shell parser. Instead, the expanded line is reloaded into the readline editing buffer for further modification.

Sources
95% confidence
A

The histchars variable controls two or three characters for history expansion and tokenization. The first character is the history expansion character (default !). The second character is the quick substitution character (default ^). The optional third character is the history comment character (default #).

Sources
95% confidence

Controlling the Prompt > Location Context

39 questions
A

PS4 is the prompt displayed before each command during execution tracing (when using 'set -x' for debugging). The default value is '+ '.

Sources
95% confidence
A

[ and ] delimit a sequence of non-printing characters in the prompt. Bash does not count characters between these delimiters when calculating the prompt width, which is essential for proper line wrapping when using ANSI color codes.

Sources
95% confidence
A

\w displays the full current working directory path (with $HOME abbreviated as ~), while \W displays only the basename (the last component) of the current working directory. For /home/user/projects/bash, \w shows ~/projects/bash and \W shows 'bash'.

Sources
95% confidence
A

PS1 is the primary prompt string, which is displayed before each command is executed. It is the main prompt you see when using Bash interactively.

Sources
95% confidence
A

PS3 is the value of the prompt for the select command. The default value is '#? '.

Sources
95% confidence
A

PS2 is the secondary prompt string, which is displayed when Bash needs more input to complete a command. The default value is '> '.

Sources
95% confidence

Using History Interactively > Word Extraction

38 questions

Shell Scripts

38 questions
A

Using ;;& causes the shell to test the next pattern list in the statement and execute any associated list on a successful match, continuing the case statement execution as if the previous pattern list had not matched.

Sources
95% confidence

Using History Interactively > History Storage and Management

38 questions

Modifying Shell Behavior > History Management

37 questions
A

A colon-separated list of patterns to decide which commands should be saved in the history list (e.g., HISTIGNORE='ls:pwd:exit')

Sources
95% confidence

Interactive Shells > Error and Exit Behavior

37 questions

Shell Variables > Special Parameters

36 questions

Command Line Editing > Text Manipulation

36 questions

Shell Syntax > Command Structures

36 questions
A

Brace expansion generates arbitrary strings. It takes the form of an optional preamble, followed by comma-separated strings or a sequence expression {x..y[..incr]} between braces, followed by an optional postscript. Example: a{d,c,b}e expands to 'ade ace abe'.

Sources
95% confidence
A

A simple command is a sequence of words separated by blanks (spaces/tabs), terminated by one of the shell's control operators. The first word typically specifies the command to execute, and the remaining words are arguments to that command.

Sources
95% confidence
A

Trailing newlines are deleted from the output of command substitution. Embedded newlines are not deleted but may be removed during word splitting. The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).

Sources
95% confidence
A

The standard modern form is $(command). The deprecated form uses backticks: command. Both execute the command in a subshell environment and replace the substitution with the command's standard output, with trailing newlines deleted.

Sources
95% confidence
A

If a word begins with an unquoted tilde (), all characters up to the first unquoted slash (or all characters if no slash) are considered a tilde-prefix. If the tilde-prefix is null (just ''), it's replaced with the value of the HOME shell variable (or the executing user's home directory if HOME is unset).

Sources
95% confidence
A

The 'lastpipe' option, when enabled via 'shopt -s lastpipe', causes the last element of a pipeline to be run by the shell process (not a subshell) when job control is not active. This allows variable assignments in the last pipeline command to persist in the current shell.

Sources
95% confidence
A

Arithmetic expansion uses the format $(( expression )). The expression undergoes the same expansions as if within double quotes, but double quote characters in the expression are not treated specially and are removed. All tokens undergo parameter and variable expansion, command substitution, and quote removal.

Sources
95% confidence
A

PIPESTATUS is an array variable that holds the exit status of each command in the most recently executed foreground pipeline. ${PIPESTATUS[0]} is the first command's status, ${PIPESTATUS[1]} is the second, etc.

Sources
95% confidence
A

The '|&' operator connects command1's standard error (in addition to standard output) to command2's standard input through the pipe. It is shorthand for '2>&1 |'. This implicit redirection of stderr to stdout occurs after any redirections specified by command1.

Sources
95% confidence
A

The reserved word 'time' causes timing statistics to be printed for the pipeline once it finishes. Statistics include elapsed (wall-clock) time and user and system time consumed by command execution. The -p option changes output format to POSIX standard. The TIMEFORMAT variable may be set to customize the display format.

Sources
95% confidence
A

Enclosing characters in single quotes (') preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.

Sources
95% confidence
A

Bash provides two ways: (list) - parentheses create a subshell and execute commands in that subshell environment; { list; } - curly braces execute commands in the current shell environment (no subshell).

Sources
95% confidence
A

When a command is terminated by '&', the shell executes it asynchronously in a subshell (background). The shell does not wait for the command to finish, and the return status is 0 (true). When job control is not active, the standard input for asynchronous commands is redirected from /dev/null in the absence of explicit redirections.

Sources
95% confidence
A

Process substitution takes the form <(list) or >(list). The process list is run asynchronously, and its input or output appears as a filename passed as an argument to the current command. No space may appear between the '<' or '>' and the left parenthesis, otherwise it's interpreted as redirection.

Sources
95% confidence
A

Brace expansion sequences support an optional increment: {x..y..incr} where x and y are integers or letters, and incr is an integer. When x or y begins with '0', the shell zero-pads to force equal width. Default increment is 1 or -1 as appropriate.

Sources
95% confidence
A

Enclosing characters in double quotes (") preserves the literal value of all characters within quotes, except for '$', '', '\', and (when history expansion is enabled) '!'. The characters '$' and '' retain their special meaning within double quotes. The backslash retains its special meaning only when followed by one of: '$', '`', '"', '', or newline.

Sources
95% confidence
A

A pipeline is a sequence of one or more commands separated by the control operators '|' (pipe) or '|&' (pipe and stderr). The format is: [time [-p]] [!] command1 [ | or |& command2 ] …

Sources
95% confidence
A

When the reserved word '!' precedes a pipeline, the exit status is the logical negation of the pipeline's exit status as described above. The shell waits for all commands in the pipeline to terminate before returning this negated value.

Sources
95% confidence
A

Bash reserved words include: !, case, do, done, elif, else, esac, fi, for, function, if, in, select, then, until, while, {, }, [[, ]], and time. Reserved words have special meaning and are used to begin/end compound commands.

Sources
95% confidence
A

ANSI-C quoting uses the syntax $'string' and treats string as a special kind of single quotes. It expands string with backslash-escaped characters replaced according to ANSI-C standards (e.g., \n for newline, \t for tab, ' for single quote).

Sources
95% confidence
A

Yes, each command in a multi-command pipeline (where pipes are created) is executed in its own subshell, which is a separate process. Exception: if the 'lastpipe' option is enabled using 'shopt' and job control is not active, the last element may run in the current shell process.

Sources
95% confidence

Bourne Shell Builtins > Directory and Path Management

35 questions
A

The -e option causes cd to return a failure status if the current directory cannot be determined or cannot be reached after successfully changing the directory.

Sources
95% confidence
A

The dirs -l option produces a longer listing with the full pathnames instead of using ~ for the home directory.

Sources
95% confidence
A

The hash -p option uses pathname as the full path of command, adding it to the hash table.

Sources
95% confidence
A

The hash -l option displays the contents of the hash table in a format that can be reused as input.

Sources
95% confidence
A

The hash -r option clears the hash table, forgetting all remembered command locations.

Sources
95% confidence
A

The hash -t option prints the remembered pathname for each specified command, or all remembered commands if none specified.

Sources
95% confidence
A

The -n option suppresses the normal directory change when adding directories to the stack, so the current working directory is not changed.

Sources
95% confidence
A

The dirs -c option clears the directory stack by deleting all of its entries.

Sources
95% confidence
A

The -n flag for popd suppresses the normal directory change when removing entries from the directory stack.

Sources
95% confidence
A

The hash -d option forgets the remembered location of each specified command (or all commands if none specified).

Sources
95% confidence
A

The dirs -v option outputs the directory stack with one entry per line, prefixing each entry with its index in the stack.

Sources
95% confidence

Interactive Shells > Signal Handling

35 questions
A

When bash is running without job control enabled and receives SIGINT while waiting for a foreground command, it waits until that foreground command terminates and then decides: 1) If the command terminates due to the SIGINT, bash acts on the SIGINT (e.g., by running a SIGINT trap or exiting itself); 2) If the command does not terminate due to SIGINT (the program handled it), bash does not treat SIGINT as a fatal signal, but will still run any trap set on SIGINT.

95% confidence
A

The disown command with the -h option marks each jobspec so that SIGHUP is not sent to the job if the shell receives a SIGHUP. The job is not removed from the table.

95% confidence
A

Any trap on SIGCHLD is executed for each child that exits. The shell learns immediately whenever a job changes state, but normally waits until it is about to print a prompt before reporting changes in job status unless the -b option is enabled.

95% confidence
A

If a sigspec is DEBUG, the command arg is executed before every simple command, for command, case command, select command, every arithmetic for command, and before the first command executes in a shell function.

95% confidence
A

The RETURN trap command is executed each time a shell function or a script executed with the . or source builtins finishes executing. Any command associated with the RETURN trap is executed before execution resumes after the function or script.

95% confidence
A

The checkjobs shell option is disabled by default. When set, bash lists the status of any stopped and running jobs before exiting an interactive shell. If any jobs are running, this causes the exit to be deferred until a second exit is attempted without an intervening command.

95% confidence

Programmable Completion > Result Filtering and Processing

35 questions
A

The -D option in compopt indicates that other supplied options should apply to the 'default' command completion - that is, completion attempted on a command for which no completion has previously been defined.

Sources
95% confidence
A

The -o default option uses readline's default filename completion if the compspec generates no matches. This is different from bashdefault as it uses readline's completion rather than bash's default completions.

Sources
95% confidence
A

The -o plusdirs option causes directory name completion to be attempted AFTER any matches defined by the compspec are generated, and any directory matches are added to the results of the other actions (in addition to, not replacing them).

Sources
95% confidence
A

The -X filterpat option applies a pattern (used for pathname expansion) to filter completions. Each completion matching filterpat is removed from the list of possible completions. The filter is applied after all possible completions have been generated by preceding options and arguments.

Sources
95% confidence
A

The -E option in compopt indicates that other supplied options should apply to 'empty' command completion - that is, completion attempted on a blank line.

Sources
95% confidence
A

The -W wordlist string is first split using characters in IFS as delimiters (shell quoting is honored). Each word is then expanded using brace expansion, tilde expansion, parameter/variable expansion, command substitution, and arithmetic expansion. Results are split using Word Splitting rules, then prefix-matched against the word being completed.

Sources
95% confidence
A

The -o filenames option tells readline that the compspec generates filenames, so it can perform any filename-specific processing such as adding a slash to directory names, quoting special characters, or suppressing trailing spaces. This is intended to be used with shell functions.

Sources
95% confidence
A

The -I option in compopt indicates that other supplied options should apply to completion on the initial non-assignment word on the line, or after a command delimiter such as ; or |, which is usually command name completion.

Sources
95% confidence
A

A command specified with -C is invoked in an environment equivalent to command substitution. It should print a list of completions, one per line, to standard output. Backslash may be used to escape a newline if necessary.

Sources
95% confidence
A

By default, if a compspec is found, whatever it generates is returned as the full set of possible completions. The default bash completions are NOT attempted, and the readline default of filename completion is disabled unless -o bashdefault or -o default is specified.

Sources
95% confidence
A

Yes. The compopt command accepts both -o option (to set an option) and +o option (to unset/remove an option) syntax, similar to other bash builtins like set.

Sources
95% confidence

Executing Commands > Command Location and Invocation

34 questions
A

'command' suppresses shell function lookup. If you have a function named 'cd', running 'cd' calls your function, but 'command cd' bypasses the function and calls the builtin directly. This applies to all commands, not just builtins.

Sources
95% confidence
A

'type -p commandname' returns the name of the disk file that would be executed, or nothing if the command is not a file (i.e., it's an alias, function, or builtin). This is similar to the 'command -p' or 'which' command behavior.

Sources
95% confidence
A

The PATH_SEPARATOR is a colon (':') on Unix/Linux systems. It separates directories in the PATH environment variable. On Windows (when using Bash via WSL or Cygwin), it may be semicolon (';') depending on the build.

Sources
95% confidence
A

When PATH is empty or unset, Bash only searches the current directory for commands (plus builtins, functions, aliases). This is a security consideration, as it differs from the default behavior of searching standard system directories.

Sources
95% confidence
A

The 'hash -r' command clears the entire hash table, forcing Bash to search the PATH again for all subsequent commands. This is useful when you've moved executables or updated your PATH.

Sources
95% confidence
A

No, Bash does NOT cache command lookup failures. If a command is not found, Bash will search PATH again each time you invoke it, rather than remembering that it doesn't exist.

Sources
95% confidence
A

Hashing improves performance by avoiding repeated filesystem searches. However, if you install a new version of a program in a PATH directory that appears earlier than the hashed location, Bash will still use the old hashed location unless you run 'hash -r' or restart the shell.

Sources
95% confidence
A

Bash uses command hashing by default. When the shell finds a command in the PATH, it remembers its location in a hash table. Subsequent executions of the same command use the hashed location instead of searching PATH again. The hash table is cleared when you start a new shell.

Sources
95% confidence
A

'type' is a Bash builtin that understands shell functions, aliases, keywords, and builtins. 'which' is typically an external command (on some systems it's also a builtin) that only searches PATH for executable files. 'type' is more comprehensive and shell-aware.

Sources
95% confidence
A

Bash searches PATH directories from left to right (in the order they appear in the PATH variable, separated by colons). It stops at the first match found and executes that file. The search is NOT recursive within directories.

Sources
95% confidence
A

'enable -a' displays all enabled and disabled shell builtins, showing which are currently active and which have been disabled.

Sources
95% confidence
A

The 'hash -d commandname' command removes the specified command from the hash table, causing Bash to search PATH again for that specific command on the next invocation.

Sources
95% confidence
A

'command -p commandname' uses a default value for PATH that guarantees it finds all standard utilities. This ensures the command is found even if the current PATH has been modified. The default PATH is '/bin:/usr/bin' on most systems (implementation dependent).

Sources
95% confidence
A

If a command name contains a slash ('/'), Bash does NOT search PATH. It treats it as a pathname (relative or absolute) and attempts to execute that specific file directly. If the file doesn't exist or isn't executable, Bash returns an error.

Sources
95% confidence
A

'enable -n commandname' disables the specified builtin command, allowing an external command with the same name to be executed without using the full path. Use 'enable commandname' to re-enable the builtin.

Sources
95% confidence
A

'enable -s' enables only the specified dynamic loadable builtins (if Bash was compiled with support for dynamic loading of builtins). Without arguments, 'enable -s' lists all currently enabled dynamic builtins.

Sources
95% confidence
A

'hash -l' displays the hash table in a format that can be reused as input. The output shows commands and their full paths, useful for saving and restoring the hash table state.

Sources
95% confidence
A

'type -t commandname' returns a single word indicating the command type: 'alias', 'keyword', 'function', 'builtin', or 'file'. If the command is not found, it returns nothing.

Sources
95% confidence
A

When a command is not found, Bash executes the function named 'command_not_found_handle' if it exists. This function receives the command name and arguments as parameters. If not defined, Bash prints an error message. This is a Bash extension, not POSIX.

Sources
95% confidence
A

Using './commandname' explicitly tells Bash to execute 'commandname' from the current directory. The './' prefix bypasses PATH searching entirely and directly accesses the file. This is required for executables in the current directory when '.' is not in PATH.

Sources
95% confidence
A

'command -v commandname' returns a description of the command similar to 'type', but without executing it. Returns the path or alias/function definition. Returns failure status if command not found.

Sources
95% confidence
A

Bash automatically updates the hash table when it successfully finds a command in PATH. It also updates the table if PATH is changed. However, if a command is moved or deleted, Bash won't know until you run 'hash -r' or the lookup fails.

Sources
95% confidence
A

CDPATH is used by the 'cd' builtin command to search for the target directory. It works like PATH but for directory changes. If the directory argument to 'cd' doesn't start with '/', Bash searches directories listed in CDPATH (colon-separated).

Sources
95% confidence
A

'type -P commandname' forces a PATH search even if the command is a builtin, alias, or function. It returns the disk file path or nothing if no file is found in PATH. This is useful when you specifically want the external command location.

Sources
95% confidence
A

'enable -p' displays only the disabled shell builtins, showing which builtin commands have been turned off and can be shadowed by external commands.

Sources
95% confidence
A

Use 'set +h' or 'set +o hash' to disable command hashing. With hashing disabled, Bash searches the PATH directories on every command invocation. To re-enable hashing, use 'set -h' or 'set -o hash'.

Sources
95% confidence

Bourne Shell Builtins > Flow Control

34 questions
A

Yes, shift is a Bourne Shell builtin that shifts positional parameters to the left by n (default 1). Parameters from $n+1...$# are renamed to $1...$#-n, and parameters $1...$n are unset. shift returns 0 if n is in range, or 1 if n is greater than $#.

Sources
95% confidence
A

The wait builtin waits for each specified background process to complete and returns the exit status of the last awaited command. If no jobspec is specified, it waits for all currently active child processes and returns the exit status of the last command to finish.

Sources
95% confidence
A

The ERR signal with trap causes the command to be executed whenever the shell would exit if a pipeline or command list returns a non-zero exit status. The ERR trap is not executed if the failed command is part of an until or while loop, part of an if statement, part of a && or || list except the command following the final || or &&, or if the command's return status is being inverted with !.

Sources
95% confidence
A

The local builtin creates local variables within a function. Variables declared with local are visible only within the function and its children. When the function returns, the previous value (if any) is restored. local can only be used within functions.

Sources
95% confidence
A

The false builtin does nothing unsuccessfully and returns an exit status of 1. It is typically used to force a loop exit condition or to fail a test condition.

Sources
95% confidence
A

The let builtin evaluates each arithmetic expression argument. If the last expression evaluates to 0, let returns 1; otherwise it returns 0. Each expression is evaluated as a shell arithmetic expression.

Sources
95% confidence
A

trap -p displays a list of currently set traps in a form that can be reused as shell input. If sigspec is supplied, only the traps for those signals are displayed.

Sources
95% confidence
A

The eval builtin reads its arguments, concatenates them with spaces, and evaluates the resulting string as bash commands. The resulting command is then read and executed by the shell, and its exit status is returned as the exit status of eval.

Sources
95% confidence
A

The continue builtin skips the remaining commands in the current loop iteration and begins the next iteration. If N is specified, it resumes with the N-th enclosing loop. The default value for N is 1.

Sources
95% confidence
A

The return builtin causes a function to exit with a specified return status (n). If n is not supplied, the return status is that of the last command executed within the function. If used outside a function, but during script execution with the . or source builtin, it causes the shell to stop executing that script and return to the calling context.

Sources
95% confidence
A

The exit builtin causes the shell to exit with a given status. If n is omitted, the exit status is that of the last command executed. When used in a subshell, only the subshell exits.

Sources
95% confidence
A

The . builtin (source) reads and executes commands from the filename argument in the current shell context. If filename does not contain a slash, the PATH variable is used to find the file. The return status is the exit status of the last command executed, or 0 if no commands were executed.

Sources
95% confidence
A

The : builtin is a null command that does nothing and returns a successful exit status (0). It expands arguments and performs redirections, but executes no commands. Commonly used as a placeholder in while loops or for evaluating conditions without side effects.

Sources
95% confidence
A

The trap builtin allows you to specify commands that will be executed when the shell receives signals. Syntax: trap [-lp] [[arg] sigspec ...]. If arg is absent, all signals specified are reset to their original values. If arg is -, each specified signal is set to its original disposition.

Sources
95% confidence
A

The exec builtin replaces the shell with a given command without creating a new process. If command is specified, it replaces the shell. If no command is specified, any redirections take effect in the current shell. Commonly used to redirect file descriptors or change the shell's standard input/output.

Sources
95% confidence

Executing Commands > Signal Processing

34 questions
A

The 'wait -n' option (available in bash 4.3+) waits for any single background job to complete and returns its exit status. When multiple jobs are specified, it returns the exit status of the next job that completes.

Sources
95% confidence
A

The 'trap -l' command causes the shell to print a list of signal names and their corresponding numbers.

Sources
95% confidence
A

The 'trap -p' command causes the shell to display the trap commands associated with each sigspec. If no sigspec is supplied, 'trap -p' prints all of the traps currently set.

Sources
95% confidence
A

The ERR pseudo-signal. When a pipeline command (which may be a simple command, a compound command, or a function) returns a non-zero exit status, trap executes the command associated with ERR. However, ERR is not triggered if the failed command is part of a command list immediately following an 'if', 'elif', 'while', or 'until' keyword, part of a test in an 'if' statement, part of an '&&' or '||' list where the command following failed, or if the command's return status is being inverted with '!'

Sources
95% confidence
A

The trap builtin has the syntax: trap [-lp] [[arg] sigspec ...]. The 'arg' is the command to execute when the signal 'sigspec' is received. If arg is absent or '-', the signal handling is reset to the default. If arg is the null string, the signal is ignored.

Sources
95% confidence
A

The ERR trap is triggered when any command returns a non-zero exit status (with exceptions for conditional contexts), while 'set -e' causes the shell to exit immediately when any command exits with a non-zero status. The ERR trap allows you to run cleanup code, whereas errexit terminates execution. Both can be used together.

Sources
95% confidence
A

The 'wait -f' option (available in bash 5.1+) causes wait to wait until all jobs in the job specification have terminated before returning exit status, instead of returning when the status of the last job in the list is known. This option is only effective when job control is enabled.

Sources
95% confidence
A

The 'disown -h' option marks each job so that SIGHUP is not sent to the job if the shell receives a SIGHUP (hangup signal). This prevents the job from being killed when the shell's controlling terminal is closed.

Sources
95% confidence

Readline Interaction > Navigation

34 questions
A

In readline notation, M-x means Meta-X. On keyboards without a meta key, M-x means ESC x (press Escape then the x key). ESC becomes the meta prefix. M-C-x means ESC-Control-x (press Escape, then hold Control while pressing x).

Sources
95% confidence
A

Readline commands may be given numeric arguments which normally act as a repeat count. For navigation commands, a positive argument repeats the movement, while a negative argument reverses the direction (e.g., negative argument with forward-word moves backward).

Sources
95% confidence

Quoting > Extended Quoting Formats

34 questions
A

Bash has two extended quoting formats: ANSI-C Quoting ($'string') and Locale-Specific Translation ($"string"). These are in addition to the basic quoting mechanisms: escape character, single quotes, and double quotes.

Sources
95% confidence
A

When the noexpand_translation option is enabled using the shopt builtin, translated strings are single-quoted instead of double-quoted. This prevents variable and command expansion within translated strings.

Sources
95% confidence
A

ANSI-C quoting uses the syntax $'string'. Character sequences of this form are treated as a special kind of single quotes where backslash-escaped characters are replaced as specified by the ANSI C standard.

Sources
95% confidence

Shell Variables > Execution Context and Debugging

33 questions
A

No, BASH_XTRACEFD must be set to an integer that refers to an already open file descriptor. If set to an invalid file descriptor, Bash will produce an error when debugging is enabled.

Sources
95% confidence
A

The ERR trap is executed whenever a command returns a non-zero exit status, but only if the command is not part of a compound list like && or ||, or part of an if/while/until construct.

Sources
95% confidence
A

BASH_ARGC contains the number of parameters in each stack frame. BASH_ARGC[0] is the total number of parameters for the current subshell, BASH_ARGC[1] for the parent, etc.

Sources
95% confidence
A

EPOCHREALTIME contains the time since the epoch in seconds with microsecond precision as a floating-point value (e.g., 1704067200.123456).

Sources
95% confidence
A

BASH_REMATCH is populated after a successful match using the =~ conditional operator in [[ ]]. BASH_REMATCH[0] contains the entire match, and BASH_REMATCH[1] through BASH_REMATCH[n] contain captured groups.

Sources
95% confidence
A

BASH_ENV is read and executed when Bash is invoked to execute a shell script in non-POSIX mode, but only if Bash is an interactive shell. It is not executed for login shells or when Bash is started with the --norc option.

Sources
95% confidence
A

BASHOPTS contains enabled shell options in a colon-separated list, similar to SHELLOPTS, but for options controlled by the 'shopt' builtin rather than 'set'.

Sources
95% confidence
A

SHELLOPTS is a read-only variable. It contains enabled shell options in a colon-separated format and cannot be directly modified. Use 'set -o option' or 'shopt' commands to change options.

Sources
95% confidence
A

The DEBUG trap is executed before every simple command in a script, allowing for debugging and tracing execution. The BASH_COMMAND variable shows the command about to execute.

Sources
95% confidence

Bash Conditional Expressions > File Comparison Tests

33 questions
A

The -r, -w, and -x operators check the effective permissions, which considers the real user ID, effective user ID, and group memberships. These operators test whether the current process can actually read, write, or execute the file, not just what the permission bits show. For example, a file owned by root with mode 600 may still show as readable if the current user has appropriate capabilities or group membership.

Sources
95% confidence

Redirections > File Descriptor Operations

33 questions
A

There is no functional difference in most cases. 2>&1 explicitly duplicates fd 1 to fd 2. >&1 is an older form where the leading digit is omitted, defaulting to 1, so it means 1>&1 (which redirects stdout to stdout) followed by 2>&1. The explicit 2>&1 form is preferred for clarity.

Sources
95% confidence
A

The null command : with redirections opens or creates files without executing any command. For example, : >file creates an empty file or truncates an existing one. This is useful for creating zero-length files from within a script.

Sources
95% confidence
A

The &>file redirection redirects both stdout (fd 1) and stderr (fd 2) to file. This is equivalent to >file 2>&1. The append form is &>>file, equivalent to >>file 2>&1.

Sources
95% confidence
A

The <<-delimiter form strips leading tab characters from each line of the here document body. This allows the here document content to be indented naturally within a script while still maintaining proper formatting.

Sources
95% confidence
A

The |& operator is shorthand for 2>&1 |. It pipes both stdout and stderr to the standard input of the following command. For example: command1 |& command2 is equivalent to command1 2>&1 | command2.

Sources
95% confidence
A

The redirection 2>&1 duplicates file descriptor 1 (stdout) to file descriptor 2 (stderr), causing stderr to go to the same destination as stdout. The order matters: it must appear after any redirection of fd 1.

Sources
95% confidence

Shell Commands > Compound Commands

32 questions

Shell Functions > Return Values and Exit Status

32 questions
A

Bash does not accept negative arguments to the return statement. If you pass a negative value to return, it's treated as an error. However, exit status 255 may sometimes appear from negative values due to unsigned integer wrapping.

Sources
95% confidence

Bash Builtin Commands > Special Builtins

32 questions
A

Syntax: break [n]. Exits from within a for, while, until, or select loop. If n is specified, break n levels. n must be ≥ 1. If n is greater than the number of enclosing loops, all enclosing loops are exited. Returns 0 unless n is not greater than or equal to 1.

Sources
95% confidence
A

If arg is absent (and there is a single sigspec) or -, each specified signal is reset to its original disposition (the value it had upon entrance to the shell).

Sources
95% confidence
A

If a sigspec is RETURN, the command arg is executed each time a shell function or a script executed with the . or source builtins finishes executing.

Sources
95% confidence
A

The ERR trap is not executed if the failed command is: part of the command list immediately following a while or until keyword, part of the test in an if statement, part of a command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted using !.

Sources
95% confidence
A

If the -n option is supplied, and name is a variable with the nameref attribute, name will be unset rather than the variable it references. -n has no effect if the -f option is supplied.

Sources
95% confidence
A

If a sigspec is DEBUG, the command arg is executed before every simple command, for command, case command, select command, every arithmetic for command, and before the first command executes in a shell function.

Sources
95% confidence

Introduction

32 questions
A

Shells may be used interactively or non-interactively. In interactive mode, they accept input typed from the keyboard. When executing non-interactively, shells execute commands read from a file or a string.

Sources
95% confidence
A

A token is a sequence of characters considered a single unit by the shell. It is either a word or an operator.

Sources
95% confidence
A

Job control is a mechanism by which users can selectively stop (suspend) and restart (resume) execution of processes.

Sources
95% confidence
A

POSIX stands for a family of open system standards based on Unix, and Bash is primarily concerned with the Shell and Utilities portion of the POSIX 1003.1 standard.

Sources
95% confidence
A

A shell is both a command interpreter and a programming language. As a command interpreter, the shell provides the user interface to the rich set of GNU utilities. The programming language features allow these utilities to be combined. Users can create files containing commands that become commands themselves with the same status as system commands in directories such as /bin.

Sources
95% confidence
A

A name is a word consisting solely of letters, numbers, and underscores, and beginning with a letter or underscore. Names are used as shell variable and function names, also referred to as an identifier.

Sources
95% confidence
A

At its base, a shell is simply a macro processor that executes commands. The term macro processor means functionality where text and symbols are expanded to create larger expressions.

Sources
95% confidence
A

A control operator is a token that performs a control function. It is a newline or one of the following: '||', '&&', '&', ';', ';;', ';&', ';;&', '|', '|&', '(', or ')'.

Sources
95% confidence
A

The exit status is the value returned by a command to its caller. The value is restricted to eight bits, so the maximum value is 255.

Sources
95% confidence
A

A metacharacter is a character that, when unquoted, separates words. A metacharacter is a space, tab, newline, or one of the following characters: '|', '&', ';', '(', ')', '<', or '>'.

Sources
95% confidence
A

Bash is the shell, or command language interpreter, for the GNU operating system. It is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and the C shell (csh), intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard.

Sources
95% confidence
A

Redirection constructs permit fine-grained control of the input and output of commands through constructs like '>', '<', '>>', and pipe operators.

Sources
95% confidence
A

A process group is a collection of related processes each having the same process group ID.

Sources
95% confidence
A

A shell allows execution of GNU commands, both synchronously and asynchronously. The shell waits for synchronous commands to complete before accepting more input; asynchronous commands continue to execute in parallel with the shell while it reads and executes additional commands.

Sources
95% confidence
A

Shell builtins are commands that are implemented internally by the shell itself, rather than by an executable program somewhere in the file system. Examples include cd, break, continue, and exec which cannot be implemented outside of the shell because they directly manipulate the shell itself.

Sources
95% confidence
A

Bash is an acronym for 'Bourne-Again SHell', a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell sh.

Sources
95% confidence
A

A special builtin is a shell builtin command that has been classified as special by the POSIX standard.

Sources
95% confidence
A

Bash offers functional improvements over sh for both programming and interactive use, including command-line editing, unlimited size command history, job control, shell functions and aliases, indexed arrays of unlimited size, and integer arithmetic in any base from two to sixty-four.

Sources
95% confidence
A

A builtin is a command that is implemented internally by the shell itself, rather than by an executable program somewhere in the file system.

Sources
95% confidence
A

A reserved word is a word that has a special meaning to the shell. Most reserved words introduce shell flow control constructs, such as 'for' and 'while'.

Sources
95% confidence

Bindable Readline Commands > Commands For Changing Text

31 questions
A

capitalize-word capitalizes the current (or following) word (first character uppercase, rest lowercase). With a negative argument, it capitalizes the previous word but does not move point. Default binding is M-c (Meta-c).

Sources
95% confidence
A

kill-word kills from point to the end of the current word, or if between words, to the end of the next word. Word boundaries are the same as those used by forward-word. Default binding is M-d (Meta-d).

Sources
95% confidence

Shell Commands > Lists

31 questions
A

Bash provides one-dimensional indexed and associative array variables. Indexed arrays are referenced using integers (including arithmetic expressions) and are zero-based. Associative arrays use arbitrary strings as keys.

Sources
95% confidence
A

A negative offset in array slicing is taken relative to one greater than the maximum index of the specified array. You must separate the negative offset from the colon with a space to avoid confusion with the ':-' expansion operator: '${array[@]: -2}' gets the last 2 elements.

Sources
95% confidence
A

Use 'unset name' where name is the array to remove the entire array. Using 'unset name[@]' or 'unset name[*]' on an indexed array removes all elements but does not remove the array itself.

Sources
95% confidence
A

Use substring expansion syntax: '${name[@]:offset:length}' to get 'length' elements starting at 'offset'. For example, '${array[@]:1:3}' returns 3 elements starting at index 1. Omit 'length' to get all elements from offset to the end.

Sources
95% confidence
A

No, unsetting an array element does not re-index the array. The array retains gaps in its indices. To get a contiguous array after unsetting, you must rebuild it by copying non-empty elements to a new array.

Sources
95% confidence
A

Use '${name[@]}' or '${name[]}' to expand to all members of the array. The difference matters when within double quotes: '${name[]}' expands to a single word with values separated by the first character of IFS, while '${name[@]}' expands each element to a separate word.

Sources
95% confidence

Command Line Editing > Killing and Yanking

31 questions
A

M-C-y (Meta+Ctrl+Y). This yanks the nth argument from the previous command, prompted by a digit. After entering M-C-y, you type a digit to specify which argument to retrieve (0 for command name, 1 for first argument, etc.).

Sources
95% confidence
A

Use the bind builtin command: 'bind "\C-xk": kill-whole-line' or add to ~/.inputrc: '"\C-xk": kill-whole-line'. The bind command affects the current shell session, while .inputrc affects all readline applications.

Sources
95% confidence
A

Consecutive kill commands append to the kill-ring entry rather than creating separate entries. For example, pressing M-d multiple times kills multiple words into a single kill-ring entry that can be yanked together.

Sources
95% confidence

Bourne Shell Builtins > Command Execution

30 questions
A

The : builtin does nothing and returns a successful exit status (0). It expands arguments but performs no other actions. It is often used as a placeholder in conditional constructs or to provide a successful exit status.

Sources
95% confidence

Executing Commands > Exit Status and Return Codes

30 questions

Definitions

30 questions
A

A builtin is a command that is implemented internally by the shell itself, rather than by an executable program somewhere in the file system.

Sources
95% confidence
A

'in' is recognized as a reserved word if it is the third word of a 'case' or 'select' command. 'in' and 'do' are recognized as reserved words if they are the third word in a 'for' command. Otherwise, reserved words are recognized when unquoted and the first word of a command.

Sources
95% confidence
A

An operator is a control operator or a redirection operator. Operators contain at least one unquoted metacharacter.

Sources
95% confidence
A

A word is a sequence of characters treated as a unit by the shell. Words may not include unquoted metacharacters.

Sources
95% confidence
A

A job is a set of processes comprising a pipeline, and any processes descended from it, that are all in the same process group.

Sources
95% confidence
A

A reserved word is a word that has a special meaning to the shell. Most reserved words introduce shell flow control constructs, such as 'for' and 'while'.

Sources
95% confidence
A

A token is a sequence of characters considered a single unit by the shell. It is either a word or an operator.

Sources
95% confidence
A

POSIX is a family of open system standards based on Unix. Bash is primarily concerned with the Shell and Utilities portion of the POSIX 1003.1 standard.

Sources
95% confidence
A

A signal is a mechanism by which a process may be notified by the kernel of an event occurring in the system.

Sources
95% confidence
A

Job control is a mechanism by which users can selectively stop (suspend) and restart (resume) execution of processes.

Sources
95% confidence
A

A field is a unit of text that is the result of one of the shell expansions. After expansion, when executing a command, the resulting fields are used as the command name and arguments.

Sources
95% confidence

Job Control > Interactive vs Non-Interactive Behavior

30 questions
A

No, non-interactive shells do not expand aliases by default. Aliases are expanded by default only in interactive shells. The 'expand_aliases' shell option must be set in a non-interactive shell to use aliases.

Sources
95% confidence
A

The 'm' character in the $- special parameter indicates that job control (monitor mode) is enabled. For example, if 'echo $-' shows 'himBH', the 'm' means job control is active.

Sources
95% confidence
A

Bash determines if a shell is interactive by checking: 1) it was started without non-option arguments and without -c, 2) both standard input and standard error are connected to terminals, or 3) it was started with the -i option. It also checks if the 'i' flag in the $- special parameter is set.

Sources
95% confidence
A

No, non-interactive shells do not source ~/.bashrc by default. They look for the environment variable BASH_ENV and if it is set, expands its value and uses it as the name of a file to read and execute.

Sources
95% confidence
A

An interactive shell is one started without non-option arguments and without the -c option, with standard input and error connected to terminals, or one started with the -i option. Interactive shells also have the 'ps1' prompt set.

Sources
95% confidence
A

When job control is not active, background jobs (those started with &) report their job status but the shell does not maintain a job table, and job control builtins like 'fg', 'bg', and 'jobs' are not available.

Sources
95% confidence

Shell Arithmetic > Bitwise Operations

30 questions

Readline Init File > Init File Structure

29 questions

History Expansion > Modifiers

29 questions
A

The :p modifier can be combined with other modifiers. When :p is present, the entire history expansion is printed but not executed, regardless of other modifiers applied. For example, '!!:s/foo/bar/:p' prints the substitution result without running it.

Sources
95% confidence
A

There is no :% modifier in bash history expansion. The percent sign (%) is used in the history expansion event designator !% to refer to the most recent command matched by string search, but it is not a word modifier.

Sources
95% confidence

Quoting > Basic Quoting Mechanisms

29 questions
A

Character sequences of the form $'string' are treated as a special kind of single quotes. The sequence expands to string, with backslash-escaped characters in string replaced as specified by the ANSI C standard.

Sources
95% confidence
A

ANSI-C quoting supports these escape sequences: \a (alert/bell), \b (backspace), \e or \E (escape character), \f (form feed), \n (newline), \r (carriage return), \t (horizontal tab), \v (vertical tab), \ (backslash), ' (single quote), " (double quote), ? (question mark), \nnn (octal value, 1-3 digits), \xHH (hexadecimal value, 1-2 digits), \uHHHH (Unicode character, 4 hex digits), \UHHHHHHHH (Unicode character, 8 hex digits), \cx (control-x character).

Sources
95% confidence
A

The four quoting mechanisms in Bash are: the escape character, single quotes, double quotes, and ANSI-C quoting (dollar-single quotes). Locale-Specific Translation is also listed as a fifth mechanism in some contexts.

Sources
95% confidence
A

A metacharacter is a character that, when unquoted, separates words. A metacharacter is a space, tab, newline, or one of the following characters: |, &, ;, (, ), <, >.

Sources
95% confidence

Shell Syntax > Shell Processing Mechanics

29 questions
A

Brace expansion sequence expressions take the form {x..y[..incr]} where x and y are either integers or letters, and incr is an optional integer increment. When integers are supplied, it expands to each number between x and y inclusive. When letters are supplied, it expands to each character lexicographically between x and y inclusive. The default increment is 1 or -1 as appropriate.

Sources
95% confidence
A

A subshell is a copy of the shell process. Command substitution, commands grouped with parentheses, asynchronous commands, and builtin commands invoked as part of a pipeline (except possibly the last element with lastpipe option) are invoked in a subshell environment.

Sources
95% confidence
A

Bash uses a hash table to remember the full pathnames of executable files. Once a command is found in PATH, its location is cached. Bash performs a full search of PATH directories only if the command is not found in the hash table.

Sources
95% confidence
A

The seven types of shell expansion in order are: 1) Brace expansion, 2) Tilde expansion, 3) Parameter and variable expansion, 4) Arithmetic expansion, 5) Command substitution, 6) Word splitting, 7) Filename expansion. Tilde expansion, parameter/variable expansion, arithmetic expansion, and command substitution are performed in a left-to-right fashion. After all expansions, quote removal is performed. Process substitution is performed at the same time as tilde, parameter, variable, and arithmetic expansion and command substitution.

Sources
95% confidence
A

Bash searches for commands in this order: 1) Aliases (in interactive shells), 2) Shell functions, 3) Shell builtin commands, 4) Hash table (cached executables), 5) Directories in PATH variable (searched left to right). The search stops at the first match.

95% confidence
A

The 'set -o pipefail' option causes a pipeline to return the exit status of the last command to exit with a non-zero status, or zero if all commands exit successfully. This is available in Bash version 3 and beyond.

Sources
95% confidence
A

Brace expansion is performed before any other expansions. Any characters special to other expansions are preserved in the brace expansion result. Brace expansion is strictly textual and Bash does not apply any syntactic interpretation to the text between the braces.

Sources
95% confidence
A

A simple command other than a builtin or shell function is invoked in a separate execution environment consisting of: the shell's open files plus redirections, the current working directory, the file creation mode mask, exported shell variables and functions, and traps (caught traps reset to inherited values, ignored traps stay ignored).

Sources
95% confidence

Controlling the Prompt > System Identity

29 questions

Arithmetic Expansion

29 questions
A

Division in Bash arithmetic expansion truncates toward zero (integer division). For example: echo $((7 / 3)) outputs 2, and echo $((-7 / 3)) outputs -2 (not -3). This behavior differs from some languages that floor toward negative infinity.

Sources
95% confidence
A

$((expression)) is arithmetic expansion that returns a value and can be used in commands like echo $((x+1)). ((expression)) is an arithmetic compound command that evaluates an expression but doesn't return a value; it sets the exit status based on whether the result is zero (false) or non-zero (true). It's used in conditionals.

Sources
95% confidence

Shell Functions > Function Definition and Syntax

29 questions
A

The FUNCNEST variable, if set to a numeric value greater than 0, defines a maximum function nesting level. Function invocations that exceed the limit cause the entire command to abort. By default, Bash places no limit on the number of recursive calls.

Sources
95% confidence
A

Yes, the body of the function is the compound command, which is usually a list enclosed between { and }, but may be any compound command including subshells (), if/then/else/fi, case/esac, for/do/done, while/do/done, until/do/done, or select/do/done.

Sources
95% confidence
A

If the builtin command return is executed in a function, the function completes and execution resumes with the next command after the function call. Any command associated with the RETURN trap is executed before execution resumes.

Sources
95% confidence
A

For historical reasons, the curly braces that surround the body of the function must be separated from the body by blanks or newlines. This is because braces are reserved words and are only recognized as such when separated from the command list by whitespace or another shell metacharacter.

Sources
95% confidence
A

Yes, functions may be recursive. The FUNCNEST variable may be used to limit the depth of the function call stack and restrict the number of function invocations.

Sources
95% confidence

Using History Interactively > Event Selection

28 questions

Shell Arithmetic > Arithmetic Operations

28 questions
A

No, Bash arithmetic expansion only supports integer arithmetic. All numbers are treated as signed 64-bit integers (or at least signed long integers on the platform). For floating-point arithmetic, you must use external commands like bc or awk.

Sources
95% confidence
A

let evaluates expressions but doesn't output the result; it only sets the exit status based on whether the result is non-zero. $(( )) evaluates and substitutes the result. Also, let requires quotes around expressions with spaces, while $(( )) does not.

Sources
95% confidence

Modifying Shell Behavior > Debugging and Tracing

28 questions
A

Read commands but do not execute them. This may be used to check a shell script for syntax errors. This is ignored by interactive shells.

Sources
95% confidence
A

After expanding each simple command, for command, case command, select command, or arithmetic for command, display the expanded value of PS4, followed by the command and its expanded arguments or associated word list. This is commonly called xtrace or execution tracing.

Sources
95% confidence
A

Using - with no arguments signals the end of options, causes all remaining args to be assigned to the positional parameters. The -x and -v options are turned off. If there are no args, the positional parameters remain unchanged.

Sources
95% confidence
A

set -o xtrace is the same as set -x - it enables execution tracing that displays the expanded value of PS4 followed by commands and their expanded arguments.

Sources
95% confidence
A

If set, any trap on ERR is inherited by shell functions, command substitutions, and commands executed in a subshell environment. The ERR trap is normally not inherited in such cases.

Sources
95% confidence
A

If set, any traps on DEBUG and RETURN are inherited by shell functions, command substitutions, and commands executed in a subshell environment. The DEBUG and RETURN traps are normally not inherited in such cases.

Sources
95% confidence

Bash Builtin Commands > Directory Stack Builtins

28 questions
A

The -N argument removes the Nth entry counting from the right of the list shown by dirs, starting with zero. For example, 'popd -0' removes the last directory, 'popd -1' removes the next to last.

Sources
95% confidence
A

The +N argument removes the Nth entry counting from the left of the list shown by dirs, starting with zero. For example, 'popd +0' removes the first directory, 'popd +1' removes the second.

Sources
95% confidence

Filename Expansion > Shell Options for Globbing Behavior

28 questions
A

The extglob option enables five extended pattern matching operators: ?(pattern-list) matches zero or one occurrence, *(pattern-list) matches zero or more occurrences, +(pattern-list) matches one or more occurrences, @(pattern-list) matches exactly one occurrence, and !(pattern-list) matches anything except the pattern-list.

Sources
95% confidence
A

The extglob option is on by default in bash when enabled programmatically (in scripts), but the default varies by bash version. Starting from bash 4.1, extglob is enabled by default in interactive shells on Linux. Extended pattern matching includes patterns such as ?(pattern-list), *(pattern-list), +(pattern-list), @(pattern-list), and !(pattern-list).

Sources
95% confidence

Job Control > Execution States

28 questions
A

SIGCONT is signal number 18. It resumes execution of a process that has been stopped by SIGSTOP or SIGTSTP. If a stopped process receives SIGCONT, it continues execution even if it was in the foreground or background.

Sources
95% confidence
A

SIGTTIN is signal number 21. It is sent by the kernel when a background process attempts to read from the terminal. The signal causes the process to stop, preventing background jobs from interfering with terminal input.

Sources
95% confidence
A

The 'disown' command removes jobs from Bash's job table, causing Bash to stop tracking them. The jobs continue running but are no longer listed by 'jobs' and won't receive SIGHUP when the shell exits.

Sources
95% confidence

Quoting > Character Interpretation Control

28 questions
A

The four quoting mechanisms in Bash are: the escape character (backslash), single quotes, double quotes, and ANSI-C quoting (dollar-single quotes). Locale-specific translation is a fifth related mechanism.

Sources
95% confidence
A

Quoting is used to remove the special meaning of certain characters or words to the shell, disable special treatment for special characters, prevent reserved words from being recognized as such, and prevent parameter expansion.

Sources
95% confidence

Shell Arithmetic > Comparison Operations

28 questions
A

Within (( )), bitwise operators work on integer binary representations: & (bitwise AND), | (bitwise OR), ^ (bitwise XOR), ~ (bitwise NOT), << (left shift), >> (right shift). These are arithmetic, not comparison operators, but can be used in comparisons: (( (a & b) > 0 ))

Sources
95% confidence

Modifying Shell Behavior > Pathname Expansion and Globbing

28 questions
A

Yes, when GLOBIGNORE is set and not empty, filenames beginning with '.' are no longer treated specially. This means dot files will be included in pathname expansion unless explicitly excluded by patterns in GLOBIGNORE.

Sources
95% confidence
A

The 'casematch' option controls case sensitivity in pattern matching performed by the '[[ conditional command' and 'case' statements. When disabled via 'shopt -u casematch', pattern matching becomes case-insensitive.

Sources
95% confidence
A

When 'globstar' is enabled via 'shopt -s globstar', the pattern '**' matches all files and zero or more directories and subdirectories. If followed by a '/', only directories and subdirectories match.

Sources
95% confidence
A

While not directly related to globbing, 'expand_aliases' controls whether aliases are expanded during pathname expansion context. By default, aliases are not expanded in non-interactive shells unless this option is set.

Sources
95% confidence
A

The 'extglob' option (extended globbing) enables additional pattern matching operators: ?(pattern-list) for zero or one occurrence, *(pattern-list) for zero or more occurrences, +(pattern-list) for one or more occurrences, @(pattern-list) for exactly one occurrence, and !(pattern-list) for anything except the pattern.

Sources
95% confidence
A

GLOBIGNORE is a colon-separated list of patterns defining filenames to ignore during pathname expansion. Files matching these patterns are excluded from expansion results. If GLOBIGNORE is set and not empty, dot files are included unless the pattern explicitly excludes them.

Sources
95% confidence

Conditional Constructs > Pattern Matching Conditionals

27 questions
A

When extglob is enabled, five extended pattern matching operators are recognized: ?(pattern-list) matches zero or one occurrence, *(pattern-list) matches zero or more occurrences, +(pattern-list) matches one or more occurrences, @(pattern-list) matches one of the patterns, and !(pattern-list) matches anything except one of the patterns.

Sources
95% confidence

Interactive Shells > Job Control

27 questions
A

In Bash job control, each job is a process group with a unique process group ID (PGID). The foreground job has control of the terminal, and background jobs do not. The 'jobs -l' command displays both job numbers and process group IDs.

Sources
95% confidence
A

In interactive shells, Bash does not send SIGHUP to background jobs by default when the shell exits, unless the huponexit option is set. The jobs continue running (or are orphaned) after the shell exits. Using 'disown' removes jobs from the job table but they continue running.

Sources
95% confidence
A

The wait builtin waits for background processes to complete. If given job specifications or process IDs, wait waits for each specified process/job to exit and returns the exit status of the last command waited for. With no arguments, wait waits for all currently active child processes and returns 0.

Sources
95% confidence
A

The huponexit option controls whether Bash sends SIGHUP to all jobs when an interactive login shell exits. If set (shopt -s huponexit), Bash sends SIGHUP to all jobs; if unset (the default), jobs are not sent SIGHUP on exit.

Sources
95% confidence
A

The suspend builtin suspends the execution of the shell until it receives a SIGCONT signal. The -f option prevents the shell from complaining if it cannot suspend itself (e.g., if it's a login shell).

Sources
95% confidence
A

The job_control variable (set automatically by Bash, not settable by users) indicates whether job control is enabled. It is set when the shell has job control enabled, typically in interactive shells on systems that support job control.

Sources
95% confidence
A

The auto_resume option controls how the shell treats single word simple commands without redirections. If set, the shell searches the job table for a job whose command starts with the specified word and resumes it in the foreground or background depending on how the job was started.

Sources
95% confidence
A

Ctrl+Y sends the SIGSTOP signal to the foreground process group when the shell supports software flow control (IXON), causing the process to suspend but delaying the signal until the process attempts to read from the terminal.

Sources
95% confidence
A

Job control is typically disabled in non-interactive shells. The 'set -m' option can enable it, but job control is primarily designed for interactive use where the shell has a controlling terminal.

Sources
95% confidence
A

In job listings, the symbol + indicates the current job (the most recent job started or foregrounded), and - indicates the previous job (the second most recent job). These symbols are used with job specifications: %% or %+ refers to the current job, and %- refers to the previous job.

Sources
95% confidence
A

Job control is a facility that allows users to stop and resume processes, and move processes between the foreground and background. It requires the operating system to support job control and is typically only available in interactive shells.

Sources
95% confidence
A

The monitor option (set -m or set -o monitor) enables job control. When set, Bash places all processes in each pipeline into separate process groups and allows interactive job control facilities.

Sources
95% confidence
A

The default format for job status includes: job number, status (Running, Done, Stopped, Exit), and the command. For example: '[1]+ Running sleep 100 &' where 1 is the job number, + indicates it's the current job, 'Running' is the status, and 'sleep 100 &' is the command.

Sources
95% confidence
A

The disown builtin removes jobs from the shell's job table. Options include -a (remove all jobs), -h (mark each job so SIGHUP is not sent to the job if the shell receives a SIGHUP), and -r (remove only running jobs). Jobs that have been disowned are no longer managed by the shell.

Sources
95% confidence
A

The jobs builtin displays the status of jobs in the current shell. Options include -l (list process IDs in addition to job numbers), -n (list only jobs whose status has changed since the last notification), -p (list process group IDs only), and -r (restrict to running jobs) or -s (restrict to stopped jobs).

Sources
95% confidence

Filename Expansion > Character Classes and Bracket Expressions

27 questions
A

When globasciiranges is enabled (default in bash 4.3+), range expressions like [a-z] are interpreted based on ASCII/Unicode code point ordering regardless of locale. When disabled, ranges respect the current locale's collation order.

Sources
95% confidence
A

When nocaseglob is enabled, bash matches filenames in a case-insensitive manner during filename expansion. This means [[:upper:]] and [[:lower:]] would match both uppercase and lowercase letters.

Sources
95% confidence

Shell Parameters > Positional Parameters

27 questions
A

When a positional parameter consisting of more than a single digit is expanded, it must be enclosed in braces. Without braces, a digit following '$' can only refer to one of the first nine positional parameters ($1-$9). For example, if the first positional parameter has the value 'a', then ${11} expands to the value of the eleventh positional parameter, while $11 expands to 'a1'.

Sources
95% confidence
A

A positional parameter is a parameter denoted by one or more digits, other than the single digit 0. Positional parameters are assigned from the shell's arguments when it is invoked, and may be reassigned using the set builtin command.

Sources
95% confidence
A

If parameter is '@' or '*', the result is length positional parameters beginning at offset. Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1 by default. If offset is 0, and the positional parameters are used, $0 is prefixed to the list.

Sources
95% confidence
A

Within double quotes, "$*" expands to a single word with the value of each parameter separated by the first character of the IFS variable (equivalent to "$1c$2c…" where c is the first character of IFS). "$@" expands to each parameter as a separate word (equivalent to "$1" "$2" …).

Sources
95% confidence
A

$0 expands to the name of the shell or shell script. This is set at shell initialization. If Bash is invoked with a file of commands, $0 is set to the name of that file. If Bash is started with the -c option, then $0 is set to the first argument after the string to be executed, if one is present. Otherwise, it is set to the filename used to invoke Bash.

Sources
95% confidence
A

getopts is used by shell scripts to parse positional parameters. Each time it is invoked, getopts places the next option in the shell variable name, and the index of the next argument to be processed into the variable OPTIND. OPTIND is initialized to 1 each time the shell or a shell script is invoked. When an option requires an argument, getopts places that argument into the variable OPTARG.

Sources
95% confidence
A

The positional parameters are temporarily replaced when a shell function is executed. When a function is executed, the arguments to the function become the positional parameters during its execution. The special parameter '#' is updated to reflect the new set of positional parameters, but special parameter 0 is unchanged.

Sources
95% confidence

Readline Interaction > Text Manipulation

26 questions
A

M-o (Meta-o or Alt-o) is the default key binding for 'overwrite-mode', which toggles between insert mode and overwrite mode. In overwrite mode, typed characters replace existing characters instead of being inserted.

Sources
95% confidence

Shell Functions > Function Execution and Invocation

26 questions
A

Bash uses dynamic scoping to control a variable's visibility within functions. With dynamic scoping, visible variables and their values are a result of the sequence of function calls that caused execution to reach the current function.

Sources
95% confidence
A

Shell functions are executed just like a 'regular' simple command. They are executed in the current shell context; no new process is created to interpret them.

Sources
95% confidence
A

If a variable at the current local scope is unset, it remains so (appearing as unset) until it is reset in that scope or until the function returns. Once the function returns, any instance of the variable at a previous scope becomes visible.

Sources
95% confidence
A

FUNCNEST defines a maximum function nesting level when set to a numeric value greater than 0. Function invocations that exceed this nesting level will cause the current command to abort.

Sources
95% confidence
A

FUNCNAME is an array variable containing the names of all shell functions currently in the execution call stack. The element with index 0 is the name of any currently-executing shell function. This variable exists only when a shell function is executing. Assignments to FUNCNAME have no effect.

Sources
95% confidence
A

If return is executed by a trap handler, the last command used to determine the status is the last command executed before the trap handler. If return is executed during a DEBUG trap, the last command used to determine the status is the last command executed by the trap handler before return was invoked.

Sources
95% confidence

Controlling the Prompt > Command Context

26 questions
A

PS1 is displayed when bash is ready to read a command. PS2 is displayed when bash needs more input to complete a command. PS0 is displayed after reading a command but before executing it. PS4 is displayed before tracing each command when the -x option is enabled.

Sources
95% confidence

Bourne Shell Builtins > Script Lifecycle

26 questions
A

The 'wait -n' option waits for exactly one background job or process to complete and returns its exit status. If multiple jobs terminate while wait is waiting, the status of one of them is returned (not necessarily the one that terminated first).

Sources
95% confidence
A

ERR is a special condition that trap recognizes. When used (trap 'command' ERR), the command is executed whenever a pipeline or list of commands (which may be a single compound command) exits with a non-zero status, subject to these conditions: the ERR trap is not executed if the failed command is part of an until or while loop, part of an if statement, part of a && or || list, or if the command's return status is being inverted with !.

Sources
95% confidence
A

Traps that are set while a subshell is executing remain in effect when the subshell exits. However, traps are not inherited by subshells when they are first created.

Sources
95% confidence
A

The exec builtin replaces the shell with a new command without creating a new process. After exec, the new command becomes the shell process, and the original shell's PID is retained. If no command is specified, any redirections take effect in the current shell.

Sources
95% confidence
A

RETURN is a special condition that trap recognizes. When used (trap 'command' RETURN), the command is executed after each shell function or script sourced with the . or source builtins finishes executing.

Sources
95% confidence
A

The command 'trap -p' displays the trap commands associated with each signal. If signal specifications are provided, only traps for those signals are displayed.

Sources
95% confidence
A

The times builtin prints the accumulated user and system times for the shell and for all processes that have executed as children of the shell. The output format shows two lines: user and system time for the shell, and user and system time for child processes.

Sources
95% confidence
A

DEBUG is a special condition that trap recognizes. When used (trap 'command' DEBUG), the command is executed before every simple command, for command, case command, select command, every arithmetic for command, and before the first command executes in a shell function.

Sources
95% confidence
A

The eval builtin concatenates all its arguments with spaces and evaluates the resulting string as a command. The command is then read and executed by the shell, and its exit status is returned as the exit status of eval.

Sources
95% confidence
A

EXIT is not a real signal but a special condition that trap recognizes. When used (trap 'command' EXIT), the command is executed when the shell exits, regardless of whether the exit is from an exit command, reaching end-of-file, or from a signal.

Sources
95% confidence
A

The 'wait -f' option causes wait to wait until each job or process terminates before returning its exit status, rather than returning when the job status changes. This requires job control to be enabled.

Sources
95% confidence
A

The wait builtin waits for each specified job or process to complete and returns the exit status of the last awaited command. If no specifications are given, it waits for all currently active child processes.

Sources
95% confidence

Filename Expansion > Extended Pattern Matching

26 questions

Shell Parameter Expansion > Substring Extraction

25 questions
A

${parameter:offset:length} - where 'parameter' is the variable name, 'offset' is the starting position, and 'length' is the number of characters to extract. The length parameter can be omitted to extract from offset to the end of the value.

Sources
95% confidence
A

If length evaluates to a number less than zero, it is interpreted as an offset in characters from the end of the value of parameter rather than a number of characters. The expansion is the characters between offset and that result. For example, with string='01234567890abcdefgh', ${string:7:-2} returns '7890abcdef'.

Sources
95% confidence

Arrays > Element Access and Retrieval

25 questions
A

${array[@]^} - first char uppercase, ${array[@]^} - all first chars uppercase, ${array[@],} - first char lowercase, ${array[@],} - all first chars lowercase, ${array[@]^^} - all uppercase, ${array[@,,} - all lowercase (Bash 4.0+)

Sources
95% confidence

Pipelines

25 questions
A

A pipeline is a sequence of simple commands separated by one of the control operators '|' or '|&'. The output of each command in the pipeline is connected via a pipe to the input of the next command.

Sources
95% confidence
A

The reserved word 'time' causes timing statistics to be printed for the pipeline once it finishes. The statistics currently consist of elapsed (wall-clock) time and user and system time consumed by the command's execution.

Sources
95% confidence
A

The TIMEFORMAT variable is a format string that specifies how the timing information for pipelines prefixed with the 'time' reserved word should be displayed.

Sources
95% confidence
A

Builtin commands that are invoked as part of a pipeline, except possibly in the last element depending on the value of the 'lastpipe' shell option, are also executed in a subshell environment.

Sources
95% confidence
A

If the precision (p) is not specified in TIMEFORMAT escape sequences, the value 3 is used (3 decimal places). At most three places after the decimal point may be specified; values of p greater than 3 are changed to 3.

Sources
95% confidence
A

PIPESTATUS is an array variable containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command).

Sources
95% confidence
A

If '|&' is used, the standard error of command1 is connected to command2's standard input through the pipe; it is shorthand for '2>&1 |'. This implicit redirection of the standard error is performed after any redirections specified by the command.

Sources
95% confidence
A

If set, and job control is not active, the shell runs the last command of a pipeline not executed in the background in the current shell environment (not a subshell).

Sources
95% confidence

Shell Parameters > Special Parameters

25 questions

Readline Interaction > Command Modifiers

25 questions
A

The exchange-point-and-mark command (Ctrl-x Ctrl-x) swaps the positions of the mark and point (cursor). This allows you to jump back to a previously marked location and then return to the original position by invoking it again. It's useful for working with marked regions of text.

Sources
95% confidence
A

The dump-macros command prints all currently defined Readline macros and their key bindings. Macros are sequences of characters or commands that are bound to a single key sequence and expanded when that key is pressed.

Sources
95% confidence
A

The do-lowercase-version command is used internally by Readline when a Meta-character is entered without a valid binding. It executes the lowercase version of the unbound character if it exists. This is an internal mechanism and not typically invoked directly by users.

Sources
95% confidence
A

The character-search command (Ctrl-]) searches forward in the command line for the next character that matches the character typed immediately after Ctrl-]. The cursor moves to that character. For example, Ctrl-] followed by 'n' moves to the next 'n' in the line.

Sources
95% confidence
A

The skip-csi-sequence command is used internally by Readline to skip over CSI (Control Sequence Introducer) escape sequences that are produced by certain function keys. This ensures that these special escape sequences don't interfere with normal editing operations. It's part of Readline's terminal handling and not typically invoked directly.

Sources
95% confidence
A

The re-read-init-file command (Meta-Ctrl-x or Alt-Ctrl-x) re-reads the inputrc file (~/.inputrc or /etc/inputrc) and applies any changes immediately without restarting Bash. This allows you to test new key bindings or variable changes in your current session.

Sources
95% confidence
A

The numeric argument in Readline can be any integer value that fits in a C int type (typically -2,147,483,648 to 2,147,483,647 on 32-bit systems, or larger on 64-bit systems). In practice, you can enter very large numbers by typing multiple digits, but most commands will have practical limits based on the buffer size.

Sources
95% confidence
A

To specify a numeric argument in Emacs mode, type Meta-0 through Meta-9 (or Alt-0 through Alt-9) followed by the command. For example, Meta-4 Meta-f moves forward four words. You can also type the digit and then hold Meta while typing additional digits. A negative argument is specified with Meta-- (Alt+-).

Sources
95% confidence
A

You can execute the last Readline command again using Ctrl-o (operate-and-get-next). After the current command is executed, Ctrl-o fetches the next line from history and allows you to edit it. This is different from simply pressing Enter which just executes and shows the next prompt.

Sources
95% confidence
A

The complete command (Tab) performs completion according to the settings of 'readline-completion-auto-skip', 'readline-completion-case-fold', and other variables. It either completes the word, lists possible completions, or does nothing depending on the situation. The possible-completions command (Meta-? or Alt-?) always lists all possible completions without attempting to complete.

Sources
95% confidence
A

The tilde-expand command (Meta-& or Alt-&) performs tilde expansion on the current word. It expands ~ to the value of HOME, ~user to user's home directory, and other tilde prefixes according to the rules in the Bash manual. This can be invoked on a word before pressing Enter to see the expansion.

Sources
95% confidence
A

The undo command (Ctrl-_ or Ctrl-x Ctrl-u) undoes the most recent change to the command line. To undo multiple changes, you can invoke it repeatedly. Each undo reverses one unit of editing (insertions, deletions, or other modifications). In some configurations, you can also use Meta-- (Alt+-) followed by commands to apply numeric arguments.

Sources
95% confidence
A

The prefix-meta command (Meta or Escape) makes the next character typed be interpreted as a Meta-character. This allows you to use the Escape key as a Meta prefix on keyboards that don't have a dedicated Meta or Alt key. For example, pressing Escape followed by 'f' is equivalent to Meta-f.

Sources
95% confidence
A

When a Readline command is executed without a numeric argument, it uses a default count of 1 for commands that repeat actions. For some commands like 'kill-line', the absence of a numeric argument may affect how much text is affected (e.g., killing from point to end of line versus a specific number of characters).

Sources
95% confidence
A

The dump-variables command prints all Readline variables that can be set in the inputrc file along with their current values. This is useful for checking the current state of Readline configuration and understanding which options are enabled.

Sources
95% confidence
A

The quoted-insert command (Ctrl-v or Ctrl-q) allows you to insert the next character literally, even if it would normally be interpreted as a Readline command. For example, Ctrl-v followed by Ctrl-c would insert a literal Ctrl-C character rather than interrupting. This is useful for inserting special characters into the command line.

Sources
95% confidence
A

You can execute any Readline command by name using Meta-x (or Alt-x) which invokes the 'execute-extended-command' function. This prompts for a command name and then executes it. You can use Tab completion at the prompt to see and select from available Readline commands.

Sources
95% confidence
A

The insert-completions command (Meta-* or Alt-*) inserts all possible completions for the current word before point. If there are multiple completions, they are all inserted separated by spaces. This is useful when you want to see or operate on all possible matches at once.

Sources
95% confidence
A

The set-mark command (Ctrl-@ or Ctrl-Space) sets the mark at the current cursor position. The mark is used in conjunction with point (cursor) to define a region of text for operations like copy and kill-region. In some terminal configurations Ctrl-Space may not work due to terminal flow control, making Ctrl-@ the alternative.

Sources
95% confidence
A

The keyboard-quit command (Ctrl-g) aborts the current editing command or incremental search and returns to the top-level prompt. It clears the current input line if not in a search, and exits incremental search mode if one is active. It's essentially the same as the 'abort' command.

Sources
95% confidence
A

A negative numeric argument reverses the direction of movement commands. For example, if Meta-f normally moves forward one word, a negative argument (Meta-- Meta-f) will move backward one word instead. Similarly, a negative argument to 'forward-char' moves backward instead of forward.

Sources
95% confidence

Bash Conditional Expressions > File Permission Tests

24 questions
A

In Bash, [ is a synonym for the test builtin. They are functionally equivalent. Both support file permission tests like -r file, -w file, and -x file. The modern [[ compound command is preferred for conditional expressions as it has fewer quirks and better handling of special characters.

Sources
95% confidence
A

The -r test respects the operating system's access() system call, which typically considers ACLs on systems that support them (Linux with POSIX ACLs, FreeBSD, etc.). If an ACL grants read permission, -r will return true even if traditional Unix permissions would deny it.

Sources
95% confidence
A

In POSIX mode (enabled with sh -c or set -o posix), Bash follows POSIX standards more strictly. The [[ ]] construct is not POSIX compliant and may not work. Use [ ] for portable scripts. However, the basic file test operators (-r, -w, -x, -O, -G, -u, -g, -k) remain available in POSIX mode.

Sources
95% confidence
A

The -a (AND) and -o (OR) binary operators used inside [ ] are deprecated in favor of the && and || shell control operators. However, single-letter file test operators like -r, -w, -x are not deprecated.

Sources
95% confidence
A

File permission tests return exit status 0 (true) if the condition is met, and 1 (false) if not met. Exit status >1 indicates an error (e.g., invalid syntax). The if and while commands interpret 0 as true and non-zero as false.

Sources
95% confidence

Bash Builtin Commands > Command History Builtins

24 questions
A

The fc -s option re-executes a command from history after optionally performing pat=rep substitution. This is commonly aliased as 'r' for quick re-execution.

Sources
95% confidence

Shell Commands > Simple Commands

24 questions
A

A simple command is a sequence of words separated by blanks (spaces or tabs), terminated by one of the shell's control operators. The first word generally specifies the command to be executed, with the rest of the words being that command's arguments.

Sources
95% confidence
A

If the search is unsuccessful, the shell searches for a defined shell function named command_not_found_handle. If that function exists, it is invoked in a separate execution environment and its exit status becomes the exit status. If not defined, the shell prints an error message and returns exit status 127.

Sources
95% confidence

Installing Bash > Basic Installation Process

24 questions

Bash Startup Files > File Selection Order

24 questions
A

When Bash is started non-interactively (for example, to run a shell script), it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if the command 'if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi' were executed, but the value of the PATH variable is not used to search for the filename.

Sources
95% confidence
A

When Bash is started in POSIX mode (as with the --posix command line option), it follows the POSIX standard for startup files. In this mode, interactive shells expand the ENV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read.

Sources
95% confidence
A

If Bash determines it is being run non-interactively with its standard input connected to a network connection (as when executed by rshd or sshd), it reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist and are readable. It will not do this if invoked as 'sh'. The --norc option may be used to inhibit this behavior, and --rcfile may force another file to be read.

Sources
95% confidence
A

When an interactive shell that is not a login shell is started, Bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This can be inhibited using the --norc option, or the --rcfile file option can force Bash to read and execute commands from a specified file instead of /etc/bash.bashrc and ~/.bashrc.

Sources
95% confidence

Grouping Commands

24 questions

Shell Syntax > Advanced Command Forms

24 questions
A

The process ID of the shell spawned to execute the coprocess is available as the value of the variable NAME_PID (or COPROC_PID for the default coprocess). The wait builtin can be used to wait for the coprocess to terminate.

Sources
95% confidence
A

Yes, arithmetic expansions may be nested. The expression undergoes the same expansions as if it were within double quotes, but double quote characters in the expression are not treated specially and are removed.

Sources
95% confidence
A

Bash supports two forms of process substitution: <(list) for input (reading from the process) and >(list) for output (writing to the process). The process list runs asynchronously and its input/output appears as a filename.

Sources
95% confidence
A

Yes, command substitutions may be nested. When using the backquoted form, you must escape the inner backquotes with backslashes. When using the $(command) form, no escaping is needed.

Sources
95% confidence

Programmable Completion > Completion Specification Management

24 questions
A

The 'complete' builtin command specifies how arguments to a command are to be completed by Readline. For each NAME supplied, it defines how arguments should be completed. If no options are supplied, existing completion specifications are printed in a reusable format.

Sources
95% confidence
A

The 'complete -A action' option specifies the type of completion to perform. Actions include: alias, arrayvar, binding, builtin, command, directory, disabled, enabled, export, file, function, group, helptopic, hostname, job, keyword, running, service, setopt, shopt, signal, stopped, user, variable.

Sources
95% confidence
A

The 'complete -r' option removes a completion specification for each NAME supplied. If no NAMEs are supplied, it removes all completion specifications.

Sources
95% confidence
A

Yes, compopt can modify completion options for named commands (NAME arguments) outside of a completion function. However, if no NAMEs are supplied, compopt must be called from within a function currently generating completions.

Sources
95% confidence
A

The 'compgen' builtin displays possible completions depending on the options. It is intended to be used from within a shell function generating possible completions. If the optional WORD argument is supplied, matches against WORD are generated.

Sources
95% confidence
A

The 'complete -D' option applies the completions and actions as the default for commands without any specific completion defined. This allows defining a fallback completion behavior.

Sources
95% confidence
A

The 'complete -I' option applies the completions and actions to the initial (usually the command) word. This allows defining custom completion for the command word itself.

Sources
95% confidence
A

The 'complete -p' option prints existing completion specifications in a reusable format that can be reused as input. This is useful for viewing currently defined completion specifications.

Sources
95% confidence

Shell Commands > Reserved Words

24 questions
A

The 'function' reserved word is used to define shell functions. When the 'function' reserved word is supplied, the parentheses are optional. For example, both 'function foo() {}' and 'function foo {}' are valid syntax.

Sources
95% confidence
A

The conditional constructs use the reserved words: 'if' (starts the conditional), 'then' (required after the condition), 'elif' (else if), 'else' (optional alternative), 'fi' (closes the entire conditional structure), and '[[', ']]' (conditional expression constructs).

Sources
95% confidence
A

Yes, technically reserved words can be used as variable names when quoted, as quoting prevents reserved words from being recognized as such. However, this is strongly discouraged as it leads to confusing and hard-to-maintain code.

Sources
95% confidence
A

No, the 'function' keyword is a Bash-specific extension and is not part of the POSIX standard. It is a pre-POSIX ksh-ism supported for backwards compatibility. The POSIX-compatible syntax is 'funcname() {}' without the 'function' keyword.

95% confidence
A

No, reserved words cannot be aliased in Bash. The POSIX standard states that reserved words cannot be subject to alias expansion. Operators and reserved words are hard-coded with no syntax to override them.

95% confidence
A

'[[' and ']]' are reserved words that form a conditional construct for testing expressions. They support pattern matching with the '==' operator and regular expression matching with the '=~' operator, unlike the single '[' test command.

Sources
95% confidence
A

The complete list of Bash reserved words is: !, case, coproc, do, done, elif, else, esac, fi, for, function, if, in, select, then, until, while, {, }, [[, ]], time

Sources
95% confidence
A

The looping constructs use the reserved words: 'for' (iterates over a list), 'while' (repeats while condition is true), 'until' (repeats until condition is true), 'do' (marks beginning of loop body), and 'done' (marks end of loop body).

Sources
95% confidence

Shell Variables > History Management

23 questions
A

If set and not null, its value is used as a format string for strftime(3) to print the timestamp associated with each history entry displayed by the history builtin.

Sources
95% confidence
A

HISTCONTROL accepts: ignorespace (lines beginning with space are not saved), ignoredups (lines matching previous entry are not saved), ignoreboth (shorthand for ignorespace and ignoredups), and erasedups (all previous lines matching current line are removed before saving).

Sources
95% confidence
A

The history comment character indicates that the remainder of the line is a comment when found as the first character of a word. It causes history substitution to be skipped for the remaining words on the line but does not necessarily cause the shell parser to treat the rest of the line as a comment.

Sources
95% confidence

Bash Conditional Expressions > Arithmetic Comparison Tests

23 questions
A

The = operator (or == in [[ ]]) performs string/lexical comparison, while -eq performs integer/numeric comparison. Example: [ 10 -eq 010 ] is false (different numeric values), but [ 10 = 010 ] or [[ 10 == 010 ]] may have different behavior depending on context. Always use -eq for numbers to ensure numeric comparison.

Sources
95% confidence

Bash Conditional Expressions > File Type Tests

23 questions

Invoking Bash > Startup File Processing

23 questions
A

The --rcfile option forces Bash to read and execute commands from the specified file instead of ~/.bashrc when starting as an interactive shell. For example: bash --rcfile /custom/custom_bashrc

Sources
95% confidence
A

No, non-interactive shells do not read any startup files by default. However, if the environment variable BASH_ENV is set and the shell is not in POSIX mode, Bash expands BASH_ENV and reads the file it names before executing the script.

Sources
95% confidence
A

In POSIX mode, Bash follows POSIX standard behavior and uses the ENV variable instead of BASH_ENV. If ENV is set in POSIX mode, Bash expands and executes the file it names when starting an interactive shell. BASH_ENV is only used in non-POSIX mode for non-interactive shells.

Sources
95% confidence
A

Yes. If a startup file returns a non-zero exit status (e.g., due to 'exit 1' or a command that fails with 'set -e'), the shell startup may be affected. However, for interactive shells, the shell typically continues despite errors in startup files, though error messages are displayed.

Sources
95% confidence
A

Bash determines if a shell is interactive by checking: 1) if standard input is a terminal, 2) if the -i option is used, 3) if the 'i' option is set in $-. A shell started with bash -i is always interactive. A shell started with 'ssh host' (no command) is typically an interactive login shell.

Sources
95% confidence
A

When Bash is invoked as a non-interactive shell (e.g., running a script), it checks if BASH_ENV is set. If set (and not in POSIX mode), Bash expands the value of BASH_ENV and executes commands from that file before running the script. This is similar to how ENV works for POSIX shells.

Sources
95% confidence
A

The --login (or -l) option forces Bash to be treated as a login shell, regardless of how it was invoked. This causes Bash to read /etc/profile and the first available of ~/.bash_profile, ~/.bash_login, or ~/.profile, even if started from a GUI terminal or with bash -c.

Sources
95% confidence
A

The --norc option prevents Bash from reading ~/.bashrc when starting as an interactive shell. This option only works for interactive shells. To disable reading /etc/bash.bashrc as well, use --norc and also set the environment variable or use distribution-specific methods.

Sources
95% confidence
A

Most GUI terminal emulators (gnome-terminal, xterm, konsole, etc.) start shells as non-login interactive shells by default. This means they read ~/.bashrc but not ~/.bash_profile or /etc/profile. This can be configured in terminal emulator settings.

Sources
95% confidence
A

Bash looks for ~/.profile when invoked as an interactive login shell AND neither ~/.bash_profile nor ~/.bash_login exist. Additionally, when Bash is invoked as 'sh' or in POSIX mode, it looks for ~/.profile instead of ~/.bash_profile.

Sources
95% confidence
A

The --noprofile option prevents Bash from reading /etc/profile and any of the personal initialization files (~/.bash_profile, ~/.bash_login, or ~/.profile) when starting as an interactive login shell, or when invoked as bash --login.

Sources
95% confidence
A

SSH sessions typically start login shells, which means they read /etc/profile and then the first available of ~/.bash_profile, ~/.bash_login, or ~/.profile. This is why environment variables set in ~/.bashrc may not be available in SSH sessions unless ~/.bash_profile sources ~/.bashrc.

Sources
95% confidence

Shell Parameter Expansion > Pattern Removal

22 questions
A

Pattern removal operators use glob-style pathname expansion patterns, not regular expressions. They support * (matches any string), ? (matches any single character), and [...] (matches any character in brackets). They do not support regex syntax like +, {n,m}, or | unless extended globbing (extglob) is enabled.

Sources
95% confidence
A

${parameter##word} removes the longest matching prefix pattern from the expanded value of parameter. The word is expanded to produce a pattern that is matched against the beginning of the parameter's value. If the pattern matches the beginning, the result is the expanded value with the longest matching pattern deleted.

Sources
95% confidence
A

When the extglob shell option is enabled, extended pattern matching operators like ?(pattern-list), *(pattern-list), +(pattern-list), @(pattern-list), and !(pattern-list) can be used in patterns for pattern removal. These allow more complex matching patterns such as removing a suffix that matches one or more alternatives.

Sources
95% confidence
A

${parameter#word} removes the shortest matching prefix pattern from the expanded value of parameter. The word is expanded to produce a pattern that is matched against the beginning of the parameter's value using pattern matching rules. If the pattern matches the beginning, the result is the expanded value with the shortest matching pattern deleted.

Sources
95% confidence
A

${parameter%%word} removes the longest matching suffix pattern from the expanded value of parameter. The word is expanded to produce a pattern that is matched against a trailing portion of the parameter's value. If the pattern matches the end, the result is the value with the longest matching pattern deleted.

Sources
95% confidence
A

The word is expanded to produce a pattern just as in pathname expansion, and matched against the expanded value of parameter using the rules described under Pattern Matching in the Bash manual. The pattern uses glob-style wildcards: * matches any string, ? matches any single character, and [...] matches any character in brackets.

Sources
95% confidence
A

Pattern removal operations can be chained by using multiple parameter expansions. For example: ${path##/} removes the directory path to get the filename, then ${filename%.} removes the extension. You can nest them like: ${${path##/}%.} to get the filename without extension from a full path.

Sources
95% confidence
A

The pattern supports glob-style wildcards: * matches any string (including empty string), ? matches any single character, [abc...] matches any one of the enclosed characters, [!abc...] or [^abc...] matches any character not enclosed. The pattern can also include character classes like [:class:] where class can be alnum, alpha, digit, etc.

Sources
95% confidence
A

${parameter%word} removes the shortest matching suffix pattern from the expanded value of parameter. The word is expanded to produce a pattern that is matched against a trailing portion of the parameter's value. If the pattern matches the end, the result is the value with the shortest matching pattern deleted.

Sources
95% confidence

Shell Commands > Pipelines

22 questions
A

If lastpipe is set, and job control is not active, the shell runs the last command of a pipeline not executed in the background in the current shell environment instead of a subshell.

Sources
95% confidence
A

A pipeline is a sequence of simple commands separated by one of the control operators '|' or '|&'. The output of each command in the pipeline is connected via a pipe to the input of the next command, so each command reads the previous command's output.

Sources
95% confidence
A

BASH_SUBSHELL is a variable that is incremented by one each time a subshell or subshell environment is spawned. The initial value is 0.

Sources
95% confidence
A

If TIMEFORMAT is not set, Bash acts as if it had the value $'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'. If the value is null, no timing information is displayed.

Sources
95% confidence
A

lastpipe only works when job control is not active. The shopt documentation states: 'If set, and job control is not active, the shell runs the last command of a pipeline not executed in the background in the current shell environment.'

Sources
95% confidence
A

If |& is used, the standard error of command1 is connected to command2's standard input through the pipe; it is shorthand for 2>&1 |. This implicit redirection of the standard error is performed after any redirections specified by the command.

Sources
95% confidence
A

PIPESTATUS is an array variable containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command).

Sources
95% confidence

Lists of Commands

22 questions
A

The 'set -o pipestatus' option is not a valid Bash option. Instead, Bash provides the PIPESTATUS array variable which contains the exit status of each command in the most recently executed pipeline. Access it with ${PIPESTATUS[0]}, ${PIPESTATUS[1]}, etc.

Sources
95% confidence
A

Bash supports two types of command groups: (1) Group commands enclosed in curly braces { } execute in the current shell environment, and (2) Group commands enclosed in parentheses ( ) execute in a subshell. The subshell version isolates changes to variables and the working directory.

Sources
95% confidence
A

When 'set -e' (errexit) is enabled, the shell exits immediately if any command in a command list exits with a non-zero status, unless the command is part of a compound list (using && or ||), or the failing command is followed by a while or until loop, or part of a test in an if statement.

Sources
95% confidence
A

The 'time' reserved word, when placed before a pipeline or command list, causes timing statistics to be printed for the pipeline when it completes. The statistics include user time, system time, and elapsed real time. The format can be controlled with the TIMEFORMAT variable.

Sources
95% confidence

Arrays > Array Types and Declaration

22 questions

Process Substitution

21 questions
A

Bash supports two forms of process substitution: 1) Input process substitution with syntax <(list) which provides the output of list as a file, and 2) Output process substitution with syntax >(list) which passes input written to the file as input to list.

Sources
95% confidence
A

A pipe (|) connects stdout of one command directly to stdin of another, while process substitution creates a temporary file-like object (typically in /dev/fd) that can be passed to commands expecting file arguments. Process substitution allows a command to accept multiple file inputs where pipes would only allow one input stream.

Sources
95% confidence
A

No, process substitutions typically do not create files in /tmp. On systems with /dev/fd support, they create file descriptors in the /dev/fd filesystem. On systems without /dev/fd, they may create named pipes using mkfifo, but these are not necessarily in /tmp.

Sources
95% confidence

Executing Commands > Execution Environment Management

21 questions
A

When 'exec' is used with arguments, those arguments replace the current shell's positional parameters ($0, $1, $2, etc.) and the command replaces the shell process. If no command is specified and only redirections are given, positional parameters are unchanged.

Sources
95% confidence
A

When a command is invoked, it inherits: (1) the shell's open files, (2) file descriptors modified by any redirections applied to the command, (3) the current working directory, (4) the file creation mask, (5) all exported variables and functions, (6) signal traps are reset to default except for those ignored by the shell.

Sources
95% confidence
A

The execution environment includes: (1) open files inherited by the command at invocation, plus any modifications and additions specified by redirections, (2) the current working directory, (3) the file creation mode mask, (4) shell variables and functions marked for export, and (5) traps caught by the shell are reset to the values inherited from the shell's parent.

Sources
95% confidence

The Restricted Shell

21 questions

Modifying Shell Behavior > Error Handling and Exit Behavior

21 questions
A

The 'set -u' option causes Bash to treat unset variables as an error when performing parameter expansion. An error message will be written to the standard error, and a non-interactive shell will exit. This does NOT apply to special parameters like '*', '@', '#', '?', '$', '!', '0', or '_' that are expanded when the shell is invoked.

Sources
95% confidence
A

It depends on context. When 'set -e' is active, a 'command not found' error (exit status 127) will cause the shell to exit UNLESS it's part of a condition (if, while, etc.) or the command is part of a pipeline where 'pipefail' is not set. The error is treated like any other non-zero exit status.

Sources
95% confidence
A

The 'set -o pipefail' option changes the exit status of a pipeline. Without pipefail, the pipeline's exit status is the last command's exit status. With pipefail, the exit status is the exit status of the rightmost command that exited with a non-zero status, or zero if all commands exited successfully. This option is disabled by default.

Sources
95% confidence
A

By default, NO. 'set -e' alone does NOT cause the shell to exit when a command in a pipeline fails, because the pipeline's exit status is determined by the last command. You must also set 'set -o pipefail' to detect failures anywhere in the pipeline and cause the shell to exit when any command in the pipeline fails.

Sources
95% confidence
A

The '?' special parameter expands to the exit status of the most recently executed foreground pipeline. It is read-only and cannot be assigned to. It's commonly used to check if a command succeeded ('if [ $? -eq 0 ]') or to return the last command's exit status.

Sources
95% confidence
A

The 'set -e' option causes the shell to exit immediately if a command exits with a non-zero status. However, it will NOT exit if: (1) the command that fails is part of a compound command (like if, while, until, ||, &&), (2) the command's exit status is being tested with !, (3) the command follows while/until, or (4) the pipeline in which the command appears has its exit status checked with '!'

Sources
95% confidence
A

The 'set -o ignoreeof' option prevents an interactive shell from exiting when it encounters EOF (end-of-file, typically Ctrl+D). Instead, the shell displays 'Use "exit" to leave the shell.' This helps prevent accidental shell termination.

Sources
95% confidence
A

Bash exit status values range from 0 to 255. Exit status 0 indicates success, while 1-255 indicate various failure conditions. Exit status 126 indicates command was found but could not be executed, 127 indicates command was not found, and 128 and above typically indicate termination by a signal (128 + signal number).

Sources
95% confidence
A

Unlike 'set -e' which immediately exits on error, 'trap command ERR' allows you to execute custom error handling code (cleanup, logging, etc.) when a command fails. The ERR trap runs before the shell would exit (if errexit is also set), giving you a chance to perform cleanup operations. The trap command can receive the exit status in '$?' and line number in '$LINENO'.

Sources
95% confidence
A

The ERR trap is triggered when a command exits with a non-zero status. However, it is NOT triggered if: (1) the failed command is part of a compound command (if, while, until, etc.), (2) the command follows 'while' or 'until', (3) the command is in a pipeline except the last one (without pipefail), or (4) the command's exit status is being inverted with '!'. The ERR trap is also not inherited by functions, command substitutions, or subshells unless 'set -E' (set -o errtrace) is enabled.

Sources
95% confidence
A

The 'set -o posix' option changes Bash behavior to be more POSIX-compliant. One key effect is that it causes the shell to exit if a special builtin (like 'source', '.', 'return', 'break', 'continue', 'exec') fails. Without this option, failures in special builtins don't necessarily exit the shell.

Sources
95% confidence

Bash Startup Files > Shell Invocation Types

21 questions
A

When bash is started in posix mode, as with the --posix command line option, it follows the POSIX standard for startup files. In this mode, interactive shells expand the ENV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read.

Sources
95% confidence
A

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from /etc/profile if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

Sources
95% confidence
A

If the shell is started with the effective user (group) id not equal to the real user (group) id, and the -p option is not supplied, no startup files are read, shell functions are not inherited from the environment, the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if they appear in the environment, are ignored, and the effective user id is set to the real user id.

Sources
95% confidence
A

The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc. This can also be specified as --init-file file.

Sources
95% confidence
A

An interactive shell is one started without non-option arguments (unless -s is specified) and without the -c option, whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option.

Sources
95% confidence

Bindable Readline Commands > Miscellaneous Commands

21 questions
A

When given a numeric argument, insert-comment acts as a toggle: if the characters at the beginning of the line do not match the value of comment-begin, the value is inserted; otherwise, the characters in comment-begin are deleted from the beginning of the line. In either case, the line is accepted as if a newline had been typed.

Sources
95% confidence
A

The dump-variables command prints all of the settable variables and their values to the readline output stream. If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an inputrc file.

Sources
95% confidence
A

A Control Sequence Indicator (CSI) is the beginning of a multi-key sequence, usually ESC-[, used by keys like Home and End. The skip-csi-sequence command is designed to read and consume these sequences to prevent stray characters from being inserted into the editing buffer.

Sources
95% confidence
A

The skip-csi-sequence command reads enough characters to consume a multi-key sequence such as those defined for keys like Home and End. Such sequences begin with a Control Sequence Indicator (CSI), usually ESC-[. If this sequence is bound to '\e[', keys producing such sequences will have no effect unless explicitly bound to a readline command, instead of inserting stray characters into the editing buffer. This is unbound by default, but usually bound to ESC-[.

Sources
95% confidence
A

The do-lowercase-version command is bound to metafied uppercase characters (M-A, M-B, M-x, etc.). If the metafied character x is uppercase, it runs the command that is bound to the corresponding metafied lowercase character. The behavior is undefined if x is already lowercase.

Sources
95% confidence
A

The dump-functions command prints all of the functions and their key bindings to the readline output stream. If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an inputrc file.

Sources
95% confidence
A

The default key binding for insert-comment is M-# (Meta-#). Without a numeric argument, the value of the readline comment-begin variable is inserted at the beginning of the current line. If a numeric argument is supplied, this command acts as a toggle.

Sources
95% confidence
A

The dump-macros command prints all of the readline key sequences bound to macros and the strings they output. If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an inputrc file.

Sources
95% confidence

Arrays > Assignment and Modification

21 questions
A

Negative indices count from the end of the array. For an array with elements, array[-1] refers to the last element, array[-2] to the second-to-last, etc. Assignment like array[-1]=newvalue modifies the last element. This requires bash 4.3 or later.

Sources
95% confidence

Redirections > Here Documents and Here Strings

20 questions
A

With an unquoted delimiter: backslash is NOT special in the body of a here-document, except that $`, $', and $" retain their special meaning for parameter expansion.\nWith a quoted delimiter: backslash is treated literally like any other character.

Sources
95% confidence
A

The syntax is: [n]<<< word

This redirects word to the input of the command with a trailing newline appended. The word undergoes tilde expansion, parameter expansion, command substitution, and arithmetic expansion.

Sources
95% confidence

Conditional Constructs > Loop-Based Conditionals

20 questions

Bash Startup Files > Configuration Purpose

20 questions
A

The --noprofile option inhibits reading of the system-wide startup file /etc/profile or any of the personal initialization files ~/.bash_profile, ~/.bash_login, or ~/.profile when bash is invoked as a login shell.

95% confidence
A

The --rcfile file option forces bash to read and execute commands from the specified file instead of /etc/bash.bashrc and ~/.bashrc for interactive shells. The --init-file option is a synonym.

95% confidence
A

When bash is started in POSIX mode (with the --posix command line option), interactive shells expand the ENV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read.

95% confidence
A

The --norc option inhibits reading and execution of the system-wide initialization file /etc/bash.bashrc and the personal initialization file ~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as sh.

95% confidence

Shell Parameter Expansion > Case Modification

20 questions

Bash Conditional Expressions > String Comparison Tests

20 questions
A

The =~ operator performs Extended Regular Expression (ERE) matching. The string on the left is matched against the ERE on the right. If the match succeeds, the return status is 0. The regex should NOT be quoted. Captured groups are stored in BASH_REMATCH array.

Sources
95% confidence
A

Yes, when used inside [[ ]], the == operator performs pattern matching where the right-hand side can contain glob patterns like *, ?, and [character ranges].

Sources
95% confidence

Invoking Bash > Security and Privilege Settings

20 questions
A

In restricted shell mode, the following are disallowed: changing directories with cd; setting or unsetting SHELL, PATH, HISTFILE, ENV, or BASH_ENV; specifying command names containing /; specifying filenames containing / as arguments to the ., history, or hash -p builtins; importing function definitions from the environment at startup; parsing SHELLOPTS from the environment; redirecting output using >, >|, <>, >&, &>, and >>; using exec to replace the shell; adding or deleting builtins with enable -f/-d; enabling disabled builtins with enable; using command -p; and turning off restricted mode.

Sources
95% confidence
A

When bash is started in POSIX mode with the --posix command line option, it follows the POSIX standard for startup files. In this mode, interactive shells expand the ENV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read.

Sources
95% confidence
A

Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by rshd or sshd. If bash determines it is being run non-interactively in this fashion, it reads and executes commands from /etc/bash.bashrc and ~/.bashrc if these files exist and are readable, unless invoked as sh.

Sources
95% confidence
A

The --rcfile file option forces Bash to read and execute commands from the specified file instead of /etc/bash.bashrc and ~/.bashrc if the shell is interactive. This option takes precedence over the default startup file behavior.

Sources
95% confidence
A

When Bash is started with effective user (group) ID not equal to real user (group) ID and the -p option is not supplied: no startup files are read, shell functions are not inherited from the environment, the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables are ignored if they appear in the environment, and the effective user ID is set to the real user ID.

Sources
95% confidence
A

When invoked as sh in interactive login mode or with --login option, bash first attempts to read and execute commands from /etc/profile and ~/.profile, in that order. The --noprofile option may be used to inhibit this behavior. When invoked as an interactive shell with name sh, bash looks for the ENV variable instead of other startup files.

Sources
95% confidence
A

When an interactive shell is invoked in POSIX mode (or when bash is invoked with the name sh), the ENV variable is expanded and commands are read and executed from the file whose name is the expanded value.

Sources
95% confidence
A

When the -p option is supplied at invocation and the effective user ID is not equal to the real user ID, the startup behavior is the same (no startup files, functions not inherited, certain variables ignored), but the effective user ID is NOT reset to the real user ID. In privileged mode, $ENV and $BASH_ENV files are not processed, shell functions are not inherited from the environment, and SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables are ignored if they appear in the environment.

Sources
95% confidence
A

The --norc option prevents Bash from reading and executing the system-wide initialization file /etc/bash.bashrc and the personal initialization file ~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as sh.

Sources
95% confidence
A

If BASH_ENV is set when bash is executing a shell script, its value is interpreted as a filename containing commands to initialize the shell. The value is subjected to parameter expansion, command substitution, and arithmetic expansion before being interpreted as a filename. PATH is not used to search for the resultant filename.

Sources
95% confidence

Tilde Expansion

20 questions
A

If the tilde-prefix is a null string (just '~'), the tilde is replaced with the value of the HOME shell variable. If HOME is unset, the tilde expands to the home directory of the user executing the shell.

Sources
95% confidence
A

If the tilde-prefix is '~-', the shell substitutes the value of the shell variable OLDPWD (previous working directory), if it is set.

Sources
95% confidence
A

A tilde-prefix consists of all characters from the beginning of a word that starts with an unquoted tilde character ('~') up to the first unquoted slash ('/'). If there is no unquoted slash in the word, all characters up to the end of the word constitute the tilde-prefix.

Sources
95% confidence
A

The tilde-prefix is replaced with the corresponding element from the directory stack, as it would be displayed by the 'dirs' builtin invoked with the characters following tilde in the tilde-prefix as an argument. If the number has no leading '+' or '-', tilde expansion assumes '+'.

Sources
95% confidence

Conditional Constructs > Interactive Selection Constructs

20 questions
A

The select construct has almost the same syntax as the for command: 'select name [in words ...]; do commands; done' - the difference being select creates an interactive menu from the word list

Sources
95% confidence

Command Substitution

20 questions

Executing Commands > Environment Variable Handling

20 questions
A

The export command (with no arguments) lists all exported environment variables in the current shell. Alternatively, printenv or env commands can also display all environment variables, while declare -x shows exported variables with their declarations.

Sources
95% confidence
A

Each command in a pipeline (cmd1 | cmd2 | cmd3) runs in a subshell and receives a copy of the exported environment variables. Environment variable changes made in one pipeline command do not affect other commands in the pipeline or the parent shell. Using VAR=value before a pipeline affects all commands in the pipeline.

Sources
95% confidence
A

env -i command starts the command with an empty environment (no inherited environment variables). The -i or --ignore-environment option clears all environment variables before executing the command. You can then add specific variables: env -i VAR=value command.

Sources
95% confidence
A

Multiple variable assignments can be chained before a command: VAR1=value1 VAR2=value2 VAR3=value3 command. Each assignment is evaluated and all specified variables are set in the command's environment simultaneously. The order of assignments does not matter for independent variables.

Sources
95% confidence
A

export -n VAR removes the export attribute from variable VAR, turning it from an environment variable into a regular shell variable. The variable remains defined in the current shell but will no longer be passed to child processes.

Sources
95% confidence
A

Bash itself does not impose a fixed limit on environment variable name or value length. However, the operating system limits apply: Linux typically has a limit of 32 pages for environment variables (typically 128KB on 4KB page systems). Individual variable names and values can be very long (up to the total environment size limit). getconf ARG_MAX shows the maximum size of command and environment arguments.

Sources
95% confidence
A

VAR=value creates a shell variable that is local to the current shell and is not inherited by child processes. export VAR=value (or export VAR after setting) makes the variable an environment variable that will be inherited by child processes (commands and subshells). Only exported variables are passed to commands executed by the shell.

Sources
95% confidence
A

The unset VAR command removes both shell variables and environment variables. After unsetting, the variable is no longer defined in the current shell. If a variable was exported, it will no longer be passed to subsequently executed child processes. The -f option (unset -f) unsets a shell function instead.

Sources
95% confidence
A

${VAR:-default} uses 'default' as the value if VAR is unset or null (empty). This does not modify VAR. For contrast, ${VAR:=default} assigns 'default' to VAR if VAR is unset or null, and also uses that value. These are parameter expansion features for handling unset or empty variables.

Sources
95% confidence

Command Line Editing > Keyboard Macros and Arguments

20 questions
A

yank-nth-arg inserts the first argument of the previous command by default, but accepts a numeric argument to specify which argument. The default binding is Ctrl-Ctrl+Meta+y (or similar depending on terminal).

95% confidence

Bindable Readline Commands > Commands For Moving

20 questions
A

The previous-screen-line command attempts to move point to the same physical screen column on the previous physical screen line. This will not have the desired effect if the current readline line does not take up more than one physical line or if point is not greater than the length of the prompt plus the screen width.

Sources
95% confidence
A

The next-screen-line command attempts to move point to the same physical screen column on the next physical screen line. This will not have the desired effect if the current readline line does not take up more than one physical line or if the length of the current readline line is not greater than the length of the prompt plus the screen width.

Sources
95% confidence

Bash Startup Files > Execution Lifecycle

20 questions

Shell Parameter Expansion > Pattern Substitution

19 questions

Shell Functions > Variable Scope and Locality

19 questions
A

FUNCNEST is a variable that, if set to a numeric value greater than 0, defines a maximum function nesting level for recursion. Function invocations that exceed the limit cause the entire command to abort. By default, Bash places no limit on the number of recursive calls (FUNCNEST is unset or set to 0).

Sources
95% confidence
A

The '-g' option forces variables to be created or modified at the global scope, even when 'declare' is executed in a shell function. Without '-g', 'declare' makes variables local when used in a function. The '-g' option is ignored when 'declare' is not executed in a shell function.

Sources
95% confidence
A

The 'typeset' command is a synonym for the 'declare' builtin command in Bash. It is supplied for compatibility with the Korn shell. Both commands can be used to declare variables and give them attributes. When used in a function, both make variables local unless the '-g' option is supplied.

Sources
95% confidence
A

Use 'local -a arrayname' to declare a local indexed array. You can initialize it with 'local -a arrayname=(element1 element2 element2)'. The '-a' flag specifically declares the variable as an indexed array type, restricting its scope to the function.

Sources
95% confidence
A

Use 'local -A arrayname' to declare a local associative array (key-value pairs). You can then assign values with 'arrayname[key]=value'. Associative arrays require Bash 4.0+. The '-A' flag declares the variable specifically as an associative array type.

Sources
95% confidence
A

Yes, functions may be recursive in Bash. The FUNCNEST variable may be used to limit the depth of the function call stack and restrict the number of function invocations. However, recursion in shell scripts is slow and resource-intensive compared to compiled languages.

Sources
95% confidence
A

When declaring and setting a local variable in a single command like 'local t1=$(exit 1)', the variable assignment takes place BEFORE the local declaration. This means the return value is for the local declaration (success, returns 0) rather than the assignment. When declared separately, the return value reflects the assignment command's actual exit status.

Sources
95% confidence
A

Yes, you can declare a local variable as readonly using 'local -r varname' or 'declare -r varname'. Readonly variables cannot be assigned subsequent values or be unset. However, attempting to create a local variable with the same name as a global readonly variable will fail.

Sources
95% confidence
A

FUNCNAME is an array variable that contains the names of all shell functions currently in the execution call stack. The first element (index 0) is set to the name of the currently executing function. When a function completes, this variable is updated to reflect the caller's function name or becomes unset if not in a function.

Sources
95% confidence
A

The '-n' option gives each variable the 'nameref' attribute, making it a name reference to another variable. The referenced variable is defined by the value of the nameref variable. All references and assignments to the nameref are performed on the variable it references, except for changes to the '-n' attribute itself. The nameref attribute cannot be applied to array variables.

Sources
95% confidence
A

When a function is executed, the arguments to the function become the positional parameters during its execution. The special parameter '#' that expands to the number of positional parameters is updated to reflect the new set. Special parameter '0' (the script name) remains unchanged. When the function completes, the values of positional parameters and '#' are restored to their prior values.

Sources
95% confidence
A

Bash uses dynamic scoping, not lexical scoping. With dynamic scoping, visible variables and their values depend on the sequence of function calls that caused execution to reach the current function. The value of a variable that a function sees depends on its value within its caller.

Sources
95% confidence
A

The '-I' option causes local variables to inherit the attributes (except the 'nameref' attribute) and value of any existing variable with the same name at a surrounding scope. If there is no existing variable, the local variable is initially unset.

Sources
95% confidence
A

If the name argument to 'local' is '-', it makes the set of shell options local to the function. Any shell options changed using the 'set' builtin inside the function after 'local -' are restored to their original values when the function returns.

Sources
95% confidence
A

The 'unset' builtin in Bash acts using dynamic scope. If a variable is local to the current scope, 'unset' unsets it and it remains so (appearing as unset) until reset in that scope or until the function returns. Once the function returns, any instance of the variable at a previous scope becomes visible.

Sources
95% confidence

Bash Startup Files > Scope of Configuration

19 questions

Looping Constructs > Loop Flow Control

19 questions

Programmable Completion > Completion Variables

19 questions

Shell Variables > Shell Ancestry and Compatibility

19 questions
A

HOME contains the path to the current user's home directory. If HOME is not set when Bash starts, it attempts to determine the home directory from the user database (/etc/passwd). It does not have a fixed hardcoded default value.

Sources
95% confidence
A

When POSIXLY_CORRECT is set, Bash changes its behavior to conform more strictly to POSIX.1 standard. This affects variable handling, command names, built-in commands, and other shell behaviors. Bash enters POSIX mode when this variable is set or when invoked with --posix option.

Sources
95% confidence
A

BASH_VERSION is a read-only variable that expands to the version number of the current Bash instance. It contains the major, minor, and patch levels in the format 'major.minor.patchlevel'. For example, Bash 5.1.16 would be stored as '5.1.16(1)-release' or similar format including the release status.

Sources
95% confidence
A

SHELLOPTS is a read-only variable containing the currently enabled shell options. It is a colon-separated list of options such as 'braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor'. The variable cannot be modified directly.

Sources
95% confidence
A

OSTYPE is a read-only variable that describes the operating system Bash is running on. It automatically expands to indicate the OS type. Common values include 'linux-gnu', 'darwin', 'msys', 'cygwin', etc.

Sources
95% confidence
A

MACHTYPE is a read-only variable that contains a string describing the system type on which Bash is executing, in the standard GNU cpu-company-system format. For example: 'x86_64-pc-linux-gnu' or 'aarch64-apple-darwin21.1'.

Sources
95% confidence
A

UID (User ID) is a read-only variable that expands to the real user ID of the current user, initialized at shell startup. This numeric value represents the actual user who started the shell.

Sources
95% confidence
A

The BASH_COMPAT variable controls the compatibility level of Bash. When set, it forces Bash to behave as if it were the specified version. For example, setting BASH_COMPAT=4.2 will make Bash 5.x behave like Bash 4.2 in terms of certain features and behaviors. This is useful for testing scripts for backward compatibility.

Sources
95% confidence
A

BASH_ENV is used by Bash for non-interactive shells (scripts) to determine the startup file path, while ENV is used in POSIX mode for interactive shells. BASH_ENV is executed before the script runs, whereas ENV is executed when starting an interactive POSIX shell.

Sources
95% confidence
A

If PATH is not set when Bash starts, it defaults to a system-dependent value, typically '/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.' on many systems. The exact default depends on the compilation configuration and the system.

Sources
95% confidence
A

EUID (Effective User ID) is a read-only variable that expands to the effective user ID of the current user, initialized at shell startup. This numeric value represents the user ID under which the shell is executing, which may differ from the real user ID if the setuid bit is set.

Sources
95% confidence
A

When Bash is invoked as 'sh' (via symlink or rename), it behaves more like POSIX sh. It attempts to mimic the startup behavior of historical Bourne shell, doesn't read ~/.bashrc in non-interactive mode, and enables POSIX compatibility mode.

Sources
95% confidence
A

ENV is a variable that, when set, contains the path to a file that is executed for startup when the shell is invoked in POSIX mode (as sh or with --posix). This file is sourced only for interactive shells, not for non-interactive scripts. Unlike BASH_ENV which is used for all non-interactive shells, ENV is specific to POSIX mode.

Sources
95% confidence

Filename Expansion > Special Matching Rules

19 questions
A

When globasciiranges is enabled (default in bash 4.3+), range expressions like [a-z] are interpreted using the traditional ASCII ordering. When disabled, ranges use the current locale's collation order, which can cause unexpected behavior with non-ASCII characters.

Sources
95% confidence
A

extglob enables extended pattern matching operators: ?(pattern-list) for zero or one, *(pattern-list) for zero or more, +(pattern-list) for one or more, @(pattern-list) for exactly one, and !(pattern-list) for anything except the pattern. These use ksh-style extended globbing.

Sources
95% confidence
A

When failglob is enabled (shopt -s failglob), patterns that do not match any files cause an error message to be printed and the command is not executed. This prevents commands from running with unexpected literal pattern arguments.

Sources
95% confidence
A

caseglob controls whether filename expansion is case-sensitive. When disabled (shopt -u caseglob), pattern matching becomes case-insensitive. It is enabled by default, making globbing case-sensitive. The nocaseglob option provides an alternative way to control this behavior.

Sources
95% confidence
A

When dotglob is enabled (shopt -s dotglob), filenames that start with a dot (.) will be matched by wildcard characters (*, ?, and [...]). By default, dot files are not matched by wildcards.

Sources
95% confidence
A

When nullglob is enabled (shopt -s nullglob), patterns that do not match any files are removed entirely instead of being left as literal strings. For example, 'ls *.txt' with no matching .txt files would become 'ls' with no arguments.

Sources
95% confidence
A

GLOBIGNORE is a colon-separated list of patterns that define files to be ignored during pathname expansion. When set, filenames matching these patterns are removed from the list of matches. Additionally, setting GLOBIGNORE has the side effect of enabling dotglob.

Sources
95% confidence

Shell Arithmetic > Logical Operations

18 questions
A

Bash arithmetic evaluation is done in fixed-width integers with no check for overflow. The manual explicitly states 'Evaluation is done in fixed-width integers with no check for overflow'. However, division by 0 is trapped and flagged as an error.

Sources
95% confidence

Installing Bash > Multi-Platform Support

18 questions
A

Bash officially supports POSIX-compliant Unix systems including GNU/Linux (all distributions), Solaris, AIX, HP-UX, Tru64 UNIX, and BSD variants (FreeBSD, OpenBSD, NetBSD). Support is provided for systems with an ISO C99 compiler and POSIX-compliant system libraries.

Sources
95% confidence
A

Yes, Bash supports macOS (formerly Mac OS X). On macOS, you can compile Bash using the standard configure and make process. However, you must have Xcode Command Line Tools installed to provide the necessary compiler (clang) and development tools.

Sources
95% confidence

Bash Builtin Commands > Job Control Builtins

18 questions
A

The bg builtin places jobs identified by each job_spec in the background, as if they had been started with &

Sources
95% confidence

The Directory Stack

18 questions
A

The +N argument displays the Nth entry counting from the left of the list shown by dirs when invoked without options, starting with zero. For example, dirs +1 displays the second entry from the left.

Sources
95% confidence
A

The -N argument displays the Nth entry counting from the right of the list shown by dirs when invoked without options, starting with zero. For example, dirs -0 displays the last entry in the list.

Sources
95% confidence

Brace Expansion

18 questions
A

Patterns to be brace expanded take the form of an optional preamble, followed by either a series of comma-separated strings or a sequence expression between a pair of braces, followed by an optional postscript.

Sources
95% confidence

Bourne Shell Builtins > System Information and Permissions

18 questions
A

The hash builtin remembers the full pathnames of commands executed, to avoid searching PATH on subsequent invocations. 'hash' displays the remembered command locations. 'hash -r' clears the hash table.

Sources
95% confidence
A

The readonly builtin marks variables or functions as read-only, preventing them from being modified or unset. Once marked, the variable cannot have its value changed and cannot be unset. The -a option works on array variables, -f on functions.

Sources
95% confidence
A

The pwd builtin displays the current working directory. In Bash, it accepts -L (logical, follows symlinks, this is the default) and -P (physical, avoids symlinks) options to control whether it displays the logical or physical path.

Sources
95% confidence
A

The 'cd -' command changes to the previous working directory (the value of $OLDPWD). This is equivalent to 'cd $OLDPWD' but also prints the new directory name.

Sources
95% confidence
A

The umask builtin sets the shell's file mode creation mask. This mask is used to determine the permissions bits for newly created files. It can be specified as an octal number (e.g., 022) or in symbolic mode (e.g., u=rwx,g=rx,o=rx). If no argument is provided, it displays the current mask value.

Sources
95% confidence
A

The type builtin displays information about command type. It indicates whether a command is a shell builtin, alias, function, or external file (keyword). It's similar to the external 'which' command but is shell-aware.

Sources
95% confidence
A

The default umask is typically 022 (or in symbolic notation: u=rwx,g=rx,o=rx), which results in new files being created with permissions 644 (rw-r--r--) and new directories with permissions 755 (rwxr-xr-x).

Sources
95% confidence
A

pwd -L displays the logical current working directory (may include symlinks, uses $PWD if valid), while pwd -P displays the physical current working directory (resolves all symlinks to show the actual filesystem path).

Sources
95% confidence
A

The type builtin accepts -t (outputs a single word: 'alias', 'keyword', 'function', 'builtin', or 'file'), -p (returns the name of the disk file if command is an external command), or -P (forces a PATH search, even if command is a builtin or alias).

Sources
95% confidence
A

The -H flag sets or displays the hard limit (maximum possible, can only be increased by root), while -S sets or displays the soft limit (currently enforced, can be lowered/raised by user up to the hard limit). If neither is specified, ulimit sets both soft and hard limits.

Sources
95% confidence
A

Yes, cd accepts -L to force symbolic link handling (default) and -P to use physical directory structure. These options affect how the shell treats the current directory when navigating through symlinks.

Sources
95% confidence
A

The ulimit builtin controls system resource limits available to the shell and processes started from it. It can control limits such as maximum file size, core dump size, number of open file descriptors, maximum memory size, CPU time, maximum user processes, and more.

Sources
95% confidence

Shell Commands > Coprocesses

18 questions

Bindable Readline Commands > Killing And Yanking

18 questions
A

The yank-nth-arg command accepts a numeric argument n and yanks the nth argument from the previous command. It has no default key binding. With a negative argument, it yanks the nth argument from the end of the previous command.

Sources
95% confidence

Programmable Completion > Completion Action Types

17 questions
A

compopt modifies or displays completion options for each NAME, or if no NAMEs are supplied, the completion currently being executed. If no OPTIONs are given, it prints the completion options for each NAME or the current completion specification.

95% confidence
A

If no NAMEs are supplied to compopt, it must be called by a function currently generating completions, and the options for that currently-executing completion generator are modified.

95% confidence
A

compgen displays possible completions depending on the options. It is intended to be used from within a shell function generating possible completions. If the optional WORD argument is supplied, matches against WORD are generated.

95% confidence

Using History Interactively > History Filtering and Control

17 questions
A

The 'history -d offset' command deletes the history entry at position 'offset'. For example, 'history -d 5' removes the 5th entry in the history list.

Sources
95% confidence
A

When 'histappend' is enabled (set via 'shopt -s histappend'), the history list is appended to the history file when the shell exits, rather than overwriting the file. This preserves history from multiple concurrent shell sessions.

Sources
95% confidence
A

When 'erasedups' is set in HISTCONTROL, all previous lines matching the current line are removed from the history list before the line is saved. This removes all duplicates, not just consecutive ones.

Sources
95% confidence
A

The 'history -c' command clears the history list by deleting all entries from the current session's history.

Sources
95% confidence
A

HISTIGNORE is a colon-separated list of patterns determining which commands should not be saved in the history list. Patterns can include shell wildcards. For example: 'HISTIGNORE="ls:cd:pwd:exit"' would prevent those commands from being saved.

Sources
95% confidence
A

HISTCONTROL can contain these colon-separated values: 'ignorespace' (don't save commands starting with space), 'ignoredups' (don't save commands matching the last history entry), 'ignoreboth' (both ignorespace and ignoredups), and 'erasedups' (remove all previous matching lines before saving). If not set, all commands are saved.

Sources
95% confidence
A

HISTTIMEFORMAT specifies a format string for strftime(3) to display timestamps in history output. If set, each history entry is preceded by its timestamp. For example, 'HISTTIMEFORMAT="%F %T "' displays timestamps as 'YYYY-MM-DD HH:MM:SS'.

Sources
95% confidence

Shell Variables > Locale and Internationalization

16 questions
A

TEXTDOMAINDIR specifies the base directory where message catalogs for the TEXTDOMAIN are stored. The actual path is constructed as TEXTDOMAINDIR/locale/LC_MESSAGES/TEXTDOMAIN.mo.

Sources
95% confidence
A

TEXTDOMAIN specifies the name of the message domain used for translating messages in shell scripts. It is used by the gettext translation system to locate the appropriate message catalog (.mo files).

Sources
95% confidence
A

Locale variable values follow standard environment variable constraints. There is no Bash-specific maximum, but system limits on environment variables apply (typically the length of the value plus the variable name cannot exceed the platform's ARG_MAX limit, usually 128KB or more on modern systems).

Sources
95% confidence
A

LC_ALL overrides all other LC_* variables and LANG. Setting LC_ALL forces the entire locale to a specific setting, ignoring any individual category variables.

Sources
95% confidence

Interactive Shells > Shell Initialization

16 questions

Word Splitting

16 questions
A

The order is: 1) Brace expansion, 2) Tilde expansion, 3) Parameter and variable expansion, 4) Arithmetic expansion, 5) Command substitution, 6) Word splitting, 7) Pathname expansion. Word splitting occurs at step 6.

Sources
95% confidence
A

Non-whitespace IFS characters (when IFS contains characters like comma, colon, etc.) are NOT treated as delimiters when they appear alone. They are treated as delimiters, but each non-whitespace IFS character serves as a separate delimiter, and sequences of them are NOT collapsed into a single delimiter.

Sources
95% confidence

Shell Parameter Expansion > Name and Key Operations

16 questions
A

${!name} performs indirect expansion. The value of 'name' is treated as a variable name, and the expansion returns the value of that variable. For example, if var='myvar' and myvar='hello', then ${!var} expands to 'hello'.

Sources
95% confidence
A

${!prefix*} expands to the names of all shell variables whose names begin with 'prefix'. The names are separated by the first character of the IFS variable.

Sources
95% confidence
A

${!prefix@} expands to the names of all shell variables whose names begin with 'prefix'. Unlike ${!prefix*}, each name appears in a separate word when using ${!prefix@}.

Sources
95% confidence

Simple Commands

16 questions
A

A simple command is a sequence of words separated by blanks, terminated by one of the shell's control operators. The first word generally specifies a command to be executed, with the rest of the words being that command's arguments.

Sources
95% confidence
A

A metacharacter is a character that, when unquoted, separates words. A metacharacter is a space, tab, newline, or one of the following characters: |, &, ;, (, ), <, or >

Sources
95% confidence
A

When a simple command other than a builtin or shell function is to be executed, it is invoked in a separate execution environment that consists of: the shell's open files plus any modifications and additions specified by redirections; the current working directory; the file creation mode mask; shell variables and functions marked for export along with variables exported for the command passed in the environment; and traps caught by the shell are reset to the values inherited from the shell's parent, while traps ignored by the shell are ignored.

Sources
95% confidence

Shell Parameter Expansion > Default and Alternative Values

16 questions
A

${parameter:?word} (with colon) triggers the error message if parameter is unset OR null. ${parameter?word} (without colon) only triggers the error if parameter is unset, but NOT if it's null (empty string). Both write the error message to stderr and cause non-interactive shells to exit.

Sources
95% confidence
A

${parameter:-word} substitutes 'word' if parameter is unset OR null (empty string), while ${parameter-word} (without the colon) only substitutes 'word' if parameter is unset (but NOT if it's null/empty). When the colon is included, the operator tests for both parameter existence AND that its value is not null. When the colon is omitted, it tests only for existence.

Sources
95% confidence
A

If parameter is null or unset, the shell writes the expansion of word (or a message to that effect if word is not present) to standard error. If the shell is not interactive, it exits with a non-zero status. An interactive shell does not exit, but does not execute the command associated with the expansion.

Sources
95% confidence
A

It's commonly used to conditionally add text or warnings when a variable is set. For example: echo "Application installed${JAVAPATH:+ NOTE: JAVAPATH is set}" - This appends the warning only if JAVAPATH is set and non-null. The parameter's value is not used, only whether it's set and non-null matters.

95% confidence

Readline Init File > Conditional Constructs

16 questions
A

The application test structure allows you to apply settings only when readline is being used by a specific application. The application name is determined from the first argument to readline (the application's name). For example:

$if application=Bash
"\C-x\C-r": re-read-init-file
$endif

$if application=python
# Python-specific readline settings
$endif

95% confidence

Arrays > Array Manipulation

15 questions
A

Bash does NOT support negative indices directly in array access like array[-1]. However, in parameter expansion slicing ${array[@]: -N}, the negative offset counts from the end. Note the space before -N is mandatory.

Sources
95% confidence
A

Use 'unset array' without any brackets or index. This completely removes the array variable. Using 'unset array[@]' will also unset the entire array.

Sources
95% confidence
A

array1+=("${array2[@]}") - This appends all elements of array2 to the end of array1. The quotes and @ expansion ensure each element is preserved correctly.

Sources
95% confidence

Looping Constructs > Condition-Based Iteration

15 questions
A

The syntax is: continue [n]. It resumes the next iteration of an enclosing for, while, until, or select loop. If n is supplied, the execution of the nth enclosing loop is resumed.

Sources
95% confidence

Bindable Readline Commands > Specifying Numeric Arguments

15 questions
A

As a special case, if universal-argument is immediately followed by a character that is neither a digit nor minus sign, the argument count for the next command is multiplied by four. The argument count is initially one, so executing this function the first time makes the argument count four, a second time makes it sixteen, and so on.

95% confidence

Looping Constructs > Iteration by Collection

15 questions
A

First, the arithmetic expression expr1 is evaluated according to the rules described in Shell Arithmetic. Then, repeatedly evaluate the arithmetic expression expr2 until it evaluates to zero. Each time expr2 evaluates to a non-zero value, execute commands and evaluate the arithmetic expression expr3.

Sources
95% confidence

Bindable Readline Commands > Keyboard Macros

15 questions

Shell Parameter Expansion > String Length and Counting

15 questions

Shell Variables > Bash-Specific Extensions

15 questions
A

This appears to be a request about BASH_XORIG_LOC which is not a documented Bash variable in the official manual. There may be a typo in this question.

Sources
95% confidence
A

BASH_SOURCE is an array whose members are the source filenames where corresponding shell function names in FUNCNAME are defined. BASH_SOURCE[$i] contains the file that defines function ${FUNCNAME[$i]}.

Sources
95% confidence

Filename Expansion > Basic Wildcard Patterns

15 questions
A

The / character (slash) must be matched explicitly by wildcards in pathname expansion. The * and ? wildcards do NOT match / in pathname expansion. This means that patterns like *.txt will only match .txt files in the current directory, not recursively in subdirectories.

Sources
95% confidence
A

In filename expansion, a dot (.) at the beginning of a filename must be matched explicitly. It is NOT matched by wildcard patterns like , ?, or [..]. For example, * matches all files except hidden files (those starting with .). To match hidden files, you must use . explicitly.

Sources
95% confidence
A

Bash processes filename expansion after brace expansion, tilde expansion, parameter and variable expansion, and arithmetic expansion, but before command substitution. This ordering ensures that expanded values can then be used as patterns for filename matching.

Sources
95% confidence
A

When wildcard characters (, ?, [, ]) are quoted (with single quotes, double quotes, or backslash), they lose their special meaning and are treated as literal characters. For example, '.txt' matches only a file literally named '*.txt', not all .txt files.

Sources
95% confidence
A

The * (asterisk) matches any string, including the empty string. It is a pattern that expands to all filenames that match the pattern. For example, *.txt matches all files ending in .txt, including .txt itself (if it exists as a filename).

Sources
95% confidence
A

There is no option to disable this behavior - it's a fundamental rule of bash filename expansion. Wildcards never match filenames that begin with a dot unless the wildcard pattern itself starts with a dot. This is a built-in security feature to prevent accidental manipulation of hidden configuration files.

Sources
95% confidence
A

When a wildcard pattern fails to match any files, the pattern itself is left unchanged and passed literally to the command. This is different from the behavior when nullglob is enabled. For example, if no .txt files exist, 'echo .txt' will literally print '.txt'.

Sources
95% confidence
A

No, bash pattern matching is case-sensitive by default. [a-z] matches only lowercase letters, not uppercase. However, you can use nocasematch shell option with some constructs, but this does not apply to filename expansion, only to case statements and [[ commands.

Sources
95% confidence
A

To include a literal hyphen - in a bracket expression, it must be placed as the first or last character within the brackets. For example, [-abc] or [abc-] includes - as a literal character to match. If placed in the middle, it creates a range.

Sources
95% confidence
A

Multiple bracket expressions in a pattern are evaluated independently and sequentially. For example, [a-z][0-9] matches any two-character string where the first character is a lowercase letter and the second is a digit. Each bracket expression matches exactly one character.

Sources
95% confidence

Shell Arithmetic > Assignment Operations

15 questions
A

The decrement operator is -- and can be used as either a pre-decrement (( --var )) or post-decrement (( var-- )). The pre-decrement decrements the variable before using its value, while post-decrement returns the original value before decrementing.

Sources
95% confidence
A

The bitwise AND assignment &= performs: (( x &= mask )) equivalent to (( x = x & mask )). The bitwise OR assignment |= performs: (( x |= mask )) equivalent to (( x = x | mask )). The bitwise XOR assignment ^= performs: (( x ^= mask )) equivalent to (( x = x ^ mask )).

Sources
95% confidence
A

Both assign a value to var, but (( var = value )) is a compound command that performs the assignment and returns an exit status based on whether the result is non-zero, while var=$(( value )) is an assignment that uses arithmetic expansion to compute the value. The (( )) form is preferred for arithmetic assignment operations.

Sources
95% confidence
A

Bash supports the following assignment operators in shell arithmetic: = (assignment), += (addition assignment), -= (subtraction assignment), *= (multiplication assignment), /= (division assignment), %= (modulo assignment), <<= (left shift assignment), >>= (right shift assignment), &= (bitwise AND assignment), |= (bitwise OR assignment), and ^= (bitwise XOR assignment).

Sources
95% confidence
A

The increment operator is ++ and can be used as either a pre-increment (( ++var )) or post-increment (( var++ )). The pre-increment increments the variable before using its value, while post-increment returns the original value before incrementing.

Sources
95% confidence
A

Yes, the assignment operator = can be used in arithmetic expansion. For example: $(( x = 5 )) assigns 5 to x and returns 5. However, note that variables assigned inside $(( )) do not retain their value outside the expansion unless they were already declared. Use (( )) without the $ prefix for assignment side effects.

Sources
95% confidence

Bash Conditional Expressions > Logical and Negation Operators

13 questions
A

The exit status is non-zero (false). The ! operator inverts the exit status: if a command returns 0, ! makes it return 1; if a command returns non-zero, ! makes it return 0.

Sources
95% confidence

Bindable Readline Commands > Commands For Completion

12 questions
A

The 'dabbrev-expand' command attempts completion on the text before point from the list of words in the other lines currently in the history. It expands to the longest matching prefix and is not bound to any key by default.

Sources
95% confidence
A

The 'complete-into-braces' command performs filename completion and inserts the list of possible completions enclosed in braces, converting 'file' to '{file1,file2,file3}'. It is not bound to any key by default.

Sources
95% confidence

Controlling the Prompt > Temporal Information

12 questions

Shell Parameter Expansion > Basic Value Access

11 questions
A

Indirect expansion occurs when the first character of parameter is an exclamation point (!) and parameter is not a nameref. Bash uses the value formed by expanding the rest of parameter as the new parameter, then expands that value and uses it in the rest of the expansion.

Sources
95% confidence
A

Braces are required when parameter is a positional parameter with more than one digit. For example, if $1 has value 'a', then ${11} expands to the eleventh positional parameter, while $11 expands to 'a1'.

Sources
95% confidence

Redirections > Process Substitution

8 questions

Installing Bash > Shared Configuration

8 questions

Bash Conditional Expressions > File Ownership Tests

8 questions

Programmable Completion > Completion Behavior Options

2 questions
A

The 'nospace' option prevents a trailing space from being added to the completed word. This is useful when you want to immediately continue typing more characters after the completion without an intervening space.

Sources
95% confidence

Interactive Shells > Interactive Features

1 question