From: Chet Ramey Date: Wed, 11 Sep 2024 19:54:24 +0000 (-0400) Subject: `wait -n' notifies on a job it returns; in posix mode, `wait' defers notification... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc5ddc8698d56df588fd99864a650b834426ccf7;p=thirdparty%2Fbash.git `wait -n' notifies on a job it returns; in posix mode, `wait' defers notification on a reaped pid unless the shell is interactive, as posix now specifies --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 571df988..ead914e6 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -10163,3 +10163,34 @@ builtins/printf.def to a closing right paren, rejecting the format if it's not a `)' when the loop breaks Report from Andrey Kovalev + + 9/6 + --- +jobs.c,jobs.h + - notify_and_cleanup: now takes an argument saying which job to notify + about; if arg is -1 it notifies about all jobs as previously + - maybe_print_job_notifications: convenience function to encapsulate + policy about when to call notify_of_job_status in one place; called + by notify_and_cleanup + - notify_of_job_status,maybe_print_job_notifications: now take an int + argument with the same semantics as notify_and_cleanup + - wait_for_any_job: now call notify_of_job_status only on the job we + just retrieved and will return + - wait_for: don't call notify_and_cleanup if posixly_correct unless + the shell is not currently interactive, since posix says we can + notify in a non-interactive shell when a foreground job changes + state + +jobs.c,parse.y,eval.c,execute_cmd.c,builtins/jobs.def,trap.c + - notify_and_cleanup: changed all callers appropriately + +builtins/evalfile.c + - _evalfile: renamed to evalfile_internal + - evalfile_internal: increment and decrement (or unwind-protect) the + value of want_job_notifications; increment it to a non-zero value + if the shell is interactive and the compatibility level is <= 52 + (see change to notify_and_cleanup of 8/26) + +jobs.c + - maybe_print_job_notifications: remove clause testing sourcelevel; + use want_job_notifications for this diff --git a/builtins/evalfile.c b/builtins/evalfile.c index b9b325ff..1fee9880 100644 --- a/builtins/evalfile.c +++ b/builtins/evalfile.c @@ -58,7 +58,7 @@ extern int errno; #endif -/* Flags for _evalfile() */ +/* Flags for evalfile_internal() */ #define FEVAL_ENOENTOK 0x001 #define FEVAL_BUILTIN 0x002 #define FEVAL_UNWINDPROT 0x004 @@ -74,7 +74,7 @@ extern int errno; int sourcelevel = 0; static int -_evalfile (const char *filename, int flags) +evalfile_internal (const char *filename, int flags) { volatile int old_interactive; procenv_t old_return_catch; @@ -212,13 +212,14 @@ file_error_and_exit: if (flags & FEVAL_UNWINDPROT) { - begin_unwind_frame ("_evalfile"); + begin_unwind_frame ("evalfile_internal"); unwind_protect_int (return_catch_flag); unwind_protect_jmp_buf (return_catch); if (flags & FEVAL_NONINT) unwind_protect_int (interactive); unwind_protect_int (sourcelevel); + unwind_protect_int (want_job_notifications); unwind_protect_int (retain_fifos); } else @@ -233,6 +234,8 @@ file_error_and_exit: return_catch_flag++; sourcelevel++; + if (interactive_shell && shell_compatibility_level <= 52) + want_job_notifications++; retain_fifos++; /* XXX */ @@ -297,7 +300,7 @@ file_error_and_exit: result = parse_and_execute (string, filename, pflags); if (flags & FEVAL_UNWINDPROT) - run_unwind_frame ("_evalfile"); + run_unwind_frame ("evalfile_internal"); else { if (flags & FEVAL_NONINT) @@ -316,6 +319,8 @@ file_error_and_exit: #endif return_catch_flag--; sourcelevel--; + if (interactive_shell && shell_compatibility_level <= 52) + want_job_notifications--; retain_fifos--; COPY_PROCENV (old_return_catch, return_catch); } @@ -338,7 +343,7 @@ maybe_execute_file (const char *fname, int force_noninteractive) flags = FEVAL_ENOENTOK|FEVAL_RETRY; if (force_noninteractive) flags |= FEVAL_NONINT; - result = _evalfile (filename, flags); + result = evalfile_internal (filename, flags); free (filename); return result; } @@ -353,7 +358,7 @@ force_execute_file (const char *fname, int force_noninteractive) flags = FEVAL_RETRY; if (force_noninteractive) flags |= FEVAL_NONINT; - result = _evalfile (filename, flags); + result = evalfile_internal (filename, flags); free (filename); return result; } @@ -368,7 +373,7 @@ fc_execute_file (const char *filename) remember_on_history is set. We use FEVAL_BUILTIN to return the result of parse_and_execute. */ flags = FEVAL_ENOENTOK|FEVAL_HISTORY|FEVAL_REGFILE|FEVAL_BUILTIN; - return (_evalfile (filename, flags)); + return (evalfile_internal (filename, flags)); } #endif /* HISTORY */ @@ -383,7 +388,7 @@ source_file (const char *filename, int sflags) /* POSIX shells exit if non-interactive and file error. */ if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0) flags |= FEVAL_LONGJMP; - rval = _evalfile (filename, flags); + rval = evalfile_internal (filename, flags); run_return_trap (); return rval; diff --git a/builtins/jobs.def b/builtins/jobs.def index df7305c4..63d7785e 100644 --- a/builtins/jobs.def +++ b/builtins/jobs.def @@ -138,7 +138,7 @@ jobs_builtin (WORD_LIST *list) list_all_jobs (form); /* POSIX says to remove terminated jobs from the list after the jobs builtin reports their status. */ - notify_and_cleanup (); /* the notify part will be a no-op */ + notify_and_cleanup (-1); /* the notify part will be a no-op */ break; case JSTATE_RUNNING: list_running_jobs (form); @@ -168,7 +168,7 @@ jobs_builtin (WORD_LIST *list) } /* POSIX says to remove terminated jobs from the list after the jobs builtin reports their status. */ - notify_and_cleanup (); + notify_and_cleanup (-1); /* XXX - why here? list_one_job already deletes dead jobs */ return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS); } diff --git a/doc/bash.0 b/doc/bash.0 index 12761fbd..0c80d738 100644 --- a/doc/bash.0 +++ b/doc/bash.0 @@ -772,15 +772,16 @@ PPAARRAAMMEETTEERRSS only be referenced; assignment to them is not allowed. ** Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional para- - meter expands to a separate word. In contexts where it is per- - formed, those words are subject to further word splitting and - pathname expansion. When the expansion occurs within double - quotes, it expands to a single word with the value of each para- - meter separated by the first character of the IIFFSS special vari- - able. That is, ""$$**"" is equivalent to ""$$11_c$$22_c......"", where _c is - the first character of the value of the IIFFSS variable. If IIFFSS is - unset, the parameters are separated by spaces. If IIFFSS is null, - the parameters are joined without intervening separators. + meter expands to a separate word. In contexts where these ex- + pansions are performed, those words are subject to further word + splitting and pathname expansion. When the expansion occurs + within double quotes, it expands to a single word with the value + of each parameter separated by the first character of the IIFFSS + special variable. That is, ""$$**"" is equivalent to ""$$11_c$$22_c......"", + where _c is the first character of the value of the IIFFSS variable. + If IIFFSS is unset, the parameters are separated by spaces. If IIFFSS + is null, the parameters are joined without intervening separa- + tors. @@ Expands to the positional parameters, starting from one. In contexts where word splitting is performed, this expands each positional parameter to a separate word; if not within double @@ -796,8 +797,8 @@ PPAARRAAMMEETTEERRSS word. When there are no positional parameters, ""$$@@"" and $$@@ ex- pand to nothing (i.e., they are removed). ## Expands to the number of positional parameters in decimal. - ?? Expands to the exit status of the most recently executed fore- - ground command. + ?? Expands to the exit status of the most recently executed com- + mand. -- Expands to the current option flags as specified upon invoca- tion, by the sseett builtin command, or those set by the shell it- self (such as the --ii option). @@ -3191,40 +3192,41 @@ JJOOBB CCOONNTTRROOLL The shell learns immediately whenever a job changes state. Normally, bbaasshh waits until it is about to print a prompt before reporting changes - in a job's status so as to not interrupt any other output. If the --bb - option to the sseett builtin command is enabled, bbaasshh reports such changes - immediately. Any trap on SSIIGGCCHHLLDD is executed for each child that ex- - its. - - If an attempt to exit bbaasshh is made while jobs are stopped (or, if the - cchheecckkjjoobbss shell option has been enabled using the sshhoopptt builtin, run- + in a job's status so as to not interrupt any other output, though it + will notify of changes in a job's status after a command in a list com- + pletes, before executing the next command. If the --bb option to the sseett + builtin command is enabled, bbaasshh reports such changes immediately. Any + trap on SSIIGGCCHHLLDD is executed for each child that exits. + + If an attempt to exit bbaasshh is made while jobs are stopped (or, if the + cchheecckkjjoobbss shell option has been enabled using the sshhoopptt builtin, run- ning), the shell prints a warning message, and, if the cchheecckkjjoobbss option - is enabled, lists the jobs and their statuses. The jjoobbss command may - then be used to inspect their status. If a second attempt to exit is - made without an intervening command, the shell does not print another + is enabled, lists the jobs and their statuses. The jjoobbss command may + then be used to inspect their status. 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. - When the shell is waiting for a job or process using the wwaaiitt builtin, - and job control is enabled, wwaaiitt will return when the job changes - state. The --ff option causes wwaaiitt to wait until the job or process ter- + When the shell is waiting for a job or process using the wwaaiitt builtin, + and job control is enabled, wwaaiitt will return when the job changes + state. The --ff option causes wwaaiitt to wait until the job or process ter- minates before returning. PPRROOMMPPTTIINNGG When executing interactively, bbaasshh displays the primary prompt PPSS11 when - it is ready to read a command, and the secondary prompt PPSS22 when it - needs more input to complete a command. BBaasshh displays PPSS00 after it - reads a command but before executing it. BBaasshh displays PPSS44 as de- - scribed above before tracing each command when the --xx option is en- - abled. BBaasshh allows these prompt strings to be customized by inserting - a number of backslash-escaped special characters that are decoded as + it is ready to read a command, and the secondary prompt PPSS22 when it + needs more input to complete a command. BBaasshh displays PPSS00 after it + reads a command but before executing it. BBaasshh displays PPSS44 as de- + scribed above before tracing each command when the --xx option is en- + abled. BBaasshh allows these prompt strings to be customized by inserting + a number of backslash-escaped special characters that are decoded as follows: \\aa an ASCII bell character (07) - \\dd the date in "Weekday Month Date" format (e.g., "Tue May + \\dd the date in "Weekday Month Date" format (e.g., "Tue May 26") \\DD{{_f_o_r_m_a_t}} the _f_o_r_m_a_t is passed to _s_t_r_f_t_i_m_e(3) and the result is in- serted into the prompt string; an empty _f_o_r_m_a_t results in - a locale-specific time representation. The braces are + a locale-specific time representation. The braces are required \\ee an ASCII escape character (033) \\hh the hostname up to the first "." @@ -3233,7 +3235,7 @@ PPRROOMMPPTTIINNGG \\ll the basename of the shell's terminal device name \\nn newline \\rr carriage return - \\ss the name of the shell, the basename of $$00 (the portion + \\ss the name of the shell, the basename of $$00 (the portion following the final slash) \\tt the current time in 24-hour HH:MM:SS format \\TT the current time in 12-hour HH:MM:SS format @@ -3242,8 +3244,8 @@ PPRROOMMPPTTIINNGG \\uu the username of the current user \\vv the version of bbaasshh (e.g., 2.00) \\VV the release of bbaasshh, version + patch level (e.g., 2.00.0) - \\ww the value of the PPWWDD shell variable ($$PPWWDD), with $$HHOOMMEE - abbreviated with a tilde (uses the value of the + \\ww the value of the PPWWDD shell variable ($$PPWWDD), with $$HHOOMMEE + abbreviated with a tilde (uses the value of the PPRROOMMPPTT__DDIIRRTTRRIIMM variable) \\WW the basename of $$PPWWDD, with $$HHOOMMEE abbreviated with a tilde \\!! the history number of this command @@ -3251,70 +3253,82 @@ PPRROOMMPPTTIINNGG \\$$ if the effective UID is 0, a ##, otherwise a $$ \\_n_n_n the character corresponding to the octal number _n_n_n \\\\ a backslash - \\[[ begin a sequence of non-printing characters, which could - be used to embed a terminal control sequence into the + \\[[ begin a sequence of non-printing characters, which could + be used to embed a terminal control sequence into the prompt \\]] end a sequence of non-printing characters - The command number and the history number are usually different: the - history number of a command is its position in the history list, which - may include commands restored from the history file (see HHIISSTTOORRYY be- - low), while the command number is the position in the sequence of com- - mands executed during the current shell session. After the string is - decoded, it is expanded via parameter expansion, command substitution, - arithmetic expansion, and quote removal, subject to the value of the + The command number and the history number are usually different: the + history number of a command is its position in the history list, which + may include commands restored from the history file (see HHIISSTTOORRYY be- + low), while the command number is the position in the sequence of com- + mands executed during the current shell session. After the string is + decoded, it is expanded via parameter expansion, command substitution, + arithmetic expansion, and quote removal, subject to the value of the pprroommppttvvaarrss shell option (see the description of the sshhoopptt command under - SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). This can have unwanted side effects if - escaped portions of the string appear within command substitution or + SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). This can have unwanted side effects if + escaped portions of the string appear within command substitution or contain characters special to word expansion. RREEAADDLLIINNEE - This is the library that handles reading input when using an interac- + This is the library that handles reading input when using an interac- tive shell, unless the ----nnooeeddiittiinngg option is given at shell invocation. Line editing is also used when using the --ee option to the rreeaadd builtin. By default, the line editing commands are similar to those of Emacs. A vi-style line editing interface is also available. Line editing can be - enabled at any time using the --oo eemmaaccss or --oo vvii options to the sseett - builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). To turn off line editing - after the shell is running, use the ++oo eemmaaccss or ++oo vvii options to the + enabled at any time using the --oo eemmaaccss or --oo vvii options to the sseett + builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). To turn off line editing + after the shell is running, use the ++oo eemmaaccss or ++oo vvii options to the sseett builtin. RReeaaddlliinnee NNoottaattiioonn In this section, the Emacs-style notation is used to denote keystrokes. - Control keys are denoted by C-_k_e_y, e.g., C-n means Control-N. Simi- - larly, _m_e_t_a keys are denoted by M-_k_e_y, so M-x means Meta-X. (On key- - boards without a _m_e_t_a key, M-_x means ESC _x, i.e., press the Escape key - then the _x key. This makes ESC the _m_e_t_a _p_r_e_f_i_x. The combination M-C-_x - means ESC-Control-_x, or press the Escape key then hold the Control key - while pressing the _x key.) + Control keys are denoted by C-_k_e_y, e.g., C-n means Control-N. Simi- + larly, _m_e_t_a keys are denoted by M-_k_e_y, so M-x means Meta-X. + + On keyboards without a _M_e_t_a key, M-_x means ESC _x, i.e., press the Es- + cape key then the _x key. This makes ESC the _m_e_t_a _p_r_e_f_i_x. The combina- + tion M-C-_x means ESC-Control-_x, or press the Escape key then hold the + Control key while pressing the _x key.) + + On some keyboards, the Meta key modifier produces meta characters with + the eighth bit (0200) set (you can use the eennaabbllee--mmeettaa--kkeeyy variable to + control whether or not it does this, if the keyboard allows it). On + many others, the terminal or terminal emulator converts the metafied + key to a key sequence beginning with ESC as described in the preceding + paragraph. + + If the _M_e_t_a key produces a key sequence with the ESC meta prefix, you + can make M-_k_e_y key bindings you specify (see RReeaaddlliinnee KKeeyy BBiinnddiinnggss be- + low) do the same thing by setting the ffoorrccee--mmeettaa--pprreeffiixx variable. Readline commands may be given numeric _a_r_g_u_m_e_n_t_s, which normally act as - a repeat count. Sometimes, however, it is the sign of the argument - that is significant. Passing a negative argument to a command that - acts in the forward direction (e.g., kkiillll--lliinnee) causes that command to - act in a backward direction. Commands whose behavior with arguments + a repeat count. Sometimes, however, it is the sign of the argument + that is significant. Passing a negative argument to a command that + acts in the forward direction (e.g., kkiillll--lliinnee) causes that command to + act in a backward direction. Commands whose behavior with arguments deviates from this are noted below. - When a command is described as _k_i_l_l_i_n_g text, the text deleted is saved + When a command is described as _k_i_l_l_i_n_g text, the text deleted is saved for possible future retrieval (_y_a_n_k_i_n_g). The killed text is saved in a _k_i_l_l _r_i_n_g. Consecutive kills cause the text to be accumulated into one unit, which can be yanked all at once. Commands which do not kill text separate the chunks of text on the kill ring. RReeaaddlliinnee IInniittiiaalliizzaattiioonn - Readline is customized by putting commands in an initialization file - (the _i_n_p_u_t_r_c file). The name of this file is taken from the value of + Readline is customized by putting commands in an initialization file + (the _i_n_p_u_t_r_c file). The name of this file is taken from the value of the IINNPPUUTTRRCC variable. If that variable is unset, the default is _~_/_._i_n_- - _p_u_t_r_c. If that file does not exist or cannot be read, the ultimate - default is _/_e_t_c_/_i_n_p_u_t_r_c. When a program which uses the readline li- - brary starts up, the initialization file is read, and the key bindings - and variables are set. There are only a few basic constructs allowed - in the readline initialization file. Blank lines are ignored. Lines - beginning with a ## are comments. Lines beginning with a $$ indicate - conditional constructs. Other lines denote key bindings and variable + _p_u_t_r_c. If that file does not exist or cannot be read, the ultimate + default is _/_e_t_c_/_i_n_p_u_t_r_c. When a program which uses the readline li- + brary starts up, the initialization file is read, and the key bindings + and variables are set. There are only a few basic constructs allowed + in the readline initialization file. Blank lines are ignored. Lines + beginning with a ## are comments. Lines beginning with a $$ indicate + conditional constructs. Other lines denote key bindings and variable settings. - The default key-bindings may be changed with an _i_n_p_u_t_r_c file. Other + The default key-bindings may be changed with an _i_n_p_u_t_r_c file. Other programs that use this library may add their own commands and bindings. For example, placing @@ -3323,18 +3337,18 @@ RREEAADDLLIINNEE or C-Meta-u: universal-argument - into the _i_n_p_u_t_r_c would make M-C-u execute the readline command _u_n_i_v_e_r_- + into the _i_n_p_u_t_r_c would make M-C-u execute the readline command _u_n_i_v_e_r_- _s_a_l_-_a_r_g_u_m_e_n_t. - The following symbolic character names are recognized: _R_U_B_O_U_T, _D_E_L, + The following symbolic character names are recognized: _R_U_B_O_U_T, _D_E_L, _E_S_C, _L_F_D, _N_E_W_L_I_N_E, _R_E_T, _R_E_T_U_R_N, _S_P_C, _S_P_A_C_E, and _T_A_B. - In addition to command names, readline allows keys to be bound to a + In addition to command names, readline allows keys to be bound to a string that is inserted when the key is pressed (a _m_a_c_r_o). RReeaaddlliinnee KKeeyy BBiinnddiinnggss - The syntax for controlling key bindings in the _i_n_p_u_t_r_c file is simple. - All that is required is the name of the command or the text of a macro + The syntax for controlling key bindings in the _i_n_p_u_t_r_c file is simple. + All that is required is the name of the command or the text of a macro and a key sequence to which it should be bound. The name may be speci- fied in one of two ways: as a symbolic key name, possibly with _M_e_t_a_- or _C_o_n_t_r_o_l_- prefixes, or as a key sequence. @@ -3346,15 +3360,15 @@ RREEAADDLLIINNEE Meta-Rubout: backward-kill-word Control-o: "> output" - In the above example, _C_-_u is bound to the function uunniivveerrssaall--aarrgguummeenntt, - _M_-_D_E_L is bound to the function bbaacckkwwaarrdd--kkiillll--wwoorrdd, and _C_-_o is bound to - run the macro expressed on the right hand side (that is, to insert the + In the above example, _C_-_u is bound to the function uunniivveerrssaall--aarrgguummeenntt, + _M_-_D_E_L is bound to the function bbaacckkwwaarrdd--kkiillll--wwoorrdd, and _C_-_o is bound to + run the macro expressed on the right hand side (that is, to insert the text "> output" into the line). - In the second form, ""kkeeyysseeqq"":_f_u_n_c_t_i_o_n_-_n_a_m_e or _m_a_c_r_o, kkeeyysseeqq differs - from kkeeyynnaammee above in that strings denoting an entire key sequence may - be specified by placing the sequence within double quotes. Some GNU - Emacs style key escapes can be used, as in the following example, but + In the second form, ""kkeeyysseeqq"":_f_u_n_c_t_i_o_n_-_n_a_m_e or _m_a_c_r_o, kkeeyysseeqq differs + from kkeeyynnaammee above in that strings denoting an entire key sequence may + be specified by placing the sequence within double quotes. Some GNU + Emacs style key escapes can be used, as in the following example, but the symbolic character names are not recognized. "\C-u": universal-argument @@ -3362,18 +3376,20 @@ RREEAADDLLIINNEE "\e[11~": "Function Key 1" In this example, _C_-_u is again bound to the function uunniivveerrssaall--aarrgguummeenntt. - _C_-_x _C_-_r is bound to the function rree--rreeaadd--iinniitt--ffiillee, and _E_S_C _[ _1 _1 _~ is + _C_-_x _C_-_r is bound to the function rree--rreeaadd--iinniitt--ffiillee, and _E_S_C _[ _1 _1 _~ is bound to insert the text "Function Key 1". The full set of GNU Emacs style escape sequences is \\CC-- control prefix - \\MM-- meta prefix + \\MM-- adding the meta prefix or converting the following char- + acter to a meta character, as described below under + ffoorrccee--mmeettaa--pprreeffiixx \\ee an escape character \\\\ backslash \\"" literal " \\'' literal ' - In addition to the GNU Emacs style escape sequences, a second set of + In addition to the GNU Emacs style escape sequences, a second set of backslash escapes is available: \\aa alert (bell) \\bb backspace @@ -3383,20 +3399,20 @@ RREEAADDLLIINNEE \\rr carriage return \\tt horizontal tab \\vv vertical tab - \\_n_n_n the eight-bit character whose value is the octal value + \\_n_n_n the eight-bit character whose value is the octal value _n_n_n (one to three digits) - \\xx_H_H the eight-bit character whose value is the hexadecimal + \\xx_H_H the eight-bit character whose value is the hexadecimal value _H_H (one or two hex digits) When entering the text of a macro, single or double quotes must be used to indicate a macro definition. Unquoted text is assumed to be a func- - tion name. In the macro body, the backslash escapes described above - are expanded. Backslash will quote any other character in the macro + tion name. In the macro body, the backslash escapes described above + are expanded. Backslash will quote any other character in the macro text, including " and '. - BBaasshh allows the current readline key bindings to be displayed or modi- - fied with the bbiinndd builtin command. The editing mode may be switched - during interactive use by using the --oo option to the sseett builtin com- + BBaasshh allows the current readline key bindings to be displayed or modi- + fied with the bbiinndd builtin command. The editing mode may be switched + during interactive use by using the --oo option to the sseett builtin com- mand (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). RReeaaddlliinnee VVaarriiaabblleess @@ -3407,109 +3423,111 @@ RREEAADDLLIINNEE sseett _v_a_r_i_a_b_l_e_-_n_a_m_e _v_a_l_u_e or using the bbiinndd builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). - Except where noted, readline variables can take the values OOnn or OOffff - (without regard to case). Unrecognized variable names are ignored. + Except where noted, readline variables can take the values OOnn or OOffff + (without regard to case). Unrecognized variable names are ignored. When readline reads a variable value, empty or null values, "on" (case- - insensitive), and "1" are equivalent to OOnn. All other values are + insensitive), and "1" are equivalent to OOnn. All other values are equivalent to OOffff. The variables and their default values are: aaccttiivvee--rreeggiioonn--ssttaarrtt--ccoolloorr - A string variable that controls the text color and background - when displaying the text in the active region (see the descrip- - tion of eennaabbllee--aaccttiivvee--rreeggiioonn below). This string must not take + A string variable that controls the text color and background + when displaying the text in the active region (see the descrip- + tion of eennaabbllee--aaccttiivvee--rreeggiioonn below). This string must not take up any physical character positions on the display, so it should - consist only of terminal escape sequences. It is output to the - terminal before displaying the text in the active region. This - variable is reset to the default value whenever the terminal - type changes. The default value is the string that puts the - terminal in standout mode, as obtained from the terminal's ter- + consist only of terminal escape sequences. It is output to the + terminal before displaying the text in the active region. This + variable is reset to the default value whenever the terminal + type changes. The default value is the string that puts the + terminal in standout mode, as obtained from the terminal's ter- minfo description. A sample value might be "\e[01;33m". aaccttiivvee--rreeggiioonn--eenndd--ccoolloorr - A string variable that "undoes" the effects of aaccttiivvee--rree-- - ggiioonn--ssttaarrtt--ccoolloorr and restores "normal" terminal display appear- - ance after displaying text in the active region. This string - must not take up any physical character positions on the dis- - play, so it should consist only of terminal escape sequences. - It is output to the terminal after displaying the text in the - active region. This variable is reset to the default value - whenever the terminal type changes. The default value is the - string that restores the terminal from standout mode, as ob- + A string variable that "undoes" the effects of aaccttiivvee--rree-- + ggiioonn--ssttaarrtt--ccoolloorr and restores "normal" terminal display appear- + ance after displaying text in the active region. This string + must not take up any physical character positions on the dis- + play, so it should consist only of terminal escape sequences. + It is output to the terminal after displaying the text in the + active region. This variable is reset to the default value + whenever the terminal type changes. The default value is the + string that restores the terminal from standout mode, as ob- tained from the terminal's terminfo description. A sample value might be "\e[0m". bbeellll--ssttyyllee ((aauuddiibbllee)) - Controls what happens when readline wants to ring the terminal + Controls what happens when readline wants to ring the terminal bell. If set to nnoonnee, readline never rings the bell. If set to - vviissiibbllee, readline uses a visible bell if one is available. If + vviissiibbllee, readline uses a visible bell if one is available. If set to aauuddiibbllee, readline attempts to ring the terminal's bell. bbiinndd--ttttyy--ssppeecciiaall--cchhaarrss ((OOnn)) - If set to OOnn (the default), readline attempts to bind the con- + If set to OOnn (the default), readline attempts to bind the con- trol characters that are treated specially by the kernel's ter- - minal driver to their readline equivalents. These override the - default readline bindings described here. Type "stty -a" at a + minal driver to their readline equivalents. These override the + default readline bindings described here. Type "stty -a" at a bbaasshh prompt to see your current terminal settings, including the special control characters (usually cccchhaarrss). bblliinnkk--mmaattcchhiinngg--ppaarreenn ((OOffff)) If set to OOnn, readline attempts to briefly move the cursor to an opening parenthesis when a closing parenthesis is inserted. ccoolloorreedd--ccoommpplleettiioonn--pprreeffiixx ((OOffff)) - If set to OOnn, when listing completions, readline displays the + If set to OOnn, when listing completions, readline displays the common prefix of the set of possible completions using a differ- - ent color. The color definitions are taken from the value of + ent color. The color definitions are taken from the value of the LLSS__CCOOLLOORRSS environment variable. If there is a color defini- - tion in $$LLSS__CCOOLLOORRSS for the custom suffix "readline-colored-com- - pletion-prefix", readline uses this color for the common prefix + tion in $$LLSS__CCOOLLOORRSS for the custom suffix "readline-colored-com- + pletion-prefix", readline uses this color for the common prefix instead of its default. ccoolloorreedd--ssttaattss ((OOffff)) - If set to OOnn, readline displays possible completions using dif- - ferent colors to indicate their file type. The color defini- - tions are taken from the value of the LLSS__CCOOLLOORRSS environment + If set to OOnn, readline displays possible completions using dif- + ferent colors to indicate their file type. The color defini- + tions are taken from the value of the LLSS__CCOOLLOORRSS environment variable. ccoommmmeenntt--bbeeggiinn (("##")) - The string that is inserted when the readline iinnsseerrtt--ccoommmmeenntt + The string that is inserted when the readline iinnsseerrtt--ccoommmmeenntt command is executed. This command is bound to MM--## in emacs mode and to ## in vi command mode. ccoommpplleettiioonn--ddiissppllaayy--wwiiddtthh ((--11)) - The number of screen columns used to display possible matches - when performing completion. The value is ignored if it is less - than 0 or greater than the terminal screen width. A value of 0 - will cause matches to be displayed one per line. The default + The number of screen columns used to display possible matches + when performing completion. The value is ignored if it is less + than 0 or greater than the terminal screen width. A value of 0 + will cause matches to be displayed one per line. The default value is -1. ccoommpplleettiioonn--iiggnnoorree--ccaassee ((OOffff)) If set to OOnn, readline performs filename matching and completion in a case-insensitive fashion. ccoommpplleettiioonn--mmaapp--ccaassee ((OOffff)) - If set to OOnn, and ccoommpplleettiioonn--iiggnnoorree--ccaassee is enabled, readline - treats hyphens (_-) and underscores (__) as equivalent when per- + If set to OOnn, and ccoommpplleettiioonn--iiggnnoorree--ccaassee is enabled, readline + treats hyphens (_-) and underscores (__) as equivalent when per- forming case-insensitive filename matching and completion. ccoommpplleettiioonn--pprreeffiixx--ddiissppllaayy--lleennggtthh ((00)) - The length in characters of the common prefix of a list of pos- - sible 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 possi- + The length in characters of the common prefix of a list of pos- + sible 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 possi- ble completions. ccoommpplleettiioonn--qquueerryy--iitteemmss ((110000)) - This determines when the user is queried about viewing the num- - ber of possible completions generated by the ppoossssiibbllee--ccoommppllee-- - ttiioonnss command. It may be set to any integer value greater than - or equal to zero. If the number of possible completions is - greater than or equal to the value of this variable, readline - will ask whether or not the user wishes to view them; otherwise - they are simply listed on the terminal. A zero value means + This determines when the user is queried about viewing the num- + ber of possible completions generated by the ppoossssiibbllee--ccoommppllee-- + ttiioonnss command. It may be set to any integer value greater than + or equal to zero. If the number of possible completions is + greater than or equal to the value of this variable, readline + will ask whether or not the user wishes to view them; otherwise + they are simply listed on the terminal. A zero value means readline should never ask; negative values are treated as zero. ccoonnvveerrtt--mmeettaa ((OOnn)) - If set to OOnn, readline will convert characters with the eighth - bit set to an ASCII key sequence by stripping the eighth bit and - prefixing an escape character (in effect, using escape as the - _m_e_t_a _p_r_e_f_i_x). The default is _O_n, but readline will set it to - _O_f_f if the locale contains eight-bit characters. This variable - is dependent on the LLCC__CCTTYYPPEE locale category, and may change if - the locale is changed. + If set to OOnn, readline will convert characters it reads with the + eighth bit set to an ASCII key sequence by stripping the eighth + bit and prefixing it with an escape character (converting the + character to have the _m_e_t_a _p_r_e_f_i_x). The default is _O_n, but + readline will set it to _O_f_f if the locale contains characters + whose encodings may include bytes with the eighth bit set. This + variable is dependent on the LLCC__CCTTYYPPEE locale category, and may + change if the locale is changed. This variable also affects key + bindings; see the description of ffoorrccee--mmeettaa--pprreeffiixx below. ddiissaabbllee--ccoommpplleettiioonn ((OOffff)) If set to OOnn, readline will inhibit word completion. Completion - characters will be inserted into the line as if they had been + characters will be inserted into the line as if they had been mapped to sseellff--iinnsseerrtt. eecchhoo--ccoonnttrrooll--cchhaarraacctteerrss ((OOnn)) - When set to OOnn, on operating systems that indicate they support + When set to OOnn, on operating systems that indicate they support it, readline echoes a character corresponding to a signal gener- ated from the keyboard. eeddiittiinngg--mmooddee ((eemmaaccss)) @@ -3517,29 +3535,29 @@ RREEAADDLLIINNEE ilar to _E_m_a_c_s or _v_i. eeddiittiinngg--mmooddee can be set to either eemmaaccss or vvii. eemmaaccss--mmooddee--ssttrriinngg ((@@)) - If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is + If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is displayed immediately before the last line of the primary prompt when emacs editing mode is active. The value is expanded like a - key binding, so the standard set of meta- and control prefixes - and backslash escape sequences is available. Use the \1 and \2 - escapes to begin and end sequences of non-printing characters, - which can be used to embed a terminal control sequence into the + key binding, so the standard set of meta- and control prefixes + and backslash escape sequences is available. Use the \1 and \2 + escapes to begin and end sequences of non-printing characters, + which can be used to embed a terminal control sequence into the mode string. eennaabbllee--aaccttiivvee--rreeggiioonn ((OOnn)) - The _p_o_i_n_t is the current cursor position, and _m_a_r_k refers to a - saved cursor position. The text between the point and mark is - referred to as the _r_e_g_i_o_n. When this variable is set to _O_n, - readline allows certain commands to designate the region as _a_c_- - _t_i_v_e. When the region is active, readline highlights the text - in the region using the value of the aaccttiivvee--rreeggiioonn--ssttaarrtt--ccoolloorr, - which defaults to the string that enables the terminal's stand- - out mode. The active region shows the text inserted by brack- - eted-paste and any matching text found by incremental and non- + The _p_o_i_n_t is the current cursor position, and _m_a_r_k refers to a + saved cursor position. The text between the point and mark is + referred to as the _r_e_g_i_o_n. When this variable is set to _O_n, + readline allows certain commands to designate the region as _a_c_- + _t_i_v_e. When the region is active, readline highlights the text + in the region using the value of the aaccttiivvee--rreeggiioonn--ssttaarrtt--ccoolloorr, + which defaults to the string that enables the terminal's stand- + out mode. The active region shows the text inserted by brack- + eted-paste and any matching text found by incremental and non- incremental history searches. eennaabbllee--bbrraacckkeetteedd--ppaassttee ((OOnn)) - When set to OOnn, readline configures the terminal to insert each - paste into the editing buffer as a single string of characters, - instead of treating each character as if it had been read from + When set to OOnn, readline configures the terminal to insert each + paste into the editing buffer as a single string of characters, + instead of treating each character as if it had been read from the keyboard. This prevents readline from executing any editing commands bound to key sequences appearing in the pasted text. eennaabbllee--kkeeyyppaadd ((OOffff)) @@ -3547,39 +3565,54 @@ RREEAADDLLIINNEE pad when it is called. Some systems need this to enable the ar- row keys. eennaabbllee--mmeettaa--kkeeyy ((OOnn)) - When set to OOnn, readline will try to enable any meta modifier - key the terminal claims to support when it is called. On many - terminals, the meta key is used to send eight-bit characters. + When set to OOnn, readline will try to enable any meta modifier + key the terminal claims to support when it is called. On many + terminals, the Meta key is used to send eight-bit characters; + this variable checks for the terminal capability that indicates + the terminal can enable and disable a mode that sets the eighth + bit of a character (0200) if the Meta key is held down when the + character is typed (a meta character). + ffoorrccee--mmeettaa--pprreeffiixx ((OOffff)) + If set to OOnn, readline modifies its behavior when binding key + sequences containing \M- or Meta- (see KKeeyy BBiinnddiinnggss above) by + converting a key sequence of the form \M-_C or Meta-_C to the two- + character sequence EESSCC_C (adding the meta prefix). If + ffoorrccee--mmeettaa--pprreeffiixx is set to OOffff (the default), readline uses the + value of the ccoonnvveerrtt--mmeettaa variable to determine whether to per- + form this conversion: if ccoonnvveerrtt--mmeettaa is OOnn, readline performs + the conversion described above; if it is OOffff, Readline converts + _C to a meta character by setting the eighth bit (0200). eexxppaanndd--ttiillddee ((OOffff)) - If set to OOnn, tilde expansion is performed when readline at- + If set to OOnn, tilde expansion is performed when readline at- tempts word completion. hhiissttoorryy--pprreesseerrvvee--ppooiinntt ((OOffff)) - If set to OOnn, the history code attempts to place point at the - same location on each history line retrieved with pprreevviioouuss--hhiiss-- + If set to OOnn, the history code attempts to place point at the + same location on each history line retrieved with pprreevviioouuss--hhiiss-- ttoorryy or nneexxtt--hhiissttoorryy. hhiissttoorryy--ssiizzee ((uunnsseett)) - Set the maximum number of history entries saved in the history - list. If set to zero, any existing history entries are deleted + Set the maximum number of history entries saved in the history + list. If set to zero, any 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. By default, the - number of history entries is set to the value of the HHIISSTTSSIIZZEE - shell variable. If an attempt is made to set _h_i_s_t_o_r_y_-_s_i_z_e to a + the number of history entries is not limited. By default, the + number of history entries is set to the value of the HHIISSTTSSIIZZEE + shell variable. If an attempt is made to set _h_i_s_t_o_r_y_-_s_i_z_e to a non-numeric value, the maximum number of history entries will be set to 500. hhoorriizzoonnttaall--ssccrroollll--mmooddee ((OOffff)) - When set to OOnn, makes readline use a single line for display, + When set to OOnn, 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 + becomes longer than the screen width rather than wrapping to a + new line. This setting is automatically enabled for terminals of height 1. iinnppuutt--mmeettaa ((OOffff)) - If set to OOnn, readline will enable eight-bit input (that is, it + If set to OOnn, readline will enable eight-bit input (that is, it will not strip the eighth bit from the characters it reads), re- - gardless of what the terminal claims it can support. The name - mmeettaa--ffllaagg is a synonym for this variable. The default is _O_f_f, - but readline will set it to _O_n if the locale contains eight-bit - characters. This variable is dependent on the LLCC__CCTTYYPPEE locale - category, and may change if the locale is changed. + gardless of what the terminal claims it can support. The name + mmeettaa--ffllaagg is a synonym for this variable. The default is _O_f_f, + but readline will set it to _O_n if the locale contains characters + whose encodings may include bytes with the eighth bit set. This + variable is dependent on the LLCC__CCTTYYPPEE locale category, and may + change if the locale is changed. iisseeaarrcchh--tteerrmmiinnaattoorrss (("CC--[[CC--JJ")) The string of characters that should terminate an incremental search without subsequently executing the character as a com- @@ -3625,9 +3658,9 @@ RREEAADDLLIINNEE If set to OOnn, readline will display characters with the eighth bit set directly rather than as a meta-prefixed escape sequence. The default is _O_f_f, but readline will set it to _O_n if the locale - contains eight-bit characters. This variable is dependent on - the LLCC__CCTTYYPPEE locale category, and may change if the locale is - changed. + contains characters whose encodings may include bytes with the + eighth bit set. This variable is dependent on the LLCC__CCTTYYPPEE lo- + cale category, and may change if the locale is changed. ppaaggee--ccoommpplleettiioonnss ((OOnn)) If set to OOnn, readline uses an internal _m_o_r_e-like pager to dis- play a screenful of possible completions at a time. @@ -6945,4 +6978,4 @@ BBUUGGSS There may be only one active coprocess at a time. -GNU Bash 5.3 2024 August 16 _B_A_S_H(1) +GNU Bash 5.3 2024 September 5 _B_A_S_H(1) diff --git a/doc/bash.1 b/doc/bash.1 index 1d58d6b2..cd4fd4ef 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -5,14 +5,14 @@ .\" Case Western Reserve University .\" chet.ramey@case.edu .\" -.\" Last Change: Fri Aug 23 09:09:35 EDT 2024 +.\" Last Change: Thu Sep 5 15:41:56 EDT 2024 .\" .\" bash_builtins, strip all but Built-Ins section .\" avoid a warning about an undefined register .\" .if !rzY .nr zY 0 .if \n(zZ=1 .ig zZ .if \n(zY=1 .ig zY -.TH BASH 1 "2024 August 23" "GNU Bash 5.3" +.TH BASH 1 "2024 September 5" "GNU Bash 5.3" .\" .ie \n(.g \{\ .ds ' \(aq @@ -1465,8 +1465,7 @@ expand to nothing (i.e., they are removed). Expands to the number of positional parameters in decimal. .TP .B ? -Expands to the exit status of the most recently executed foreground -command. +Expands to the exit status of the most recently executed command. .TP .B \- Expands to the current option flags as specified upon invocation, @@ -5739,7 +5738,10 @@ Normally, .B bash waits until it is about to print a prompt before reporting changes in a job's status so as to not interrupt -any other output. If the +any other output, +though it will notify of changes in a job's status after a command in +a list completes, before executing the next command. +If the .B \-b option to the .B set diff --git a/doc/bash.info b/doc/bash.info index 4763c673..bff8f1a3 100644 --- a/doc/bash.info +++ b/doc/bash.info @@ -1,9 +1,9 @@ This is bash.info, produced by makeinfo version 7.1 from bashref.texi. This text is a brief description of the features that are present in the -Bash shell (version 5.3, 16 August 2024). +Bash shell (version 5.3, 5 September 2024). - This is Edition 5.3, last updated 16 August 2024, of ‘The GNU Bash + This is Edition 5.3, last updated 5 September 2024, of ‘The GNU Bash Reference Manual’, for ‘Bash’, Version 5.3. Copyright © 1988-2023 Free Software Foundation, Inc. @@ -26,10 +26,10 @@ Bash Features ************* This text is a brief description of the features that are present in the -Bash shell (version 5.3, 16 August 2024). The Bash home page is +Bash shell (version 5.3, 5 September 2024). The Bash home page is . - This is Edition 5.3, last updated 16 August 2024, of ‘The GNU Bash + This is Edition 5.3, last updated 5 September 2024, of ‘The GNU Bash Reference Manual’, for ‘Bash’, Version 5.3. Bash contains features that appear in other popular shells, and some @@ -903,11 +903,11 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: Each clause must be terminated with ‘;;’, ‘;&’, or ‘;;&’. The WORD undergoes tilde expansion, parameter expansion, command - substitution, arithmetic expansion, and quote removal (*note Shell - Parameter Expansion::) before matching is attempted. Each PATTERN - undergoes tilde expansion, parameter expansion, command - substitution, arithmetic expansion, process substitution, and quote - removal. + substitution, process substitution, arithmetic expansion, and quote + removal (*note Shell Parameter Expansion::) before the shell + attempts to match the pattern. Each PATTERN undergoes tilde + expansion, parameter expansion, command substitution, arithmetic + expansion, process substitution, and quote removal. There may be an arbitrary number of ‘case’ clauses, each terminated by a ‘;;’, ‘;&’, or ‘;;&’. The first pattern that matches @@ -1555,10 +1555,10 @@ only be referenced; assignment to them is not allowed. ‘*’ ($*) Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional - parameter expands to a separate word. In contexts where it is - performed, those words are subject to further word splitting and - filename expansion. When the expansion occurs within double - quotes, it expands to a single word with the value of each + parameter expands to a separate word. In contexts where these + expansions are performed, those words are subject to further word + splitting and filename expansion. When the expansion occurs within + double quotes, it expands to a single word with the value of each parameter separated by the first character of the ‘IFS’ special variable. That is, ‘"$*"’ is equivalent to ‘"$1C$2C..."’, where C is the first character of the value of the ‘IFS’ variable. If @@ -1587,7 +1587,7 @@ only be referenced; assignment to them is not allowed. ‘?’ ($?) Expands to the exit status of the most recently executed - foreground command. + command. ‘-’ ($-, a hyphen.) Expands to the current option flags as specified @@ -7356,102 +7356,113 @@ startup files. is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for example, ‘SIGTSTP’. - 6. Alias expansion is always enabled, even in non-interactive shells. + 6. If the shell is interactive, Bash does not perform job + notifications between executing commands in lists separated by ‘;’ + or newline. Non-interactive shells print status messages after a + foreground job in a list completes. + + 7. If the shell is interactive, Bash waits until the next prompt + before printing the status of a background job that changes status + or a foreground job that terminates due to a signal. + Non-interactive shells print status messages after a foreground job + completes. - 7. Reserved words appearing in a context where reserved words are + 8. Alias expansion is always enabled, even in non-interactive shells. + + 9. Reserved words appearing in a context where reserved words are recognized do not undergo alias expansion. - 8. Alias expansion is performed when initially parsing a command + 10. Alias expansion is performed when initially parsing a command substitution. The default mode generally defers it, when enabled, until the command substitution is executed. This means that command substitution will not expand aliases that are defined after the command substitution is initially parsed (e.g., as part of a function definition). - 9. The POSIX ‘PS1’ and ‘PS2’ expansions of ‘!’ to the history number + 11. The POSIX ‘PS1’ and ‘PS2’ expansions of ‘!’ to the history number and ‘!!’ to ‘!’ are enabled, and parameter expansion is performed on the values of ‘PS1’ and ‘PS2’ regardless of the setting of the ‘promptvars’ option. - 10. The POSIX startup files are executed (‘$ENV’) rather than the + 12. The POSIX startup files are executed (‘$ENV’) rather than the normal Bash files. - 11. Tilde expansion is only performed on assignments preceding a + 13. Tilde expansion is only performed on assignments preceding a command name, rather than on all assignment statements on the line. - 12. The default history file is ‘~/.sh_history’ (this is the default + 14. The default history file is ‘~/.sh_history’ (this is the default value the shell assigns to ‘$HISTFILE’). - 13. Redirection operators do not perform filename expansion on the + 15. Redirection operators do not perform filename expansion on the word in the redirection unless the shell is interactive. - 14. Redirection operators do not perform word splitting on the word in + 16. Redirection operators do not perform word splitting on the word in the redirection. - 15. Function names must be valid shell ‘name’s. That is, they may not + 17. Function names must be valid shell ‘name’s. That is, they may not contain characters other than letters, digits, and underscores, and may not start with a digit. Declaring a function with an invalid name causes a fatal syntax error in non-interactive shells. - 16. Function names may not be the same as one of the POSIX special + 18. Function names may not be the same as one of the POSIX special builtins. - 17. Even if a shell function whose name contains a slash was defined + 19. Even if a shell function whose name contains a slash was defined before entering POSIX mode, the shell will not execute a function whose name contains one or more slashes. - 18. POSIX special builtins are found before shell functions during + 20. POSIX special builtins are found before shell functions during command lookup, including output printed by the ‘type’ and ‘command’ builtins. - 19. When printing shell function definitions (e.g., by ‘type’), Bash + 21. When printing shell function definitions (e.g., by ‘type’), Bash does not print the ‘function’ keyword. - 20. Literal tildes that appear as the first character in elements of + 22. Literal tildes that appear as the first character in elements of the ‘PATH’ variable are not expanded as described above under *note Tilde Expansion::. - 21. The ‘time’ reserved word may be used by itself as a command. When + 23. The ‘time’ reserved word may be used by itself as a command. When used in this way, it displays timing statistics for the shell and its completed children. The ‘TIMEFORMAT’ variable controls the format of the timing information. - 22. When parsing and expanding a ${...} expansion that appears within + 24. When parsing and expanding a ${...} expansion that appears within double quotes, single quotes are no longer special and cannot be used to quote a closing brace or other special character, unless the operator is one of those defined to perform pattern removal. In this case, they do not have to appear as matched pairs. - 23. The parser does not recognize ‘time’ as a reserved word if the + 25. The parser does not recognize ‘time’ as a reserved word if the next token begins with a ‘-’. - 24. The ‘!’ character does not introduce history expansion within a + 26. The ‘!’ character does not introduce history expansion within a double-quoted string, even if the ‘histexpand’ option is enabled. - 25. If a POSIX special builtin returns an error status, a + 27. If a POSIX special builtin returns an error status, a non-interactive shell exits. The fatal errors are those listed in the POSIX standard, and include things like passing incorrect options, redirection errors, variable assignment errors for assignments preceding the command name, and so on. - 26. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal + 28. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal error if it attempts to unset a ‘readonly’ or ‘non-unsettable’ variable, or encounters a variable name argument that is an invalid identifier, which causes a non-interactive shell to exit. - 27. When asked to unset a variable that appears in an assignment + 29. When asked to unset a variable that appears in an assignment statement preceding the command, the ‘unset’ builtin attempts to unset a variable of the same name in the current or previous scope as well. This implements the required "if an assigned variable is further modified by the utility, the modifications made by the utility shall persist" behavior. - 28. A non-interactive shell exits with an error status if a variable + 30. A non-interactive shell exits with an error status if a variable assignment error occurs when no command name follows the assignment statements. A variable assignment error occurs, for example, when trying to assign a value to a readonly variable. - 29. A non-interactive shell exits with an error status if a variable + 31. A non-interactive shell exits with an error status if a variable assignment error occurs in an assignment statement preceding a special builtin, but not with any other simple command. For any other simple command, the shell aborts execution of that command, @@ -7459,166 +7470,166 @@ startup files. perform any further processing of the command in which the error occurred"). - 30. A non-interactive shell exits with an error status if the + 32. A non-interactive shell exits with an error status if the iteration variable in a ‘for’ statement or the selection variable in a ‘select’ statement is a readonly variable or has an invalid name. - 31. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not + 33. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not found. - 32. Non-interactive shells exit if a syntax error in an arithmetic + 34. Non-interactive shells exit if a syntax error in an arithmetic expansion results in an invalid expression. - 33. Non-interactive shells exit if a parameter expansion error occurs. + 35. Non-interactive shells exit if a parameter expansion error occurs. - 34. Non-interactive shells exit if there is a syntax error in a script + 36. Non-interactive shells exit if there is a syntax error in a script read with the ‘.’ or ‘source’ builtins, or in a string processed by the ‘eval’ builtin. - 35. While variable indirection is available, it may not be applied to + 37. While variable indirection is available, it may not be applied to the ‘#’ and ‘?’ special parameters. - 36. Expanding the ‘*’ special parameter in a pattern context where the + 38. Expanding the ‘*’ special parameter in a pattern context where the expansion is double-quoted does not treat the ‘$*’ as if it were double-quoted. - 37. Assignment statements preceding POSIX special builtins persist in + 39. Assignment statements preceding POSIX special builtins persist in the shell environment after the builtin completes. - 38. The ‘command’ builtin does not prevent builtins that take + 40. The ‘command’ builtin does not prevent builtins that take assignment statements as arguments from expanding them as assignment statements; when not in POSIX mode, assignment builtins lose their assignment statement expansion properties when preceded by ‘command’. - 39. The ‘bg’ builtin uses the required format to describe each job + 41. The ‘bg’ builtin uses the required format to describe each job placed in the background, which does not include an indication of whether the job is the current or previous job. - 40. The output of ‘kill -l’ prints all the signal names on a single + 42. The output of ‘kill -l’ prints all the signal names on a single line, separated by spaces, without the ‘SIG’ prefix. - 41. The ‘kill’ builtin does not accept signal names with a ‘SIG’ + 43. The ‘kill’ builtin does not accept signal names with a ‘SIG’ prefix. - 42. The ‘export’ and ‘readonly’ builtin commands display their output + 44. The ‘export’ and ‘readonly’ builtin commands display their output in the format required by POSIX. - 43. If the ‘export’ and ‘readonly’ builtin commands get an argument + 45. If the ‘export’ and ‘readonly’ builtin commands get an argument that is not a valid identifier, and they are not operating on shell functions, they return an error. This will cause a non-interactive shell to exit because these are special builtins. - 44. The ‘trap’ builtin displays signal names without the leading + 46. The ‘trap’ builtin displays signal names without the leading ‘SIG’. - 45. The ‘trap’ builtin doesn't check the first argument for a possible + 47. The ‘trap’ builtin doesn't check the first argument for a possible signal specification and revert the signal handling to the original disposition if it is, unless that argument consists solely of digits and is a valid signal number. If users want to reset the handler for a given signal to the original disposition, they should use ‘-’ as the first argument. - 46. ‘trap -p’ without arguments displays signals whose dispositions + 48. ‘trap -p’ without arguments displays signals whose dispositions are set to SIG_DFL and those that were ignored when the shell started, not just trapped signals. - 47. The ‘.’ and ‘source’ builtins do not search the current directory + 49. The ‘.’ and ‘source’ builtins do not search the current directory for the filename argument if it is not found by searching ‘PATH’. - 48. Enabling POSIX mode has the effect of setting the + 50. Enabling POSIX mode has the effect of setting the ‘inherit_errexit’ option, so subshells spawned to execute command substitutions inherit the value of the ‘-e’ option from the parent shell. When the ‘inherit_errexit’ option is not enabled, Bash clears the ‘-e’ option in such subshells. - 49. Enabling POSIX mode has the effect of setting the ‘shift_verbose’ + 51. Enabling POSIX mode has the effect of setting the ‘shift_verbose’ option, so numeric arguments to ‘shift’ that exceed the number of positional parameters will result in an error message. - 50. When the ‘alias’ builtin displays alias definitions, it does not + 52. When the ‘alias’ builtin displays alias definitions, it does not display them with a leading ‘alias ’ unless the ‘-p’ option is supplied. - 51. When the ‘set’ builtin is invoked without options, it does not + 53. When the ‘set’ builtin is invoked without options, it does not display shell function names and definitions. - 52. When the ‘set’ builtin is invoked without options, it displays + 54. When the ‘set’ builtin is invoked without options, it displays variable values without quotes, unless they contain shell metacharacters, even if the result contains nonprinting characters. - 53. When the ‘cd’ builtin is invoked in logical mode, and the pathname + 55. When the ‘cd’ builtin is invoked in logical mode, and the pathname constructed from ‘$PWD’ and the directory name supplied as an argument does not refer to an existing directory, ‘cd’ will fail instead of falling back to physical mode. - 54. When the ‘cd’ builtin cannot change a directory because the length + 56. When the ‘cd’ builtin cannot change a directory because the length of the pathname constructed from ‘$PWD’ and the directory name supplied as an argument exceeds ‘PATH_MAX’ when canonicalized, ‘cd’ will attempt to use the supplied directory name. - 55. The ‘pwd’ builtin verifies that the value it prints is the same as + 57. The ‘pwd’ builtin verifies that the value it prints is the same as the current directory, even if it is not asked to check the file system with the ‘-P’ option. - 56. When listing the history, the ‘fc’ builtin does not include an + 58. When listing the history, the ‘fc’ builtin does not include an indication of whether or not a history entry has been modified. - 57. The default editor used by ‘fc’ is ‘ed’. + 59. The default editor used by ‘fc’ is ‘ed’. - 58. ‘fc’ treats extra arguments as an error instead of ignoring them. + 60. ‘fc’ treats extra arguments as an error instead of ignoring them. - 59. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints + 61. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints an error message and returns failure. - 60. The ‘type’ and ‘command’ builtins will not report a non-executable + 62. The ‘type’ and ‘command’ builtins will not report a non-executable file as having been found, though the shell will attempt to execute such a file if it is the only so-named file found in ‘$PATH’. - 61. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when + 63. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when the ‘v’ command is run, instead of checking ‘$VISUAL’ and ‘$EDITOR’. - 62. When the ‘xpg_echo’ option is enabled, Bash does not attempt to + 64. When the ‘xpg_echo’ option is enabled, Bash does not attempt to interpret any arguments to ‘echo’ as options. Each argument is displayed, after escape characters are converted. - 63. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’ + 65. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’ and ‘-f’ options. - 64. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not + 66. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not interrupt the ‘wait’ builtin and cause it to return immediately. The trap command is run once for each child that exits. - 65. The ‘read’ builtin may be interrupted by a signal for which a trap + 67. The ‘read’ builtin may be interrupted by a signal for which a trap has been set. If Bash receives a trapped signal while executing ‘read’, the trap handler executes and ‘read’ returns an exit status greater than 128. - 66. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert + 68. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert arguments corresponding to floating point conversion specifiers, instead of ‘long double’ if it's available. The ‘L’ length modifier forces ‘printf’ to use ‘long double’ if it's available. - 67. Bash removes an exited background process's status from the list + 69. Bash removes an exited background process's status from the list of such statuses after the ‘wait’ builtin is used to obtain it. - 68. A double quote character (‘"’) is treated specially when it + 70. A double quote character (‘"’) is treated specially when it appears in a backquoted command substitution in the body of a here-document that undergoes expansion. That means, for example, that a backslash preceding a double quote character will escape it and the backslash will be removed. - 69. The ‘test’ builtin compares strings using the current locale when + 71. The ‘test’ builtin compares strings using the current locale when processing the ‘<’ and ‘>’ binary operators. - 70. The ‘test’ builtin's ‘-t’ unary primary requires an argument. + 72. The ‘test’ builtin's ‘-t’ unary primary requires an argument. Historical versions of ‘test’ made the argument optional in certain cases, and Bash attempts to accommodate those for backwards compatibility. - 71. Command substitutions don't set the ‘?’ special parameter. The + 73. Command substitutions don't set the ‘?’ special parameter. The exit status of a simple command without a command word is still the exit status of the last command substitution that occurred while evaluating the variable assignments and redirections in that @@ -7804,6 +7815,9 @@ required for bash-5.1 and later versions. as bindable command names, and displays any key sequences bound to those commands, instead of treating the arguments as key sequences to bind. + • Interactive shells will notify the user of completed jobs + while sourcing a script. Newer versions defer notification + until script execution completes.  File: bash.info, Node: Job Control, Next: Command Line Editing, Prev: Bash Features, Up: Top @@ -7896,10 +7910,12 @@ equivalent to ‘bg %1’ The shell learns immediately whenever a job changes state. Normally, Bash waits until it is about to print a prompt before reporting changes -in a job's status so as to not interrupt any other output. If the ‘-b’ -option to the ‘set’ builtin is enabled, Bash reports such changes -immediately (*note The Set Builtin::). Any trap on ‘SIGCHLD’ is -executed for each child process that exits. +in a job's status so as to not interrupt any other output, though it +will notify of changes in a job's status after a command in a list +completes, before executing the next command. If the ‘-b’ option to the +‘set’ builtin is enabled, Bash reports such changes immediately (*note +The Set Builtin::). Any trap on ‘SIGCHLD’ is executed for each child +process that exits. If an attempt to exit Bash is made while jobs are stopped, (or running, if the ‘checkjobs’ option is enabled - see *note The Shopt @@ -8120,20 +8136,29 @@ produced when the key is pressed while the Control key is depressed. The text ‘M-k’ is read as 'Meta-K' and describes the character produced when the Meta key (if you have one) is depressed, and the -key is pressed. The Meta key is labeled on many keyboards. On -keyboards with two keys labeled (usually to either side of the -space bar), the on the left side is generally set to work as a -Meta key. The key on the right may also be configured to work as -a Meta key or may be configured as some other modifier, such as a -Compose key for typing accented characters. +key is pressed (a “meta character”). The Meta key is labeled on +many keyboards. On keyboards with two keys labeled (usually to +either side of the space bar), the on the left side is generally +set to work as a Meta key. The key on the right may also be +configured to work as a Meta key or may be configured as some other +modifier, such as a Compose key for typing accented characters. + + On some keyboards, the Meta key modifier produces meta characters +with the eighth bit (0200) set (you can use the ‘enable-meta-key’ +variable to control whether or not it does this, if the keyboard allows +it). On many others, the terminal or terminal emulator converts the +metafied key to a key sequence beginning with as described in the +next paragraph. If you do not have a Meta or key, or another key working as a -Meta key, the identical keystroke can be generated by typing -_first_, and then typing . Either process is known as “metafying” -the key. +Meta key, you can generally achieve the latter effect by typing +_first_, and then typing . The character is known as the “meta +prefix”). + + Either process is known as “metafying” the key. The text ‘M-C-k’ is read as 'Meta-Control-k' and describes the -character produced by “metafying” ‘C-k’. +character produced by metafying ‘C-k’. In addition, several keys have their own names. Specifically, , , , , , and all stand for themselves when seen @@ -8522,14 +8547,16 @@ Variable Settings limit is ‘100’. ‘convert-meta’ - If set to ‘on’, Readline will convert characters with the - eighth bit set to an ASCII key sequence by stripping the + If set to ‘on’, Readline will convert characters it reads with + the eighth bit set to an ASCII key sequence by stripping the eighth bit and prefixing an character, converting them to a meta-prefixed key sequence. The default value is ‘on’, - but will be set to ‘off’ if the locale is one that contains - eight-bit characters. This variable is dependent on the - ‘LC_CTYPE’ locale category, and may change if the locale is - changed. + but Readline will set it to ‘off’ if the locale contains + characters whose encodings may include bytes with the eighth + bit set. This variable is dependent on the ‘LC_CTYPE’ locale + category, and may change if the locale is changed. This + variable also affects key bindings; see the description of + ‘force-meta-prefix’ below. ‘disable-completion’ If set to ‘On’, Readline will inhibit word completion. @@ -8587,13 +8614,30 @@ Variable Settings ‘enable-meta-key’ When set to ‘on’, Readline will try to enable any meta modifier key the terminal claims to support when it is called. - On many terminals, the meta key is used to send eight-bit - characters. The default is ‘on’. + On many terminals, the Meta key is used to send eight-bit + characters; this variable checks for the terminal capability + that indicates the terminal can enable and disable a mode that + sets the eighth bit of a character (0200) if the Meta key is + held down when the character is typed (a meta character). The + default is ‘on’. ‘expand-tilde’ If set to ‘on’, tilde expansion is performed when Readline attempts word completion. The default is ‘off’. + ‘force-meta-prefix’ + If set to ‘on’, Readline modifies its behavior when binding + key sequences containing ‘\M-’ or ‘Meta-’ (see ‘Key Bindings’ + in *note Readline Init File Syntax::) by converting a key + sequence of the form ‘\M-’C or ‘Meta-’C to the two-character + sequence ‘ESC’C (adding the meta prefix). If + ‘force-meta-prefix’ is set to ‘off’ (the default), Readline + uses the value of the ‘convert-meta’ variable to determine + whether to perform this conversion: if ‘convert-meta’ is ‘on’, + Readline performs the conversion described above; if it is + ‘off’, Readline converts C to a meta character by setting the + eighth bit (0200). The default is ‘off’. + ‘history-preserve-point’ If set to ‘on’, the history code attempts to place the point (the current cursor position) at the same location on each @@ -8623,10 +8667,11 @@ Variable Settings not clear the eighth bit in the characters it reads), regardless of what the terminal claims it can support. The default value is ‘off’, but Readline will set it to ‘on’ if - the locale contains eight-bit characters. The name - ‘meta-flag’ is a synonym for this variable. This variable is - dependent on the ‘LC_CTYPE’ locale category, and may change if - the locale is changed. + the locale contains characters whose encodings may include + bytes with the eighth bit set. The name ‘meta-flag’ is a + synonym for this variable. This variable is dependent on the + ‘LC_CTYPE’ locale category, and may change if the locale is + changed. ‘isearch-terminators’ The string of characters that should terminate an incremental @@ -8691,9 +8736,10 @@ Variable Settings If set to ‘on’, Readline will display characters with the eighth bit set directly rather than as a meta-prefixed escape sequence. The default is ‘off’, but Readline will set it to - ‘on’ if the locale contains eight-bit characters. This - variable is dependent on the ‘LC_CTYPE’ locale category, and - may change if the locale is changed. + ‘on’ if the locale contains characters whose encodings may + include bytes with the eighth bit set. This variable is + dependent on the ‘LC_CTYPE’ locale category, and may change if + the locale is changed. ‘page-completions’ If set to ‘on’, Readline uses an internal ‘more’-like pager to @@ -8839,7 +8885,10 @@ Key Bindings ‘\C-’ control prefix ‘\M-’ - meta prefix + adding the meta prefix or converting the following character + to a meta character, as described above under + ‘force-meta-prefix’ (see ‘Variable Settings’ in *note Readline + Init File Syntax::). ‘\e’ an escape character ‘\\’ @@ -12474,29 +12523,31 @@ D.3 Parameter and Variable Index * COPROC: Bash Variables. (line 278) * DIRSTACK: Bash Variables. (line 282) * disable-completion: Readline Init File Syntax. - (line 151) + (line 153) * echo-control-characters: Readline Init File Syntax. - (line 156) + (line 158) * editing-mode: Readline Init File Syntax. - (line 161) + (line 163) * EMACS: Bash Variables. (line 292) * emacs-mode-string: Readline Init File Syntax. - (line 167) + (line 169) * enable-active-region: Readline Init File Syntax. - (line 177) + (line 179) * enable-bracketed-paste: Readline Init File Syntax. - (line 190) + (line 192) * enable-keypad: Readline Init File Syntax. - (line 199) + (line 201) * ENV: Bash Variables. (line 297) * EPOCHREALTIME: Bash Variables. (line 302) * EPOCHSECONDS: Bash Variables. (line 310) * EUID: Bash Variables. (line 317) * EXECIGNORE: Bash Variables. (line 321) * expand-tilde: Readline Init File Syntax. - (line 210) + (line 216) * FCEDIT: Bash Variables. (line 334) * FIGNORE: Bash Variables. (line 338) +* force-meta-prefix: Readline Init File Syntax. + (line 220) * FUNCNAME: Bash Variables. (line 344) * FUNCNEST: Bash Variables. (line 361) * GLOBIGNORE: Bash Variables. (line 366) @@ -12509,15 +12560,15 @@ D.3 Parameter and Variable Index * HISTFILESIZE: Bash Variables. (line 456) * HISTIGNORE: Bash Variables. (line 467) * history-preserve-point: Readline Init File Syntax. - (line 214) + (line 233) * history-size: Readline Init File Syntax. - (line 220) + (line 239) * HISTSIZE: Bash Variables. (line 489) * HISTTIMEFORMAT: Bash Variables. (line 496) * HOME: Bourne Shell Variables. (line 13) * horizontal-scroll-mode: Readline Init File Syntax. - (line 229) + (line 248) * HOSTFILE: Bash Variables. (line 505) * HOSTNAME: Bash Variables. (line 516) * HOSTTYPE: Bash Variables. (line 519) @@ -12525,13 +12576,13 @@ D.3 Parameter and Variable Index (line 18) * IGNOREEOF: Bash Variables. (line 522) * input-meta: Readline Init File Syntax. - (line 238) + (line 257) * INPUTRC: Bash Variables. (line 532) * INSIDE_EMACS: Bash Variables. (line 536) * isearch-terminators: Readline Init File Syntax. - (line 248) + (line 268) * keymap: Readline Init File Syntax. - (line 255) + (line 275) * LANG: Creating Internationalized Scripts. (line 51) * LANG <1>: Bash Variables. (line 542) @@ -12553,15 +12604,15 @@ D.3 Parameter and Variable Index (line 27) * MAPFILE: Bash Variables. (line 597) * mark-modified-lines: Readline Init File Syntax. - (line 285) + (line 305) * mark-symlinked-directories: Readline Init File Syntax. - (line 290) + (line 310) * match-hidden-files: Readline Init File Syntax. - (line 295) + (line 315) * menu-complete-display-prefix: Readline Init File Syntax. - (line 302) + (line 322) * meta-flag: Readline Init File Syntax. - (line 238) + (line 257) * OLDPWD: Bash Variables. (line 601) * OPTARG: Bourne Shell Variables. (line 34) @@ -12570,9 +12621,9 @@ D.3 Parameter and Variable Index (line 38) * OSTYPE: Bash Variables. (line 608) * output-meta: Readline Init File Syntax. - (line 307) + (line 327) * page-completions: Readline Init File Syntax. - (line 315) + (line 336) * PATH: Bourne Shell Variables. (line 42) * PIPESTATUS: Bash Variables. (line 611) @@ -12595,21 +12646,21 @@ D.3 Parameter and Variable Index * READLINE_POINT: Bash Variables. (line 684) * REPLY: Bash Variables. (line 688) * revert-all-at-newline: Readline Init File Syntax. - (line 325) + (line 346) * search-ignore-case: Readline Init File Syntax. - (line 332) + (line 353) * SECONDS: Bash Variables. (line 691) * SHELL: Bash Variables. (line 701) * SHELLOPTS: Bash Variables. (line 706) * SHLVL: Bash Variables. (line 715) * show-all-if-ambiguous: Readline Init File Syntax. - (line 337) + (line 358) * show-all-if-unmodified: Readline Init File Syntax. - (line 343) + (line 364) * show-mode-in-prompt: Readline Init File Syntax. - (line 352) + (line 373) * skip-completed-text: Readline Init File Syntax. - (line 358) + (line 379) * SRANDOM: Bash Variables. (line 720) * TEXTDOMAIN: Creating Internationalized Scripts. (line 51) @@ -12620,11 +12671,11 @@ D.3 Parameter and Variable Index * TMPDIR: Bash Variables. (line 779) * UID: Bash Variables. (line 783) * vi-cmd-mode-string: Readline Init File Syntax. - (line 371) + (line 392) * vi-ins-mode-string: Readline Init File Syntax. - (line 382) + (line 403) * visible-stats: Readline Init File Syntax. - (line 393) + (line 414)  File: bash.info, Node: Function Index, Next: Concept Index, Prev: Variable Index, Up: Indexes @@ -13010,138 +13061,138 @@ D.5 Concept Index  Tag Table: -Node: Top897 -Node: Introduction2834 -Node: What is Bash?3047 -Node: What is a shell?4188 -Node: Definitions6767 -Node: Basic Shell Features9943 -Node: Shell Syntax11163 -Node: Shell Operation12190 -Node: Quoting13488 -Node: Escape Character14801 -Node: Single Quotes15299 -Node: Double Quotes15648 -Node: ANSI-C Quoting16991 -Node: Locale Translation18376 -Node: Creating Internationalized Scripts19720 -Node: Comments23918 -Node: Shell Commands24553 -Node: Reserved Words25492 -Node: Simple Commands26357 -Node: Pipelines27016 -Node: Lists30079 -Node: Compound Commands31951 -Node: Looping Constructs32960 -Node: Conditional Constructs35504 -Node: Command Grouping50325 -Node: Coprocesses51812 -Node: GNU Parallel54508 -Node: Shell Functions55426 -Node: Shell Parameters63532 -Node: Positional Parameters68065 -Node: Special Parameters69000 -Node: Shell Expansions72306 -Node: Brace Expansion74495 -Node: Tilde Expansion77158 -Node: Shell Parameter Expansion79924 -Node: Command Substitution99031 -Node: Arithmetic Expansion102564 -Node: Process Substitution103529 -Node: Word Splitting104666 -Node: Filename Expansion106807 -Node: Pattern Matching109903 -Node: Quote Removal115136 -Node: Redirections115440 -Node: Executing Commands125249 -Node: Simple Command Expansion125916 -Node: Command Search and Execution128027 -Node: Command Execution Environment130435 -Node: Environment133744 -Node: Exit Status135448 -Node: Signals137233 -Node: Shell Scripts140847 -Node: Shell Builtin Commands143939 -Node: Bourne Shell Builtins146050 -Node: Bash Builtins170820 -Node: Modifying Shell Behavior205919 -Node: The Set Builtin206261 -Node: The Shopt Builtin217844 -Node: Special Builtins234806 -Node: Shell Variables235795 -Node: Bourne Shell Variables236229 -Node: Bash Variables238422 -Node: Bash Features275617 -Node: Invoking Bash276631 -Node: Bash Startup Files283030 -Node: Interactive Shells288333 -Node: What is an Interactive Shell?288741 -Node: Is this Shell Interactive?289407 -Node: Interactive Shell Behavior290231 -Node: Bash Conditional Expressions293985 -Node: Shell Arithmetic299159 -Node: Aliases302241 -Node: Arrays305196 -Node: The Directory Stack311995 -Node: Directory Stack Builtins312792 -Node: Controlling the Prompt317241 -Node: The Restricted Shell320379 -Node: Bash POSIX Mode323166 -Node: Shell Compatibility Mode340677 -Node: Job Control349444 -Node: Job Control Basics349901 -Node: Job Control Builtins355075 -Node: Job Control Variables361019 -Node: Command Line Editing362196 -Node: Introduction and Notation363900 -Node: Readline Interaction365544 -Node: Readline Bare Essentials366732 -Node: Readline Movement Commands368550 -Node: Readline Killing Commands369547 -Node: Readline Arguments371525 -Node: Searching372582 -Node: Readline Init File374811 -Node: Readline Init File Syntax376093 -Node: Conditional Init Constructs401031 -Node: Sample Init File405396 -Node: Bindable Readline Commands408517 -Node: Commands For Moving409742 -Node: Commands For History411969 -Node: Commands For Text417174 -Node: Commands For Killing421308 -Node: Numeric Arguments424109 -Node: Commands For Completion425261 -Node: Keyboard Macros429577 -Node: Miscellaneous Commands430278 -Node: Readline vi Mode436932 -Node: Programmable Completion437884 -Node: Programmable Completion Builtins445841 -Node: A Programmable Completion Example457407 -Node: Using History Interactively462752 -Node: Bash History Facilities463433 -Node: Bash History Builtins466545 -Node: History Interaction471788 -Node: Event Designators476113 -Node: Word Designators477696 -Node: Modifiers479848 -Node: Installing Bash481757 -Node: Basic Installation482891 -Node: Compilers and Options486770 -Node: Compiling For Multiple Architectures487520 -Node: Installation Names489269 -Node: Specifying the System Type491503 -Node: Sharing Defaults492249 -Node: Operation Controls492963 -Node: Optional Features493982 -Node: Reporting Bugs505784 -Node: Major Differences From The Bourne Shell507133 -Node: GNU Free Documentation License526868 -Node: Indexes552045 -Node: Builtin Index552496 -Node: Reserved Word Index559594 -Node: Variable Index562039 -Node: Function Index579170 -Node: Concept Index593026 +Node: Top901 +Node: Introduction2842 +Node: What is Bash?3055 +Node: What is a shell?4196 +Node: Definitions6775 +Node: Basic Shell Features9951 +Node: Shell Syntax11171 +Node: Shell Operation12198 +Node: Quoting13496 +Node: Escape Character14809 +Node: Single Quotes15307 +Node: Double Quotes15656 +Node: ANSI-C Quoting16999 +Node: Locale Translation18384 +Node: Creating Internationalized Scripts19728 +Node: Comments23926 +Node: Shell Commands24561 +Node: Reserved Words25500 +Node: Simple Commands26365 +Node: Pipelines27024 +Node: Lists30087 +Node: Compound Commands31959 +Node: Looping Constructs32968 +Node: Conditional Constructs35512 +Node: Command Grouping50373 +Node: Coprocesses51860 +Node: GNU Parallel54556 +Node: Shell Functions55474 +Node: Shell Parameters63580 +Node: Positional Parameters68113 +Node: Special Parameters69048 +Node: Shell Expansions72358 +Node: Brace Expansion74547 +Node: Tilde Expansion77210 +Node: Shell Parameter Expansion79976 +Node: Command Substitution99083 +Node: Arithmetic Expansion102616 +Node: Process Substitution103581 +Node: Word Splitting104718 +Node: Filename Expansion106859 +Node: Pattern Matching109955 +Node: Quote Removal115188 +Node: Redirections115492 +Node: Executing Commands125301 +Node: Simple Command Expansion125968 +Node: Command Search and Execution128079 +Node: Command Execution Environment130487 +Node: Environment133796 +Node: Exit Status135500 +Node: Signals137285 +Node: Shell Scripts140899 +Node: Shell Builtin Commands143991 +Node: Bourne Shell Builtins146102 +Node: Bash Builtins170872 +Node: Modifying Shell Behavior205971 +Node: The Set Builtin206313 +Node: The Shopt Builtin217896 +Node: Special Builtins234858 +Node: Shell Variables235847 +Node: Bourne Shell Variables236281 +Node: Bash Variables238474 +Node: Bash Features275669 +Node: Invoking Bash276683 +Node: Bash Startup Files283082 +Node: Interactive Shells288385 +Node: What is an Interactive Shell?288793 +Node: Is this Shell Interactive?289459 +Node: Interactive Shell Behavior290283 +Node: Bash Conditional Expressions294037 +Node: Shell Arithmetic299211 +Node: Aliases302293 +Node: Arrays305248 +Node: The Directory Stack312047 +Node: Directory Stack Builtins312844 +Node: Controlling the Prompt317293 +Node: The Restricted Shell320431 +Node: Bash POSIX Mode323218 +Node: Shell Compatibility Mode341267 +Node: Job Control350218 +Node: Job Control Basics350675 +Node: Job Control Builtins355972 +Node: Job Control Variables361916 +Node: Command Line Editing363093 +Node: Introduction and Notation364797 +Node: Readline Interaction366892 +Node: Readline Bare Essentials368080 +Node: Readline Movement Commands369898 +Node: Readline Killing Commands370895 +Node: Readline Arguments372873 +Node: Searching373930 +Node: Readline Init File376159 +Node: Readline Init File Syntax377441 +Node: Conditional Init Constructs403981 +Node: Sample Init File408346 +Node: Bindable Readline Commands411467 +Node: Commands For Moving412692 +Node: Commands For History414919 +Node: Commands For Text420124 +Node: Commands For Killing424258 +Node: Numeric Arguments427059 +Node: Commands For Completion428211 +Node: Keyboard Macros432527 +Node: Miscellaneous Commands433228 +Node: Readline vi Mode439882 +Node: Programmable Completion440834 +Node: Programmable Completion Builtins448791 +Node: A Programmable Completion Example460357 +Node: Using History Interactively465702 +Node: Bash History Facilities466383 +Node: Bash History Builtins469495 +Node: History Interaction474738 +Node: Event Designators479063 +Node: Word Designators480646 +Node: Modifiers482798 +Node: Installing Bash484707 +Node: Basic Installation485841 +Node: Compilers and Options489720 +Node: Compiling For Multiple Architectures490470 +Node: Installation Names492219 +Node: Specifying the System Type494453 +Node: Sharing Defaults495199 +Node: Operation Controls495913 +Node: Optional Features496932 +Node: Reporting Bugs508734 +Node: Major Differences From The Bourne Shell510083 +Node: GNU Free Documentation License529818 +Node: Indexes554995 +Node: Builtin Index555446 +Node: Reserved Word Index562544 +Node: Variable Index564989 +Node: Function Index582261 +Node: Concept Index596117  End Tag Table diff --git a/doc/bashref.info b/doc/bashref.info index 496d2424..136f15c2 100644 --- a/doc/bashref.info +++ b/doc/bashref.info @@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 7.1 from bashref.texi. This text is a brief description of the features that are present in the -Bash shell (version 5.3, 16 August 2024). +Bash shell (version 5.3, 5 September 2024). - This is Edition 5.3, last updated 16 August 2024, of ‘The GNU Bash + This is Edition 5.3, last updated 5 September 2024, of ‘The GNU Bash Reference Manual’, for ‘Bash’, Version 5.3. Copyright © 1988-2023 Free Software Foundation, Inc. @@ -27,10 +27,10 @@ Bash Features ************* This text is a brief description of the features that are present in the -Bash shell (version 5.3, 16 August 2024). The Bash home page is +Bash shell (version 5.3, 5 September 2024). The Bash home page is . - This is Edition 5.3, last updated 16 August 2024, of ‘The GNU Bash + This is Edition 5.3, last updated 5 September 2024, of ‘The GNU Bash Reference Manual’, for ‘Bash’, Version 5.3. Bash contains features that appear in other popular shells, and some @@ -904,11 +904,11 @@ File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Pre Each clause must be terminated with ‘;;’, ‘;&’, or ‘;;&’. The WORD undergoes tilde expansion, parameter expansion, command - substitution, arithmetic expansion, and quote removal (*note Shell - Parameter Expansion::) before matching is attempted. Each PATTERN - undergoes tilde expansion, parameter expansion, command - substitution, arithmetic expansion, process substitution, and quote - removal. + substitution, process substitution, arithmetic expansion, and quote + removal (*note Shell Parameter Expansion::) before the shell + attempts to match the pattern. Each PATTERN undergoes tilde + expansion, parameter expansion, command substitution, arithmetic + expansion, process substitution, and quote removal. There may be an arbitrary number of ‘case’ clauses, each terminated by a ‘;;’, ‘;&’, or ‘;;&’. The first pattern that matches @@ -1556,10 +1556,10 @@ only be referenced; assignment to them is not allowed. ‘*’ ($*) Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional - parameter expands to a separate word. In contexts where it is - performed, those words are subject to further word splitting and - filename expansion. When the expansion occurs within double - quotes, it expands to a single word with the value of each + parameter expands to a separate word. In contexts where these + expansions are performed, those words are subject to further word + splitting and filename expansion. When the expansion occurs within + double quotes, it expands to a single word with the value of each parameter separated by the first character of the ‘IFS’ special variable. That is, ‘"$*"’ is equivalent to ‘"$1C$2C..."’, where C is the first character of the value of the ‘IFS’ variable. If @@ -1588,7 +1588,7 @@ only be referenced; assignment to them is not allowed. ‘?’ ($?) Expands to the exit status of the most recently executed - foreground command. + command. ‘-’ ($-, a hyphen.) Expands to the current option flags as specified @@ -7357,102 +7357,113 @@ startup files. is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for example, ‘SIGTSTP’. - 6. Alias expansion is always enabled, even in non-interactive shells. + 6. If the shell is interactive, Bash does not perform job + notifications between executing commands in lists separated by ‘;’ + or newline. Non-interactive shells print status messages after a + foreground job in a list completes. + + 7. If the shell is interactive, Bash waits until the next prompt + before printing the status of a background job that changes status + or a foreground job that terminates due to a signal. + Non-interactive shells print status messages after a foreground job + completes. - 7. Reserved words appearing in a context where reserved words are + 8. Alias expansion is always enabled, even in non-interactive shells. + + 9. Reserved words appearing in a context where reserved words are recognized do not undergo alias expansion. - 8. Alias expansion is performed when initially parsing a command + 10. Alias expansion is performed when initially parsing a command substitution. The default mode generally defers it, when enabled, until the command substitution is executed. This means that command substitution will not expand aliases that are defined after the command substitution is initially parsed (e.g., as part of a function definition). - 9. The POSIX ‘PS1’ and ‘PS2’ expansions of ‘!’ to the history number + 11. The POSIX ‘PS1’ and ‘PS2’ expansions of ‘!’ to the history number and ‘!!’ to ‘!’ are enabled, and parameter expansion is performed on the values of ‘PS1’ and ‘PS2’ regardless of the setting of the ‘promptvars’ option. - 10. The POSIX startup files are executed (‘$ENV’) rather than the + 12. The POSIX startup files are executed (‘$ENV’) rather than the normal Bash files. - 11. Tilde expansion is only performed on assignments preceding a + 13. Tilde expansion is only performed on assignments preceding a command name, rather than on all assignment statements on the line. - 12. The default history file is ‘~/.sh_history’ (this is the default + 14. The default history file is ‘~/.sh_history’ (this is the default value the shell assigns to ‘$HISTFILE’). - 13. Redirection operators do not perform filename expansion on the + 15. Redirection operators do not perform filename expansion on the word in the redirection unless the shell is interactive. - 14. Redirection operators do not perform word splitting on the word in + 16. Redirection operators do not perform word splitting on the word in the redirection. - 15. Function names must be valid shell ‘name’s. That is, they may not + 17. Function names must be valid shell ‘name’s. That is, they may not contain characters other than letters, digits, and underscores, and may not start with a digit. Declaring a function with an invalid name causes a fatal syntax error in non-interactive shells. - 16. Function names may not be the same as one of the POSIX special + 18. Function names may not be the same as one of the POSIX special builtins. - 17. Even if a shell function whose name contains a slash was defined + 19. Even if a shell function whose name contains a slash was defined before entering POSIX mode, the shell will not execute a function whose name contains one or more slashes. - 18. POSIX special builtins are found before shell functions during + 20. POSIX special builtins are found before shell functions during command lookup, including output printed by the ‘type’ and ‘command’ builtins. - 19. When printing shell function definitions (e.g., by ‘type’), Bash + 21. When printing shell function definitions (e.g., by ‘type’), Bash does not print the ‘function’ keyword. - 20. Literal tildes that appear as the first character in elements of + 22. Literal tildes that appear as the first character in elements of the ‘PATH’ variable are not expanded as described above under *note Tilde Expansion::. - 21. The ‘time’ reserved word may be used by itself as a command. When + 23. The ‘time’ reserved word may be used by itself as a command. When used in this way, it displays timing statistics for the shell and its completed children. The ‘TIMEFORMAT’ variable controls the format of the timing information. - 22. When parsing and expanding a ${...} expansion that appears within + 24. When parsing and expanding a ${...} expansion that appears within double quotes, single quotes are no longer special and cannot be used to quote a closing brace or other special character, unless the operator is one of those defined to perform pattern removal. In this case, they do not have to appear as matched pairs. - 23. The parser does not recognize ‘time’ as a reserved word if the + 25. The parser does not recognize ‘time’ as a reserved word if the next token begins with a ‘-’. - 24. The ‘!’ character does not introduce history expansion within a + 26. The ‘!’ character does not introduce history expansion within a double-quoted string, even if the ‘histexpand’ option is enabled. - 25. If a POSIX special builtin returns an error status, a + 27. If a POSIX special builtin returns an error status, a non-interactive shell exits. The fatal errors are those listed in the POSIX standard, and include things like passing incorrect options, redirection errors, variable assignment errors for assignments preceding the command name, and so on. - 26. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal + 28. The ‘unset’ builtin with the ‘-v’ option specified returns a fatal error if it attempts to unset a ‘readonly’ or ‘non-unsettable’ variable, or encounters a variable name argument that is an invalid identifier, which causes a non-interactive shell to exit. - 27. When asked to unset a variable that appears in an assignment + 29. When asked to unset a variable that appears in an assignment statement preceding the command, the ‘unset’ builtin attempts to unset a variable of the same name in the current or previous scope as well. This implements the required "if an assigned variable is further modified by the utility, the modifications made by the utility shall persist" behavior. - 28. A non-interactive shell exits with an error status if a variable + 30. A non-interactive shell exits with an error status if a variable assignment error occurs when no command name follows the assignment statements. A variable assignment error occurs, for example, when trying to assign a value to a readonly variable. - 29. A non-interactive shell exits with an error status if a variable + 31. A non-interactive shell exits with an error status if a variable assignment error occurs in an assignment statement preceding a special builtin, but not with any other simple command. For any other simple command, the shell aborts execution of that command, @@ -7460,166 +7471,166 @@ startup files. perform any further processing of the command in which the error occurred"). - 30. A non-interactive shell exits with an error status if the + 32. A non-interactive shell exits with an error status if the iteration variable in a ‘for’ statement or the selection variable in a ‘select’ statement is a readonly variable or has an invalid name. - 31. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not + 33. Non-interactive shells exit if FILENAME in ‘.’ FILENAME is not found. - 32. Non-interactive shells exit if a syntax error in an arithmetic + 34. Non-interactive shells exit if a syntax error in an arithmetic expansion results in an invalid expression. - 33. Non-interactive shells exit if a parameter expansion error occurs. + 35. Non-interactive shells exit if a parameter expansion error occurs. - 34. Non-interactive shells exit if there is a syntax error in a script + 36. Non-interactive shells exit if there is a syntax error in a script read with the ‘.’ or ‘source’ builtins, or in a string processed by the ‘eval’ builtin. - 35. While variable indirection is available, it may not be applied to + 37. While variable indirection is available, it may not be applied to the ‘#’ and ‘?’ special parameters. - 36. Expanding the ‘*’ special parameter in a pattern context where the + 38. Expanding the ‘*’ special parameter in a pattern context where the expansion is double-quoted does not treat the ‘$*’ as if it were double-quoted. - 37. Assignment statements preceding POSIX special builtins persist in + 39. Assignment statements preceding POSIX special builtins persist in the shell environment after the builtin completes. - 38. The ‘command’ builtin does not prevent builtins that take + 40. The ‘command’ builtin does not prevent builtins that take assignment statements as arguments from expanding them as assignment statements; when not in POSIX mode, assignment builtins lose their assignment statement expansion properties when preceded by ‘command’. - 39. The ‘bg’ builtin uses the required format to describe each job + 41. The ‘bg’ builtin uses the required format to describe each job placed in the background, which does not include an indication of whether the job is the current or previous job. - 40. The output of ‘kill -l’ prints all the signal names on a single + 42. The output of ‘kill -l’ prints all the signal names on a single line, separated by spaces, without the ‘SIG’ prefix. - 41. The ‘kill’ builtin does not accept signal names with a ‘SIG’ + 43. The ‘kill’ builtin does not accept signal names with a ‘SIG’ prefix. - 42. The ‘export’ and ‘readonly’ builtin commands display their output + 44. The ‘export’ and ‘readonly’ builtin commands display their output in the format required by POSIX. - 43. If the ‘export’ and ‘readonly’ builtin commands get an argument + 45. If the ‘export’ and ‘readonly’ builtin commands get an argument that is not a valid identifier, and they are not operating on shell functions, they return an error. This will cause a non-interactive shell to exit because these are special builtins. - 44. The ‘trap’ builtin displays signal names without the leading + 46. The ‘trap’ builtin displays signal names without the leading ‘SIG’. - 45. The ‘trap’ builtin doesn't check the first argument for a possible + 47. The ‘trap’ builtin doesn't check the first argument for a possible signal specification and revert the signal handling to the original disposition if it is, unless that argument consists solely of digits and is a valid signal number. If users want to reset the handler for a given signal to the original disposition, they should use ‘-’ as the first argument. - 46. ‘trap -p’ without arguments displays signals whose dispositions + 48. ‘trap -p’ without arguments displays signals whose dispositions are set to SIG_DFL and those that were ignored when the shell started, not just trapped signals. - 47. The ‘.’ and ‘source’ builtins do not search the current directory + 49. The ‘.’ and ‘source’ builtins do not search the current directory for the filename argument if it is not found by searching ‘PATH’. - 48. Enabling POSIX mode has the effect of setting the + 50. Enabling POSIX mode has the effect of setting the ‘inherit_errexit’ option, so subshells spawned to execute command substitutions inherit the value of the ‘-e’ option from the parent shell. When the ‘inherit_errexit’ option is not enabled, Bash clears the ‘-e’ option in such subshells. - 49. Enabling POSIX mode has the effect of setting the ‘shift_verbose’ + 51. Enabling POSIX mode has the effect of setting the ‘shift_verbose’ option, so numeric arguments to ‘shift’ that exceed the number of positional parameters will result in an error message. - 50. When the ‘alias’ builtin displays alias definitions, it does not + 52. When the ‘alias’ builtin displays alias definitions, it does not display them with a leading ‘alias ’ unless the ‘-p’ option is supplied. - 51. When the ‘set’ builtin is invoked without options, it does not + 53. When the ‘set’ builtin is invoked without options, it does not display shell function names and definitions. - 52. When the ‘set’ builtin is invoked without options, it displays + 54. When the ‘set’ builtin is invoked without options, it displays variable values without quotes, unless they contain shell metacharacters, even if the result contains nonprinting characters. - 53. When the ‘cd’ builtin is invoked in logical mode, and the pathname + 55. When the ‘cd’ builtin is invoked in logical mode, and the pathname constructed from ‘$PWD’ and the directory name supplied as an argument does not refer to an existing directory, ‘cd’ will fail instead of falling back to physical mode. - 54. When the ‘cd’ builtin cannot change a directory because the length + 56. When the ‘cd’ builtin cannot change a directory because the length of the pathname constructed from ‘$PWD’ and the directory name supplied as an argument exceeds ‘PATH_MAX’ when canonicalized, ‘cd’ will attempt to use the supplied directory name. - 55. The ‘pwd’ builtin verifies that the value it prints is the same as + 57. The ‘pwd’ builtin verifies that the value it prints is the same as the current directory, even if it is not asked to check the file system with the ‘-P’ option. - 56. When listing the history, the ‘fc’ builtin does not include an + 58. When listing the history, the ‘fc’ builtin does not include an indication of whether or not a history entry has been modified. - 57. The default editor used by ‘fc’ is ‘ed’. + 59. The default editor used by ‘fc’ is ‘ed’. - 58. ‘fc’ treats extra arguments as an error instead of ignoring them. + 60. ‘fc’ treats extra arguments as an error instead of ignoring them. - 59. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints + 61. If there are too many arguments supplied to ‘fc -s’, ‘fc’ prints an error message and returns failure. - 60. The ‘type’ and ‘command’ builtins will not report a non-executable + 62. The ‘type’ and ‘command’ builtins will not report a non-executable file as having been found, though the shell will attempt to execute such a file if it is the only so-named file found in ‘$PATH’. - 61. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when + 63. The ‘vi’ editing mode will invoke the ‘vi’ editor directly when the ‘v’ command is run, instead of checking ‘$VISUAL’ and ‘$EDITOR’. - 62. When the ‘xpg_echo’ option is enabled, Bash does not attempt to + 64. When the ‘xpg_echo’ option is enabled, Bash does not attempt to interpret any arguments to ‘echo’ as options. Each argument is displayed, after escape characters are converted. - 63. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’ + 65. The ‘ulimit’ builtin uses a block size of 512 bytes for the ‘-c’ and ‘-f’ options. - 64. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not + 66. The arrival of ‘SIGCHLD’ when a trap is set on ‘SIGCHLD’ does not interrupt the ‘wait’ builtin and cause it to return immediately. The trap command is run once for each child that exits. - 65. The ‘read’ builtin may be interrupted by a signal for which a trap + 67. The ‘read’ builtin may be interrupted by a signal for which a trap has been set. If Bash receives a trapped signal while executing ‘read’, the trap handler executes and ‘read’ returns an exit status greater than 128. - 66. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert + 68. The ‘printf’ builtin uses ‘double’ (via ‘strtod’) to convert arguments corresponding to floating point conversion specifiers, instead of ‘long double’ if it's available. The ‘L’ length modifier forces ‘printf’ to use ‘long double’ if it's available. - 67. Bash removes an exited background process's status from the list + 69. Bash removes an exited background process's status from the list of such statuses after the ‘wait’ builtin is used to obtain it. - 68. A double quote character (‘"’) is treated specially when it + 70. A double quote character (‘"’) is treated specially when it appears in a backquoted command substitution in the body of a here-document that undergoes expansion. That means, for example, that a backslash preceding a double quote character will escape it and the backslash will be removed. - 69. The ‘test’ builtin compares strings using the current locale when + 71. The ‘test’ builtin compares strings using the current locale when processing the ‘<’ and ‘>’ binary operators. - 70. The ‘test’ builtin's ‘-t’ unary primary requires an argument. + 72. The ‘test’ builtin's ‘-t’ unary primary requires an argument. Historical versions of ‘test’ made the argument optional in certain cases, and Bash attempts to accommodate those for backwards compatibility. - 71. Command substitutions don't set the ‘?’ special parameter. The + 73. Command substitutions don't set the ‘?’ special parameter. The exit status of a simple command without a command word is still the exit status of the last command substitution that occurred while evaluating the variable assignments and redirections in that @@ -7805,6 +7816,9 @@ required for bash-5.1 and later versions. as bindable command names, and displays any key sequences bound to those commands, instead of treating the arguments as key sequences to bind. + • Interactive shells will notify the user of completed jobs + while sourcing a script. Newer versions defer notification + until script execution completes.  File: bashref.info, Node: Job Control, Next: Command Line Editing, Prev: Bash Features, Up: Top @@ -7897,10 +7911,12 @@ equivalent to ‘bg %1’ The shell learns immediately whenever a job changes state. Normally, Bash waits until it is about to print a prompt before reporting changes -in a job's status so as to not interrupt any other output. If the ‘-b’ -option to the ‘set’ builtin is enabled, Bash reports such changes -immediately (*note The Set Builtin::). Any trap on ‘SIGCHLD’ is -executed for each child process that exits. +in a job's status so as to not interrupt any other output, though it +will notify of changes in a job's status after a command in a list +completes, before executing the next command. If the ‘-b’ option to the +‘set’ builtin is enabled, Bash reports such changes immediately (*note +The Set Builtin::). Any trap on ‘SIGCHLD’ is executed for each child +process that exits. If an attempt to exit Bash is made while jobs are stopped, (or running, if the ‘checkjobs’ option is enabled - see *note The Shopt @@ -8121,20 +8137,29 @@ produced when the key is pressed while the Control key is depressed. The text ‘M-k’ is read as 'Meta-K' and describes the character produced when the Meta key (if you have one) is depressed, and the -key is pressed. The Meta key is labeled on many keyboards. On -keyboards with two keys labeled (usually to either side of the -space bar), the on the left side is generally set to work as a -Meta key. The key on the right may also be configured to work as -a Meta key or may be configured as some other modifier, such as a -Compose key for typing accented characters. +key is pressed (a “meta character”). The Meta key is labeled on +many keyboards. On keyboards with two keys labeled (usually to +either side of the space bar), the on the left side is generally +set to work as a Meta key. The key on the right may also be +configured to work as a Meta key or may be configured as some other +modifier, such as a Compose key for typing accented characters. + + On some keyboards, the Meta key modifier produces meta characters +with the eighth bit (0200) set (you can use the ‘enable-meta-key’ +variable to control whether or not it does this, if the keyboard allows +it). On many others, the terminal or terminal emulator converts the +metafied key to a key sequence beginning with as described in the +next paragraph. If you do not have a Meta or key, or another key working as a -Meta key, the identical keystroke can be generated by typing -_first_, and then typing . Either process is known as “metafying” -the key. +Meta key, you can generally achieve the latter effect by typing +_first_, and then typing . The character is known as the “meta +prefix”). + + Either process is known as “metafying” the key. The text ‘M-C-k’ is read as 'Meta-Control-k' and describes the -character produced by “metafying” ‘C-k’. +character produced by metafying ‘C-k’. In addition, several keys have their own names. Specifically, , , , , , and all stand for themselves when seen @@ -8523,14 +8548,16 @@ Variable Settings limit is ‘100’. ‘convert-meta’ - If set to ‘on’, Readline will convert characters with the - eighth bit set to an ASCII key sequence by stripping the + If set to ‘on’, Readline will convert characters it reads with + the eighth bit set to an ASCII key sequence by stripping the eighth bit and prefixing an character, converting them to a meta-prefixed key sequence. The default value is ‘on’, - but will be set to ‘off’ if the locale is one that contains - eight-bit characters. This variable is dependent on the - ‘LC_CTYPE’ locale category, and may change if the locale is - changed. + but Readline will set it to ‘off’ if the locale contains + characters whose encodings may include bytes with the eighth + bit set. This variable is dependent on the ‘LC_CTYPE’ locale + category, and may change if the locale is changed. This + variable also affects key bindings; see the description of + ‘force-meta-prefix’ below. ‘disable-completion’ If set to ‘On’, Readline will inhibit word completion. @@ -8588,13 +8615,30 @@ Variable Settings ‘enable-meta-key’ When set to ‘on’, Readline will try to enable any meta modifier key the terminal claims to support when it is called. - On many terminals, the meta key is used to send eight-bit - characters. The default is ‘on’. + On many terminals, the Meta key is used to send eight-bit + characters; this variable checks for the terminal capability + that indicates the terminal can enable and disable a mode that + sets the eighth bit of a character (0200) if the Meta key is + held down when the character is typed (a meta character). The + default is ‘on’. ‘expand-tilde’ If set to ‘on’, tilde expansion is performed when Readline attempts word completion. The default is ‘off’. + ‘force-meta-prefix’ + If set to ‘on’, Readline modifies its behavior when binding + key sequences containing ‘\M-’ or ‘Meta-’ (see ‘Key Bindings’ + in *note Readline Init File Syntax::) by converting a key + sequence of the form ‘\M-’C or ‘Meta-’C to the two-character + sequence ‘ESC’C (adding the meta prefix). If + ‘force-meta-prefix’ is set to ‘off’ (the default), Readline + uses the value of the ‘convert-meta’ variable to determine + whether to perform this conversion: if ‘convert-meta’ is ‘on’, + Readline performs the conversion described above; if it is + ‘off’, Readline converts C to a meta character by setting the + eighth bit (0200). The default is ‘off’. + ‘history-preserve-point’ If set to ‘on’, the history code attempts to place the point (the current cursor position) at the same location on each @@ -8624,10 +8668,11 @@ Variable Settings not clear the eighth bit in the characters it reads), regardless of what the terminal claims it can support. The default value is ‘off’, but Readline will set it to ‘on’ if - the locale contains eight-bit characters. The name - ‘meta-flag’ is a synonym for this variable. This variable is - dependent on the ‘LC_CTYPE’ locale category, and may change if - the locale is changed. + the locale contains characters whose encodings may include + bytes with the eighth bit set. The name ‘meta-flag’ is a + synonym for this variable. This variable is dependent on the + ‘LC_CTYPE’ locale category, and may change if the locale is + changed. ‘isearch-terminators’ The string of characters that should terminate an incremental @@ -8692,9 +8737,10 @@ Variable Settings If set to ‘on’, Readline will display characters with the eighth bit set directly rather than as a meta-prefixed escape sequence. The default is ‘off’, but Readline will set it to - ‘on’ if the locale contains eight-bit characters. This - variable is dependent on the ‘LC_CTYPE’ locale category, and - may change if the locale is changed. + ‘on’ if the locale contains characters whose encodings may + include bytes with the eighth bit set. This variable is + dependent on the ‘LC_CTYPE’ locale category, and may change if + the locale is changed. ‘page-completions’ If set to ‘on’, Readline uses an internal ‘more’-like pager to @@ -8840,7 +8886,10 @@ Key Bindings ‘\C-’ control prefix ‘\M-’ - meta prefix + adding the meta prefix or converting the following character + to a meta character, as described above under + ‘force-meta-prefix’ (see ‘Variable Settings’ in *note Readline + Init File Syntax::). ‘\e’ an escape character ‘\\’ @@ -12475,29 +12524,31 @@ D.3 Parameter and Variable Index * COPROC: Bash Variables. (line 278) * DIRSTACK: Bash Variables. (line 282) * disable-completion: Readline Init File Syntax. - (line 151) + (line 153) * echo-control-characters: Readline Init File Syntax. - (line 156) + (line 158) * editing-mode: Readline Init File Syntax. - (line 161) + (line 163) * EMACS: Bash Variables. (line 292) * emacs-mode-string: Readline Init File Syntax. - (line 167) + (line 169) * enable-active-region: Readline Init File Syntax. - (line 177) + (line 179) * enable-bracketed-paste: Readline Init File Syntax. - (line 190) + (line 192) * enable-keypad: Readline Init File Syntax. - (line 199) + (line 201) * ENV: Bash Variables. (line 297) * EPOCHREALTIME: Bash Variables. (line 302) * EPOCHSECONDS: Bash Variables. (line 310) * EUID: Bash Variables. (line 317) * EXECIGNORE: Bash Variables. (line 321) * expand-tilde: Readline Init File Syntax. - (line 210) + (line 216) * FCEDIT: Bash Variables. (line 334) * FIGNORE: Bash Variables. (line 338) +* force-meta-prefix: Readline Init File Syntax. + (line 220) * FUNCNAME: Bash Variables. (line 344) * FUNCNEST: Bash Variables. (line 361) * GLOBIGNORE: Bash Variables. (line 366) @@ -12510,15 +12561,15 @@ D.3 Parameter and Variable Index * HISTFILESIZE: Bash Variables. (line 456) * HISTIGNORE: Bash Variables. (line 467) * history-preserve-point: Readline Init File Syntax. - (line 214) + (line 233) * history-size: Readline Init File Syntax. - (line 220) + (line 239) * HISTSIZE: Bash Variables. (line 489) * HISTTIMEFORMAT: Bash Variables. (line 496) * HOME: Bourne Shell Variables. (line 13) * horizontal-scroll-mode: Readline Init File Syntax. - (line 229) + (line 248) * HOSTFILE: Bash Variables. (line 505) * HOSTNAME: Bash Variables. (line 516) * HOSTTYPE: Bash Variables. (line 519) @@ -12526,13 +12577,13 @@ D.3 Parameter and Variable Index (line 18) * IGNOREEOF: Bash Variables. (line 522) * input-meta: Readline Init File Syntax. - (line 238) + (line 257) * INPUTRC: Bash Variables. (line 532) * INSIDE_EMACS: Bash Variables. (line 536) * isearch-terminators: Readline Init File Syntax. - (line 248) + (line 268) * keymap: Readline Init File Syntax. - (line 255) + (line 275) * LANG: Creating Internationalized Scripts. (line 51) * LANG <1>: Bash Variables. (line 542) @@ -12554,15 +12605,15 @@ D.3 Parameter and Variable Index (line 27) * MAPFILE: Bash Variables. (line 597) * mark-modified-lines: Readline Init File Syntax. - (line 285) + (line 305) * mark-symlinked-directories: Readline Init File Syntax. - (line 290) + (line 310) * match-hidden-files: Readline Init File Syntax. - (line 295) + (line 315) * menu-complete-display-prefix: Readline Init File Syntax. - (line 302) + (line 322) * meta-flag: Readline Init File Syntax. - (line 238) + (line 257) * OLDPWD: Bash Variables. (line 601) * OPTARG: Bourne Shell Variables. (line 34) @@ -12571,9 +12622,9 @@ D.3 Parameter and Variable Index (line 38) * OSTYPE: Bash Variables. (line 608) * output-meta: Readline Init File Syntax. - (line 307) + (line 327) * page-completions: Readline Init File Syntax. - (line 315) + (line 336) * PATH: Bourne Shell Variables. (line 42) * PIPESTATUS: Bash Variables. (line 611) @@ -12596,21 +12647,21 @@ D.3 Parameter and Variable Index * READLINE_POINT: Bash Variables. (line 684) * REPLY: Bash Variables. (line 688) * revert-all-at-newline: Readline Init File Syntax. - (line 325) + (line 346) * search-ignore-case: Readline Init File Syntax. - (line 332) + (line 353) * SECONDS: Bash Variables. (line 691) * SHELL: Bash Variables. (line 701) * SHELLOPTS: Bash Variables. (line 706) * SHLVL: Bash Variables. (line 715) * show-all-if-ambiguous: Readline Init File Syntax. - (line 337) + (line 358) * show-all-if-unmodified: Readline Init File Syntax. - (line 343) + (line 364) * show-mode-in-prompt: Readline Init File Syntax. - (line 352) + (line 373) * skip-completed-text: Readline Init File Syntax. - (line 358) + (line 379) * SRANDOM: Bash Variables. (line 720) * TEXTDOMAIN: Creating Internationalized Scripts. (line 51) @@ -12621,11 +12672,11 @@ D.3 Parameter and Variable Index * TMPDIR: Bash Variables. (line 779) * UID: Bash Variables. (line 783) * vi-cmd-mode-string: Readline Init File Syntax. - (line 371) + (line 392) * vi-ins-mode-string: Readline Init File Syntax. - (line 382) + (line 403) * visible-stats: Readline Init File Syntax. - (line 393) + (line 414)  File: bashref.info, Node: Function Index, Next: Concept Index, Prev: Variable Index, Up: Indexes @@ -13011,138 +13062,138 @@ D.5 Concept Index  Tag Table: -Node: Top900 -Node: Introduction2840 -Node: What is Bash?3056 -Node: What is a shell?4200 -Node: Definitions6782 -Node: Basic Shell Features9961 -Node: Shell Syntax11184 -Node: Shell Operation12214 -Node: Quoting13515 -Node: Escape Character14831 -Node: Single Quotes15332 -Node: Double Quotes15684 -Node: ANSI-C Quoting17030 -Node: Locale Translation18418 -Node: Creating Internationalized Scripts19765 -Node: Comments23966 -Node: Shell Commands24604 -Node: Reserved Words25546 -Node: Simple Commands26414 -Node: Pipelines27076 -Node: Lists30142 -Node: Compound Commands32017 -Node: Looping Constructs33029 -Node: Conditional Constructs35576 -Node: Command Grouping50400 -Node: Coprocesses51890 -Node: GNU Parallel54589 -Node: Shell Functions55510 -Node: Shell Parameters63619 -Node: Positional Parameters68155 -Node: Special Parameters69093 -Node: Shell Expansions72402 -Node: Brace Expansion74594 -Node: Tilde Expansion77260 -Node: Shell Parameter Expansion80029 -Node: Command Substitution99139 -Node: Arithmetic Expansion102675 -Node: Process Substitution103643 -Node: Word Splitting104783 -Node: Filename Expansion106927 -Node: Pattern Matching110026 -Node: Quote Removal115262 -Node: Redirections115569 -Node: Executing Commands125381 -Node: Simple Command Expansion126051 -Node: Command Search and Execution128165 -Node: Command Execution Environment130576 -Node: Environment133888 -Node: Exit Status135595 -Node: Signals137383 -Node: Shell Scripts141000 -Node: Shell Builtin Commands144095 -Node: Bourne Shell Builtins146209 -Node: Bash Builtins170982 -Node: Modifying Shell Behavior206084 -Node: The Set Builtin206429 -Node: The Shopt Builtin218015 -Node: Special Builtins234980 -Node: Shell Variables235972 -Node: Bourne Shell Variables236409 -Node: Bash Variables238605 -Node: Bash Features275803 -Node: Invoking Bash276820 -Node: Bash Startup Files283222 -Node: Interactive Shells288528 -Node: What is an Interactive Shell?288939 -Node: Is this Shell Interactive?289608 -Node: Interactive Shell Behavior290435 -Node: Bash Conditional Expressions294192 -Node: Shell Arithmetic299369 -Node: Aliases302454 -Node: Arrays305412 -Node: The Directory Stack312214 -Node: Directory Stack Builtins313014 -Node: Controlling the Prompt317466 -Node: The Restricted Shell320607 -Node: Bash POSIX Mode323397 -Node: Shell Compatibility Mode340911 -Node: Job Control349681 -Node: Job Control Basics350141 -Node: Job Control Builtins355318 -Node: Job Control Variables361265 -Node: Command Line Editing362445 -Node: Introduction and Notation364152 -Node: Readline Interaction365799 -Node: Readline Bare Essentials366990 -Node: Readline Movement Commands368811 -Node: Readline Killing Commands369811 -Node: Readline Arguments371792 -Node: Searching372852 -Node: Readline Init File375084 -Node: Readline Init File Syntax376369 -Node: Conditional Init Constructs401310 -Node: Sample Init File405678 -Node: Bindable Readline Commands408802 -Node: Commands For Moving410030 -Node: Commands For History412260 -Node: Commands For Text417468 -Node: Commands For Killing421605 -Node: Numeric Arguments424409 -Node: Commands For Completion425564 -Node: Keyboard Macros429883 -Node: Miscellaneous Commands430587 -Node: Readline vi Mode437244 -Node: Programmable Completion438199 -Node: Programmable Completion Builtins446159 -Node: A Programmable Completion Example457728 -Node: Using History Interactively463076 -Node: Bash History Facilities463760 -Node: Bash History Builtins466875 -Node: History Interaction472121 -Node: Event Designators476449 -Node: Word Designators478035 -Node: Modifiers480190 -Node: Installing Bash482102 -Node: Basic Installation483239 -Node: Compilers and Options487121 -Node: Compiling For Multiple Architectures487874 -Node: Installation Names489626 -Node: Specifying the System Type491863 -Node: Sharing Defaults492612 -Node: Operation Controls493329 -Node: Optional Features494351 -Node: Reporting Bugs506156 -Node: Major Differences From The Bourne Shell507508 -Node: GNU Free Documentation License527246 -Node: Indexes552426 -Node: Builtin Index552880 -Node: Reserved Word Index559981 -Node: Variable Index562429 -Node: Function Index579563 -Node: Concept Index593422 +Node: Top904 +Node: Introduction2848 +Node: What is Bash?3064 +Node: What is a shell?4208 +Node: Definitions6790 +Node: Basic Shell Features9969 +Node: Shell Syntax11192 +Node: Shell Operation12222 +Node: Quoting13523 +Node: Escape Character14839 +Node: Single Quotes15340 +Node: Double Quotes15692 +Node: ANSI-C Quoting17038 +Node: Locale Translation18426 +Node: Creating Internationalized Scripts19773 +Node: Comments23974 +Node: Shell Commands24612 +Node: Reserved Words25554 +Node: Simple Commands26422 +Node: Pipelines27084 +Node: Lists30150 +Node: Compound Commands32025 +Node: Looping Constructs33037 +Node: Conditional Constructs35584 +Node: Command Grouping50448 +Node: Coprocesses51938 +Node: GNU Parallel54637 +Node: Shell Functions55558 +Node: Shell Parameters63667 +Node: Positional Parameters68203 +Node: Special Parameters69141 +Node: Shell Expansions72454 +Node: Brace Expansion74646 +Node: Tilde Expansion77312 +Node: Shell Parameter Expansion80081 +Node: Command Substitution99191 +Node: Arithmetic Expansion102727 +Node: Process Substitution103695 +Node: Word Splitting104835 +Node: Filename Expansion106979 +Node: Pattern Matching110078 +Node: Quote Removal115314 +Node: Redirections115621 +Node: Executing Commands125433 +Node: Simple Command Expansion126103 +Node: Command Search and Execution128217 +Node: Command Execution Environment130628 +Node: Environment133940 +Node: Exit Status135647 +Node: Signals137435 +Node: Shell Scripts141052 +Node: Shell Builtin Commands144147 +Node: Bourne Shell Builtins146261 +Node: Bash Builtins171034 +Node: Modifying Shell Behavior206136 +Node: The Set Builtin206481 +Node: The Shopt Builtin218067 +Node: Special Builtins235032 +Node: Shell Variables236024 +Node: Bourne Shell Variables236461 +Node: Bash Variables238657 +Node: Bash Features275855 +Node: Invoking Bash276872 +Node: Bash Startup Files283274 +Node: Interactive Shells288580 +Node: What is an Interactive Shell?288991 +Node: Is this Shell Interactive?289660 +Node: Interactive Shell Behavior290487 +Node: Bash Conditional Expressions294244 +Node: Shell Arithmetic299421 +Node: Aliases302506 +Node: Arrays305464 +Node: The Directory Stack312266 +Node: Directory Stack Builtins313066 +Node: Controlling the Prompt317518 +Node: The Restricted Shell320659 +Node: Bash POSIX Mode323449 +Node: Shell Compatibility Mode341501 +Node: Job Control350455 +Node: Job Control Basics350915 +Node: Job Control Builtins356215 +Node: Job Control Variables362162 +Node: Command Line Editing363342 +Node: Introduction and Notation365049 +Node: Readline Interaction367147 +Node: Readline Bare Essentials368338 +Node: Readline Movement Commands370159 +Node: Readline Killing Commands371159 +Node: Readline Arguments373140 +Node: Searching374200 +Node: Readline Init File376432 +Node: Readline Init File Syntax377717 +Node: Conditional Init Constructs404260 +Node: Sample Init File408628 +Node: Bindable Readline Commands411752 +Node: Commands For Moving412980 +Node: Commands For History415210 +Node: Commands For Text420418 +Node: Commands For Killing424555 +Node: Numeric Arguments427359 +Node: Commands For Completion428514 +Node: Keyboard Macros432833 +Node: Miscellaneous Commands433537 +Node: Readline vi Mode440194 +Node: Programmable Completion441149 +Node: Programmable Completion Builtins449109 +Node: A Programmable Completion Example460678 +Node: Using History Interactively466026 +Node: Bash History Facilities466710 +Node: Bash History Builtins469825 +Node: History Interaction475071 +Node: Event Designators479399 +Node: Word Designators480985 +Node: Modifiers483140 +Node: Installing Bash485052 +Node: Basic Installation486189 +Node: Compilers and Options490071 +Node: Compiling For Multiple Architectures490824 +Node: Installation Names492576 +Node: Specifying the System Type494813 +Node: Sharing Defaults495562 +Node: Operation Controls496279 +Node: Optional Features497301 +Node: Reporting Bugs509106 +Node: Major Differences From The Bourne Shell510458 +Node: GNU Free Documentation License530196 +Node: Indexes555376 +Node: Builtin Index555830 +Node: Reserved Word Index562931 +Node: Variable Index565379 +Node: Function Index582654 +Node: Concept Index596513  End Tag Table diff --git a/doc/bashref.texi b/doc/bashref.texi index 5c5e1a0c..f0914c6c 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -1873,8 +1873,7 @@ expand to nothing (i.e., they are removed). @item ? @vindex $? -($?) Expands to the exit status of the most recently executed foreground -command. +($?) Expands to the exit status of the most recently executed command. @item - @vindex $- @@ -8545,8 +8544,16 @@ is stopped is `Stopped(@var{signame})', where @var{signame} is, for example, @code{SIGTSTP}. @item -Bash does not perform job notifications between executing commands in -lists separated by @samp{;} or newline in interactive shells. +If the shell is interactive, Bash does not perform job notifications +between executing commands in lists separated by @samp{;} or newline. +Non-interactive shells print status messages after a foreground job in +a list completes. + +@item +If the shell is interactive, Bash waits until the next prompt before +printing the status of a background job that changes status or a foreground +job that terminates due to a signal. +Non-interactive shells print status messages after a foreground job completes. @item Alias expansion is always enabled, even in non-interactive shells. @@ -9236,7 +9243,9 @@ job 1 in the background, equivalent to @samp{bg %1} The shell learns immediately whenever a job changes state. Normally, Bash waits until it is about to print a prompt before reporting changes in a job's status so as to not interrupt -any other output. +any other output, +though it will notify of changes in a job's status after a command in +a list completes, before executing the next command. If the @option{-b} option to the @code{set} builtin is enabled, Bash reports such changes immediately (@pxref{The Set Builtin}). Any trap on @code{SIGCHLD} is executed for each child process diff --git a/doc/version.texi b/doc/version.texi index af8bf03d..47e55504 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -2,10 +2,10 @@ Copyright (C) 1988-2024 Free Software Foundation, Inc. @end ignore -@set LASTCHANGE Mon Aug 26 11:29:52 EDT 2024 +@set LASTCHANGE Thu Sep 5 15:41:56 EDT 2024 @set EDITION 5.3 @set VERSION 5.3 -@set UPDATED 26 August 2024 -@set UPDATED-MONTH August 2024 +@set UPDATED 5 September 2024 +@set UPDATED-MONTH September 2024 diff --git a/eval.c b/eval.c index c8f11163..0fc6cfca 100644 --- a/eval.c +++ b/eval.c @@ -348,7 +348,7 @@ parse_command (void) if (interactive && bash_input.type != st_string && parser_expanding_alias() == 0) { #if defined (JOB_CONTROL) - notify_and_cleanup (); + notify_and_cleanup (-1); #endif #if defined (READLINE) if (no_line_editing || (bash_input.type == st_stdin && parser_will_prompt ())) diff --git a/execute_cmd.c b/execute_cmd.c index 485e6d1d..6402f894 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -2863,7 +2863,7 @@ execute_connection (COMMAND *command, int asynchronous, int pipe_in, int pipe_ou QUIT; #if defined (JOB_CONTROL) if (command->value.Connection->connector == ';' && job_control && interactive && posixly_correct == 0) - notify_and_cleanup (); + notify_and_cleanup (-1); #endif optimize_connection_fork (command); /* XXX */ exec_result = execute_command_internal (command->value.Connection->second, diff --git a/include/shmbutil.h b/include/shmbutil.h index a8a59bf1..1feee853 100644 --- a/include/shmbutil.h +++ b/include/shmbutil.h @@ -86,7 +86,7 @@ extern int locale_utf8locale; /* XXX */ #define UTF8_SINGLEBYTE(c) (1) #define UTF8_MBFIRSTCHAR(c) (0) -#defined VALID_SINGLEBYTE_CHAR(c) (1) +#define VALID_SINGLEBYTE_CHAR(c) (1) #endif /* !HANDLE_MULTIBYTE */ diff --git a/jobs.c b/jobs.c index a51e3f1a..1e19728a 100644 --- a/jobs.c +++ b/jobs.c @@ -277,7 +277,8 @@ static WAIT raw_job_exit_status (int); static int job_killed_by_signal (int); -static void notify_of_job_status (void); +static inline void maybe_print_job_notifications (int); +static void notify_of_job_status (int); static void reset_job_indices (void); static void cleanup_dead_jobs (void); static int processes_in_job (int); @@ -3373,7 +3374,8 @@ if (job == NO_JOB) the shell is not interactive, make sure we turn on the notify bit so we don't get an unwanted message about the job's termination, and so delete_job really clears the slot in the jobs table. */ - notify_and_cleanup (); + if (posixly_correct == 0 || (interactive_shell == 0 || interactive == 0)) + notify_and_cleanup (job); } wait_for_return: @@ -3471,7 +3473,11 @@ return_job: } if (jobs_list_frozen == 0) /* must be running a funsub to get here */ { - notify_of_job_status (); /* XXX */ +#if 1 + notify_of_job_status (i); /* XXX */ +#else + maybe_print_job_notifications (i); +#endif /* kre@munnari.oz.au 01/30/2024 */ delete_job (i, posixly_correct ? DEL_NOBGPID : 0); @@ -3607,17 +3613,15 @@ return_procsub: /* Print info about dead jobs, and then delete them from the list of known jobs. This does not actually delete jobs when the shell is not interactive, because the dead jobs are not marked - as notified. */ + as notified. + If JOB is >= 0, only print info about that job and then clean it up. */ void -notify_and_cleanup (void) +notify_and_cleanup (int job) { if (jobs_list_frozen > 0) return; - if (want_job_notifications || interactive || interactive_shell == 0) - notify_of_job_status (); - else if (interactive_shell && sourcelevel && shell_compatibility_level <= 52) - notify_of_job_status (); /* XXX - was not dependent on BASH_COMPAT */ + maybe_print_job_notifications (job); if (jobs_list_frozen < 0) return; /* status changes only */ @@ -4239,7 +4243,7 @@ itrace("waitchld: waitpid returns %d block = %d children_exited = %d", pid, bloc that this process belongs to is no longer running, then notify the user of that fact now. */ if (children_exited && asynchronous_notification && interactive && executing_builtin == 0) - notify_of_job_status (); + notify_of_job_status (-1); return (children_exited); } @@ -4497,11 +4501,13 @@ run_sigchld_trap (int nchild) } /* Function to call when you want to notify people of changes - in job status. This prints out all jobs which are pending - notification to stderr, and marks those printed as already - notified, thus making them candidates for cleanup. */ + in job status. This prints out all requested jobs which are + pending notification to stderr, and marks those printed as + notified, thus making them candidates for cleanup. + if WANTED is >=0, we print information only about that job; + otherwise we print all jobs whose status has changed. */ static void -notify_of_job_status (void) +notify_of_job_status (int wanted) { register int job, termsig; char *dir; @@ -4525,6 +4531,9 @@ notify_of_job_status (void) /* XXX could use js.j_firstj here */ for (job = 0, dir = NULL; job < js.j_jobslots; job++) { + if (wanted >= 0 && job != wanted) + continue; + if (jobs[job] && IS_NOTIFIED (job) == 0) { s = raw_job_exit_status (job); @@ -4671,6 +4680,19 @@ internal_debug("notify_of_job_status: catch-all setting J_NOTIFIED on job %d (%d queue_sigchld--; } +/* Use this to determine when to conditionally print job notifications. We + print notifications if another part of the shell forces it, if we are + currently interactive, or if we are not an interactive shell. For + compatibility, we can also print notifications if we are sourcing a file + in an interactive shell. + In a separate inline function so the conditions are in one place. */ +static inline void +maybe_print_job_notifications (int job) +{ + if (want_job_notifications || interactive || interactive_shell == 0) + notify_of_job_status (job); +} + /* Initialize the job control mechanism, and set up the tty stuff. */ int initialize_job_control (int force) diff --git a/jobs.h b/jobs.h index d8fb2f9a..64509e2b 100644 --- a/jobs.h +++ b/jobs.h @@ -312,7 +312,7 @@ extern int wait_for_any_job (int, struct procstat *); extern void wait_sigint_cleanup (void); -extern void notify_and_cleanup (void); +extern void notify_and_cleanup (int); extern void reap_dead_jobs (void); extern int start_job (int, int); extern int kill_pid (pid_t, int, int); diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c index 34c999f5..a5fb11d2 100644 --- a/lib/readline/histfile.c +++ b/lib/readline/histfile.c @@ -647,6 +647,7 @@ history_truncate_file (const char *fname, int lines) truncate_write: tempname = history_tempfile (filename); + rv = 0; if ((file = open (tempname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600)) != -1) { if (write (file, bp, chars_read - (bp - buffer)) < 0) diff --git a/parse.y b/parse.y index ccca5819..6ed8b5f0 100644 --- a/parse.y +++ b/parse.y @@ -2493,7 +2493,7 @@ shell_getc (int remove_quoted_newline) of a trap, when the trap is called from flush_child. This call had better not cause jobs to disappear from the job table in that case, or we will have big trouble. */ - notify_and_cleanup (); + notify_and_cleanup (-1); #else /* !JOB_CONTROL */ cleanup_dead_jobs (); #endif /* !JOB_CONTROL */ diff --git a/trap.c b/trap.c index ae761508..33fa04d0 100644 --- a/trap.c +++ b/trap.c @@ -1296,7 +1296,7 @@ run_debug_trap (void) if (job_control && pipeline_pgrp > 0 && ((subshell_environment & (SUBSHELL_ASYNC|SUBSHELL_PIPE)) == 0)) give_terminal_to (pipeline_pgrp, 1); - notify_and_cleanup (); + notify_and_cleanup (-1); #endif #if defined (DEBUGGER)