From: Chet Ramey Date: Thu, 3 Jan 2013 15:46:55 +0000 (-0500) Subject: commit bash-20121214 snapshot X-Git-Tag: bash-4.3-alpha~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77b3aacbdfa8786847658c972b7cac45e1988c29;p=thirdparty%2Fbash.git commit bash-20121214 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 37a78eeba..5a49a6585 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -3989,3 +3989,84 @@ lib/sh/zread.c saying how many bytes to read into the local buffer. Can be used to implement `read -N' without so many one-byte calls to zreadc. Code from Mike Frysinger + + 12/12 + ----- +lib/glob/sm_loop.c + - PATSCAN (glob_patscan): if passed string already points to end of + pattern, return NULL immediately. Fixes problem with + extglob_skipname reported by Raphaël Droz + + 12/13 + ----- +execute_cmd.c + - execute_coproc: handle the command's exit status being inverted + (an oversight). Fixes bug reported by DJ Mills + and Andreas Schwab + + 12/14 + ----- +lib/readline/readline.c + - bind_arrow_keys_internal: add MINGW key bindings for Home, End, + Delete, and Insert keys. Fix from Pierre Muller + + +builtins/printf.def + - printf_builtin: '%()T' conversion: if there is no argument supplied, + behave as if -1 had been supplied (current time). ksh93-like feature + suggested by Clark Wang + +doc/{bash.1,bashref.texi} + - document new printf %()T default argument behavior + + 12/15 + ----- +lib/readline/display.c + - displaying_prompt_first_line: new variable, indicates whether or + not the first line of output is displaying the prompt. Always true + in normal mode, sometimes false in horizontal scrolling mode + - rl_redisplay: set displaying_prompt_first_line to true unless we + are in horizontal mode; set to false in horizontal mode if the left + margin of the displayed line is greater than the end of the prompt + string + - rl_redisplay: when in horizontal scroll mode, don't adjust + _rl_last_c_pos by the wrap offset unless the line is displaying + a prompt containing invisible chars + - update line: don't adjust _rl_last_c_pos by the wrap offset unless + the line is displaying a prompt containing invisible chars + - update_line: if shrinking the line by reducing the number of + displayed characters, but we have already moved the cursor to the + beginning of the line where the first difference starts, don't + try to delete characters + +builtins/read.def + - unbuffered_read: set to 2 if invoked as `read -N' + - if unbuffered_read is set to 2, compute the number of chars we + need to read and read that many with zreadn. Posix mode still + uses zreadintr. Code from Mike Frysinger + +doc/{bash.1,bashref.texi} + - read: make it clear that if read times out, it saves any input + read to that point into the variable arguments. Report from + Fiedler Roman + +subst.c + - command_substitute: change direct assignment of exit_immediately_on_error + to use change_flag ('e', FLAG_OFF) instead + +flags.c + - use errexit_flag as the variable modified by changes to the -e + option, reflect those changes to exit_immediately_on_error + +execute_cmd.c + - execute_builtin: new global variable, builtin_ignoring_errexit, set + to 0 by default and set to 1 if eval/source/command executing in a + context where -e should be ignored + - execute_builtin: set exit_immediately_on_error to errextit_flag + after executing eval/source/command in a context where -e should + be ignored + +flags.c + - if builtin_ignoring_errexit is set, changes to errexit_flag are + not reflected in the setting of exit_immediately_on_error. Fixes + bug reported by Robert Schiele diff --git a/CWRU/CWRU.chlog~ b/CWRU/CWRU.chlog~ index 6f6bdd909..3f23a6713 100644 --- a/CWRU/CWRU.chlog~ +++ b/CWRU/CWRU.chlog~ @@ -3983,3 +3983,86 @@ lib/glob/glob.c o note when the directory name is all ** or ends in ** so we can treat it specially when the filename is ** All inspired by report from Andrey Borzenkov + +lib/sh/zread.c + - zreadn: new function, like zread, but takes an additional argument + saying how many bytes to read into the local buffer. Can be used to + implement `read -N' without so many one-byte calls to zreadc. Code + from Mike Frysinger + + 12/12 + ----- +lib/glob/sm_loop.c + - PATSCAN (glob_patscan): if passed string already points to end of + pattern, return NULL immediately. Fixes problem with + extglob_skipname reported by Raphaël Droz + + 12/13 + ----- +execute_cmd.c + - execute_coproc: handle the command's exit status being inverted + (an oversight). Fixes bug reported by DJ Mills + and Andreas Schwab + + 12/14 + ----- +lib/readline/readline.c + - bind_arrow_keys_internal: add MINGW key bindings for Home, End, + Delete, and Insert keys. Fix from Pierre Muller + + +builtins/printf.def + - printf_builtin: '%()T' conversion: if there is no argument supplied, + behave as if -1 had been supplied (current time). ksh93-like feature + suggested by Clark Wang + +doc/{bash.1,bashref.texi} + - document new printf %()T default argument behavior + + 12/15 + ----- +lib/readline/display.c + - displaying_prompt_first_line: new variable, indicates whether or + not the first line of output is displaying the prompt. Always true + in normal mode, sometimes false in horizontal scrolling mode + - rl_redisplay: set displaying_prompt_first_line to true unless we + are in horizontal mode; set to false in horizontal mode if the left + margin of the displayed line is greater than the end of the prompt + string + - rl_redisplay: when in horizontal scroll mode, don't adjust + _rl_last_c_pos by the wrap offset unless the line is displaying + a prompt containing invisible chars + - update line: don't adjust _rl_last_c_pos by the wrap offset unless + the line is displaying a prompt containing invisible chars + - update_line: if shrinking the line by reducing the number of + displayed characters, but we have already moved the cursor to the + beginning of the line where the first difference starts, don't + try to delete characters + +builtins/read.def + - unbuffered_read: set to 2 if invoked as `read -N' + - if unbuffered_read is set to 2, compute the number of chars we + need to read and read that many with zreadn. Posix mode still + uses zreadintr. Code from Mike Frysinger + +doc/{bash.1,bashref.texi} + - read: make it clear that if read times out, it saves any input + read to that point into the variable arguments. Report from + Fiedler Roman + +subst.c + - command_substitute: change direct assignment of exit_immediately_on_error + to use change_flag ('e', FLAG_OFF) instead + +flags.c + - use errexit_flag as the variable modified by changes to the -e + option, reflect those changes to exit_immediately_on_error + +execute_cmd.c + - execute_builtin: new global variable, builtin_ignoring_errexit, set + to 0 by default and set to 1 if eval/source/command executing in a + context where -e should be ignored + - execute_builtin: set exit_immediately_on_error to errextit_flag + after executing eval/source/command in a context where -e should + be ignored + diff --git a/builtins/declare.def b/builtins/declare.def index 260c947af..345bd15f5 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -56,7 +56,8 @@ When used in a function, `declare' makes NAMEs local, as with the `local' command. The `-g' option suppresses this behavior. Exit Status: -Returns success unless an invalid option is supplied or an error occurs. +Returns success unless an invalid option is supplied or a variable +assignment error occurs. $END $BUILTIN typeset @@ -111,8 +112,8 @@ Local variables can only be used within a function; they are visible only to the function where they are defined and its children. Exit Status: -Returns success unless an invalid option is supplied, an error occurs, -or the shell is not executing a function. +Returns success unless an invalid option is supplied, a variable +assignment error occurs, or the shell is not executing a function. $END int local_builtin (list) diff --git a/builtins/printf.def b/builtins/printf.def index aee76a5fa..cf33f6bee 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -466,7 +466,8 @@ printf_builtin (list) timefmt[2] = '\0'; } /* argument is seconds since the epoch with special -1 and -2 */ - arg = getintmax (); + /* default argument is equivalent to -1; special case */ + arg = garglist ? getintmax () : -1; if (arg == -1) secs = NOW; /* roughly date +%s */ else if (arg == -2) diff --git a/builtins/read.def b/builtins/read.def index b6aed3115..27d319498 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -483,7 +483,10 @@ read_builtin (list) add_unwind_protect (xfree, input_string); CHECK_ALRM; - unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe; + if ((nchars > 0) && (input_is_tty == 0) && ignore_delim) /* read -N */ + unbuffered_read = 2; + else if ((nchars > 0) || (delim != '\n') || input_is_pipe) + unbuffered_read = 1; if (prompt && edit == 0) { @@ -540,7 +543,9 @@ read_builtin (list) interrupt_immediately++; #endif reading = 1; - if (unbuffered_read) + if (unbuffered_read == 2) + retval = posixly_correct ? zreadintr (fd, &c, 1) : zreadn (fd, &c, nchars - nr); + else if (unbuffered_read) retval = posixly_correct ? zreadintr (fd, &c, 1) : zread (fd, &c, 1); else retval = posixly_correct ? zreadcintr (fd, &c) : zreadc (fd, &c); diff --git a/builtins/read.def~ b/builtins/read.def~ new file mode 100644 index 000000000..b6aed3115 --- /dev/null +++ b/builtins/read.def~ @@ -0,0 +1,1067 @@ +This file is read.def, from which is created read.c. +It implements the builtin "read" in Bash. + +Copyright (C) 1987-2012 Free Software Foundation, Inc. + +This file is part of GNU Bash, the Bourne Again SHell. + +Bash is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Bash is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Bash. If not, see . + +$PRODUCES read.c + +$BUILTIN read +$FUNCTION read_builtin +$SHORT_DOC read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] +Read a line from the standard input and split it into fields. + +Reads a single line from the standard input, or from file descriptor FD +if the -u option is supplied. The line is split into fields as with word +splitting, and the first word is assigned to the first NAME, the second +word to the second NAME, and so on, with any leftover words assigned to +the last NAME. Only the characters found in $IFS are recognized as word +delimiters. + +If no NAMEs are supplied, the line read is stored in the REPLY variable. + +Options: + -a array assign the words read to sequential indices of the array + variable ARRAY, starting at zero + -d delim continue until the first character of DELIM is read, rather + than newline + -e use Readline to obtain the line in an interactive shell + -i text Use TEXT as the initial text for Readline + -n nchars return after reading NCHARS characters rather than waiting + for a newline, but honor a delimiter if fewer than NCHARS + characters are read before the delimiter + -N nchars return only after reading exactly NCHARS characters, unless + EOF is encountered or read times out, ignoring any delimiter + -p prompt output the string PROMPT without a trailing newline before + attempting to read + -r do not allow backslashes to escape any characters + -s do not echo input coming from a terminal + -t timeout time out and return failure if a complete line of input is + not read within TIMEOUT seconds. The value of the TMOUT + variable is the default timeout. TIMEOUT may be a + fractional number. If TIMEOUT is 0, read returns immediately, + without trying to read any data, returning success only if + input is available on the specified file descriptor. The + exit status is greater than 128 if the timeout is exceeded + -u fd read from file descriptor FD instead of the standard input + +Exit Status: +The return code is zero, unless end-of-file is encountered, read times out +(in which case it's greater than 128), a variable assignment error occurs, +or an invalid file descriptor is supplied as the argument to -u. +$END + +#include + +#include "bashtypes.h" +#include "posixstat.h" + +#include + +#include "bashansi.h" + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include +#include + +#ifdef __CYGWIN__ +# include +# include +#endif + +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" +#include "bashgetopt.h" + +#include + +#if defined (READLINE) +#include "../bashline.h" +#include +#endif + +#if defined (BUFFERED_INPUT) +# include "input.h" +#endif + +#include "shmbutil.h" + +#if !defined(errno) +extern int errno; +#endif + +extern void run_pending_traps __P((void)); + +extern int posixly_correct; +extern int trapped_signal_received; + +struct ttsave +{ + int fd; + TTYSTRUCT *attrs; +}; + +#if defined (READLINE) +static void reset_attempted_completion_function __P((char *)); +static int set_itext __P((void)); +static char *edit_line __P((char *, char *)); +static void set_eol_delim __P((int)); +static void reset_eol_delim __P((char *)); +#endif +static SHELL_VAR *bind_read_variable __P((char *, char *)); +#if defined (HANDLE_MULTIBYTE) +static int read_mbchar __P((int, char *, int, int, int)); +#endif +static void ttyrestore __P((struct ttsave *)); + +static sighandler sigalrm __P((int)); +static void reset_alarm __P((void)); + +static procenv_t alrmbuf; +static int sigalrm_seen, reading; +static SigHandler *old_alrm; +static unsigned char delim; + +/* In most cases, SIGALRM just sets a flag that we check periodically. This + avoids problems with the semi-tricky stuff we do with the xfree of + input_string at the top of the unwind-protect list (see below). */ +#define CHECK_ALRM \ + do { \ + if (sigalrm_seen) \ + longjmp (alrmbuf, 1); \ + } while (0) + +static sighandler +sigalrm (s) + int s; +{ + sigalrm_seen = 1; + if (reading) /* do the longjmp if we get SIGALRM while in read() */ + longjmp (alrmbuf, 1); +} + +static void +reset_alarm () +{ + set_signal_handler (SIGALRM, old_alrm); + falarm (0, 0); +} + +/* Read the value of the shell variables whose names follow. + The reading is done from the current input stream, whatever + that may be. Successive words of the input line are assigned + to the variables mentioned in LIST. The last variable in LIST + gets the remainder of the words on the line. If no variables + are mentioned in LIST, then the default variable is $REPLY. */ +int +read_builtin (list) + WORD_LIST *list; +{ + register char *varname; + int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2; + int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul; + int raw, edit, nchars, silent, have_timeout, ignore_delim, fd, lastsig, t_errno; + unsigned int tmsec, tmusec; + long ival, uval; + intmax_t intval; + char c; + char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname; + char *e, *t, *t1, *ps2, *tofree; + struct stat tsb; + SHELL_VAR *var; + TTYSTRUCT ttattrs, ttset; + struct ttsave termsave; +#if defined (ARRAY_VARS) + WORD_LIST *alist; +#endif +#if defined (READLINE) + char *rlbuf, *itext; + int rlind; +#endif + + USE_VAR(size); + USE_VAR(i); + USE_VAR(pass_next); + USE_VAR(print_ps2); + USE_VAR(saw_escape); + USE_VAR(input_is_pipe); +/* USE_VAR(raw); */ + USE_VAR(edit); + USE_VAR(tmsec); + USE_VAR(tmusec); + USE_VAR(nchars); + USE_VAR(silent); + USE_VAR(ifs_chars); + USE_VAR(prompt); + USE_VAR(arrayname); +#if defined (READLINE) + USE_VAR(rlbuf); + USE_VAR(rlind); + USE_VAR(itext); +#endif + USE_VAR(list); + USE_VAR(ps2); + USE_VAR(lastsig); + + sigalrm_seen = reading = 0; + + i = 0; /* Index into the string that we are reading. */ + raw = edit = 0; /* Not reading raw input by default. */ + silent = 0; + arrayname = prompt = (char *)NULL; + fd = 0; /* file descriptor to read from */ + +#if defined (READLINE) + rlbuf = itext = (char *)0; + rlind = 0; +#endif + + tmsec = tmusec = 0; /* no timeout */ + nr = nchars = input_is_tty = input_is_pipe = unbuffered_read = have_timeout = 0; + delim = '\n'; /* read until newline */ + ignore_delim = 0; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "ersa:d:i:n:p:t:u:N:")) != -1) + { + switch (opt) + { + case 'r': + raw = 1; + break; + case 'p': + prompt = list_optarg; + break; + case 's': + silent = 1; + break; + case 'e': +#if defined (READLINE) + edit = 1; +#endif + break; + case 'i': +#if defined (READLINE) + itext = list_optarg; +#endif + break; +#if defined (ARRAY_VARS) + case 'a': + arrayname = list_optarg; + break; +#endif + case 't': + code = uconvert (list_optarg, &ival, &uval); + if (code == 0 || ival < 0 || uval < 0) + { + builtin_error (_("%s: invalid timeout specification"), list_optarg); + return (EXECUTION_FAILURE); + } + else + { + have_timeout = 1; + tmsec = ival; + tmusec = uval; + } + break; + case 'N': + ignore_delim = 1; + delim = -1; + case 'n': + code = legal_number (list_optarg, &intval); + if (code == 0 || intval < 0 || intval != (int)intval) + { + sh_invalidnum (list_optarg); + return (EXECUTION_FAILURE); + } + else + nchars = intval; + break; + case 'u': + code = legal_number (list_optarg, &intval); + if (code == 0 || intval < 0 || intval != (int)intval) + { + builtin_error (_("%s: invalid file descriptor specification"), list_optarg); + return (EXECUTION_FAILURE); + } + else + fd = intval; + if (sh_validfd (fd) == 0) + { + builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno)); + return (EXECUTION_FAILURE); + } + break; + case 'd': + delim = *list_optarg; + break; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + /* `read -t 0 var' tests whether input is available with select/FIONREAD, + and fails if those are unavailable */ + if (have_timeout && tmsec == 0 && tmusec == 0) +#if 0 + return (EXECUTION_FAILURE); +#else + return (input_avail (fd) ? EXECUTION_SUCCESS : EXECUTION_FAILURE); +#endif + + /* If we're asked to ignore the delimiter, make sure we do. */ + if (ignore_delim) + delim = -1; + + /* IF IFS is unset, we use the default of " \t\n". */ + ifs_chars = getifs (); + if (ifs_chars == 0) /* XXX - shouldn't happen */ + ifs_chars = ""; + /* If we want to read exactly NCHARS chars, don't split on IFS */ + if (ignore_delim) + ifs_chars = ""; + for (skip_ctlesc = skip_ctlnul = 0, e = ifs_chars; *e; e++) + skip_ctlesc |= *e == CTLESC, skip_ctlnul |= *e == CTLNUL; + + input_string = (char *)xmalloc (size = 112); /* XXX was 128 */ + input_string[0] = '\0'; + + /* $TMOUT, if set, is the default timeout for read. */ + if (have_timeout == 0 && (e = get_string_value ("TMOUT"))) + { + code = uconvert (e, &ival, &uval); + if (code == 0 || ival < 0 || uval < 0) + tmsec = tmusec = 0; + else + { + tmsec = ival; + tmusec = uval; + } + } + + begin_unwind_frame ("read_builtin"); + +#if defined (BUFFERED_INPUT) + if (interactive == 0 && default_buffered_input >= 0 && fd_is_bash_input (fd)) + sync_buffered_stream (default_buffered_input); +#endif + + input_is_tty = isatty (fd); + if (input_is_tty == 0) +#ifndef __CYGWIN__ + input_is_pipe = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE); +#else + input_is_pipe = 1; +#endif + + /* If the -p, -e or -s flags were given, but input is not coming from the + terminal, turn them off. */ + if ((prompt || edit || silent) && input_is_tty == 0) + { + prompt = (char *)NULL; +#if defined (READLINE) + itext = (char *)NULL; +#endif + edit = silent = 0; + } + +#if defined (READLINE) + if (edit) + add_unwind_protect (xfree, rlbuf); +#endif + + pass_next = 0; /* Non-zero signifies last char was backslash. */ + saw_escape = 0; /* Non-zero signifies that we saw an escape char */ + + if (tmsec > 0 || tmusec > 0) + { + /* Turn off the timeout if stdin is a regular file (e.g. from + input redirection). */ + if ((fstat (fd, &tsb) < 0) || S_ISREG (tsb.st_mode)) + tmsec = tmusec = 0; + } + + if (tmsec > 0 || tmusec > 0) + { + code = setjmp (alrmbuf); + if (code) + { + sigalrm_seen = 0; + /* Tricky. The top of the unwind-protect stack is the free of + input_string. We want to run all the rest and use input_string, + so we have to remove it from the stack. */ + orig_input_string = 0; + + remove_unwind_protect (); + run_unwind_frame ("read_builtin"); + input_string[i] = '\0'; /* make sure it's terminated */ + retval = 128+SIGALRM; + goto assign_vars; + } + old_alrm = set_signal_handler (SIGALRM, sigalrm); + add_unwind_protect (reset_alarm, (char *)NULL); +#if defined (READLINE) + if (edit) + add_unwind_protect (reset_attempted_completion_function, (char *)NULL); +#endif + falarm (tmsec, tmusec); + } + + /* If we've been asked to read only NCHARS chars, or we're using some + character other than newline to terminate the line, do the right + thing to readline or the tty. */ + if (nchars > 0 || delim != '\n') + { +#if defined (READLINE) + if (edit) + { + if (nchars > 0) + { + unwind_protect_int (rl_num_chars_to_read); + rl_num_chars_to_read = nchars; + } + if (delim != '\n') + { + set_eol_delim (delim); + add_unwind_protect (reset_eol_delim, (char *)NULL); + } + } + else +#endif + if (input_is_tty) + { + /* ttsave() */ + termsave.fd = fd; + ttgetattr (fd, &ttattrs); + termsave.attrs = &ttattrs; + + ttset = ttattrs; + i = silent ? ttfd_cbreak (fd, &ttset) : ttfd_onechar (fd, &ttset); + if (i < 0) + sh_ttyerror (1); + add_unwind_protect ((Function *)ttyrestore, (char *)&termsave); + } + } + else if (silent) /* turn off echo but leave term in canonical mode */ + { + /* ttsave (); */ + termsave.fd = fd; + ttgetattr (fd, &ttattrs); + termsave.attrs = &ttattrs; + + ttset = ttattrs; + i = ttfd_noecho (fd, &ttset); /* ttnoecho (); */ + if (i < 0) + sh_ttyerror (1); + + add_unwind_protect ((Function *)ttyrestore, (char *)&termsave); + } + + /* This *must* be the top unwind-protect on the stack, so the manipulation + of the unwind-protect stack after the realloc() works right. */ + add_unwind_protect (xfree, input_string); + + CHECK_ALRM; + unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe; + + if (prompt && edit == 0) + { + fprintf (stderr, "%s", prompt); + fflush (stderr); + } + +#if defined (__CYGWIN__) && defined (O_TEXT) + setmode (0, O_TEXT); +#endif + + ps2 = 0; + for (print_ps2 = eof = retval = 0;;) + { + CHECK_ALRM; + +#if defined (READLINE) + if (edit) + { + if (rlbuf && rlbuf[rlind] == '\0') + { + xfree (rlbuf); + rlbuf = (char *)0; + } + if (rlbuf == 0) + { + reading = 1; + rlbuf = edit_line (prompt ? prompt : "", itext); + reading = 0; + rlind = 0; + } + if (rlbuf == 0) + { + eof = 1; + break; + } + c = rlbuf[rlind++]; + } + else + { +#endif + + if (print_ps2) + { + if (ps2 == 0) + ps2 = get_string_value ("PS2"); + fprintf (stderr, "%s", ps2 ? ps2 : ""); + fflush (stderr); + print_ps2 = 0; + } + +#if 0 + if (posixly_correct == 0) + interrupt_immediately++; +#endif + reading = 1; + if (unbuffered_read) + retval = posixly_correct ? zreadintr (fd, &c, 1) : zread (fd, &c, 1); + else + retval = posixly_correct ? zreadcintr (fd, &c) : zreadc (fd, &c); + reading = 0; +#if 0 + if (posixly_correct == 0) + interrupt_immediately--; +#endif + + if (retval <= 0) + { + if (retval < 0 && errno == EINTR) + { + lastsig = LASTSIG(); + if (lastsig == 0) + lastsig = trapped_signal_received; + run_pending_traps (); /* because interrupt_immediately is not set */ + } + else + lastsig = 0; + CHECK_TERMSIG; + eof = 1; + break; + } + + CHECK_ALRM; + +#if defined (READLINE) + } +#endif + + CHECK_ALRM; + if (i + 4 >= size) /* XXX was i + 2; use i + 4 for multibyte/read_mbchar */ + { + char *t; + t = (char *)xrealloc (input_string, size += 128); + + /* Only need to change unwind-protect if input_string changes */ + if (t != input_string) + { + input_string = t; + remove_unwind_protect (); + add_unwind_protect (xfree, input_string); + } + } + + /* If the next character is to be accepted verbatim, a backslash + newline pair still disappears from the input. */ + if (pass_next) + { + pass_next = 0; + if (c == '\n') + { + i--; /* back up over the CTLESC */ + if (interactive && input_is_tty && raw == 0) + print_ps2 = 1; + } + else + goto add_char; + continue; + } + + /* This may cause problems if IFS contains CTLESC */ + if (c == '\\' && raw == 0) + { + pass_next++; + if (skip_ctlesc == 0) + { + saw_escape++; + input_string[i++] = CTLESC; + } + continue; + } + + if ((unsigned char)c == delim) + break; + + if (c == '\0' && delim != '\0') + continue; /* skip NUL bytes in input */ + + if ((skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL)) + { + saw_escape++; + input_string[i++] = CTLESC; + } + +add_char: + input_string[i++] = c; + CHECK_ALRM; + +#if defined (HANDLE_MULTIBYTE) + if (nchars > 0 && MB_CUR_MAX > 1 && is_basic (c) == 0) + { + input_string[i] = '\0'; /* for simplicity and debugging */ + i += read_mbchar (fd, input_string, i, c, unbuffered_read); + } +#endif + + nr++; + + if (nchars > 0 && nr >= nchars) + break; + } + input_string[i] = '\0'; + CHECK_ALRM; + + if (retval < 0) + { + t_errno = errno; + if (errno != EINTR) + builtin_error (_("read error: %d: %s"), fd, strerror (errno)); + run_unwind_frame ("read_builtin"); + return ((t_errno != EINTR) ? EXECUTION_FAILURE : 128+lastsig); + } + + if (tmsec > 0 || tmusec > 0) + reset_alarm (); + + if (nchars > 0 || delim != '\n') + { +#if defined (READLINE) + if (edit) + { + if (nchars > 0) + rl_num_chars_to_read = 0; + if (delim != '\n') + reset_eol_delim ((char *)NULL); + } + else +#endif + if (input_is_tty) + ttyrestore (&termsave); + } + else if (silent) + ttyrestore (&termsave); + + if (unbuffered_read == 0) + zsyncfd (fd); + + discard_unwind_frame ("read_builtin"); + + retval = eof ? EXECUTION_FAILURE : EXECUTION_SUCCESS; + +assign_vars: + +#if defined (ARRAY_VARS) + /* If -a was given, take the string read, break it into a list of words, + an assign them to `arrayname' in turn. */ + if (arrayname) + { + if (legal_identifier (arrayname) == 0) + { + sh_invalidid (arrayname); + xfree (input_string); + return (EXECUTION_FAILURE); + } + + var = find_or_make_array_variable (arrayname, 1); + if (var == 0) + { + xfree (input_string); + return EXECUTION_FAILURE; /* readonly or noassign */ + } + if (assoc_p (var)) + { + builtin_error (_("%s: cannot convert associative to indexed array"), arrayname); + xfree (input_string); + return EXECUTION_FAILURE; /* existing associative array */ + } + else if (invisible_p (var)) + VUNSETATTR (var, att_invisible); + array_flush (array_cell (var)); + + alist = list_string (input_string, ifs_chars, 0); + if (alist) + { + if (saw_escape) + dequote_list (alist); + else + word_list_remove_quoted_nulls (alist); + assign_array_var_from_word_list (var, alist, 0); + dispose_words (alist); + } + xfree (input_string); + return (retval); + } +#endif /* ARRAY_VARS */ + + /* If there are no variables, save the text of the line read to the + variable $REPLY. ksh93 strips leading and trailing IFS whitespace, + so that `read x ; echo "$x"' and `read ; echo "$REPLY"' behave the + same way, but I believe that the difference in behaviors is useful + enough to not do it. Without the bash behavior, there is no way + to read a line completely without interpretation or modification + unless you mess with $IFS (e.g., setting it to the empty string). + If you disagree, change the occurrences of `#if 0' to `#if 1' below. */ + if (list == 0) + { +#if 0 + orig_input_string = input_string; + for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && isifs(*t); t++) + ; + input_string = t; + input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape); +#endif + + if (saw_escape) + { + t = dequote_string (input_string); + var = bind_variable ("REPLY", t, 0); + free (t); + } + else + var = bind_variable ("REPLY", input_string, 0); + VUNSETATTR (var, att_invisible); + + xfree (input_string); + return (retval); + } + + /* This code implements the Posix.2 spec for splitting the words + read and assigning them to variables. */ + orig_input_string = input_string; + + /* Remove IFS white space at the beginning of the input string. If + $IFS is null, no field splitting is performed. */ + for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && isifs(*t); t++) + ; + input_string = t; + for (; list->next; list = list->next) + { + varname = list->word->word; +#if defined (ARRAY_VARS) + if (legal_identifier (varname) == 0 && valid_array_reference (varname) == 0) +#else + if (legal_identifier (varname) == 0) +#endif + { + sh_invalidid (varname); + xfree (orig_input_string); + return (EXECUTION_FAILURE); + } + + /* If there are more variables than words read from the input, + the remaining variables are set to the empty string. */ + if (*input_string) + { + /* This call updates INPUT_STRING. */ + t = get_word_from_string (&input_string, ifs_chars, &e); + if (t) + *e = '\0'; + /* Don't bother to remove the CTLESC unless we added one + somewhere while reading the string. */ + if (t && saw_escape) + { + t1 = dequote_string (t); + var = bind_read_variable (varname, t1); + xfree (t1); + } + else + var = bind_read_variable (varname, t ? t : ""); + } + else + { + t = (char *)0; + var = bind_read_variable (varname, ""); + } + + FREE (t); + if (var == 0) + { + xfree (orig_input_string); + return (EXECUTION_FAILURE); + } + + stupidly_hack_special_variables (varname); + VUNSETATTR (var, att_invisible); + } + + /* Now assign the rest of the line to the last variable argument. */ +#if defined (ARRAY_VARS) + if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word) == 0) +#else + if (legal_identifier (list->word->word) == 0) +#endif + { + sh_invalidid (list->word->word); + xfree (orig_input_string); + return (EXECUTION_FAILURE); + } + +#if 0 + /* This has to be done this way rather than using string_list + and list_string because Posix.2 says that the last variable gets the + remaining words and their intervening separators. */ + input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape); +#else + /* Check whether or not the number of fields is exactly the same as the + number of variables. */ + tofree = NULL; + if (*input_string) + { + t1 = input_string; + t = get_word_from_string (&input_string, ifs_chars, &e); + if (*input_string == 0) + tofree = input_string = t; + else + { + input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape); + tofree = t; + } + } +#endif + + if (saw_escape && input_string && *input_string) + { + t = dequote_string (input_string); + var = bind_read_variable (list->word->word, t); + xfree (t); + } + else + var = bind_read_variable (list->word->word, input_string ? input_string : ""); + + if (var) + { + stupidly_hack_special_variables (list->word->word); + VUNSETATTR (var, att_invisible); + } + else + retval = EXECUTION_FAILURE; + + FREE (tofree); + xfree (orig_input_string); + + return (retval); +} + +static SHELL_VAR * +bind_read_variable (name, value) + char *name, *value; +{ + SHELL_VAR *v; + +#if defined (ARRAY_VARS) + if (valid_array_reference (name) == 0) + v = bind_variable (name, value, 0); + else + v = assign_array_element (name, value, 0); +#else /* !ARRAY_VARS */ + v = bind_variable (name, value, 0); +#endif /* !ARRAY_VARS */ + return (v == 0 ? v + : ((readonly_p (v) || noassign_p (v)) ? (SHELL_VAR *)NULL : v)); +} + +#if defined (HANDLE_MULTIBYTE) +static int +read_mbchar (fd, string, ind, ch, unbuffered) + int fd; + char *string; + int ind, ch, unbuffered; +{ + char mbchar[MB_LEN_MAX + 1]; + int i, n, r; + char c; + size_t ret; + mbstate_t ps, ps_back; + wchar_t wc; + + memset (&ps, '\0', sizeof (mbstate_t)); + memset (&ps_back, '\0', sizeof (mbstate_t)); + + mbchar[0] = ch; + i = 1; + for (n = 0; n <= MB_LEN_MAX; n++) + { + ps_back = ps; + ret = mbrtowc (&wc, mbchar, i, &ps); + if (ret == (size_t)-2) + { + ps = ps_back; + /* We don't want to be interrupted during a multibyte char read */ + if (unbuffered) + r = zread (fd, &c, 1); + else + r = zreadc (fd, &c); + if (r < 0) + goto mbchar_return; + mbchar[i++] = c; + continue; + } + else if (ret == (size_t)-1 || ret == (size_t)0 || ret > (size_t)0) + break; + } + +mbchar_return: + if (i > 1) /* read a multibyte char */ + /* mbchar[0] is already string[ind-1] */ + for (r = 1; r < i; r++) + string[ind+r-1] = mbchar[r]; + return i - 1; +} +#endif + + +static void +ttyrestore (ttp) + struct ttsave *ttp; +{ + ttsetattr (ttp->fd, ttp->attrs); +} + +#if defined (READLINE) +static rl_completion_func_t *old_attempted_completion_function = 0; +static rl_hook_func_t *old_startup_hook; +static char *deftext; + +static void +reset_attempted_completion_function (cp) + char *cp; +{ + if (rl_attempted_completion_function == 0 && old_attempted_completion_function) + rl_attempted_completion_function = old_attempted_completion_function; +} + +static int +set_itext () +{ + int r1, r2; + + r1 = r2 = 0; + if (old_startup_hook) + r1 = (*old_startup_hook) (); + if (deftext) + { + r2 = rl_insert_text (deftext); + deftext = (char *)NULL; + rl_startup_hook = old_startup_hook; + old_startup_hook = (rl_hook_func_t *)NULL; + } + return (r1 || r2); +} + +static char * +edit_line (p, itext) + char *p; + char *itext; +{ + char *ret; + int len; + + if (bash_readline_initialized == 0) + initialize_readline (); + + old_attempted_completion_function = rl_attempted_completion_function; + rl_attempted_completion_function = (rl_completion_func_t *)NULL; + if (itext) + { + old_startup_hook = rl_startup_hook; + rl_startup_hook = set_itext; + deftext = itext; + } + + ret = readline (p); + + rl_attempted_completion_function = old_attempted_completion_function; + old_attempted_completion_function = (rl_completion_func_t *)NULL; + + if (ret == 0) + return ret; + len = strlen (ret); + ret = (char *)xrealloc (ret, len + 2); + ret[len++] = delim; + ret[len] = '\0'; + return ret; +} + +static int old_delim_ctype; +static rl_command_func_t *old_delim_func; +static int old_newline_ctype; +static rl_command_func_t *old_newline_func; + +static unsigned char delim_char; + +static void +set_eol_delim (c) + int c; +{ + Keymap cmap; + + if (bash_readline_initialized == 0) + initialize_readline (); + cmap = rl_get_keymap (); + + /* Change newline to self-insert */ + old_newline_ctype = cmap[RETURN].type; + old_newline_func = cmap[RETURN].function; + cmap[RETURN].type = ISFUNC; + cmap[RETURN].function = rl_insert; + + /* Bind the delimiter character to accept-line. */ + old_delim_ctype = cmap[c].type; + old_delim_func = cmap[c].function; + cmap[c].type = ISFUNC; + cmap[c].function = rl_newline; + + delim_char = c; +} + +static void +reset_eol_delim (cp) + char *cp; +{ + Keymap cmap; + + cmap = rl_get_keymap (); + + cmap[RETURN].type = old_newline_ctype; + cmap[RETURN].function = old_newline_func; + + cmap[delim_char].type = old_delim_ctype; + cmap[delim_char].function = old_delim_func; +} +#endif diff --git a/doc/bash.1 b/doc/bash.1 index b1f9fff60..c8c1328ea 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -5,12 +5,12 @@ .\" Case Western Reserve University .\" chet@po.cwru.edu .\" -.\" Last Change: Sat Nov 24 15:07:12 EST 2012 +.\" Last Change: Sat Dec 15 17:50:05 EST 2012 .\" .\" bash_builtins, strip all but Built-Ins section .if \n(zZ=1 .ig zZ .if \n(zY=1 .ig zY -.TH BASH 1 "2012 November 24" "GNU Bash 4.2" +.TH BASH 1 "2012 December 15" "GNU Bash 4.2" .\" .\" There's some problem with having a `@' .\" in a tagged paragraph with the BSD man macros. @@ -949,6 +949,8 @@ available as the value of the variable \fINAME\fP_PID. The \fBwait\fP builtin command may be used to wait for the coprocess to terminate. .PP +Since the coprocess is created as an asynchronous command, +the \fBcoproc\fP command always returns success. The return status of a coprocess is the exit status of \fIcommand\fP. .SS Shell Function Definitions .PP @@ -8413,10 +8415,13 @@ causes \fBprintf\fP to output the corresponding .TP .B %(\fIdatefmt\fP)T causes \fBprintf\fP to output the date-time string resulting from using -\fIdatefmt\fP as a format string for \fIstrftime\fP(3). The corresponding -\fIargument\fP is an integer representing the number of seconds since the -epoch. Two special argument values may be used: -1 represents the current +\fIdatefmt\fP as a format string for \fIstrftime\fP(3). +The corresponding \fIargument\fP is an integer representing the number of +seconds since the epoch. +Two special argument values may be used: -1 represents the current time, and -2 represents the time the shell was invoked. +If no argument is specified, conversion behaves as if -1 had been given. +This is an exception to the usual \fBprintf\fP behavior. .PD .PP Arguments to non-string format specifiers are treated as C constants, @@ -8584,14 +8589,17 @@ not echoed. .TP .B \-t \fItimeout\fP Cause \fBread\fP to time out and return failure if a complete line of -input is not read within \fItimeout\fP seconds. +input (or a specified number of characters) +is not read within \fItimeout\fP seconds. \fItimeout\fP may be a decimal number with a fractional portion following the decimal point. This option is only effective if \fBread\fP is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. +If \fBread\fP times out, \fBread\fP saves any partial input read into +the specified variable \fIname\fP. If \fItimeout\fP is 0, \fBread\fP returns immediately, without trying to -read any data. The exit statis is 0 if input is available on +read any data. The exit status is 0 if input is available on the specified file descriptor, non-zero otherwise. The exit status is greater than 128 if the timeout is exceeded. .TP diff --git a/doc/bash.1~ b/doc/bash.1~ new file mode 100644 index 000000000..a371c4f80 --- /dev/null +++ b/doc/bash.1~ @@ -0,0 +1,10244 @@ +.\" +.\" MAN PAGE COMMENTS to +.\" +.\" Chet Ramey +.\" Case Western Reserve University +.\" chet@po.cwru.edu +.\" +.\" Last Change: Fri Dec 14 10:13:24 EST 2012 +.\" +.\" bash_builtins, strip all but Built-Ins section +.if \n(zZ=1 .ig zZ +.if \n(zY=1 .ig zY +.TH BASH 1 "2012 December 14" "GNU Bash 4.2" +.\" +.\" There's some problem with having a `@' +.\" in a tagged paragraph with the BSD man macros. +.\" It has to do with `@' appearing in the }1 macro. +.\" This is a problem on 4.3 BSD and Ultrix, but Sun +.\" appears to have fixed it. +.\" If you're seeing the characters +.\" `@u-3p' appearing before the lines reading +.\" `possible-hostname-completions +.\" and `complete-hostname' down in READLINE, +.\" then uncomment this redefinition. +.\" +.de }1 +.ds ]X \&\\*(]B\\ +.nr )E 0 +.if !"\\$1"" .nr )I \\$1n +.}f +.ll \\n(LLu +.in \\n()Ru+\\n(INu+\\n()Iu +.ti \\n(INu +.ie !\\n()Iu+\\n()Ru-\w\\*(]Xu-3p \{\\*(]X +.br\} +.el \\*(]X\h|\\n()Iu+\\n()Ru\c +.}f +.. +.\" +.\" File Name macro. This used to be `.PN', for Path Name, +.\" but Sun doesn't seem to like that very much. +.\" +.de FN +\fI\|\\$1\|\fP +.. +.SH NAME +bash \- GNU Bourne-Again SHell +.SH SYNOPSIS +.B bash +[options] +[command_string | file] +.SH COPYRIGHT +.if n Bash is Copyright (C) 1989-2012 by the Free Software Foundation, Inc. +.if t Bash is Copyright \(co 1989-2012 by the Free Software Foundation, Inc. +.SH DESCRIPTION +.B Bash +is an \fBsh\fR-compatible command language interpreter that +executes commands read from the standard input or from a file. +.B Bash +also incorporates useful features from the \fIKorn\fP and \fIC\fP +shells (\fBksh\fP and \fBcsh\fP). +.PP +.B Bash +is intended to be a conformant implementation of the +Shell and Utilities portion of the IEEE POSIX specification +(IEEE Standard 1003.1). +.B Bash +can be configured to be POSIX-conformant by default. +.SH OPTIONS +All of the single-character shell options documented in the +description of the \fBset\fR builtin command can be used as options +when the shell is invoked. +In addition, \fBbash\fR +interprets the following options when it is invoked: +.PP +.PD 0 +.TP 10 +.B \-c +If the +.B \-c +option is present, then commands are read from the first non-option argument +.IR command_string . +If there are arguments after the +.IR command_string , +they are assigned to the positional parameters, starting with +.BR $0 . +.TP +.B \-i +If the +.B \-i +option is present, the shell is +.IR interactive . +.TP +.B \-l +Make +.B bash +act as if it had been invoked as a login shell (see +.SM +.B INVOCATION +below). +.TP +.B \-r +If the +.B \-r +option is present, the shell becomes +.I restricted +(see +.SM +.B "RESTRICTED SHELL" +below). +.TP +.B \-s +If the +.B \-s +option is present, or if no arguments remain after option +processing, then commands are read from the standard input. +This option allows the positional parameters to be set +when invoking an interactive shell. +.TP +.B \-D +A list of all double-quoted strings preceded by \fB$\fP +is printed on the standard output. +These are the strings that +are subject to language translation when the current locale +is not \fBC\fP or \fBPOSIX\fP. +This implies the \fB\-n\fP option; no commands will be executed. +.TP +.B [\-+]O [\fIshopt_option\fP] +\fIshopt_option\fP is one of the shell options accepted by the +\fBshopt\fP builtin (see +.SM +.B SHELL BUILTIN COMMANDS +below). +If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option; +\fB+O\fP unsets it. +If \fIshopt_option\fP is not supplied, the names and values of the shell +options accepted by \fBshopt\fP are printed on the standard output. +If the invocation option is \fB+O\fP, the output is displayed in a format +that may be reused as input. +.TP +.B \-\- +A +.B \-\- +signals the end of options and disables further option processing. +Any arguments after the +.B \-\- +are treated as filenames and arguments. An argument of +.B \- +is equivalent to \fB\-\-\fP. +.PD +.PP +.B Bash +also interprets a number of multi-character options. +These options must appear on the command line before the +single-character options to be recognized. +.PP +.PD 0 +.TP +.B \-\-debugger +Arrange for the debugger profile to be executed before the shell +starts. +Turns on extended debugging mode (see the description of the +.B extdebug +option to the +.B shopt +builtin below). +.TP +.B \-\-dump\-po\-strings +Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP +\fBpo\fP (portable object) file format. +.TP +.B \-\-dump\-strings +Equivalent to \fB\-D\fP. +.TP +.B \-\-help +Display a usage message on standard output and exit successfully. +.TP +\fB\-\-init\-file\fP \fIfile\fP +.PD 0 +.TP +\fB\-\-rcfile\fP \fIfile\fP +.PD +Execute commands from +.I file +instead of the standard personal initialization file +.I ~/.bashrc +if the shell is interactive (see +.SM +.B INVOCATION +below). +.TP +.B \-\-login +Equivalent to \fB\-l\fP. +.TP +.B \-\-noediting +Do not use the GNU +.B readline +library to read command lines when the shell is interactive. +.TP +.B \-\-noprofile +Do not read either the system-wide startup file +.FN /etc/profile +or any of the personal initialization files +.IR ~/.bash_profile , +.IR ~/.bash_login , +or +.IR ~/.profile . +By default, +.B bash +reads these files when it is invoked as a login shell (see +.SM +.B INVOCATION +below). +.TP +.B \-\-norc +Do not read and execute the personal initialization file +.I ~/.bashrc +if the shell is interactive. +This option is on by default if the shell is invoked as +.BR sh . +.TP +.B \-\-posix +Change the behavior of \fBbash\fP where the default operation differs +from the POSIX standard to match the standard (\fIposix mode\fP). +.TP +.B \-\-restricted +The shell becomes restricted (see +.SM +.B "RESTRICTED SHELL" +below). +.TP +.B \-\-verbose +Equivalent to \fB\-v\fP. +.TP +.B \-\-version +Show version information for this instance of +.B bash +on the standard output and exit successfully. +.PD +.SH ARGUMENTS +If arguments remain after option processing, and neither the +.B \-c +nor the +.B \-s +option has been supplied, the first argument is assumed to +be the name of a file containing shell commands. +If +.B bash +is invoked in this fashion, +.B $0 +is set to the name of the file, and the positional parameters +are set to the remaining arguments. +.B Bash +reads and executes commands from this file, then exits. +\fBBash\fP's exit status is the exit status of the last command +executed in the script. +If no commands are executed, the exit status is 0. +An attempt is first made to open the file in the current directory, and, +if no file is found, then the shell searches the directories in +.SM +.B PATH +for the script. +.SH INVOCATION +A \fIlogin shell\fP is one whose first character of argument zero is a +.BR \- , +or one started with the +.B \-\-login +option. +.PP +An \fIinteractive\fP shell is one started without non-option arguments +and without the +.B \-c +option +whose standard input and error are +both connected to terminals (as determined by +.IR isatty (3)), +or one started with the +.B \-i +option. +.SM +.B PS1 +is set and +.B $\- +includes +.B i +if +.B bash +is interactive, +allowing a shell script or a startup file to test this state. +.PP +The following paragraphs describe how +.B bash +executes its startup files. +If any of the files exist but cannot be read, +.B bash +reports an error. +Tildes are expanded in filenames as described below under +.B "Tilde Expansion" +in the +.SM +.B EXPANSION +section. +.PP +When +.B bash +is invoked as an interactive login shell, or as a non-interactive shell +with the \fB\-\-login\fP option, it first reads and +executes commands from the file \fI/etc/profile\fP, if that +file exists. +After reading that file, it looks for \fI~/.bash_profile\fP, +\fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads +and executes commands from the first one that exists and is readable. +The +.B \-\-noprofile +option may be used when the shell is started to inhibit this behavior. +.PP +When a login shell exits, +.B bash +reads and executes commands from the file \fI~/.bash_logout\fP, if it +exists. +.PP +When an interactive shell that is not a login shell is started, +.B bash +reads and executes commands from \fI~/.bashrc\fP, if that file exists. +This may be inhibited by using the +.B \-\-norc +option. +The \fB\-\-rcfile\fP \fIfile\fP option will force +.B bash +to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP. +.PP +When +.B bash +is started non-interactively, to run a shell script, for example, it +looks for the variable +.SM +.B BASH_ENV +in the environment, expands its value if it appears there, and uses the +expanded value as the name of a file to read and execute. +.B Bash +behaves as if the following command were executed: +.sp .5 +.RS +.if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP +.if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi +.RE +.sp .5 +but the value of the +.SM +.B PATH +variable is not used to search for the filename. +.PP +If +.B bash +is invoked with the name +.BR sh , +it tries to mimic the startup behavior of historical versions of +.B sh +as closely as possible, +while conforming to the POSIX standard as well. +When invoked as an interactive login shell, or a non-interactive +shell with the \fB\-\-login\fP option, it first attempts to +read and execute commands from +.I /etc/profile +and +.IR ~/.profile , +in that order. +The +.B \-\-noprofile +option may be used to inhibit this behavior. +When invoked as an interactive shell with the name +.BR sh , +.B bash +looks for the variable +.SM +.BR ENV , +expands its value if it is defined, and uses the +expanded value as the name of a file to read and execute. +Since a shell invoked as +.B sh +does not attempt to read and execute commands from any other startup +files, the +.B \-\-rcfile +option has no effect. +A non-interactive shell invoked with the name +.B sh +does not attempt to read any other startup files. +When invoked as +.BR sh , +.B bash +enters +.I posix +mode after the startup files are read. +.PP +When +.B bash +is started in +.I posix +mode, as with the +.B \-\-posix +command line option, it follows the POSIX standard for startup files. +In this mode, interactive shells expand the +.SM +.B ENV +variable and commands are read and executed from the file +whose name is the expanded value. +No other startup files are read. +.PP +.B Bash +attempts to determine when it is being run with its standard input +connected to a network connection, as when executed by the remote shell +daemon, usually \fIrshd\fP, or the secure shell daemon \fIsshd\fP. +If +.B bash +determines it is being run in this fashion, it reads and executes +commands from \fI~/.bashrc\fP, if that file exists and is readable. +It will not do this if invoked as \fBsh\fP. +The +.B \-\-norc +option may be used to inhibit this behavior, and the +.B \-\-rcfile +option may be used to force another file to be read, but +\fIrshd\fP does not generally invoke the shell with those options +or allow them to be specified. +.PP +If the shell is started with the effective user (group) id not equal to the +real user (group) id, and the \fB\-p\fP option is not supplied, no startup +files are read, shell functions are not inherited from the environment, the +.SM +.BR SHELLOPTS , +.SM +.BR BASHOPTS , +.SM +.BR CDPATH , +and +.SM +.B GLOBIGNORE +variables, if they appear in the environment, are ignored, +and the effective user id is set to the real user id. +If the \fB\-p\fP option is supplied at invocation, the startup behavior is +the same, but the effective user id is not reset. +.SH DEFINITIONS +.PP +The following definitions are used throughout the rest of this +document. +.PD 0 +.TP +.B blank +A space or tab. +.TP +.B word +A sequence of characters considered as a single unit by the shell. +Also known as a +.BR token . +.TP +.B name +A +.I word +consisting only of alphanumeric characters and underscores, and +beginning with an alphabetic character or an underscore. Also +referred to as an +.BR identifier . +.TP +.B metacharacter +A character that, when unquoted, separates words. One of the following: +.br +.RS +.PP +.if t \fB| & ; ( ) < > space tab\fP +.if n \fB| & ; ( ) < > space tab\fP +.RE +.PP +.TP +.B control operator +A \fItoken\fP that performs a control function. It is one of the following +symbols: +.RS +.PP +.if t \fB|| & && ; ;; ( ) | |& \fP +.if n \fB|| & && ; ;; ( ) | |& \fP +.RE +.PD +.SH "RESERVED WORDS" +\fIReserved words\fP are words that have a special meaning to the shell. +The following words are recognized as reserved when unquoted and either +the first word of a simple command (see +.SM +.B SHELL GRAMMAR +below) or the third word of a +.B case +or +.B for +command: +.if t .RS +.PP +.B +.if n ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] +.if t ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] +.if t .RE +.SH "SHELL GRAMMAR" +.SS Simple Commands +.PP +A \fIsimple command\fP is a sequence of optional variable assignments +followed by \fBblank\fP-separated words and redirections, and +terminated by a \fIcontrol operator\fP. The first word +specifies the command to be executed, and is passed as argument zero. +The remaining words are passed as arguments to the invoked command. +.PP +The return value of a \fIsimple command\fP is its exit status, or +128+\fIn\^\fP if the command is terminated by signal +.IR n . +.SS Pipelines +.PP +A \fIpipeline\fP is a sequence of one or more commands separated by +one of the control operators +.B | +or \fB|&\fP. +The format for a pipeline is: +.RS +.PP +[\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ [\fB|\fP\(bv\fB|&\fP] \fIcommand2\fP ... ] +.RE +.PP +The standard output of +.I command +is connected via a pipe to the standard input of +.IR command2 . +This connection is performed before any redirections specified by the +command (see +.SM +.B REDIRECTION +below). +If \fB|&\fP is used, \fIcommand\fP's standard output and standard error +are connected to +\fIcommand2\fP's standard input through the pipe; +it is shorthand for \fB2>&1 |\fP. +This implicit redirection of the standard error is +performed after any redirections specified by the command. +.PP +The return status of a pipeline is the exit status of the last +command, unless the \fBpipefail\fP option is enabled. +If \fBpipefail\fP is enabled, the pipeline's return status is the +value of the last (rightmost) command to exit with a non-zero status, +or zero if all commands exit successfully. +If the reserved word +.B ! +precedes a pipeline, the exit status of that pipeline is the logical +negation of the exit status as described above. +The shell waits for all commands in the pipeline to +terminate before returning a value. +.PP +If the +.B time +reserved word precedes a pipeline, the elapsed as well as user and +system time consumed by its execution are reported when the pipeline +terminates. +The \fB\-p\fP option changes the output format to that specified by POSIX. +When the shell is in \fIposix mode\fP, it does not recognize +\fBtime\fP as a reserved word if the next token begins with a `-'. +The +.SM +.B TIMEFORMAT +variable may be set to a format string that specifies how the timing +information should be displayed; see the description of +.SM +.B TIMEFORMAT +under +.B "Shell Variables" +below. +.PP +When the shell is in \fIposix mode\fP, \fBtime\fP +may be followed by a newline. In this case, the shell displays the +total user and system time consumed by the shell and its children. +The +.SM +.B TIMEFORMAT +variable may be used to specify the format of +the time information. +.PP +Each command in a pipeline is executed as a separate process (i.e., in a +subshell). +.SS Lists +.PP +A \fIlist\fP is a sequence of one or more pipelines separated by one +of the operators +.BR ; , +.BR & , +.BR && , +or +.BR || , +and optionally terminated by one of +.BR ; , +.BR & , +or +.BR . +.PP +Of these list operators, +.B && +and +.B || +have equal precedence, followed by +.B ; +and +.BR & , +which have equal precedence. +.PP +A sequence of one or more newlines may appear in a \fIlist\fP instead +of a semicolon to delimit commands. +.PP +If a command is terminated by the control operator +.BR & , +the shell executes the command in the \fIbackground\fP +in a subshell. The shell does not wait for the command to +finish, and the return status is 0. Commands separated by a +.B ; +are executed sequentially; the shell waits for each +command to terminate in turn. The return status is the +exit status of the last command executed. +.PP +AND and OR lists are sequences of one of more pipelines separated by the +\fB&&\fP and \fB||\fP control operators, respectively. +AND and OR lists are executed with left associativity. +An AND list has the form +.RS +.PP +\fIcommand1\fP \fB&&\fP \fIcommand2\fP +.RE +.PP +.I command2 +is executed if, and only if, +.I command1 +returns an exit status of zero. +.PP +An OR list has the form +.RS +.PP +\fIcommand1\fP \fB||\fP \fIcommand2\fP +.PP +.RE +.PP +.I command2 +is executed if and only if +.I command1 +returns a non-zero exit status. +The return status of +AND and OR lists is the exit status of the last command +executed in the list. +.SS Compound Commands +.PP +A \fIcompound command\fP is one of the following. +In most cases a \fIlist\fP in a command's description may be separated from +the rest of the command by one or more newlines, and may be followed by a +newline in place of a semicolon. +.TP +(\fIlist\fP) +\fIlist\fP is executed in a subshell environment (see +.SM +\fBCOMMAND EXECUTION ENVIRONMENT\fP +below). +Variable assignments and builtin +commands that affect the shell's environment do not remain in effect +after the command completes. The return status is the exit status of +\fIlist\fP. +.TP +{ \fIlist\fP; } +\fIlist\fP is simply executed in the current shell environment. +\fIlist\fP must be terminated with a newline or semicolon. +This is known as a \fIgroup command\fP. +The return status is the exit status of +\fIlist\fP. +Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and +\fB}\fP are \fIreserved words\fP and must occur where a reserved +word is permitted to be recognized. Since they do not cause a word +break, they must be separated from \fIlist\fP by whitespace or another +shell metacharacter. +.TP +((\fIexpression\fP)) +The \fIexpression\fP is evaluated according to the rules described +below under +.SM +.BR "ARITHMETIC EVALUATION" . +If the value of the expression is non-zero, the return status is 0; +otherwise the return status is 1. This is exactly equivalent to +\fBlet "\fIexpression\fP"\fR. +.TP +\fB[[\fP \fIexpression\fP \fB]]\fP +Return a status of 0 or 1 depending on the evaluation of +the conditional expression \fIexpression\fP. +Expressions are composed of the primaries described below under +.SM +.BR "CONDITIONAL EXPRESSIONS" . +Word splitting and pathname expansion are not performed on the words +between the \fB[[\fP and \fB]]\fP; tilde expansion, +parameter and variable expansion, +arithmetic expansion, command substitution, process +substitution, and quote removal are performed. +Conditional operators such as \fB\-f\fP must be unquoted to be recognized +as primaries. +.if t .sp 0.5 +.if n .sp 1 +When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort +lexicographically using the current locale. +.if t .sp 0.5 +.if n .sp 1 +When the \fB==\fP and \fB!=\fP operators are used, the string to the +right of the operator is considered a pattern and matched according +to the rules described below under \fBPattern Matching\fP. +The \fB=\fP operator is equivalent to \fB==\fP. +If the shell option +.B nocasematch +is enabled, the match is performed without regard to the case +of alphabetic characters. +The return value is 0 if the string matches (\fB==\fP) or does not match +(\fB!=\fP) the pattern, and 1 otherwise. +Any part of the pattern may be quoted to force the quoted portion +to be matched as a string. +.if t .sp 0.5 +.if n .sp 1 +An additional binary operator, \fB=~\fP, is available, with the same +precedence as \fB==\fP and \fB!=\fP. +When it is used, the string to the right of the operator is considered +an extended regular expression and matched accordingly (as in \fIregex\fP(3)). +The return value is 0 if the string matches +the pattern, and 1 otherwise. +If the regular expression is syntactically incorrect, the conditional +expression's return value is 2. +If the shell option +.B nocasematch +is enabled, the match is performed without regard to the case +of alphabetic characters. +Any part of the pattern may be quoted to force the quoted portion +to be matched as a string. +Bracket expressions in regular expressions must be treated carefully, +since normal quoting characters lose their meanings between brackets. +If the pattern is stored in a shell variable, quoting the variable +expansion forces the entire pattern to be matched as a string. +Substrings matched by parenthesized subexpressions within the regular +expression are saved in the array variable +.SM +.BR BASH_REMATCH . +The element of +.SM +.B BASH_REMATCH +with index 0 is the portion of the string +matching the entire regular expression. +The element of +.SM +.B BASH_REMATCH +with index \fIn\fP is the portion of the +string matching the \fIn\fPth parenthesized subexpression. +.if t .sp 0.5 +.if n .sp 1 +Expressions may be combined using the following operators, listed +in decreasing order of precedence: +.if t .sp 0.5 +.if n .sp 1 +.RS +.PD 0 +.TP +.B ( \fIexpression\fP ) +Returns the value of \fIexpression\fP. +This may be used to override the normal precedence of operators. +.TP +.B ! \fIexpression\fP +True if +.I expression +is false. +.TP +\fIexpression1\fP \fB&&\fP \fIexpression2\fP +True if both +.I expression1 +and +.I expression2 +are true. +.TP +\fIexpression1\fP \fB||\fP \fIexpression2\fP +True if either +.I expression1 +or +.I expression2 +is true. +.PD +.LP +The \fB&&\fP and \fB||\fP +operators do not evaluate \fIexpression2\fP if the value of +\fIexpression1\fP is sufficient to determine the return value of +the entire conditional expression. +.RE +.TP +\fBfor\fP \fIname\fP [ [ \fBin\fP [ \fIword ...\fP ] ] ; ] \fBdo\fP \fIlist\fP ; \fBdone\fP +The list of words following \fBin\fP is expanded, generating a list +of items. +The variable \fIname\fP is set to each element of this list +in turn, and \fIlist\fP is executed each time. +If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes +\fIlist\fP once for each positional parameter that is set (see +.SM +.B PARAMETERS +below). +The return status is the exit status of the last command that executes. +If the expansion of the items following \fBin\fP results in an empty +list, no commands are executed, and the return status is 0. +.TP +\fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP +First, the arithmetic expression \fIexpr1\fP is evaluated according +to the rules described below under +.SM +.BR "ARITHMETIC EVALUATION" . +The arithmetic expression \fIexpr2\fP is then evaluated repeatedly +until it evaluates to zero. +Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is +executed and the arithmetic expression \fIexpr3\fP is evaluated. +If any expression is omitted, it behaves as if it evaluates to 1. +The return value is the exit status of the last command in \fIlist\fP +that is executed, or false if any of the expressions is invalid. +.TP +\fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP +The list of words following \fBin\fP is expanded, generating a list +of items. The set of expanded words is printed on the standard +error, each preceded by a number. If the \fBin\fP +\fIword\fP is omitted, the positional parameters are printed (see +.SM +.B PARAMETERS +below). The +.SM +.B PS3 +prompt is then displayed and a line read from the standard input. +If the line consists of a number corresponding to one of +the displayed words, then the value of +.I name +is set to that word. If the line is empty, the words and prompt +are displayed again. If EOF is read, the command completes. Any +other value read causes +.I name +to be set to null. The line read is saved in the variable +.SM +.BR REPLY . +The +.I list +is executed after each selection until a +.B break +command is executed. +The exit status of +.B select +is the exit status of the last command executed in +.IR list , +or zero if no commands were executed. +.TP +\fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \ +... ) \fIlist\fP ;; ] ... \fBesac\fP +A \fBcase\fP command first expands \fIword\fP, and tries to match +it against each \fIpattern\fP in turn, using the same matching rules +as for pathname expansion (see +.B Pathname Expansion +below). +The \fIword\fP is expanded using tilde +expansion, parameter and variable expansion, arithmetic substitution, +command substitution, process substitution and quote removal. +Each \fIpattern\fP examined is expanded using tilde +expansion, parameter and variable expansion, arithmetic substitution, +command substitution, and process substitution. +If the shell option +.B nocasematch +is enabled, the match is performed without regard to the case +of alphabetic characters. +When a match is found, the corresponding \fIlist\fP is executed. +If the \fB;;\fP operator is used, no subsequent matches are attempted after +the first pattern match. +Using \fB;&\fP in place of \fB;;\fP causes execution to continue with +the \fIlist\fP associated with the next set of patterns. +Using \fB;;&\fP in place of \fB;;\fP causes the shell to test the next +pattern list in the statement, if any, and execute any associated \fIlist\fP +on a successful match. +The exit status is zero if no +pattern matches. Otherwise, it is the exit status of the +last command executed in \fIlist\fP. +.TP +\fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \ +[ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \ +[ \fBelse\fP \fIlist\fP; ] \fBfi\fP +The +.B if +.I list +is executed. If its exit status is zero, the +\fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP +\fIlist\fP is executed in turn, and if its exit status is zero, +the corresponding \fBthen\fP \fIlist\fP is executed and the +command completes. Otherwise, the \fBelse\fP \fIlist\fP is +executed, if present. The exit status is the exit status of the +last command executed, or zero if no condition tested true. +.TP +\fBwhile\fP \fIlist-1\fP; \fBdo\fP \fIlist-2\fP; \fBdone\fP +.PD 0 +.TP +\fBuntil\fP \fIlist-1\fP; \fBdo\fP \fIlist-2\fP; \fBdone\fP +.PD +The \fBwhile\fP command continuously executes the list +\fIlist-2\fP as long as the last command in the list \fIlist-1\fP returns +an exit status of zero. The \fBuntil\fP command is identical +to the \fBwhile\fP command, except that the test is negated; +.I list-2 +is executed as long as the last command in +.I list-1 +returns a non-zero exit status. +The exit status of the \fBwhile\fP and \fBuntil\fP commands +is the exit status +of the last command executed in \fIlist-2\fP, or zero if +none was executed. +.SS Coprocesses +.PP +A \fIcoprocess\fP is a shell command preceded by the \fBcoproc\fP reserved +word. +A coprocess is executed asynchronously in a subshell, as if the command +had been terminated with the \fB&\fP control operator, with a two-way pipe +established between the executing shell and the coprocess. +.PP +The format for a coprocess is: +.RS +.PP +\fBcoproc\fP [\fINAME\fP] \fIcommand\fP [\fIredirections\fP] +.RE +.PP +This creates a coprocess named \fINAME\fP. +If \fINAME\fP is not supplied, the default name is \fBCOPROC\fP. +\fINAME\fP must not be supplied if \fIcommand\fP is a \fIsimple +command\fP (see above); otherwise, it is interpreted as the first word +of the simple command. +When the coprocess is executed, the shell creates an array variable (see +.B Arrays +below) named \fINAME\fP in the context of the executing shell. +The standard output of +.I command +is connected via a pipe to a file descriptor in the executing shell, +and that file descriptor is assigned to \fINAME\fP[0]. +The standard input of +.I command +is connected via a pipe to a file descriptor in the executing shell, +and that file descriptor is assigned to \fINAME\fP[1]. +This pipe is established before any redirections specified by the +command (see +.SM +.B REDIRECTION +below). +The file descriptors can be utilized as arguments to shell commands +and redirections using standard word expansions. +The file descriptors are not available in subshells. +The process ID of the shell spawned to execute the coprocess is +available as the value of the variable \fINAME\fP_PID. +The \fBwait\fP +builtin command may be used to wait for the coprocess to terminate. +.PP +Since the coprocess is created as an asynchronous command, +the \fBcoproc\fP command always returns success. +The return status of a coprocess is the exit status of \fIcommand\fP. +.SS Shell Function Definitions +.PP +A shell function is an object that is called like a simple command and +executes a compound command with a new set of positional parameters. +Shell functions are declared as follows: +.TP +\fIname\fP () \fIcompound\-command\fP [\fIredirection\fP] +.PD 0 +.TP +\fBfunction\fP \fIname\fP [()] \fIcompound\-command\fP [\fIredirection\fP] +.PD +This defines a function named \fIname\fP. +The reserved word \fBfunction\fP is optional. +If the \fBfunction\fP reserved word is supplied, the parentheses are optional. +The \fIbody\fP of the function is the compound command +.I compound\-command +(see \fBCompound Commands\fP above). +That command is usually a \fIlist\fP of commands between { and }, but +may be any command listed under \fBCompound Commands\fP above. +\fIcompound\-command\fP is executed whenever \fIname\fP is specified as the +name of a simple command. +When in \fIposix mode\fP, \fIname\fP may not be the name of one of the +POSIX \fIspecial builtins\fP. +Any redirections (see +.SM +.B REDIRECTION +below) specified when a function is defined are performed +when the function is executed. +The exit status of a function definition is zero unless a syntax error +occurs or a readonly function with the same name already exists. +When executed, the exit status of a function is the exit status of the +last command executed in the body. (See +.SM +.B FUNCTIONS +below.) +.SH COMMENTS +In a non-interactive shell, or an interactive shell in which the +.B interactive_comments +option to the +.B shopt +builtin is enabled (see +.SM +.B "SHELL BUILTIN COMMANDS" +below), a word beginning with +.B # +causes that word and all remaining characters on that line to +be ignored. An interactive shell without the +.B interactive_comments +option enabled does not allow comments. The +.B interactive_comments +option is on by default in interactive shells. +.SH QUOTING +\fIQuoting\fP is used to remove the special meaning of certain +characters or words to the shell. Quoting can be used to +disable special treatment for special characters, to prevent +reserved words from being recognized as such, and to prevent +parameter expansion. +.PP +Each of the \fImetacharacters\fP listed above under +.SM +.B DEFINITIONS +has special meaning to the shell and must be quoted if it is to +represent itself. +.PP +When the command history expansion facilities are being used +(see +.SM +.B HISTORY EXPANSION +below), the +\fIhistory expansion\fP character, usually \fB!\fP, must be quoted +to prevent history expansion. +.PP +There are three quoting mechanisms: the +.IR "escape character" , +single quotes, and double quotes. +.PP +A non-quoted backslash (\fB\e\fP) is the +.IR "escape character" . +It preserves the literal value of the next character that follows, +with the exception of . If a \fB\e\fP pair +appears, and the backslash is not itself quoted, the \fB\e\fP +is treated as a line continuation (that is, it is removed from the +input stream and effectively ignored). +.PP +Enclosing characters in single quotes preserves the literal value +of each character within the quotes. A single quote may not occur +between single quotes, even when preceded by a backslash. +.PP +Enclosing characters in double quotes preserves the literal value +of all characters within the quotes, with the exception of +.BR $ , +.BR \` , +.BR \e , +and, when history expansion is enabled, +.BR ! . +The characters +.B $ +and +.B \` +retain their special meaning within double quotes. The backslash +retains its special meaning only when followed by one of the following +characters: +.BR $ , +.BR \` , +\^\fB"\fP\^, +.BR \e , +or +.BR . +A double quote may be quoted within double quotes by preceding it with +a backslash. +If enabled, history expansion will be performed unless an +.B ! +appearing in double quotes is escaped using a backslash. +The backslash preceding the +.B ! +is not removed. +.PP +The special parameters +.B * +and +.B @ +have special meaning when in double +quotes (see +.SM +.B PARAMETERS +below). +.PP +Words of the form \fB$\fP\(aq\fIstring\fP\(aq are treated specially. The +word expands to \fIstring\fP, with backslash-escaped characters replaced +as specified by the ANSI C standard. Backslash escape sequences, if +present, are decoded as follows: +.RS +.PD 0 +.TP +.B \ea +alert (bell) +.TP +.B \eb +backspace +.TP +.B \ee +.TP +.B \eE +an escape character +.TP +.B \ef +form feed +.TP +.B \en +new line +.TP +.B \er +carriage return +.TP +.B \et +horizontal tab +.TP +.B \ev +vertical tab +.TP +.B \e\e +backslash +.TP +.B \e\(aq +single quote +.TP +.B \e\(dq +double quote +.TP +.B \e\fInnn\fP +the eight-bit character whose value is the octal value \fInnn\fP +(one to three digits) +.TP +.B \ex\fIHH\fP +the eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits) +.TP +.B \eu\fIHHHH\fP +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHH\fP (one to four hex digits) +.TP +.B \eU\fIHHHHHHHH\fP +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHHHHHH\fP (one to eight hex digits) +.TP +.B \ec\fIx\fP +a control-\fIx\fP character +.PD +.RE +.LP +The expanded result is single-quoted, as if the dollar sign had +not been present. +.PP +A double-quoted string preceded by a dollar sign (\fB$\fP\(dq\fIstring\fP\(dq) +will cause the string to be translated according to the current locale. +If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign +is ignored. +If the string is translated and replaced, the replacement is +double-quoted. +.SH PARAMETERS +A +.I parameter +is an entity that stores values. +It can be a +.IR name , +a number, or one of the special characters listed below under +.BR "Special Parameters" . +A +.I variable +is a parameter denoted by a +.IR name . +A variable has a \fIvalue\fP and zero or more \fIattributes\fP. +Attributes are assigned using the +.B declare +builtin command (see +.B declare +below in +.SM +.BR "SHELL BUILTIN COMMANDS" ). +.PP +A parameter is set if it has been assigned a value. The null string is +a valid value. Once a variable is set, it may be unset only by using +the +.B unset +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.PP +A +.I variable +may be assigned to by a statement of the form +.RS +.PP +\fIname\fP=[\fIvalue\fP] +.RE +.PP +If +.I value +is not given, the variable is assigned the null string. All +.I values +undergo tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote +removal (see +.SM +.B EXPANSION +below). If the variable has its +.B integer +attribute set, then +.I value +is evaluated as an arithmetic expression even if the $((...)) expansion is +not used (see +.B "Arithmetic Expansion" +below). +Word splitting is not performed, with the exception +of \fB"$@"\fP as explained below under +.BR "Special Parameters" . +Pathname expansion is not performed. +Assignment statements may also appear as arguments to the +.BR alias , +.BR declare , +.BR typeset , +.BR export , +.BR readonly , +and +.B local +builtin commands. +When in \fIposix mode\fP, these builtins may appear in a command after +one or more instances of the \fBcommand\fP builtin and retain these +assignment statement properties. +.PP +In the context where an assignment statement is assigning a value +to a shell variable or array index, the += operator can be used to +append to or add to the variable's previous value. +When += is applied to a variable for which the \fIinteger\fP attribute has been +set, \fIvalue\fP is evaluated as an arithmetic expression and added to the +variable's current value, which is also evaluated. +When += is applied to an array variable using compound assignment (see +.B Arrays +below), the +variable's value is not unset (as it is when using =), and new values are +appended to the array beginning at one greater than the array's maximum index +(for indexed arrays) or added as additional key\-value pairs in an +associative array. +When applied to a string-valued variable, \fIvalue\fP is expanded and +appended to the variable's value. +.PP +A variable can be assigned the \fInameref\fP attribute using the +\fB\-n\fP option to the \fBdeclare\fP or \fBlocal\fP builtin commands +(see the descriptions of \fBdeclare\fP and \fBlocal\fP below) +to create a \fInameref\fP, or a reference to another variable. +This allows variables to be manipulated indirectly. +Whenever the nameref variable is referenced or assigned to, the operation +is actually performed on the variable specified by the nameref variable's +value. +A nameref is commonly used within shell functions to refer to a variable +whose name is passed as an argument to the function. +For instance, if a variable name is passed to a shell function as its first +argument, running +.sp .5 +.RS +.if t \f(CWdeclare -n ref=$1\fP +.if n declare -n ref=$1 +.RE +.sp .5 +inside the function creates a nameref variable \fBref\fP whose value is +the variable name passed as the first argument. +References and assignments to \fBref\fP are treated as references and +assignments to the variable whose name was passed as \fB$1\fP. +If the control variable in a \fBfor\fP loop has the nameref attribute, +the list of words can be a list of shell variables, and a name reference +will be established for each word in the list, in turn, when the loop is +executed. +Array variables cannot be given the \fB\-n\fP attribute. +However, nameref variables can reference array variables and subscripted +array variables. +Namerefs can be unset using the \fB\-n\fP option to the \fBunset\fP builtin. +Otherwise, if \fBunset\fP is executed with the name of a nameref variable +as an argument, the variable referenced by the nameref variable will be unset. +.SS Positional Parameters +.PP +A +.I positional parameter +is a parameter denoted by one or more +digits, other than the single digit 0. Positional parameters are +assigned from the shell's arguments when it is invoked, +and may be reassigned using the +.B set +builtin command. Positional parameters may not be assigned to +with assignment statements. The positional parameters are +temporarily replaced when a shell function is executed (see +.SM +.B FUNCTIONS +below). +.PP +When a positional parameter consisting of more than a single +digit is expanded, it must be enclosed in braces (see +.SM +.B EXPANSION +below). +.SS Special Parameters +.PP +The shell treats several parameters specially. These parameters may +only be referenced; assignment to them is not allowed. +.PD 0 +.TP +.B * +Expands to the positional parameters, starting from one. 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 +.SM +.B IFS +special variable. That is, "\fB$*\fP" is equivalent +to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where +.I c +is the first character of the value of the +.SM +.B IFS +variable. If +.SM +.B IFS +is unset, the parameters are separated by spaces. +If +.SM +.B IFS +is null, the parameters are joined without intervening separators. +.TP +.B @ +Expands to the positional parameters, starting from one. When the +expansion occurs within double quotes, each parameter expands to a +separate word. That is, "\fB$@\fP" is equivalent to +"\fB$1\fP" "\fB$2\fP" ... +If the double-quoted expansion occurs within a word, the expansion of +the first parameter is joined with the beginning part of the original +word, and the expansion of the last parameter is joined with the last +part of the original word. +When there are no positional parameters, "\fB$@\fP" and +.B $@ +expand to nothing (i.e., they are removed). +.TP +.B # +Expands to the number of positional parameters in decimal. +.TP +.B ? +Expands to the exit status of the most recently executed foreground +pipeline. +.TP +.B \- +Expands to the current option flags as specified upon invocation, +by the +.B set +builtin command, or those set by the shell itself +(such as the +.B \-i +option). +.TP +.B $ +Expands to the process ID of the shell. In a () subshell, it +expands to the process ID of the current shell, not the +subshell. +.TP +.B ! +Expands to the process ID of the most recently executed background +(asynchronous) command. +.TP +.B 0 +Expands to the name of the shell or shell script. This is set at +shell initialization. If +.B bash +is invoked with a file of commands, +.B $0 +is set to the name of that file. If +.B bash +is started with the +.B \-c +option, then +.B $0 +is set to the first argument after the string to be +executed, if one is present. Otherwise, it is set +to the filename used to invoke +.BR bash , +as given by argument zero. +.TP +.B _ +At shell startup, set to the absolute pathname used to invoke the +shell or shell script being executed as passed in the environment +or argument list. +Subsequently, expands to the last argument to the previous command, +after expansion. +Also set to the full pathname used to invoke each command executed +and placed in the environment exported to that command. +When checking mail, this parameter holds the name of the mail file +currently being checked. +.PD +.SS Shell Variables +.PP +The following variables are set by the shell: +.PP +.PD 0 +.TP +.B BASH +Expands to the full filename used to invoke this instance of +.BR bash . +.TP +.B BASHOPTS +A colon-separated list of enabled shell options. Each word in +the list is a valid argument for the +.B \-s +option to the +.B shopt +builtin command (see +.SM +.B "SHELL BUILTIN COMMANDS" +below). The options appearing in +.SM +.B BASHOPTS +are those reported as +.I on +by \fBshopt\fP. +If this variable is in the environment when +.B bash +starts up, each shell option in the list will be enabled before +reading any startup files. +This variable is read-only. +.TP +.B BASHPID +Expands to the process ID of the current \fBbash\fP process. +This differs from \fB$$\fP under certain circumstances, such as subshells +that do not require \fBbash\fP to be re-initialized. +.TP +.B BASH_ALIASES +An associative array variable whose members correspond to the internal +list of aliases as maintained by the \fBalias\fP builtin. +Elements added to this array appear in the alias list; unsetting array +elements cause aliases to be removed from the alias list. +.TP +.B BASH_ARGC +An array variable whose values are the number of parameters in each +frame of the current \fBbash\fP execution call stack. +The number of +parameters to the current subroutine (shell function or script executed +with \fB.\fP or \fBsource\fP) is at the top of the stack. +When a subroutine is executed, the number of parameters passed is pushed onto +.SM +.BR BASH_ARGC . +The shell sets +.SM +.B BASH_ARGC +only when in extended debugging mode (see the description of the +.B extdebug +option to the +.B shopt +builtin below) +.TP +.B BASH_ARGV +An array variable containing all of the parameters in the current \fBbash\fP +execution call stack. The final parameter of the last subroutine call +is at the top of the stack; the first parameter of the initial call is +at the bottom. When a subroutine is executed, the parameters supplied +are pushed onto +.SM +.BR BASH_ARGV . +The shell sets +.SM +.B BASH_ARGV +only when in extended debugging mode +(see the description of the +.B extdebug +option to the +.B shopt +builtin below) +.TP +.B BASH_CMDS +An associative array variable whose members correspond to the internal +hash table of commands as maintained by the \fBhash\fP builtin. +Elements added to this array appear in the hash table; unsetting array +elements cause commands to be removed from the hash table. +.TP +.B BASH_COMMAND +The command currently being executed or about to be executed, unless the +shell is executing a command as the result of a trap, +in which case it is the command executing at the time of the trap. +.TP +.B BASH_EXECUTION_STRING +The command argument to the \fB\-c\fP invocation option. +.TP +.B BASH_LINENO +An array variable whose members are the line numbers in source files +where each corresponding member of +.SM +.B FUNCNAME +was invoked. +\fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source +file (\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP) where +\fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called +(or \fB${BASH_LINENO[\fP\fI$i-1\fP\fB]}\fP if referenced within another +shell function). +Use +.SM +.B LINENO +to obtain the current line number. +.TP +.B BASH_REMATCH +An array variable whose members are assigned by the \fB=~\fP binary +operator to the \fB[[\fP conditional command. +The element with index 0 is the portion of the string +matching the entire regular expression. +The element with index \fIn\fP is the portion of the +string matching the \fIn\fPth parenthesized subexpression. +This variable is read-only. +.TP +.B BASH_SOURCE +An array variable whose members are the source filenames +where the corresponding shell function names in the +.SM +.B FUNCNAME +array variable are defined. +The shell function +\fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP is defined in the file +\fB${BASH_SOURCE[\fP\fI$i\fP\fB]}\fP and called from +\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP. +.TP +.B BASH_SUBSHELL +Incremented by one within each subshell or subshell environment when +the shell begins executing in that environment. +The initial value is 0. +.TP +.B BASH_VERSINFO +A readonly array variable whose members hold version information for +this instance of +.BR bash . +The values assigned to the array members are as follows: +.sp .5 +.RS +.TP 24 +.B BASH_VERSINFO[\fR0\fP] +The major version number (the \fIrelease\fP). +.TP +.B BASH_VERSINFO[\fR1\fP] +The minor version number (the \fIversion\fP). +.TP +.B BASH_VERSINFO[\fR2\fP] +The patch level. +.TP +.B BASH_VERSINFO[\fR3\fP] +The build version. +.TP +.B BASH_VERSINFO[\fR4\fP] +The release status (e.g., \fIbeta1\fP). +.TP +.B BASH_VERSINFO[\fR5\fP] +The value of +.SM +.BR MACHTYPE . +.RE +.TP +.B BASH_VERSION +Expands to a string describing the version of this instance of +.BR bash . +.TP +.B COMP_CWORD +An index into \fB${COMP_WORDS}\fP of the word containing the current +cursor position. +This variable is available only in shell functions invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B COMP_KEY +The key (or final key of a key sequence) used to invoke the current +completion function. +.TP +.B COMP_LINE +The current command line. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B COMP_POINT +The index of the current cursor position relative to the beginning of +the current command. +If the current cursor position is at the end of the current command, +the value of this variable is equal to \fB${#COMP_LINE}\fP. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B COMP_TYPE +Set to an integer value corresponding to the type of completion attempted +that caused a completion function to be called: +\fITAB\fP, for normal completion, +\fI?\fP, for listing completions after successive tabs, +\fI!\fP, for listing alternatives on partial word completion, +\fI@\fP, to list completions if the word is not unmodified, +or +\fI%\fP, for menu completion. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B COMP_WORDBREAKS +The set of characters that the \fBreadline\fP library treats as word +separators when performing word completion. +If +.SM +.B COMP_WORDBREAKS +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B COMP_WORDS +An array variable (see \fBArrays\fP below) consisting of the individual +words in the current command line. +The line is split into words as \fBreadline\fP would split it, using +.SM +.B COMP_WORDBREAKS +as described above. +This variable is available only in shell functions invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B COPROC +An array variable (see \fBArrays\fP below) created to hold the file descriptors +for output from and input to an unnamed coprocess (see \fBCoprocesses\fP +above). +.TP +.B DIRSTACK +An array variable (see +.B Arrays +below) containing the current contents of the directory stack. +Directories appear in the stack in the order they are displayed by the +.B dirs +builtin. +Assigning to members of this array variable may be used to modify +directories already in the stack, but the +.B pushd +and +.B popd +builtins must be used to add and remove directories. +Assignment to this variable will not change the current directory. +If +.SM +.B DIRSTACK +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B EUID +Expands to the effective user ID of the current user, initialized at +shell startup. This variable is readonly. +.TP +.B FUNCNAME +An array variable containing the names of all shell functions +currently in the execution call stack. +The element with index 0 is the name of any currently-executing +shell function. +The bottom-most element (the one with the highest index) is +.if t \f(CW"main"\fP. +.if n "main". +This variable exists only when a shell function is executing. +Assignments to +.SM +.B FUNCNAME +have no effect and return an error status. +If +.SM +.B FUNCNAME +is unset, it loses its special properties, even if it is +subsequently reset. +.if t .sp 0.5 +.if n .sp 1 +This variable can be used with \fBBASH_LINENO\fP and \fBBASH_SOURCE\fP. +Each element of \fBFUNCNAME\fP has corresponding elements in +\fBBASH_LINENO\fP and \fBBASH_SOURCE\fP to describe the call stack. +For instance, \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called from the file +\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP at line number +\fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP. +The \fBcaller\fP builtin displays the current call stack using this +information. +.TP +.B GROUPS +An array variable containing the list of groups of which the current +user is a member. +Assignments to +.SM +.B GROUPS +have no effect and return an error status. +If +.SM +.B GROUPS +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B HISTCMD +The history number, or index in the history list, of the current +command. +If +.SM +.B HISTCMD +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B HOSTNAME +Automatically set to the name of the current host. +.TP +.B HOSTTYPE +Automatically set to a string that uniquely +describes the type of machine on which +.B bash +is executing. +The default is system-dependent. +.TP +.B LINENO +Each time this parameter is referenced, the shell substitutes +a decimal number representing the current sequential line number +(starting with 1) within a script or function. When not in a +script or function, the value substituted is not guaranteed to +be meaningful. +If +.SM +.B LINENO +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B MACHTYPE +Automatically set to a string that fully describes the system +type on which +.B bash +is executing, in the standard GNU \fIcpu-company-system\fP format. +The default is system-dependent. +.TP +.B MAPFILE +An array variable (see \fBArrays\fP below) created to hold the text +read by the \fBmapfile\fP builtin when no variable name is supplied. +.TP +.B OLDPWD +The previous working directory as set by the +.B cd +command. +.TP +.B OPTARG +The value of the last option argument processed by the +.B getopts +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.TP +.B OPTIND +The index of the next argument to be processed by the +.B getopts +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.TP +.B OSTYPE +Automatically set to a string that +describes the operating system on which +.B bash +is executing. +The default is system-dependent. +.TP +.B PIPESTATUS +An array variable (see +.B Arrays +below) containing a list of exit status values from the processes +in the most-recently-executed foreground pipeline (which may +contain only a single command). +.TP +.B PPID +The process ID of the shell's parent. This variable is readonly. +.TP +.B PWD +The current working directory as set by the +.B cd +command. +.TP +.B RANDOM +Each time this parameter is referenced, a random integer between +0 and 32767 is +generated. The sequence of random numbers may be initialized by assigning +a value to +.SM +.BR RANDOM . +If +.SM +.B RANDOM +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B READLINE_LINE +The contents of the +.B readline +line buffer, for use with +.if t \f(CWbind -x\fP +.if n "bind -x" +(see +.SM +.B "SHELL BUILTIN COMMANDS" +below). +.TP +.B READLINE_POINT +The position of the insertion point in the +.B readline +line buffer, for use with +.if t \f(CWbind -x\fP +.if n "bind -x" +(see +.SM +.B "SHELL BUILTIN COMMANDS" +below). +.TP +.B REPLY +Set to the line of input read by the +.B read +builtin command when no arguments are supplied. +.TP +.B SECONDS +Each time this parameter is +referenced, the number of seconds since shell invocation is returned. If a +value is assigned to +.SM +.BR SECONDS , +the value returned upon subsequent +references is +the number of seconds since the assignment plus the value assigned. +If +.SM +.B SECONDS +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B SHELLOPTS +A colon-separated list of enabled shell options. Each word in +the list is a valid argument for the +.B \-o +option to the +.B set +builtin command (see +.SM +.B "SHELL BUILTIN COMMANDS" +below). The options appearing in +.SM +.B SHELLOPTS +are those reported as +.I on +by \fBset \-o\fP. +If this variable is in the environment when +.B bash +starts up, each shell option in the list will be enabled before +reading any startup files. +This variable is read-only. +.TP +.B SHLVL +Incremented by one each time an instance of +.B bash +is started. +.TP +.B UID +Expands to the user ID of the current user, initialized at shell startup. +This variable is readonly. +.PD +.PP +The following variables are used by the shell. In some cases, +.B bash +assigns a default value to a variable; these cases are noted +below. +.PP +.PD 0 +.TP +.B BASH_ENV +If this parameter is set when \fBbash\fP is executing a shell script, +its value is interpreted as a filename containing commands to +initialize the shell, as in +.IR ~/.bashrc . +The value of +.SM +.B BASH_ENV +is subjected to parameter expansion, command substitution, and arithmetic +expansion before being interpreted as a filename. +.SM +.B PATH +is not used to search for the resultant filename. +.TP +.B BASH_XTRACEFD +If set to an integer corresponding to a valid file descriptor, \fBbash\fP +will write the trace output generated when +.if t \f(CWset -x\fP +.if n \fIset -x\fP +is enabled to that file descriptor. +The file descriptor is closed when +.SM +.B BASH_XTRACEFD +is unset or assigned a new value. +Unsetting +.SM +.B BASH_XTRACEFD +or assigning it the empty string causes the +trace output to be sent to the standard error. +Note that setting +.SM +.B BASH_XTRACEFD +to 2 (the standard error file +descriptor) and then unsetting it will result in the standard error +being closed. +.TP +.B CDPATH +The search path for the +.B cd +command. +This is a colon-separated list of directories in which the shell looks +for destination directories specified by the +.B cd +command. +A sample value is +.if t \f(CW".:~:/usr"\fP. +.if n ".:~:/usr". +.TP +.B CHILD_MAX +Set the number of exited child status values for the shell to remember. +Bash will not allow this value to be decreased below a Posix-mandated +minimum, and there is a maximum value (currently 8192) that this may +not exceed. +The minimum value is system-dependent. +.TP +.B COLUMNS +Used by the \fBselect\fP compound command to determine the terminal width +when printing selection lists. Automatically set in an interactive shell +upon receipt of a +.SM +.BR SIGWINCH . +.TP +.B COMPREPLY +An array variable from which \fBbash\fP reads the possible completions +generated by a shell function invoked by the programmable completion +facility (see \fBProgrammable Completion\fP below). +Each array element contains one possible completion. +.TP +.B EMACS +If \fBbash\fP finds this variable in the environment when the shell starts +with value +.if t \f(CWt\fP, +.if n "t", +it assumes that the shell is running in an Emacs shell buffer and disables +line editing. +.TP +.B ENV +Similar to +.SM +.BR BASH_ENV ; +used when the shell is invoked in POSIX mode. +.TP +.B FCEDIT +The default editor for the +.B fc +builtin command. +.TP +.B FIGNORE +A colon-separated list of suffixes to ignore when performing +filename completion (see +.SM +.B READLINE +below). +A filename whose suffix matches one of the entries in +.SM +.B FIGNORE +is excluded from the list of matched filenames. +A sample value is +.if t \f(CW".o:~"\fP. +.if n ".o:~". +.TP +.B FUNCNEST +If set to a numeric value greater than 0, defines a maximum function +nesting level. Function invocations that exceed this nesting level +will cause the current command to abort. +.TP +.B GLOBIGNORE +A colon-separated list of patterns defining the set of filenames to +be ignored by pathname expansion. +If a filename matched by a pathname expansion pattern also matches one +of the patterns in +.SM +.BR GLOBIGNORE , +it is removed from the list of matches. +.TP +.B HISTCONTROL +A colon-separated list of values controlling how commands are saved on +the history list. +If the list of values includes +.IR ignorespace , +lines which begin with a +.B space +character are not saved in the history list. +A value of +.I ignoredups +causes lines matching the previous history entry to not be saved. +A value of +.I ignoreboth +is shorthand for \fIignorespace\fP and \fIignoredups\fP. +A value of +.IR erasedups +causes all previous lines matching the current line to be removed from +the history list before that line is saved. +Any value not in the above list is ignored. +If +.SM +.B HISTCONTROL +is unset, or does not include a valid value, +all lines read by the shell parser are saved on the history list, +subject to the value of +.SM +.BR HISTIGNORE . +The second and subsequent lines of a multi-line compound command are +not tested, and are added to the history regardless of the value of +.SM +.BR HISTCONTROL . +.TP +.B HISTFILE +The name of the file in which command history is saved (see +.SM +.B HISTORY +below). The default value is \fI~/.bash_history\fP. If unset, the +command history is not saved when a shell exits. +.TP +.B HISTFILESIZE +The maximum number of lines contained in the history file. When this +variable is assigned a value, the history file is truncated, if +necessary, +to contain no more than that number of lines by removing the oldest entries. +The history file is also truncated to this size after +writing it when a shell exits. +If the value is 0, the history file is truncated to zero size. +Non-numeric values and numeric values less than zero inhibit truncation. +The shell sets the default value to the value of \fBHISTSIZE\fP +after reading any startup files. +.TP +.B HISTIGNORE +A colon-separated list of patterns used to decide which command lines +should be saved on the history list. Each pattern is anchored at the +beginning of the line and must match the complete line (no implicit +`\fB*\fP' is appended). Each pattern is tested against the line +after the checks specified by +.SM +.B HISTCONTROL +are applied. +In addition to the normal shell pattern matching characters, `\fB&\fP' +matches the previous history line. `\fB&\fP' may be escaped using a +backslash; the backslash is removed before attempting a match. +The second and subsequent lines of a multi-line compound command are +not tested, and are added to the history regardless of the value of +.SM +.BR HISTIGNORE . +.TP +.B HISTSIZE +The number of commands to remember in the command history (see +.SM +.B HISTORY +below). +If the value is 0, commands are not saved in the history list. +Numeric values less than zero result in every command being saved +on the history list (there is no limit). +The shell sets the default value to 500 after reading any startup files. +.TP +.B HISTTIMEFORMAT +If this variable is set and not null, its value is used as a format string +for \fIstrftime\fP(3) to print the time stamp associated with each history +entry displayed by the \fBhistory\fP builtin. +If this variable is set, time stamps are written to the history file so +they may be preserved across shell sessions. +This uses the history comment character to distinguish timestamps from +other history lines. +.TP +.B HOME +The home directory of the current user; the default argument for the +\fBcd\fP builtin command. +The value of this variable is also used when performing tilde expansion. +.TP +.B HOSTFILE +Contains the name of a file in the same format as +.FN /etc/hosts +that should be read when the shell needs to complete a +hostname. +The list of possible hostname completions may be changed while the +shell is running; +the next time hostname completion is attempted after the +value is changed, +.B bash +adds the contents of the new file to the existing list. +If +.SM +.B HOSTFILE +is set, but has no value, or does not name a readable file, +\fBbash\fP attempts to read +.FN /etc/hosts +to obtain the list of possible hostname completions. +When +.SM +.B HOSTFILE +is unset, the hostname list is cleared. +.TP +.B IFS +The +.I Internal Field Separator +that is used +for word splitting after expansion and to +split lines into words with the +.B read +builtin command. The default value is +``''. +.TP +.B IGNOREEOF +Controls the +action of an interactive shell on receipt of an +.SM +.B EOF +character as the sole input. If set, the value is the number of +consecutive +.SM +.B EOF +characters which must be +typed as the first characters on an input line before +.B bash +exits. If the variable exists but does not have a numeric value, or +has no value, the default value is 10. If it does not exist, +.SM +.B EOF +signifies the end of input to the shell. +.TP +.B INPUTRC +The filename for the +.B readline +startup file, overriding the default of +.FN ~/.inputrc +(see +.SM +.B READLINE +below). +.TP +.B LANG +Used to determine the locale category for any category not specifically +selected with a variable starting with \fBLC_\fP. +.TP +.B LC_ALL +This variable overrides the value of +.SM +.B LANG +and any other +\fBLC_\fP variable specifying a locale category. +.TP +.B LC_COLLATE +This variable determines the collation order used when sorting the +results of pathname expansion, and determines the behavior of range +expressions, equivalence classes, and collating sequences within +pathname expansion and pattern matching. +.TP +.B LC_CTYPE +This variable determines the interpretation of characters and the +behavior of character classes within pathname expansion and pattern +matching. +.TP +.B LC_MESSAGES +This variable determines the locale used to translate double-quoted +strings preceded by a \fB$\fP. +.TP +.B LC_NUMERIC +This variable determines the locale category used for number formatting. +.TP +.B LINES +Used by the \fBselect\fP compound command to determine the column length +for printing selection lists. Automatically set by an interactive shell +upon receipt of a +.SM +.BR SIGWINCH . +.TP +.B MAIL +If this parameter is set to a file or directory name and the +.SM +.B MAILPATH +variable is not set, +.B bash +informs the user of the arrival of mail in the specified file or +Maildir-format directory. +.TP +.B MAILCHECK +Specifies how +often (in seconds) +.B bash +checks for mail. The default is 60 seconds. When it is time to check +for mail, the shell does so before displaying the primary prompt. +If this variable is unset, or set to a value that is not a number +greater than or equal to zero, the shell disables mail checking. +.TP +.B MAILPATH +A colon-separated list of filenames to be checked for mail. +The message to be printed when mail arrives in a particular file +may be specified by separating the filename from the message with a `?'. +When used in the text of the message, \fB$_\fP expands to the name of +the current mailfile. +Example: +.RS +.PP +\fBMAILPATH\fP=\(aq/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"\(aq +.PP +.B Bash +supplies a default value for this variable, but the location of the user +mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP). +.RE +.TP +.B OPTERR +If set to the value 1, +.B bash +displays error messages generated by the +.B getopts +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.SM +.B OPTERR +is initialized to 1 each time the shell is invoked or a shell +script is executed. +.TP +.B PATH +The search path for commands. It +is a colon-separated list of directories in which +the shell looks for commands (see +.SM +.B COMMAND EXECUTION +below). +A zero-length (null) directory name in the value of +.SM +.B PATH +indicates the current directory. +A null directory name may appear as two adjacent colons, or as an initial +or trailing colon. +The default path is system-dependent, +and is set by the administrator who installs +.BR bash . +A common value is +.if t \f(CW/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin\fP. +.if n ``/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''. +.TP +.B POSIXLY_CORRECT +If this variable is in the environment when \fBbash\fP starts, the shell +enters \fIposix mode\fP before reading the startup files, as if the +.B \-\-posix +invocation option had been supplied. If it is set while the shell is +running, \fBbash\fP enables \fIposix mode\fP, as if the command +.if t \f(CWset -o posix\fP +.if n \fIset -o posix\fP +had been executed. +.TP +.B PROMPT_COMMAND +If set, the value is executed as a command prior to issuing each primary +prompt. +.TP +.B PROMPT_DIRTRIM +If set to a number greater than zero, the value is used as the number of +trailing directory components to retain when expanding the \fB\ew\fP and +\fB\eW\fP prompt string escapes (see +.SM +.B PROMPTING +below). Characters removed are replaced with an ellipsis. +.TP +.B PS1 +The value of this parameter is expanded (see +.SM +.B PROMPTING +below) and used as the primary prompt string. The default value is +``\fB\es\-\ev\e$ \fP''. +.TP +.B PS2 +The value of this parameter is expanded as with +.SM +.B PS1 +and used as the secondary prompt string. The default is +``\fB> \fP''. +.TP +.B PS3 +The value of this parameter is used as the prompt for the +.B select +command (see +.SM +.B SHELL GRAMMAR +above). +.TP +.B PS4 +The value of this parameter is expanded as with +.SM +.B PS1 +and the value is printed before each command +.B bash +displays during an execution trace. The first character of +.SM +.B PS4 +is replicated multiple times, as necessary, to indicate multiple +levels of indirection. The default is ``\fB+ \fP''. +.TP +.B SHELL +The full pathname to the shell is kept in this environment variable. +If it is not set when the shell starts, +.B bash +assigns to it the full pathname of the current user's login shell. +.TP +.B TIMEFORMAT +The value of this parameter is used as a format string specifying +how the timing information for pipelines prefixed with the +.B time +reserved word should be displayed. +The \fB%\fP character introduces an escape sequence that is +expanded to a time value or other information. +The escape sequences and their meanings are as follows; the +braces denote optional portions. +.sp .5 +.RS +.PD 0 +.TP 10 +.B %% +A literal \fB%\fP. +.TP +.B %[\fIp\fP][l]R +The elapsed time in seconds. +.TP +.B %[\fIp\fP][l]U +The number of CPU seconds spent in user mode. +.TP +.B %[\fIp\fP][l]S +The number of CPU seconds spent in system mode. +.TP +.B %P +The CPU percentage, computed as (%U + %S) / %R. +.PD +.RE +.IP +The optional \fIp\fP is a digit specifying the \fIprecision\fP, +the number of fractional digits after a decimal point. +A value of 0 causes no decimal point or fraction to be output. +At most three places after the decimal point may be specified; +values of \fIp\fP greater than 3 are changed to 3. +If \fIp\fP is not specified, the value 3 is used. +.IP +The optional \fBl\fP specifies a longer format, including +minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs. +The value of \fIp\fP determines whether or not the fraction is +included. +.IP +If this variable is not set, \fBbash\fP acts as if it had the +value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\e\t%3lS\(aq\fP. +If the value is null, no timing information is displayed. +A trailing newline is added when the format string is displayed. +.PD 0 +.TP +.B TMOUT +If set to a value greater than zero, +.SM +.B TMOUT +is treated as the +default timeout for the \fBread\fP builtin. +The \fBselect\fP command terminates if input does not arrive +after +.SM +.B TMOUT +seconds when input is coming from a terminal. +In an interactive shell, the value is interpreted as the +number of seconds to wait for a line of input after issuing the +primary prompt. +.B Bash +terminates after waiting for that number of seconds if a complete +line of input does not arrive. +.TP +.B TMPDIR +If set, \fBbash\fP uses its value as the name of a directory in which +\fBbash\fP creates temporary files for the shell's use. +.TP +.B auto_resume +This variable controls how the shell interacts with the user and +job control. If this variable is set, single word simple +commands without redirections are treated as candidates for resumption +of an existing stopped job. There is no ambiguity allowed; if there is +more than one job beginning with the string typed, the job most recently +accessed is selected. The +.I name +of a stopped job, in this context, is the command line used to +start it. +If set to the value +.IR exact , +the string supplied must match the name of a stopped job exactly; +if set to +.IR substring , +the string supplied needs to match a substring of the name of a +stopped job. The +.I substring +value provides functionality analogous to the +.B %? +job identifier (see +.SM +.B JOB CONTROL +below). If set to any other value, the supplied string must +be a prefix of a stopped job's name; this provides functionality +analogous to the \fB%\fP\fIstring\fP job identifier. +.TP +.B histchars +The two or three characters which control history expansion +and tokenization (see +.SM +.B HISTORY EXPANSION +below). The first character is the \fIhistory expansion\fP character, +the character which signals the start of a history +expansion, normally `\fB!\fP'. +The second character is the \fIquick substitution\fP +character, which is used as shorthand for re-running the previous +command entered, substituting one string for another in the command. +The default is `\fB^\fP'. +The optional third character is the character +which indicates that the remainder of the line is a comment when found +as the first character of a word, normally `\fB#\fP'. The history +comment character causes history substitution to be skipped for the +remaining words on the line. It does not necessarily cause the shell +parser to treat the rest of the line as a comment. +.PD +.SS Arrays +.B Bash +provides one-dimensional indexed and associative array variables. +Any variable may be used as an indexed array; the +.B declare +builtin will explicitly declare an array. +There is no maximum +limit on the size of an array, nor any requirement that members +be indexed or assigned contiguously. +Indexed arrays are referenced using integers (including arithmetic +expressions) and are zero-based; associative arrays are referenced +using arbitrary strings. +Unless otherwise noted, indexed array indices must be non-negative integers. +.PP +An indexed array is created automatically if any variable is assigned to +using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The +.I subscript +is treated as an arithmetic expression that must evaluate to a number. +To explicitly declare an indexed array, use +.B declare \-a \fIname\fP +(see +.SM +.B SHELL BUILTIN COMMANDS +below). +.B declare \-a \fIname\fP[\fIsubscript\fP] +is also accepted; the \fIsubscript\fP is ignored. +.PP +Associative arrays are created using +.BR "declare \-A \fIname\fP" . +.PP +Attributes may be +specified for an array variable using the +.B declare +and +.B readonly +builtins. Each attribute applies to all members of an array. +.PP +Arrays are assigned to using compound assignments of the form +\fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each +\fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. +Indexed array assignments do not require anything but \fIstring\fP. +When assigning to indexed arrays, if the optional brackets and subscript +are supplied, that index is assigned to; +otherwise the index of the element assigned is the last index assigned +to by the statement plus one. Indexing starts at zero. +.PP +When assigning to an associative array, the subscript is required. +.PP +This syntax is also accepted by the +.B declare +builtin. Individual array elements may be assigned to using the +\fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above. +When assigning to an indexed array, if +.I name +is subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +\fIname\fP, so negative indices count back from the end of the +array, and an index of \-1 references the last element. +.PP +Any element of an array may be referenced using +${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid +conflicts with pathname expansion. If +\fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to +all members of \fIname\fP. These subscripts differ only when the +word appears within double quotes. If the word is double-quoted, +${\fIname\fP[*]} expands to a single +word with the value of each array member separated by the first +character of the +.SM +.B IFS +special variable, and ${\fIname\fP[@]} expands each element of +\fIname\fP to a separate word. When there are no array members, +${\fIname\fP[@]} expands to nothing. +If the double-quoted expansion occurs within a word, the expansion of +the first parameter is joined with the beginning part of the original +word, and the expansion of the last parameter is joined with the last +part of the original word. +This is analogous to the expansion +of the special parameters \fB*\fP and \fB@\fP (see +.B Special Parameters +above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of +${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or +\fB@\fP, the expansion is the number of elements in the array. +Referencing an array variable without a subscript is equivalent to +referencing the array with a subscript of 0. +If the +.I subscript +used to reference an element of an indexed array +evaluates to a number less than zero, it is +interpreted as relative to one greater than the maximum index of the array, +so negative indices count back from the end of the +array, and an index of \-1 references the last element. +.PP +An array variable is considered set if a subscript has been assigned a +value. The null string is a valid value. +.PP +The +.B unset +builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP] +destroys the array element at index \fIsubscript\fP. +Negative subscripts to indexed arrays are interpreted as described above. +Care must be taken to avoid unwanted side effects caused by pathname +expansion. +\fBunset\fP \fIname\fP, where \fIname\fP is an array, or +\fBunset\fP \fIname\fP[\fIsubscript\fP], where +\fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array. +.PP +The +.BR declare , +.BR local , +and +.B readonly +builtins each accept a +.B \-a +option to specify an indexed array and a +.B \-A +option to specify an associative array. +If both options are supplied, +.B \-A +takes precedence. +The +.B read +builtin accepts a +.B \-a +option to assign a list of words read from the standard input +to an array. The +.B set +and +.B declare +builtins display array values in a way that allows them to be +reused as assignments. +.SH EXPANSION +Expansion is performed on the command line after it has been split into +words. There are seven kinds of expansion performed: +.IR "brace expansion" , +.IR "tilde expansion" , +.IR "parameter and variable expansion" , +.IR "command substitution" , +.IR "arithmetic expansion" , +.IR "word splitting" , +and +.IR "pathname expansion" . +.PP +The order of expansions is: brace expansion, tilde expansion, +parameter, variable and arithmetic expansion and +command substitution +(done in a left-to-right fashion), word splitting, and pathname +expansion. +.PP +On systems that can support it, there is an additional expansion +available: \fIprocess substitution\fP. +.PP +Only brace expansion, word splitting, and pathname expansion +can change the number of words of the expansion; other expansions +expand a single word to a single word. +The only exceptions to this are the expansions of +"\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP" +as explained above (see +.SM +.BR PARAMETERS ). +.SS Brace Expansion +.PP +.I "Brace expansion" +is a mechanism by which arbitrary strings +may be generated. This mechanism is similar to +\fIpathname expansion\fP, but the filenames generated +need not exist. Patterns to be brace expanded take +the form of an optional +.IR preamble , +followed by either a series of comma-separated strings or +a sequence expression between a pair of braces, followed by +an optional +.IR postscript . +The preamble is prefixed to each string contained +within the braces, and the postscript is then appended +to each resulting string, expanding left to right. +.PP +Brace expansions may be nested. The results of each expanded +string are not sorted; left to right order is preserved. +For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'. +.PP +A sequence expression takes the form +\fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB[..\fP\fIincr\fP\fB]}\fP, +where \fIx\fP and \fIy\fP are either integers or single characters, +and \fIincr\fP, an optional increment, is an integer. +When integers are supplied, the expression expands to each number between +\fIx\fP and \fIy\fP, inclusive. +Supplied integers may be prefixed with \fI0\fP to force each term to have the +same width. +When either \fIx\fP or \fPy\fP begins with a zero, the shell +attempts to force all generated terms to contain the same number of digits, +zero-padding where necessary. +When characters are supplied, the expression expands to each character +lexicographically between \fIx\fP and \fIy\fP, inclusive, +using the default C locale. +Note that both \fIx\fP and \fIy\fP must be of the same type. +When the increment is supplied, it is used as the difference between +each term. The default increment is 1 or -1 as appropriate. +.PP +Brace expansion is performed before any other expansions, +and any characters special to other expansions are preserved +in the result. It is strictly textual. +.B Bash +does not apply any syntactic interpretation to the context of the +expansion or the text between the braces. +.PP +A correctly-formed brace expansion must contain unquoted opening +and closing braces, and at least one unquoted comma or a valid +sequence expression. +Any incorrectly formed brace expansion is left unchanged. +A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its +being considered part of a brace expression. +To avoid conflicts with parameter expansion, the string \fB${\fP +is not considered eligible for brace expansion. +.PP +This construct is typically used as shorthand when the common +prefix of the strings to be generated is longer than in the +above example: +.RS +.PP +mkdir /usr/local/src/bash/{old,new,dist,bugs} +.RE +or +.RS +chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} +.RE +.PP +Brace expansion introduces a slight incompatibility with +historical versions of +.BR sh . +.B sh +does not treat opening or closing braces specially when they +appear as part of a word, and preserves them in the output. +.B Bash +removes braces from words as a consequence of brace +expansion. For example, a word entered to +.B sh +as \fIfile{1,2}\fP +appears identically in the output. The same word is +output as +.I file1 file2 +after expansion by +.BR bash . +If strict compatibility with +.B sh +is desired, start +.B bash +with the +.B +B +option or disable brace expansion with the +.B +B +option to the +.B set +command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.SS Tilde Expansion +.PP +If a word begins with an unquoted tilde character (`\fB~\fP'), all of +the characters preceding the first unquoted slash (or all characters, +if there is no unquoted slash) are considered a \fItilde-prefix\fP. +If none of the characters in the tilde-prefix are quoted, the +characters in the tilde-prefix following the tilde are treated as a +possible \fIlogin name\fP. +If this login name is the null string, the tilde is replaced with the +value of the shell parameter +.SM +.BR HOME . +If +.SM +.B HOME +is unset, the home directory of the user executing the shell is +substituted instead. +Otherwise, the tilde-prefix is replaced with the home directory +associated with the specified login name. +.PP +If the tilde-prefix is a `~+', the value of the shell variable +.SM +.B PWD +replaces the tilde-prefix. +If the tilde-prefix is a `~\-', the value of the shell variable +.SM +.BR OLDPWD , +if it is set, is substituted. +If the characters following the tilde in the tilde-prefix consist +of a number \fIN\fP, optionally prefixed +by a `+' or a `\-', the tilde-prefix is replaced with the corresponding +element from the directory stack, as it would be displayed by the +.B dirs +builtin invoked with the tilde-prefix as an argument. +If the characters following the tilde in the tilde-prefix consist of a +number without a leading `+' or `\-', `+' is assumed. +.PP +If the login name is invalid, or the tilde expansion fails, the word +is unchanged. +.PP +Each variable assignment is checked for unquoted tilde-prefixes immediately +following a +.B : +or the first +.BR = . +In these cases, tilde expansion is also performed. +Consequently, one may use filenames with tildes in assignments to +.SM +.BR PATH , +.SM +.BR MAILPATH , +and +.SM +.BR CDPATH , +and the shell assigns the expanded value. +.SS Parameter Expansion +.PP +The `\fB$\fP' character introduces parameter expansion, +command substitution, or arithmetic expansion. The parameter name +or symbol to be expanded may be enclosed in braces, which +are optional but serve to protect the variable to be expanded from +characters immediately following it which could be +interpreted as part of the name. +.PP +When braces are used, the matching ending brace is the first `\fB}\fP' +not escaped by a backslash or within a quoted string, and not within an +embedded arithmetic expansion, command substitution, or parameter +expansion. +.PP +.PD 0 +.TP +${\fIparameter\fP} +The value of \fIparameter\fP is substituted. The braces are required +when +.I parameter +is a positional parameter with more than one digit, +or when +.I parameter +is followed by a character which is not to be +interpreted as part of its name. +The \fIparameter\fP is a shell parameter as described above +\fBPARAMETERS\fP) or an array reference (\fBArrays\fP). +.PD +.PP +If the first character of \fIparameter\fP is an exclamation point (\fB!\fP), +it introduces a level of variable indirection. +\fBBash\fP uses the value of the variable formed from the rest of +\fIparameter\fP as the name of the variable; this variable is then +expanded and that value is used in the rest of the substitution, rather +than the value of \fIparameter\fP itself. +This is known as \fIindirect expansion\fP. +The exceptions to this are the expansions of ${\fB!\fP\fIprefix\fP\fB*\fP} and +${\fB!\fP\fIname\fP[\fI@\fP]} described below. +The exclamation point must immediately follow the left brace in order to +introduce indirection. +.PP +In each of the cases below, \fIword\fP is subject to tilde expansion, +parameter expansion, command substitution, and arithmetic expansion. +.PP +When not performing substring expansion, using the forms documented below +(e.g., \fB:-\fP), +\fBbash\fP tests for a parameter that is unset or null. Omitting the colon +results in a test only for a parameter that is unset. +.PP +.PD 0 +.TP +${\fIparameter\fP\fB:\-\fP\fIword\fP} +\fBUse Default Values\fP. If +.I parameter +is unset or null, the expansion of +.I word +is substituted. Otherwise, the value of +.I parameter +is substituted. +.TP +${\fIparameter\fP\fB:=\fP\fIword\fP} +\fBAssign Default Values\fP. +If +.I parameter +is unset or null, the expansion of +.I word +is assigned to +.IR parameter . +The value of +.I parameter +is then substituted. Positional parameters and special parameters may +not be assigned to in this way. +.TP +${\fIparameter\fP\fB:?\fP\fIword\fP} +\fBDisplay Error if Null or Unset\fP. +If +.I parameter +is null or unset, the expansion of \fIword\fP (or a message to that effect +if +.I word +is not present) is written to the standard error and the shell, if it +is not interactive, exits. Otherwise, the value of \fIparameter\fP is +substituted. +.TP +${\fIparameter\fP\fB:+\fP\fIword\fP} +\fBUse Alternate Value\fP. +If +.I parameter +is null or unset, nothing is substituted, otherwise the expansion of +.I word +is substituted. +.TP +${\fIparameter\fP\fB:\fP\fIoffset\fP} +.PD 0 +.TP +${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP} +.PD +\fBSubstring Expansion\fP. +Expands to up to \fIlength\fP characters of the value of \fIparameter\fP +starting at the character specified by \fIoffset\fP. +If \fIparameter\fP is \fB@\fP, an indexed array subscripted by +\fB@\fP or \fB*\fP, or an associative array name, the results differ as +described below. +If \fIlength\fP is omitted, expands to the substring of the value of +\fIparameter\fP starting at the character specified by \fIoffset\fP +and extending to the end of the value. +\fIlength\fP and \fIoffset\fP are arithmetic expressions (see +.SM +.B +ARITHMETIC EVALUATION +below). +.sp 1 +If \fIoffset\fP evaluates to a number less than zero, the value +is used as an offset in characters +from the end of the value of \fIparameter\fP. +If \fIlength\fP evaluates to a number less than zero, +it is interpreted as an offset in characters +from the end of the value of \fIparameter\fP rather than +a number of characters, and the expansion is the characters between +\fIoffset\fP and that result. +Note that a negative offset must be separated from the colon by at least +one space to avoid being confused with the \fB:-\fP expansion. +.sp 1 +If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional +parameters beginning at \fIoffset\fP. +A negative \fIoffset\fP is taken relative to one greater than the greatest +positional parameter, so an offset of -1 evaluates to the last positional +parameter. +It is an expansion error if \fIlength\fP evaluates to a number less than +zero. +.sp 1 +If \fIparameter\fP is an indexed array name subscripted by @ or *, +the result is the \fIlength\fP +members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}. +A negative \fIoffset\fP is taken relative to one greater than the maximum +index of the specified array. +It is an expansion error if \fIlength\fP evaluates to a number less than +zero. +.sp 1 +Substring expansion applied to an associative array produces undefined +results. +.sp 1 +Substring indexing is zero-based unless the positional parameters +are used, in which case the indexing starts at 1 by default. +If \fIoffset\fP is 0, and the positional parameters are used, \fB$0\fP is +prefixed to the list. +.TP +${\fB!\fP\fIprefix\fP\fB*\fP} +.PD 0 +.TP +${\fB!\fP\fIprefix\fP\fB@\fP} +.PD +\fBNames matching prefix\fP. +Expands to the names of variables whose names begin with \fIprefix\fP, +separated by the first character of the +.SM +.B IFS +special variable. +When \fI@\fP is used and the expansion appears within double quotes, each +variable name expands to a separate word. +.TP +${\fB!\fP\fIname\fP[\fI@\fP]} +.PD 0 +.TP +${\fB!\fP\fIname\fP[\fI*\fP]} +.PD +\fBList of array keys\fP. +If \fIname\fP is an array variable, expands to the list of array indices +(keys) assigned in \fIname\fP. +If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null +otherwise. +When \fI@\fP is used and the expansion appears within double quotes, each +key expands to a separate word. +.TP +${\fB#\fP\fIparameter\fP} +\fBParameter length\fP. +The length in characters of the value of \fIparameter\fP is substituted. +If +.I parameter +is +.B * +or +.BR @ , +the value substituted is the number of positional parameters. +If +.I parameter +is an array name subscripted by +.B * +or +.BR @ , +the value substituted is the number of elements in the array. +If +.I parameter +is an indexed array name subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +\fIparameter\fP, so negative indices count back from the end of the +array, and an index of \-1 references the last element. +.TP +${\fIparameter\fP\fB#\fP\fIword\fP} +.PD 0 +.TP +${\fIparameter\fP\fB##\fP\fIword\fP} +.PD +\fBRemove matching prefix pattern\fP. +The +.I word +is expanded to produce a pattern just as in pathname +expansion. If the pattern matches the beginning of +the value of +.IR parameter , +then the result of the expansion is the expanded value of +.I parameter +with the shortest matching pattern (the ``\fB#\fP'' case) or the +longest matching pattern (the ``\fB##\fP'' case) deleted. +If +.I parameter +is +.B @ +or +.BR * , +the pattern removal operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +.I parameter +is an array variable subscripted with +.B @ +or +.BR * , +the pattern removal operation is applied to each member of the +array in turn, and the expansion is the resultant list. +.TP +${\fIparameter\fP\fB%\fP\fIword\fP} +.PD 0 +.TP +${\fIparameter\fP\fB%%\fP\fIword\fP} +.PD +\fBRemove matching suffix pattern\fP. +The \fIword\fP is expanded to produce a pattern just as in +pathname expansion. +If the pattern matches a trailing portion of the expanded value of +.IR parameter , +then the result of the expansion is the expanded value of +.I parameter +with the shortest matching pattern (the ``\fB%\fP'' case) or the +longest matching pattern (the ``\fB%%\fP'' case) deleted. +If +.I parameter +is +.B @ +or +.BR * , +the pattern removal operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +.I parameter +is an array variable subscripted with +.B @ +or +.BR * , +the pattern removal operation is applied to each member of the +array in turn, and the expansion is the resultant list. +.TP +${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP} +\fBPattern substitution\fP. +The \fIpattern\fP is expanded to produce a pattern just as in +pathname expansion. +\fIParameter\fP is expanded and the longest match of \fIpattern\fP +against its value is replaced with \fIstring\fP. +If \fIpattern\fP begins with \fB/\fP, all matches of \fIpattern\fP are +replaced with \fIstring\fP. Normally only the first match is replaced. +If \fIpattern\fP begins with \fB#\fP, it must match at the beginning +of the expanded value of \fIparameter\fP. +If \fIpattern\fP begins with \fB%\fP, it must match at the end +of the expanded value of \fIparameter\fP. +If \fIstring\fP is null, matches of \fIpattern\fP are deleted +and the \fB/\fP following \fIpattern\fP may be omitted. +If +.I parameter +is +.B @ +or +.BR * , +the substitution operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +.I parameter +is an array variable subscripted with +.B @ +or +.BR * , +the substitution operation is applied to each member of the +array in turn, and the expansion is the resultant list. +.TP +${\fIparameter\fP\fB^\fP\fIpattern\fP} +.PD 0 +.TP +${\fIparameter\fP\fB^^\fP\fIpattern\fP} +.TP +${\fIparameter\fP\fB,\fP\fIpattern\fP} +.TP +${\fIparameter\fP\fB,,\fP\fIpattern\fP} +.PD +\fBCase modification\fP. +This expansion modifies the case of alphabetic characters in \fIparameter\fP. +The \fIpattern\fP is expanded to produce a pattern just as in +pathname expansion. +Each character in the expanded value of \fIparameter\fP is tested against +\fIpattern\fP, and, if it matches the pattern, its case is converted. +The pattern should not attempt to match more than one character. +The \fB^\fP operator converts lowercase letters matching \fIpattern\fP +to uppercase; the \fB,\fP operator converts matching uppercase letters +to lowercase. +The \fB^^\fP and \fB,,\fP expansions convert each matched character in the +expanded value; the \fB^\fP and \fB,\fP expansions match and convert only +the first character in the expanded value. +If \fIpattern\fP is omitted, it is treated like a \fB?\fP, which matches +every character. +If +.I parameter +is +.B @ +or +.BR * , +the case modification operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +.I parameter +is an array variable subscripted with +.B @ +or +.BR * , +the case modification operation is applied to each member of the +array in turn, and the expansion is the resultant list. +.SS Command Substitution +.PP +\fICommand substitution\fP allows the output of a command to replace +the command name. There are two forms: +.RS +.PP +\fB$(\fP\fIcommand\fP\|\fB)\fP +.RE +or +.RS +\fB\`\fP\fIcommand\fP\fB\`\fP +.RE +.PP +.B Bash +performs the expansion by executing \fIcommand\fP and +replacing the command substitution with the standard output of the +command, with any trailing newlines deleted. +Embedded newlines are not deleted, but they may be removed during +word splitting. +The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by +the equivalent but faster \fB$(< \fIfile\fP)\fR. +.PP +When the old-style backquote form of substitution is used, +backslash retains its literal meaning except when followed by +.BR $ , +.BR \` , +or +.BR \e . +The first backquote not preceded by a backslash terminates the +command substitution. +When using the $(\^\fIcommand\fP\|) form, all characters between the +parentheses make up the command; none are treated specially. +.PP +Command substitutions may be nested. To nest when using the backquoted form, +escape the inner backquotes with backslashes. +.PP +If the substitution appears within double quotes, word splitting and +pathname expansion are not performed on the results. +.SS Arithmetic Expansion +.PP +Arithmetic expansion allows the evaluation of an arithmetic expression +and the substitution of the result. The format for arithmetic expansion is: +.RS +.PP +\fB$((\fP\fIexpression\fP\fB))\fP +.RE +.PP +The +.I expression +is treated as if it were within double quotes, but a double quote +inside the parentheses is not treated specially. +All tokens in the expression undergo parameter expansion, string +expansion, command substitution, and quote removal. +Arithmetic expansions may be nested. +.PP +The evaluation is performed according to the rules listed below under +.SM +.BR "ARITHMETIC EVALUATION" . +If +.I expression +is invalid, +.B bash +prints a message indicating failure and no substitution occurs. +.SS Process Substitution +.PP +\fIProcess substitution\fP is supported on systems that support named +pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files. +It takes the form of +\fB<(\fP\fIlist\^\fP\fB)\fP +or +\fB>(\fP\fIlist\^\fP\fB)\fP. +The process \fIlist\fP is run with its input or output connected to a +\fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is +passed as an argument to the current command as the result of the +expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to +the file will provide input for \fIlist\fP. If the +\fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an +argument should be read to obtain the output of \fIlist\fP. +.PP +When available, process substitution is performed +simultaneously with parameter and variable expansion, +command substitution, +and arithmetic expansion. +.SS Word Splitting +.PP +The shell scans the results of +parameter expansion, +command substitution, +and +arithmetic expansion +that did not occur within double quotes for +.IR "word splitting" . +.PP +The shell treats each character of +.SM +.B IFS +as a delimiter, and splits the results of the other +expansions into words on these characters. If +.SM +.B IFS +is unset, or its +value is exactly +.BR , +the default, then +sequences of +.BR , +.BR , +and +.B +at the beginning and end of the results of the previous +expansions are ignored, and +any sequence of +.SM +.B IFS +characters not at the beginning or end serves to delimit words. +If +.SM +.B IFS +has a value other than the default, then sequences of +the whitespace characters +.B space +and +.B tab +are ignored at the beginning and end of the +word, as long as the whitespace character is in the +value of +.SM +.BR IFS +(an +.SM +.B IFS +whitespace character). +Any character in +.SM +.B IFS +that is not +.SM +.B IFS +whitespace, along with any adjacent +.SM +.B IFS +whitespace characters, delimits a field. +A sequence of +.SM +.B IFS +whitespace characters is also treated as a delimiter. +If the value of +.SM +.B IFS +is null, no word splitting occurs. +.PP +Explicit null arguments (\^\f3"\^"\fP or \^\f3\(aq\^\(aq\fP\^) are retained. +Unquoted implicit null arguments, resulting from the expansion of +parameters that have no values, are removed. +If a parameter with no value is expanded within double quotes, a +null argument results and is retained. +.PP +Note that if no expansion occurs, no splitting +is performed. +.SS Pathname Expansion +.PP +After word splitting, +unless the +.B \-f +option has been set, +.B bash +scans each word for the characters +.BR * , +.BR ? , +and +.BR [ . +If one of these characters appears, then the word is +regarded as a +.IR pattern , +and replaced with an alphabetically sorted list of +filenames matching the pattern +(see +.SM +.B "Pattern Matching" +below). +If no matching filenames are found, +and the shell option +.B nullglob +is not enabled, the word is left unchanged. +If the +.B nullglob +option is set, and no matches are found, +the word is removed. +If the +.B failglob +shell option is set, and no matches are found, an error message +is printed and the command is not executed. +If the shell option +.B nocaseglob +is enabled, the match is performed without regard to the case +of alphabetic characters. +When a pattern is used for pathname expansion, +the character +.B ``.'' +at the start of a name or immediately following a slash +must be matched explicitly, unless the shell option +.B dotglob +is set. +When matching a pathname, the slash character must always be +matched explicitly. +In other cases, the +.B ``.'' +character is not treated specially. +See the description of +.B shopt +below under +.SM +.B SHELL BUILTIN COMMANDS +for a description of the +.BR nocaseglob , +.BR nullglob , +.BR failglob , +and +.B dotglob +shell options. +.PP +The +.SM +.B GLOBIGNORE +shell variable may be used to restrict the set of filenames matching a +.IR pattern . +If +.SM +.B GLOBIGNORE +is set, each matching filename that also matches one of the patterns in +.SM +.B GLOBIGNORE +is removed from the list of matches. +The filenames +.B ``.'' +and +.B ``..'' +are always ignored when +.SM +.B GLOBIGNORE +is set and not null. However, setting +.SM +.B GLOBIGNORE +to a non-null value has the effect of enabling the +.B dotglob +shell option, so all other filenames beginning with a +.B ``.'' +will match. +To get the old behavior of ignoring filenames beginning with a +.BR ``.'' , +make +.B ``.*'' +one of the patterns in +.SM +.BR GLOBIGNORE . +The +.B dotglob +option is disabled when +.SM +.B GLOBIGNORE +is unset. +.PP +\fBPattern Matching\fP +.PP +Any character that appears in a pattern, other than the special pattern +characters described below, matches itself. The NUL character may not +occur in a pattern. A backslash escapes the following character; the +escaping backslash is discarded when matching. +The special pattern characters must be quoted if +they are to be matched literally. +.PP +The special pattern characters have the following meanings: +.PP +.PD 0 +.RS +.TP +.B * +Matches any string, including the null string. +When the \fBglobstar\fP shell option is enabled, and \fB*\fP is used in +a pathname expansion context, two adjacent \fB*\fPs used as a single +pattern will match all files and zero or more directories and +subdirectories. +If followed by a \fB/\fP, two adjacent \fB*\fPs will match only directories +and subdirectories. +.TP +.B ? +Matches any single character. +.TP +.B [...] +Matches any one of the enclosed characters. A pair of characters +separated by a hyphen denotes a +\fIrange expression\fP; +any character that falls between those two characters, inclusive, +using the current locale's collating sequence and character set, +is matched. If the first character following the +.B [ +is a +.B ! +or a +.B ^ +then any character not enclosed is matched. +The sorting order of characters in range expressions is determined by +the current locale and the values of the +.SM +.B LC_COLLATE +or +.SM +.B LC_ALL +shell variables, if set. +To obtain the traditional interpretation of range expressions, where +.B [a\-d] +is equivalent to +.BR [abcd] , +set value of the +.B LC_ALL +shell variable to +.BR C , +or enable the +.B globasciiranges +shell option. +A +.B \- +may be matched by including it as the first or last character +in the set. +A +.B ] +may be matched by including it as the first character +in the set. +.br +.if t .sp 0.5 +.if n .sp 1 +Within +.B [ +and +.BR ] , +\fIcharacter classes\fP can be specified using the syntax +\fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the +following classes defined in the POSIX standard: +.PP +.RS +.B +.if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit +.if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit +.br +A character class matches any character belonging to that class. +The \fBword\fP character class matches letters, digits, and the character _. +.br +.if t .sp 0.5 +.if n .sp 1 +Within +.B [ +and +.BR ] , +an \fIequivalence class\fP can be specified using the syntax +\fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the +same collation weight (as defined by the current locale) as +the character \fIc\fP. +.br +.if t .sp 0.5 +.if n .sp 1 +Within +.B [ +and +.BR ] , +the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol +\fIsymbol\fP. +.RE +.RE +.PD +.PP +If the \fBextglob\fP shell option is enabled using the \fBshopt\fP +builtin, several extended pattern matching operators are recognized. +In the following description, a \fIpattern-list\fP is a list of one +or more patterns separated by a \fB|\fP. +Composite patterns may be formed using one or more of the following +sub-patterns: +.sp 1 +.PD 0 +.RS +.TP +\fB?(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches zero or one occurrence of the given patterns +.TP +\fB*(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches zero or more occurrences of the given patterns +.TP +\fB+(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches one or more occurrences of the given patterns +.TP +\fB@(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches one of the given patterns +.TP +\fB!(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches anything except one of the given patterns +.RE +.PD +.SS Quote Removal +.PP +After the preceding expansions, all unquoted occurrences of the +characters +.BR \e , +.BR \(aq , +and \^\f3"\fP\^ that did not result from one of the above +expansions are removed. +.SH REDIRECTION +Before a command is executed, its input and output +may be +.I redirected +using a special notation interpreted by the shell. +Redirection allows commands' file handles to be +duplicated, opened, closed, +made to refer to different files, +and can change the files the command reads from and writes to. +Redirection may also be used to modify file handles in the +current shell execution environment. +The following redirection +operators may precede or appear anywhere within a +.I simple command +or may follow a +.IR command . +Redirections are processed in the order they appear, from +left to right. +.PP +Each redirection that may be preceded by a file descriptor number +may instead be preceded by a word of the form {\fIvarname\fP}. +In this case, for each redirection operator except +>&- and <&-, the shell will allocate a file descriptor greater +than or equal to 10 and assign it to \fIvarname\fP. +If >&- or <&- is preceded +by {\fIvarname\fP}, the value of \fIvarname\fP defines the file +descriptor to close. +.PP +In the following descriptions, if the file descriptor number is +omitted, and the first character of the redirection operator is +.BR < , +the redirection refers to the standard input (file descriptor +0). If the first character of the redirection operator is +.BR > , +the redirection refers to the standard output (file descriptor +1). +.PP +The word following the redirection operator in the following +descriptions, unless otherwise noted, is subjected to +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, quote removal, +pathname expansion, and word splitting. +If it expands to more than one word, +.B bash +reports an error. +.PP +Note that the order of redirections is significant. For example, +the command +.RS +.PP +ls \fB>\fP dirlist 2\fB>&\fP1 +.RE +.PP +directs both standard output and standard error to the file +.IR dirlist , +while the command +.RS +.PP +ls 2\fB>&\fP1 \fB>\fP dirlist +.RE +.PP +directs only the standard output to file +.IR dirlist , +because the standard error was duplicated from the standard output +before the standard output was redirected to +.IR dirlist . +.PP +\fBBash\fP handles several filenames specially when they are used in +redirections, as described in the following table: +.RS +.PP +.PD 0 +.TP +.B /dev/fd/\fIfd\fP +If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated. +.TP +.B /dev/stdin +File descriptor 0 is duplicated. +.TP +.B /dev/stdout +File descriptor 1 is duplicated. +.TP +.B /dev/stderr +File descriptor 2 is duplicated. +.TP +.B /dev/tcp/\fIhost\fP/\fIport\fP +If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP +is an integer port number or service name, \fBbash\fP attempts to open +the corresponding TCP socket. +.TP +.B /dev/udp/\fIhost\fP/\fIport\fP +If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP +is an integer port number or service name, \fBbash\fP attempts to open +the corresponding UDP socket. +.PD +.RE +.PP +A failure to open or create a file causes the redirection to fail. +.PP +Redirections using file descriptors greater than 9 should be used with +care, as they may conflict with file descriptors the shell uses +internally. +.SS Redirecting Input +.PP +Redirection of input causes the file whose name results from +the expansion of +.I word +to be opened for reading on file descriptor +.IR n , +or the standard input (file descriptor 0) if +.I n +is not specified. +.PP +The general format for redirecting input is: +.RS +.PP +[\fIn\fP]\fB<\fP\fIword\fP +.RE +.SS Redirecting Output +.PP +Redirection of output causes the file whose name results from +the expansion of +.I word +to be opened for writing on file descriptor +.IR n , +or the standard output (file descriptor 1) if +.I n +is not specified. If the file does not exist it is created; +if it does exist it is truncated to zero size. +.PP +The general format for redirecting output is: +.RS +.PP +[\fIn\fP]\fB>\fP\fIword\fP +.RE +.PP +If the redirection operator is +.BR > , +and the +.B noclobber +option to the +.B set +builtin has been enabled, the redirection will fail if the file +whose name results from the expansion of \fIword\fP exists and is +a regular file. +If the redirection operator is +.BR >| , +or the redirection operator is +.B > +and the +.B noclobber +option to the +.B set +builtin command is not enabled, the redirection is attempted even +if the file named by \fIword\fP exists. +.SS Appending Redirected Output +.PP +Redirection of output in this fashion +causes the file whose name results from +the expansion of +.I word +to be opened for appending on file descriptor +.IR n , +or the standard output (file descriptor 1) if +.I n +is not specified. If the file does not exist it is created. +.PP +The general format for appending output is: +.RS +.PP +[\fIn\fP]\fB>>\fP\fIword\fP +.RE +.PP +.SS Redirecting Standard Output and Standard Error +.PP +This construct allows both the +standard output (file descriptor 1) and +the standard error output (file descriptor 2) +to be redirected to the file whose name is the +expansion of +.IR word . +.PP +There are two formats for redirecting standard output and +standard error: +.RS +.PP +\fB&>\fP\fIword\fP +.RE +and +.RS +\fB>&\fP\fIword\fP +.RE +.PP +Of the two forms, the first is preferred. +This is semantically equivalent to +.RS +.PP +\fB>\fP\fIword\fP 2\fB>&\fP1 +.RE +.PP +When using the second form, \fIword\fP may not expand to a number or +\fB\-\fP. If it does, other redirection operators apply +(see \fBDuplicating File Descriptors\fP below) for compatibility +reasons. +.SS Appending Standard Output and Standard Error +.PP +This construct allows both the +standard output (file descriptor 1) and +the standard error output (file descriptor 2) +to be appended to the file whose name is the +expansion of +.IR word . +.PP +The format for appending standard output and standard error is: +.RS +.PP +\fB&>>\fP\fIword\fP +.RE +.PP +This is semantically equivalent to +.RS +.PP +\fB>>\fP\fIword\fP 2\fB>&\fP1 +.RE +.PP +(see \fBDuplicating File Descriptors\fP below). +.SS Here Documents +.PP +This type of redirection instructs the shell to read input from the +current source until a line containing only +.I delimiter +(with no trailing blanks) +is seen. All of +the lines read up to that point are then used as the standard +input for a command. +.PP +The format of here-documents is: +.RS +.PP +.nf +\fB<<\fP[\fB\-\fP]\fIword\fP + \fIhere-document\fP +\fIdelimiter\fP +.fi +.RE +.PP +No parameter and variable expansion, command substitution, +arithmetic expansion, or pathname expansion is performed on +.IR word . +If any characters in +.I word +are quoted, the +.I delimiter +is the result of quote removal on +.IR word , +and the lines in the here-document are not expanded. +If \fIword\fP is unquoted, +all lines of the here-document are subjected to +parameter expansion, command substitution, and arithmetic expansion, +the character sequence +.B \e +is ignored, and +.B \e +must be used to quote the characters +.BR \e , +.BR $ , +and +.BR \` . +.PP +If the redirection operator is +.BR <<\- , +then all leading tab characters are stripped from input lines and the +line containing +.IR delimiter . +This allows +here-documents within shell scripts to be indented in a +natural fashion. +.SS "Here Strings" +A variant of here documents, the format is: +.RS +.PP +.nf +\fB<<<\fP\fIword\fP +.fi +.RE +.PP +The \fIword\fP undergoes +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote removal. +Pathname expansion and word splitting are not performed. +The result is supplied as a single string to the command on its +standard input. +.SS "Duplicating File Descriptors" +.PP +The redirection operator +.RS +.PP +[\fIn\fP]\fB<&\fP\fIword\fP +.RE +.PP +is used to duplicate input file descriptors. +If +.I word +expands to one or more digits, the file descriptor denoted by +.I n +is made to be a copy of that file descriptor. +If the digits in +.I word +do not specify a file descriptor open for input, a redirection error occurs. +If +.I word +evaluates to +.BR \- , +file descriptor +.I n +is closed. If +.I n +is not specified, the standard input (file descriptor 0) is used. +.PP +The operator +.RS +.PP +[\fIn\fP]\fB>&\fP\fIword\fP +.RE +.PP +is used similarly to duplicate output file descriptors. If +.I n +is not specified, the standard output (file descriptor 1) is used. +If the digits in +.I word +do not specify a file descriptor open for output, a redirection error occurs. +If +.I word +evaluates to +.BR \- , +file descriptor +.I n +is closed. +As a special case, if \fIn\fP is omitted, and \fIword\fP does not +expand to one or more digits or \fB\-\fP, the standard output and standard +error are redirected as described previously. +.SS "Moving File Descriptors" +.PP +The redirection operator +.RS +.PP +[\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP +.RE +.PP +moves the file descriptor \fIdigit\fP to file descriptor +.IR n , +or the standard input (file descriptor 0) if \fIn\fP is not specified. +\fIdigit\fP is closed after being duplicated to \fIn\fP. +.PP +Similarly, the redirection operator +.RS +.PP +[\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP +.RE +.PP +moves the file descriptor \fIdigit\fP to file descriptor +.IR n , +or the standard output (file descriptor 1) if \fIn\fP is not specified. +.SS "Opening File Descriptors for Reading and Writing" +.PP +The redirection operator +.RS +.PP +[\fIn\fP]\fB<>\fP\fIword\fP +.RE +.PP +causes the file whose name is the expansion of +.I word +to be opened for both reading and writing on file descriptor +.IR n , +or on file descriptor 0 if +.I n +is not specified. If the file does not exist, it is created. +.SH ALIASES +\fIAliases\fP allow a string to be substituted for a word when it is used +as the first word of a simple command. +The shell maintains a list of aliases that may be set and unset with the +.B alias +and +.B unalias +builtin commands (see +.SM +.B SHELL BUILTIN COMMANDS +below). +The first word of each simple command, if unquoted, +is checked to see if it has an +alias. If so, that word is replaced by the text of the alias. +The characters \fB/\fP, \fB$\fP, \fB\`\fP, and \fB=\fP and +any of the shell \fImetacharacters\fP or quoting characters +listed above may not appear in an alias name. +The replacement text may contain any valid shell input, +including shell metacharacters. +The first word of the replacement text is tested +for aliases, but a word that is identical to an alias being expanded +is not expanded a second time. +This means that one may alias +.B ls +to +.BR "ls \-F" , +for instance, and +.B bash +does not try to recursively expand the replacement text. +If the last character of the alias value is a +.IR blank , +then the next command +word following the alias is also checked for alias expansion. +.PP +Aliases are created and listed with the +.B alias +command, and removed with the +.B unalias +command. +.PP +There is no mechanism for using arguments in the replacement text. +If arguments are needed, a shell function should be used (see +.SM +.B FUNCTIONS +below). +.PP +Aliases are not expanded when the shell is not interactive, unless +the +.B expand_aliases +shell option is set using +.B shopt +(see the description of +.B shopt +under +.SM +\fBSHELL BUILTIN COMMANDS\fP +below). +.PP +The rules concerning the definition and use of aliases are +somewhat confusing. +.B Bash +always reads at least one complete line +of input before executing any +of the commands on that line. Aliases are expanded when a +command is read, not when it is executed. Therefore, an +alias definition appearing on the same line as another +command does not take effect until the next line of input is read. +The commands following the alias definition +on that line are not affected by the new alias. +This behavior is also an issue when functions are executed. +Aliases are expanded when a function definition is read, +not when the function is executed, because a function definition +is itself a compound command. As a consequence, aliases +defined in a function are not available until after that +function is executed. To be safe, always put +alias definitions on a separate line, and do not use +.B alias +in compound commands. +.PP +For almost every purpose, aliases are superseded by +shell functions. +.SH FUNCTIONS +A shell function, defined as described above under +.SM +.BR "SHELL GRAMMAR" , +stores a series of commands for later execution. +When the name of a shell function is used as a simple command name, +the list of commands associated with that function name is executed. +Functions are executed in the context of the +current shell; no new process is created to interpret +them (contrast this with the execution of a shell script). +When a function is executed, the arguments to the +function become the positional parameters +during its execution. +The special parameter +.B # +is updated to reflect the change. Special parameter \fB0\fP +is unchanged. +The first element of the +.SM +.B FUNCNAME +variable is set to the name of the function while the function +is executing. +.PP +All other aspects of the shell execution +environment are identical between a function and its caller +with these exceptions: the +.SM +.B DEBUG +and +.B RETURN +traps (see the description of the +.B trap +builtin under +.SM +.B SHELL BUILTIN COMMANDS +below) are not inherited unless the function has been given the +\fBtrace\fP attribute (see the description of the +.SM +.B declare +builtin below) or the +\fB\-o functrace\fP shell option has been enabled with +the \fBset\fP builtin +(in which case all functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps), +and the +.SM +.B ERR +trap is not inherited unless the \fB\-o errtrace\fP shell option has +been enabled. +.PP +Variables local to the function may be declared with the +.B local +builtin command. Ordinarily, variables and their values +are shared between the function and its caller. +.PP +The \fBFUNCNEST\fP variable, if set to a numeric value greater +than 0, defines a maximum function nesting level. Function +invocations that exceed the limit cause the entire command to +abort. +.PP +If the builtin command +.B return +is executed in a function, the function completes and +execution resumes with the next command after the function +call. +Any command associated with the \fBRETURN\fP trap is executed +before execution resumes. +When a function completes, the values of the +positional parameters and the special parameter +.B # +are restored to the values they had prior to the function's +execution. +.PP +Function names and definitions may be listed with the +.B \-f +option to the +.B declare +or +.B typeset +builtin commands. The +.B \-F +option to +.B declare +or +.B typeset +will list the function names only +(and optionally the source file and line number, if the \fBextdebug\fP +shell option is enabled). +Functions may be exported so that subshells +automatically have them defined with the +.B \-f +option to the +.B export +builtin. +A function definition may be deleted using the \fB\-f\fP option to +the +.B unset +builtin. +Note that shell functions and variables with the same name may result +in multiple identically-named entries in the environment passed to the +shell's children. +Care should be taken in cases where this may cause a problem. +.PP +Functions may be recursive. +The \fBFUNCNEST\fP variable may be used to limit the depth of the +function call stack and restrict the number of function invocations. +By default, no limit is imposed on the number of recursive calls. +.SH "ARITHMETIC EVALUATION" +The shell allows arithmetic expressions to be evaluated, under +certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin +commands and \fBArithmetic Expansion\fP). +Evaluation is done in fixed-width integers with no check for overflow, +though division by 0 is trapped and flagged as an error. +The operators and their precedence, associativity, and values +are the same as in the C language. +The following list of operators is grouped into levels of +equal-precedence operators. +The levels are listed in order of decreasing precedence. +.PP +.PD 0 +.TP +.B \fIid\fP++ \fIid\fP\-\- +variable post-increment and post-decrement +.TP +.B ++\fIid\fP \-\-\fIid\fP +variable pre-increment and pre-decrement +.TP +.B \- + +unary minus and plus +.TP +.B ! ~ +logical and bitwise negation +.TP +.B ** +exponentiation +.TP +.B * / % +multiplication, division, remainder +.TP +.B + \- +addition, subtraction +.TP +.B << >> +left and right bitwise shifts +.TP +.B <= >= < > +comparison +.TP +.B == != +equality and inequality +.TP +.B & +bitwise AND +.TP +.B ^ +bitwise exclusive OR +.TP +.B | +bitwise OR +.TP +.B && +logical AND +.TP +.B || +logical OR +.TP +.B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP +conditional operator +.TP +.B = *= /= %= += \-= <<= >>= &= ^= |= +assignment +.TP +.B \fIexpr1\fP , \fIexpr2\fP +comma +.PD +.PP +Shell variables are allowed as operands; parameter expansion is +performed before the expression is evaluated. +Within an expression, shell variables may also be referenced by name +without using the parameter expansion syntax. +A shell variable that is null or unset evaluates to 0 when referenced +by name without using the parameter expansion syntax. +The value of a variable is evaluated as an arithmetic expression +when it is referenced, or when a variable which has been given the +\fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value. +A null value evaluates to 0. +A shell variable need not have its \fIinteger\fP attribute +turned on to be used in an expression. +.PP +Constants with a leading 0 are interpreted as octal numbers. +A leading 0x or 0X denotes hexadecimal. +Otherwise, numbers take the form [\fIbase#\fP]n, where the optional \fIbase\fP +is a decimal number between 2 and 64 representing the arithmetic +base, and \fIn\fP is a number in that base. +If \fIbase#\fP is omitted, then base 10 is used. +When specifying \fIn\fP, +the digits greater< than 9 are represented by the lowercase letters, +the uppercase letters, @, and _, in that order. +If \fIbase\fP is less than or equal to 36, lowercase and uppercase +letters may be used interchangeably to represent numbers between 10 +and 35. +.PP +Operators are evaluated in order of precedence. Sub-expressions in +parentheses are evaluated first and may override the precedence +rules above. +.SH "CONDITIONAL EXPRESSIONS" +Conditional expressions are used by the \fB[[\fP compound command and +the \fBtest\fP and \fB[\fP builtin commands to test file attributes +and perform string and arithmetic comparisons. +Expressions are formed from the following unary or binary primaries. +If any \fIfile\fP argument to one of the primaries is of the form +\fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked. +If the \fIfile\fP argument to one of the primaries is one of +\fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file +descriptor 0, 1, or 2, respectively, is checked. +.PP +Unless otherwise specified, primaries that operate on files follow symbolic +links and operate on the target of the link, rather than the link itself. +.if t .sp 0.5 +.if n .sp 1 +When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort +lexicographically using the current locale. +The \fBtest\fP command sorts using ASCII ordering. +.sp 1 +.PD 0 +.TP +.B \-a \fIfile\fP +True if \fIfile\fP exists. +.TP +.B \-b \fIfile\fP +True if \fIfile\fP exists and is a block special file. +.TP +.B \-c \fIfile\fP +True if \fIfile\fP exists and is a character special file. +.TP +.B \-d \fIfile\fP +True if \fIfile\fP exists and is a directory. +.TP +.B \-e \fIfile\fP +True if \fIfile\fP exists. +.TP +.B \-f \fIfile\fP +True if \fIfile\fP exists and is a regular file. +.TP +.B \-g \fIfile\fP +True if \fIfile\fP exists and is set-group-id. +.TP +.B \-h \fIfile\fP +True if \fIfile\fP exists and is a symbolic link. +.TP +.B \-k \fIfile\fP +True if \fIfile\fP exists and its ``sticky'' bit is set. +.TP +.B \-p \fIfile\fP +True if \fIfile\fP exists and is a named pipe (FIFO). +.TP +.B \-r \fIfile\fP +True if \fIfile\fP exists and is readable. +.TP +.B \-s \fIfile\fP +True if \fIfile\fP exists and has a size greater than zero. +.TP +.B \-t \fIfd\fP +True if file descriptor +.I fd +is open and refers to a terminal. +.TP +.B \-u \fIfile\fP +True if \fIfile\fP exists and its set-user-id bit is set. +.TP +.B \-w \fIfile\fP +True if \fIfile\fP exists and is writable. +.TP +.B \-x \fIfile\fP +True if \fIfile\fP exists and is executable. +.TP +.B \-G \fIfile\fP +True if \fIfile\fP exists and is owned by the effective group id. +.TP +.B \-L \fIfile\fP +True if \fIfile\fP exists and is a symbolic link. +.TP +.B \-N \fIfile\fP +True if \fIfile\fP exists and has been modified since it was last read. +.TP +.B \-O \fIfile\fP +True if \fIfile\fP exists and is owned by the effective user id. +.TP +.B \-S \fIfile\fP +True if \fIfile\fP exists and is a socket. +.TP +\fIfile1\fP \fB\-ef\fP \fIfile2\fP +True if \fIfile1\fP and \fIfile2\fP refer to the same device and +inode numbers. +.TP +\fIfile1\fP \-\fBnt\fP \fIfile2\fP +True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP, +or if \fIfile1\fP exists and \fPfile2\fP does not. +.TP +\fIfile1\fP \-\fBot\fP \fIfile2\fP +True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists +and \fIfile1\fP does not. +.TP +.B \-o \fIoptname\fP +True if the shell option +.I optname +is enabled. +See the list of options under the description of the +.B \-o +option to the +.B set +builtin below. +.TP +.B \-v \fIvarname\fP +True if the shell variable +.I varname +is set (has been assigned a value). +.TP +.B \-R \fIvarname\fP +True if the shell variable +.I varname +is set and is a name reference. +.TP +.B \-z \fIstring\fP +True if the length of \fIstring\fP is zero. +.TP +\fIstring\fP +.PD 0 +.TP +.B \-n \fIstring\fP +.PD +True if the length of +.I string +is non-zero. +.TP +\fIstring1\fP \fB==\fP \fIstring2\fP +.PD 0 +.TP +\fIstring1\fP \fB=\fP \fIstring2\fP +.PD +True if the strings are equal. \fB=\fP should be used +with the \fBtest\fP command for POSIX conformance. +When used with the \fB[[\fP command, this performs pattern matching as +described above (\fBCompound Commands\fP). +.TP +\fIstring1\fP \fB!=\fP \fIstring2\fP +True if the strings are not equal. +.TP +\fIstring1\fP \fB<\fP \fIstring2\fP +True if \fIstring1\fP sorts before \fIstring2\fP lexicographically. +.TP +\fIstring1\fP \fB>\fP \fIstring2\fP +True if \fIstring1\fP sorts after \fIstring2\fP lexicographically. +.TP +.I \fIarg1\fP \fBOP\fP \fIarg2\fP +.SM +.B OP +is one of +.BR \-eq , +.BR \-ne , +.BR \-lt , +.BR \-le , +.BR \-gt , +or +.BR \-ge . +These arithmetic binary operators return true if \fIarg1\fP +is equal to, not equal to, less than, less than or equal to, +greater than, or greater than or equal to \fIarg2\fP, respectively. +.I Arg1 +and +.I arg2 +may be positive or negative integers. +.PD +.SH "SIMPLE COMMAND EXPANSION" +When a simple command is executed, the shell performs the following +expansions, assignments, and redirections, from left to right. +.IP 1. +The words that the parser has marked as variable assignments (those +preceding the command name) and redirections are saved for later +processing. +.IP 2. +The words that are not variable assignments or redirections are +expanded. If any words remain after expansion, the first word +is taken to be the name of the command and the remaining words are +the arguments. +.IP 3. +Redirections are performed as described above under +.SM +.BR REDIRECTION . +.IP 4. +The text after the \fB=\fP in each variable assignment undergoes tilde +expansion, parameter expansion, command substitution, arithmetic expansion, +and quote removal before being assigned to the variable. +.PP +If no command name results, the variable assignments affect the current +shell environment. Otherwise, the variables are added to the environment +of the executed command and do not affect the current shell environment. +If any of the assignments attempts to assign a value to a readonly variable, +an error occurs, and the command exits with a non-zero status. +.PP +If no command name results, redirections are performed, but do not +affect the current shell environment. A redirection error causes the +command to exit with a non-zero status. +.PP +If there is a command name left after expansion, execution proceeds as +described below. Otherwise, the command exits. If one of the expansions +contained a command substitution, the exit status of the command is +the exit status of the last command substitution performed. If there +were no command substitutions, the command exits with a status of zero. +.SH "COMMAND EXECUTION" +After a command has been split into words, if it results in a +simple command and an optional list of arguments, the following +actions are taken. +.PP +If the command name contains no slashes, the shell attempts to +locate it. If there exists a shell function by that name, that +function is invoked as described above in +.SM +.BR FUNCTIONS . +If the name does not match a function, the shell searches for +it in the list of shell builtins. If a match is found, that +builtin is invoked. +.PP +If the name is neither a shell function nor a builtin, +and contains no slashes, +.B bash +searches each element of the +.SM +.B PATH +for a directory containing an executable file by that name. +.B Bash +uses a hash table to remember the full pathnames of executable +files (see +.B hash +under +.SM +.B "SHELL BUILTIN COMMANDS" +below). +A full search of the directories in +.SM +.B PATH +is performed only if the command is not found in the hash table. +If the search is unsuccessful, the shell searches for a defined shell +function named \fBcommand_not_found_handle\fP. +If that function exists, it is invoked with the original command and +the original command's arguments as its arguments, and the function's +exit status becomes the exit status of the shell. +If that function is not defined, the shell prints an error +message and returns an exit status of 127. +.PP +If the search is successful, or if the command name contains +one or more slashes, the shell executes the named program in a +separate execution environment. +Argument 0 is set to the name given, and the remaining arguments +to the command are set to the arguments given, if any. +.PP +If this execution fails because the file is not in executable +format, and the file is not a directory, it is assumed to be +a \fIshell script\fP, a file +containing shell commands. A subshell is spawned to execute +it. This subshell reinitializes itself, so +that the effect is as if a new shell had been invoked +to handle the script, with the exception that the locations of +commands remembered by the parent (see +.B hash +below under +.SM +\fBSHELL BUILTIN COMMANDS\fP) +are retained by the child. +.PP +If the program is a file beginning with +.BR #! , +the remainder of the first line specifies an interpreter +for the program. The shell executes the +specified interpreter on operating systems that do not +handle this executable format themselves. The arguments to the +interpreter consist of a single optional argument following the +interpreter name on the first line of the program, followed +by the name of the program, followed by the command +arguments, if any. +.SH COMMAND EXECUTION ENVIRONMENT +The shell has an \fIexecution environment\fP, which consists of the +following: +.IP \(bu +open files inherited by the shell at invocation, as modified by +redirections supplied to the \fBexec\fP builtin +.IP \(bu +the current working directory as set by \fBcd\fP, \fBpushd\fP, or +\fBpopd\fP, or inherited by the shell at invocation +.IP \(bu +the file creation mode mask as set by \fBumask\fP or inherited from +the shell's parent +.IP \(bu +current traps set by \fBtrap\fP +.IP \(bu +shell parameters that are set by variable assignment or with \fBset\fP +or inherited from the shell's parent in the environment +.IP \(bu +shell functions defined during execution or inherited from the shell's +parent in the environment +.IP \(bu +options enabled at invocation (either by default or with command-line +arguments) or by \fBset\fP +.IP \(bu +options enabled by \fBshopt\fP +.IP \(bu +shell aliases defined with \fBalias\fP +.IP \(bu +various process IDs, including those of background jobs, the value +of \fB$$\fP, and the value of +.SM +.B PPID +.PP +When a simple command other than a builtin or shell function +is to be executed, it +is invoked in a separate execution environment that consists of +the following. Unless otherwise noted, the values are inherited +from the shell. +.if n .sp 1 +.IP \(bu +the shell's open files, plus any modifications and additions specified +by redirections to the command +.IP \(bu +the current working directory +.IP \(bu +the file creation mode mask +.IP \(bu +shell variables and functions marked for export, along with variables +exported for the command, passed in the environment +.IP \(bu +traps caught by the shell are reset to the values inherited from the +shell's parent, and traps ignored by the shell are ignored +.PP +A command invoked in this separate environment cannot affect the +shell's execution environment. +.PP +Command substitution, commands grouped with parentheses, +and asynchronous commands are invoked in a +subshell environment that is a duplicate of the shell environment, +except that traps caught by the shell are reset to the values +that the shell inherited from its parent at invocation. Builtin +commands that are invoked as part of a pipeline are also executed in a +subshell environment. Changes made to the subshell environment +cannot affect the shell's execution environment. +.PP +Subshells spawned to execute command substitutions inherit the value of +the \fB\-e\fP option from the parent shell. When not in \fIposix\fP mode, +\fBbash\fP clears the \fB\-e\fP option in such subshells. +.PP +If a command is followed by a \fB&\fP and job control is not active, the +default standard input for the command is the empty file \fI/dev/null\fP. +Otherwise, the invoked command inherits the file descriptors of the calling +shell as modified by redirections. +.SH ENVIRONMENT +When a program is invoked it is given an array of strings +called the +.IR environment . +This is a list of +\fIname\fP\-\fIvalue\fP pairs, of the form +.IR "name\fR=\fPvalue" . +.PP +The shell provides several ways to manipulate the environment. +On invocation, the shell scans its own environment and +creates a parameter for each name found, automatically marking +it for +.I export +to child processes. Executed commands inherit the environment. +The +.B export +and +.B declare \-x +commands allow parameters and functions to be added to and +deleted from the environment. If the value of a parameter +in the environment is modified, the new value becomes part +of the environment, replacing the old. The environment +inherited by any executed command consists of the shell's +initial environment, whose values may be modified in the shell, +less any pairs removed by the +.B unset +command, plus any additions via the +.B export +and +.B declare \-x +commands. +.PP +The environment for any +.I simple command +or function may be augmented temporarily by prefixing it with +parameter assignments, as described above in +.SM +.BR PARAMETERS . +These assignment statements affect only the environment seen +by that command. +.PP +If the +.B \-k +option is set (see the +.B set +builtin command below), then +.I all +parameter assignments are placed in the environment for a command, +not just those that precede the command name. +.PP +When +.B bash +invokes an external command, the variable +.B _ +is set to the full filename of the command and passed to that +command in its environment. +.SH "EXIT STATUS" +.PP +The exit status of an executed command is the value returned by the +\fIwaitpid\fP system call or equivalent function. Exit statuses +fall between 0 and 255, though, as explained below, the shell may +use values above 125 specially. Exit statuses from shell builtins and +compound commands are also limited to this range. Under certain +circumstances, the shell will use special values to indicate specific +failure modes. +.PP +For the shell's purposes, a command which exits with a +zero exit status has succeeded. An exit status of zero +indicates success. A non-zero exit status indicates failure. +When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses +the value of 128+\fIN\fP as the exit status. +.PP +If a command is not found, the child process created to +execute it returns a status of 127. If a command is found +but is not executable, the return status is 126. +.PP +If a command fails because of an error during expansion or redirection, +the exit status is greater than zero. +.PP +Shell builtin commands return a status of 0 (\fItrue\fP) if +successful, and non-zero (\fIfalse\fP) if an error occurs +while they execute. +All builtins return an exit status of 2 to indicate incorrect usage. +.PP +\fBBash\fP itself returns the exit status of the last command +executed, unless a syntax error occurs, in which case it exits +with a non-zero value. See also the \fBexit\fP builtin +command below. +.SH SIGNALS +When \fBbash\fP is interactive, in the absence of any traps, it ignores +.SM +.B SIGTERM +(so that \fBkill 0\fP does not kill an interactive shell), +and +.SM +.B SIGINT +is caught and handled (so that the \fBwait\fP builtin is interruptible). +In all cases, \fBbash\fP ignores +.SM +.BR SIGQUIT . +If job control is in effect, +.B bash +ignores +.SM +.BR SIGTTIN , +.SM +.BR SIGTTOU , +and +.SM +.BR SIGTSTP . +.PP +Non-builtin commands run by \fBbash\fP have signal handlers +set to the values inherited by the shell from its parent. +When job control is not in effect, asynchronous commands +ignore +.SM +.B SIGINT +and +.SM +.B SIGQUIT +in addition to these inherited handlers. +Commands run as a result of command substitution ignore the +keyboard-generated job control signals +.SM +.BR SIGTTIN , +.SM +.BR SIGTTOU , +and +.SM +.BR SIGTSTP . +.PP +The shell exits by default upon receipt of a +.SM +.BR SIGHUP . +Before exiting, an interactive shell resends the +.SM +.B SIGHUP +to all jobs, running or stopped. +Stopped jobs are sent +.SM +.B SIGCONT +to ensure that they receive the +.SM +.BR SIGHUP . +To prevent the shell from +sending the signal to a particular job, it should be removed from the +jobs table with the +.B disown +builtin (see +.SM +.B "SHELL BUILTIN COMMANDS" +below) or marked +to not receive +.SM +.B SIGHUP +using +.BR "disown \-h" . +.PP +If the +.B huponexit +shell option has been set with +.BR shopt , +.B bash +sends a +.SM +.B SIGHUP +to all jobs when an interactive login shell exits. +.PP +If \fBbash\fP is waiting for a command to complete and receives a signal +for which a trap has been set, the trap will not be executed until +the command completes. +When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP +builtin, the reception of a signal for which a trap has been set will +cause the \fBwait\fP builtin to return immediately with an exit status +greater than 128, immediately after which the trap is executed. +.SH "JOB CONTROL" +.I Job control +refers to the ability to selectively stop (\fIsuspend\fP) +the execution of processes and continue (\fIresume\fP) +their execution at a later point. A user typically employs +this facility via an interactive interface supplied jointly +by the operating system kernel's terminal driver and +.BR bash . +.PP +The shell associates a +.I job +with each pipeline. It keeps a table of currently executing +jobs, which may be listed with the +.B jobs +command. When +.B bash +starts a job asynchronously (in the +.IR background ), +it prints a line that looks like: +.RS +.PP +[1] 25647 +.RE +.PP +indicating that this job is job number 1 and that the process ID +of the last process in the pipeline associated with this job is 25647. +All of the processes in a single pipeline are members of the same job. +.B Bash +uses the +.I job +abstraction as the basis for job control. +.PP +To facilitate the implementation of the user interface to job +control, the operating system maintains the notion of a \fIcurrent terminal +process group ID\fP. Members of this process group (processes whose +process group ID is equal to the current terminal process group ID) +receive keyboard-generated signals such as +.SM +.BR SIGINT . +These processes are said to be in the +.IR foreground . +.I Background +processes are those whose process group ID differs from the terminal's; +such processes are immune to keyboard-generated signals. +Only foreground processes are allowed to read from or, if the +user so specifies with \f(CWstty tostop\fP, write to the +terminal. +Background processes which attempt to read from (write to when +\f(CWstty tostop\fP is in effect) the +terminal are sent a +.SM +.B SIGTTIN (SIGTTOU) +signal by the kernel's terminal driver, +which, unless caught, suspends the process. +.PP +If the operating system on which +.B bash +is running supports +job control, +.B bash +contains facilities to use it. +Typing the +.I suspend +character (typically +.BR ^Z , +Control-Z) while a process is running +causes that process to be stopped and returns control to +.BR bash . +Typing the +.I "delayed suspend" +character (typically +.BR ^Y , +Control-Y) causes the process to be stopped when it +attempts to read input from the terminal, and control to +be returned to +.BR bash . +The user may then manipulate the state of this job, using the +.B bg +command to continue it in the background, the +.B fg +command to continue it in the foreground, or +the +.B kill +command to kill it. A \fB^Z\fP takes effect immediately, +and has the additional side effect of causing pending output +and typeahead to be discarded. +.PP +There are a number of ways to refer to a job in the shell. +The character +.B % +introduces a job specification (\fIjobspec\fP). Job number +.I n +may be referred to as +.BR %n . +A job may also be referred to using a prefix of the name used to +start it, or using a substring that appears in its command line. +For example, +.B %ce +refers to a stopped +.B ce +job. If a prefix matches more than one job, +.B bash +reports an error. Using +.BR %?ce , +on the other hand, refers to any job containing the string +.B ce +in its command line. If the substring matches more than one job, +.B bash +reports an error. The symbols +.B %% +and +.B %+ +refer to the shell's notion of the +.IR "current job" , +which is the last job stopped while it was in +the foreground or started in the background. +The +.I "previous job" +may be referenced using +.BR %\- . +If there is only a single job, \fB%+\fP and \fB%\-\fP can both be used +to refer to that job. +In output pertaining to jobs (e.g., the output of the +.B jobs +command), the current job is always flagged with a +.BR + , +and the previous job with a +.BR \- . +A single % (with no accompanying job specification) also refers to the +current job. +.PP +Simply naming a job can be used to bring it into the +foreground: +.B %1 +is a synonym for +\fB``fg %1''\fP, +bringing job 1 from the background into the foreground. +Similarly, +.B ``%1 &'' +resumes job 1 in the background, equivalent to +\fB``bg %1''\fP. +.PP +The shell learns immediately whenever a job changes state. +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 +.B \-b +option to the +.B set +builtin command +is enabled, +.B bash +reports such changes immediately. +Any trap on +.SM +.B SIGCHLD +is executed for each child that exits. +.PP +If an attempt to exit +.B bash +is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has +been enabled using the \fBshopt\fP builtin, running), the shell prints a +warning message, and, if the \fBcheckjobs\fP option is enabled, lists the +jobs and their statuses. +The +.B jobs +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. +.SH PROMPTING +When executing interactively, +.B bash +displays the primary prompt +.SM +.B PS1 +when it is ready to read a command, and the secondary prompt +.SM +.B PS2 +when it needs more input to complete a command. +.B Bash +allows these prompt strings to be customized by inserting a number of +backslash-escaped special characters that are decoded as follows: +.RS +.PD 0 +.TP +.B \ea +an ASCII bell character (07) +.TP +.B \ed +the date in "Weekday Month Date" format (e.g., "Tue May 26") +.TP +.B \eD{\fIformat\fP} +the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted +into the prompt string; an empty \fIformat\fP results in a locale-specific +time representation. The braces are required +.TP +.B \ee +an ASCII escape character (033) +.TP +.B \eh +the hostname up to the first `.' +.TP +.B \eH +the hostname +.TP +.B \ej +the number of jobs currently managed by the shell +.TP +.B \el +the basename of the shell's terminal device name +.TP +.B \en +newline +.TP +.B \er +carriage return +.TP +.B \es +the name of the shell, the basename of +.B $0 +(the portion following the final slash) +.TP +.B \et +the current time in 24-hour HH:MM:SS format +.TP +.B \eT +the current time in 12-hour HH:MM:SS format +.TP +.B \e@ +the current time in 12-hour am/pm format +.TP +.B \eA +the current time in 24-hour HH:MM format +.TP +.B \eu +the username of the current user +.TP +.B \ev +the version of \fBbash\fP (e.g., 2.00) +.TP +.B \eV +the release of \fBbash\fP, version + patch level (e.g., 2.00.0) +.TP +.B \ew +the current working directory, with +.SM +.B $HOME +abbreviated with a tilde +(uses the value of the +.SM +.B PROMPT_DIRTRIM +variable) +.TP +.B \eW +the basename of the current working directory, with +.SM +.B $HOME +abbreviated with a tilde +.TP +.B \e! +the history number of this command +.TP +.B \e# +the command number of this command +.TP +.B \e$ +if the effective UID is 0, a +.BR # , +otherwise a +.B $ +.TP +.B \e\fInnn\fP +the character corresponding to the octal number \fInnn\fP +.TP +.B \e\e +a backslash +.TP +.B \e[ +begin a sequence of non-printing characters, which could be used to +embed a terminal control sequence into the prompt +.TP +.B \e] +end a sequence of non-printing characters +.PD +.RE +.PP +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 +.SM +.B HISTORY +below), while the command number is the position in the sequence +of commands 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 +.B promptvars +shell option (see the description of the +.B shopt +command under +.SM +.B "SHELL BUILTIN COMMANDS" +below). +.SH READLINE +This is the library that handles reading input when using an interactive +shell, unless the +.B \-\-noediting +option is given at shell invocation. +Line editing is also used when using the \fB\-e\fP option to the +\fBread\fP 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 +.B \-o emacs +or +.B \-o vi +options to the +.B set +builtin (see +.SM +.B SHELL BUILTIN COMMANDS +below). +To turn off line editing after the shell is running, use the +.B +o emacs +or +.B +o vi +options to the +.B set +builtin. +.SS "Readline Notation" +.PP +In this section, the Emacs-style notation is used to denote +keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n +means Control\-N. Similarly, +.I meta +keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards +without a +.I meta +key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key +then the +.I x +key. This makes ESC the \fImeta prefix\fP. +The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP, +or press the Escape key +then hold the Control key while pressing the +.I x +key.) +.PP +Readline commands may be given numeric +.IR arguments , +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., \fBkill\-line\fP) causes that command to act in a +backward direction. +Commands whose behavior with arguments deviates from this are noted +below. +.PP +When a command is described as \fIkilling\fP text, the text +deleted is saved for possible future retrieval +(\fIyanking\fP). The killed text is saved in a +\fIkill ring\fP. 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. +.SS "Readline Initialization" +.PP +Readline is customized by putting commands in an initialization +file (the \fIinputrc\fP file). +The name of this file is taken from the value of the +.SM +.B INPUTRC +variable. If that variable is unset, the default is +.IR ~/.inputrc . +When a program which uses the readline library 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 \fB#\fP are comments. +Lines beginning with a \fB$\fP indicate conditional constructs. +Other lines denote key bindings and variable settings. +.PP +The default key-bindings may be changed with an +.I inputrc +file. +Other programs that use this library may add their own commands +and bindings. +.PP +For example, placing +.RS +.PP +M\-Control\-u: universal\-argument +.RE +or +.RS +C\-Meta\-u: universal\-argument +.RE +into the +.I inputrc +would make M\-C\-u execute the readline command +.IR universal\-argument . +.PP +The following symbolic character names are recognized: +.IR RUBOUT , +.IR DEL , +.IR ESC , +.IR LFD , +.IR NEWLINE , +.IR RET , +.IR RETURN , +.IR SPC , +.IR SPACE , +and +.IR TAB . +.PP +In addition to command names, readline allows keys to be bound +to a string that is inserted when the key is pressed (a \fImacro\fP). +.SS "Readline Key Bindings" +.PP +The syntax for controlling key bindings in the +.I inputrc +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 specified in one of two ways: +as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP +prefixes, or as a key sequence. +.PP +When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP, +.I keyname +is the name of a key spelled out in English. For example: +.sp +.RS +Control-u: universal\-argument +.br +Meta-Rubout: backward-kill-word +.br +Control-o: "> output" +.RE +.LP +In the above example, +.I C\-u +is bound to the function +.BR universal\-argument , +.I M\-DEL +is bound to the function +.BR backward\-kill\-word , +and +.I C\-o +is bound to run the macro +expressed on the right hand side (that is, to insert the text +.if t \f(CW> output\fP +.if n ``> output'' +into the line). +.PP +In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP, +.B keyseq +differs from +.B keyname +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. +.sp +.RS +"\eC\-u": universal\-argument +.br +"\eC\-x\eC\-r": re\-read\-init\-file +.br +"\ee[11~": "Function Key 1" +.RE +.PP +In this example, +.I C\-u +is again bound to the function +.BR universal\-argument . +.I "C\-x C\-r" +is bound to the function +.BR re\-read\-init\-file , +and +.I "ESC [ 1 1 ~" +is bound to insert the text +.if t \f(CWFunction Key 1\fP. +.if n ``Function Key 1''. +.PP +The full set of GNU Emacs style escape sequences is +.RS +.PD 0 +.TP +.B \eC\- +control prefix +.TP +.B \eM\- +meta prefix +.TP +.B \ee +an escape character +.TP +.B \e\e +backslash +.TP +.B \e" +literal " +.TP +.B \e\(aq +literal \(aq +.RE +.PD +.PP +In addition to the GNU Emacs style escape sequences, a second +set of backslash escapes is available: +.RS +.PD 0 +.TP +.B \ea +alert (bell) +.TP +.B \eb +backspace +.TP +.B \ed +delete +.TP +.B \ef +form feed +.TP +.B \en +newline +.TP +.B \er +carriage return +.TP +.B \et +horizontal tab +.TP +.B \ev +vertical tab +.TP +.B \e\fInnn\fP +the eight-bit character whose value is the octal value \fInnn\fP +(one to three digits) +.TP +.B \ex\fIHH\fP +the eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits) +.RE +.PD +.PP +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 function name. +In the macro body, the backslash escapes described above are expanded. +Backslash will quote any other character in the macro text, +including " and \(aq. +.PP +.B Bash +allows the current readline key bindings to be displayed or modified +with the +.B bind +builtin command. The editing mode may be switched during interactive +use by using the +.B \-o +option to the +.B set +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.SS "Readline Variables" +.PP +Readline has variables that can be used to further customize its +behavior. A variable may be set in the +.I inputrc +file with a statement of the form +.RS +.PP +\fBset\fP \fIvariable\-name\fP \fIvalue\fP +.RE +.PP +Except where noted, readline variables can take the values +.B On +or +.B Off +(without regard to case). +Unrecognized variable names are ignored. +When a variable value is read, empty or null values, "on" (case-insensitive), +and "1" are equivalent to \fBOn\fP. All other values are equivalent to +\fBOff\fP. +The variables and their default values are: +.PP +.PD 0 +.TP +.B bell\-style (audible) +Controls what happens when readline wants to ring the terminal bell. +If set to \fBnone\fP, readline never rings the bell. If set to +\fBvisible\fP, readline uses a visible bell if one is available. +If set to \fBaudible\fP, readline attempts to ring the terminal's bell. +.TP +.B bind\-tty\-special\-chars (On) +If set to \fBOn\fP, readline attempts to bind the control characters +treated specially by the kernel's terminal driver to their readline +equivalents. +.TP +.B colored\-stats (Off) +If set to \fBOn\fP, readline displays possible completions using different +colors to indicate their file type. +The color definitions are taken from the value of the \fBLS_COLORS\fP +environment variable. +.TP +.B comment\-begin (``#'') +The string that is inserted when the readline +.B insert\-comment +command is executed. +This command is bound to +.B M\-# +in emacs mode and to +.B # +in vi command mode. +.TP +.B completion\-ignore\-case (Off) +If set to \fBOn\fP, readline performs filename matching and completion +in a case\-insensitive fashion. +.TP +.B completion\-prefix\-display\-length (0) +The length in characters of the common prefix of a list of possible +completions that is displayed without modification. When set to a +value greater than zero, common prefixes longer than this value are +replaced with an ellipsis when displaying possible completions. +.TP +.B completion\-query\-items (100) +This determines when the user is queried about viewing +the number of possible completions +generated by the \fBpossible\-completions\fP 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, the user is asked whether +or not he wishes to view them; otherwise they are simply listed +on the terminal. +.TP +.B convert\-meta (On) +If set to \fBOn\fP, 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 \fImeta prefix\fP). +.TP +.B disable\-completion (Off) +If set to \fBOn\fP, readline will inhibit word completion. Completion +characters will be inserted into the line as if they had been +mapped to \fBself-insert\fP. +.TP +.B editing\-mode (emacs) +Controls whether readline begins with a set of key bindings similar +to \fIEmacs\fP or \fIvi\fP. +.B editing\-mode +can be set to either +.B emacs +or +.BR vi . +.TP +.B echo\-control\-characters (On) +When set to \fBOn\fP, on operating systems that indicate they support it, +readline echoes a character corresponding to a signal generated from the +keyboard. +.TP +.B enable\-keypad (Off) +When set to \fBOn\fP, readline will try to enable the application +keypad when it is called. Some systems need this to enable the +arrow keys. +.TP +.B enable\-meta\-key (On) +When set to \fBOn\fP, 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. +.TP +.B expand\-tilde (Off) +If set to \fBOn\fP, tilde expansion is performed when readline +attempts word completion. +.TP +.B history\-preserve\-point (Off) +If set to \fBOn\fP, the history code attempts to place point at the +same location on each history line retrieved with \fBprevious-history\fP +or \fBnext-history\fP. +.TP +.B history\-size (0) +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 not limited. +.TP +.B horizontal\-scroll\-mode (Off) +When set to \fBOn\fP, 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. +.TP +.B input\-meta (Off) +If set to \fBOn\fP, readline will enable eight-bit input (that is, +it will not strip the high bit from the characters it reads), +regardless of what the terminal claims it can support. The name +.B meta\-flag +is a synonym for this variable. +.TP +.B isearch\-terminators (``C\-[C\-J'') +The string of characters that should terminate an incremental +search without subsequently executing the character as a command. +If this variable has not been given a value, the characters +\fIESC\fP and \fIC\-J\fP will terminate an incremental search. +.TP +.B keymap (emacs) +Set the current readline keymap. The set of valid keymap names is +\fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, +vi\-command\fP, and +.IR vi\-insert . +\fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is +equivalent to \fIemacs\-standard\fP. The default value is +.IR emacs ; +the value of +.B editing\-mode +also affects the default keymap. +.TP +.B keyseq\-timeout (500) +Specifies the duration \fIreadline\fP will wait for a character when reading an +ambiguous key sequence (one that can form a complete key sequence using +the input read so far, or can take additional input to complete a longer +key sequence). +If no input is received within the timeout, \fIreadline\fP will use the shorter +but complete key sequence. +The value is specified in milliseconds, so a value of 1000 means that +\fIreadline\fP will wait one second for additional input. +If this variable is set to a value less than or equal to zero, or to a +non-numeric value, \fIreadline\fP will wait until another key is pressed to +decide which key sequence to complete. +.TP +.B mark\-directories (On) +If set to \fBOn\fP, completed directory names have a slash +appended. +.TP +.B mark\-modified\-lines (Off) +If set to \fBOn\fP, history lines that have been modified are displayed +with a preceding asterisk (\fB*\fP). +.TP +.B mark\-symlinked\-directories (Off) +If set to \fBOn\fP, completed names which are symbolic links to directories +have a slash appended (subject to the value of +\fBmark\-directories\fP). +.TP +.B match\-hidden\-files (On) +This variable, when set to \fBOn\fP, causes readline to match files whose +names begin with a `.' (hidden files) when performing filename +completion. +If set to \fBOff\fP, the leading `.' must be +supplied by the user in the filename to be completed. +.TP +.B menu\-complete\-display\-prefix (Off) +If set to \fBOn\fP, menu completion displays the common prefix of the +list of possible completions (which may be empty) before cycling through +the list. +.TP +.B output\-meta (Off) +If set to \fBOn\fP, readline will display characters with the +eighth bit set directly rather than as a meta-prefixed escape +sequence. +.TP +.B page\-completions (On) +If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager +to display a screenful of possible completions at a time. +.TP +.B print\-completions\-horizontally (Off) +If set to \fBOn\fP, readline will display completions with matches +sorted horizontally in alphabetical order, rather than down the screen. +.TP +.B revert\-all\-at\-newline (Off) +If set to \fBOn\fP, readline will undo all changes to history lines +before returning when \fBaccept\-line\fP is executed. By default, +history lines may be modified and retain individual undo lists across +calls to \fBreadline\fP. +.TP +.B show\-all\-if\-ambiguous (Off) +This alters the default behavior of the completion functions. If +set to +.BR On , +words which have more than one possible completion cause the +matches to be listed immediately instead of ringing the bell. +.TP +.B show\-all\-if\-unmodified (Off) +This alters the default behavior of the completion functions in +a fashion similar to \fBshow\-all\-if\-ambiguous\fP. +If set to +.BR On , +words which have more than one possible completion without any +possible partial completion (the possible completions don't share +a common prefix) cause the matches to be listed immediately instead +of ringing the bell. +.TP +.B show\-mode\-in\-prompt (Off) +If set to \fBOn\fP, add a character to the beginning of the prompt +indicating the editing mode: emacs (@), vi command (:) or vi +insertion (+). +.TP +.B skip\-completed\-text (Off) +If set to \fBOn\fP, this alters the default completion behavior when +inserting a single match into the line. It's only active when +performing completion in the middle of a word. If enabled, readline +does not insert characters from the completion that match characters +after point in the word being completed, so portions of the word +following the cursor are not duplicated. +.TP +.B visible\-stats (Off) +If set to \fBOn\fP, a character denoting a file's type as reported +by \fIstat\fP(2) is appended to the filename when listing possible +completions. +.PD +.SS "Readline Conditional Constructs" +.PP +Readline implements a facility similar in spirit to the conditional +compilation features of the C preprocessor which allows key +bindings and variable settings to be performed as the result +of tests. There are four parser directives used. +.IP \fB$if\fP +The +.B $if +construct allows bindings to be made based on the +editing mode, the terminal being used, or the application using +readline. The text of the test extends to the end of the line; +no characters are required to isolate it. +.RS +.IP \fBmode\fP +The \fBmode=\fP form of the \fB$if\fP directive is used to test +whether readline is in emacs or vi mode. +This may be used in conjunction +with the \fBset keymap\fP command, for instance, to set bindings in +the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if +readline is starting out in emacs mode. +.IP \fBterm\fP +The \fBterm=\fP form may be used to include terminal-specific +key bindings, perhaps to bind the key sequences output by the +terminal's function keys. The word on the right side of the +.B = +is tested against the both full name of the terminal and the portion +of the terminal name before the first \fB\-\fP. This allows +.I sun +to match both +.I sun +and +.IR sun\-cmd , +for instance. +.IP \fBapplication\fP +The \fBapplication\fP construct is used to include +application-specific settings. Each program using the readline +library sets the \fIapplication name\fP, and an initialization +file can test for a particular value. +This could be used to bind key sequences to functions useful for +a specific program. For instance, the following command adds a +key sequence that quotes the current or previous word in \fBbash\fP: +.sp 1 +.RS +.nf +\fB$if\fP Bash +# Quote the current or previous word +"\eC\-xq": "\eeb\e"\eef\e"" +\fB$endif\fP +.fi +.RE +.RE +.IP \fB$endif\fP +This command, as seen in the previous example, terminates an +\fB$if\fP command. +.IP \fB$else\fP +Commands in this branch of the \fB$if\fP directive are executed if +the test fails. +.IP \fB$include\fP +This directive takes a single filename as an argument and reads commands +and bindings from that file. For example, the following directive +would read \fI/etc/inputrc\fP: +.sp 1 +.RS +.nf +\fB$include\fP \^ \fI/etc/inputrc\fP +.fi +.RE +.SS Searching +.PP +Readline provides commands for searching through the command history +(see +.SM +.B HISTORY +below) for lines containing a specified string. +There are two search modes: +.I incremental +and +.IR non-incremental . +.PP +Incremental searches begin before the user has finished typing the +search string. +As each character of the search string is typed, readline displays +the next entry from the history matching the string typed so far. +An incremental search requires only as many characters as needed to +find the desired history entry. +The characters present in the value of the \fBisearch-terminators\fP +variable are used to terminate an incremental search. +If that variable has not been assigned a value the Escape and +Control-J characters will terminate an incremental search. +Control-G will abort an incremental search and restore the original +line. +When the search is terminated, the history entry containing the +search string becomes the current line. +.PP +To find other matching entries in the history list, type Control-S or +Control-R as appropriate. +This will search backward or forward in the history for the next +entry matching the search string typed so far. +Any other key sequence bound to a readline command will terminate +the search and execute that command. +For instance, a \fInewline\fP will terminate the search and accept +the line, thereby executing the command from the history list. +.PP +Readline remembers the last incremental search string. If two +Control-Rs are typed without any intervening characters defining a +new search string, any remembered search string is used. +.PP +Non-incremental searches read the entire search string before starting +to search for matching history lines. The search string may be +typed by the user or be part of the contents of the current line. +.SS "Readline Command Names" +.PP +The following is a list of the names of the commands and the default +key sequences to which they are bound. +Command names without an accompanying key sequence are unbound by default. +In the following descriptions, \fIpoint\fP refers to the current cursor +position, and \fImark\fP refers to a cursor position saved by the +\fBset\-mark\fP command. +The text between the point and mark is referred to as the \fIregion\fP. +.SS Commands for Moving +.PP +.PD 0 +.TP +.B beginning\-of\-line (C\-a) +Move to the start of the current line. +.TP +.B end\-of\-line (C\-e) +Move to the end of the line. +.TP +.B forward\-char (C\-f) +Move forward a character. +.TP +.B backward\-char (C\-b) +Move back a character. +.TP +.B forward\-word (M\-f) +Move forward to the end of the next word. Words are composed of +alphanumeric characters (letters and digits). +.TP +.B backward\-word (M\-b) +Move back to the start of the current or previous word. +Words are composed of alphanumeric characters (letters and digits). +.TP +.B shell\-forward\-word +Move forward to the end of the next word. +Words are delimited by non-quoted shell metacharacters. +.TP +.B shell\-backward\-word +Move back to the start of the current or previous word. +Words are delimited by non-quoted shell metacharacters. +.TP +.B clear\-screen (C\-l) +Clear the screen leaving the current line at the top of the screen. +With an argument, refresh the current line without clearing the +screen. +.TP +.B redraw\-current\-line +Refresh the current line. +.PD +.SS Commands for Manipulating the History +.PP +.PD 0 +.TP +.B accept\-line (Newline, Return) +Accept the line regardless of where the cursor is. If this line is +non-empty, add it to the history list according to the state of the +.SM +.B HISTCONTROL +variable. If the line is a modified history +line, then restore the history line to its original state. +.TP +.B previous\-history (C\-p) +Fetch the previous command from the history list, moving back in +the list. +.TP +.B next\-history (C\-n) +Fetch the next command from the history list, moving forward in the +list. +.TP +.B beginning\-of\-history (M\-<) +Move to the first line in the history. +.TP +.B end\-of\-history (M\->) +Move to the end of the input history, i.e., the line currently being +entered. +.TP +.B reverse\-search\-history (C\-r) +Search backward starting at the current line and moving `up' through +the history as necessary. This is an incremental search. +.TP +.B forward\-search\-history (C\-s) +Search forward starting at the current line and moving `down' through +the history as necessary. This is an incremental search. +.TP +.B non\-incremental\-reverse\-search\-history (M\-p) +Search backward through the history starting at the current line +using a non-incremental search for a string supplied by the user. +.TP +.B non\-incremental\-forward\-search\-history (M\-n) +Search forward through the history using a non-incremental search for +a string supplied by the user. +.TP +.B history\-search\-forward +Search forward through the history for the string of characters +between the start of the current line and the point. +This is a non-incremental search. +.TP +.B history\-search\-backward +Search backward through the history for the string of characters +between the start of the current line and the point. +This is a non-incremental search. +.TP +.B yank\-nth\-arg (M\-C\-y) +Insert the first argument to the previous command (usually +the second word on the previous line) at point. +With an argument +.IR n , +insert the \fIn\fPth word from the previous command (the words +in the previous command begin with word 0). A negative argument +inserts the \fIn\fPth word from the end of the previous command. +Once the argument \fIn\fP is computed, the argument is extracted +as if the "!\fIn\fP" history expansion had been specified. +.TP +.B +yank\-last\-arg (M\-.\^, M\-_\^) +Insert the last argument to the previous command (the last word of +the previous history entry). +With a numeric argument, behave exactly like \fByank\-nth\-arg\fP. +Successive calls to \fByank\-last\-arg\fP move back through the history +list, inserting the last word (or the word specified by the argument to +the first call) of each line in turn. +Any numeric argument supplied to these successive calls determines +the direction to move through the history. A negative argument switches +the direction through the history (back or forward). +The history expansion facilities are used to extract the last argument, +as if the "!$" history expansion had been specified. +.TP +.B shell\-expand\-line (M\-C\-e) +Expand the line as the shell does. This +performs alias and history expansion as well as all of the shell +word expansions. See +.SM +.B HISTORY EXPANSION +below for a description of history expansion. +.TP +.B history\-expand\-line (M\-^) +Perform history expansion on the current line. +See +.SM +.B HISTORY EXPANSION +below for a description of history expansion. +.TP +.B magic\-space +Perform history expansion on the current line and insert a space. +See +.SM +.B HISTORY EXPANSION +below for a description of history expansion. +.TP +.B alias\-expand\-line +Perform alias expansion on the current line. +See +.SM +.B ALIASES +above for a description of alias expansion. +.TP +.B history\-and\-alias\-expand\-line +Perform history and alias expansion on the current line. +.TP +.B insert\-last\-argument (M\-.\^, M\-_\^) +A synonym for \fByank\-last\-arg\fP. +.TP +.B operate\-and\-get\-next (C\-o) +Accept the current line for execution and fetch the next line +relative to the current line from the history for editing. Any +argument is ignored. +.TP +.B edit\-and\-execute\-command (C\-xC\-e) +Invoke an editor on the current command line, and execute the result as shell +commands. +\fBBash\fP attempts to invoke +.SM +.BR $VISUAL , +.SM +.BR $EDITOR , +and \fIemacs\fP as the editor, in that order. +.PD +.SS Commands for Changing Text +.PP +.PD 0 +.TP +.B delete\-char (C\-d) +Delete the character at point. If point is at the +beginning of the line, there are no characters in the line, and +the last character typed was not bound to \fBdelete\-char\fP, +then return +.SM +.BR EOF . +.TP +.B backward\-delete\-char (Rubout) +Delete the character behind the cursor. When given a numeric argument, +save the deleted text on the kill ring. +.TP +.B forward\-backward\-delete\-char +Delete the character under the cursor, unless the cursor is at the +end of the line, in which case the character behind the cursor is +deleted. +.TP +.B quoted\-insert (C\-q, C\-v) +Add the next character typed to the line verbatim. This is +how to insert characters like \fBC\-q\fP, for example. +.TP +.B tab\-insert (C\-v TAB) +Insert a tab character. +.TP +.B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...) +Insert the character typed. +.TP +.B transpose\-chars (C\-t) +Drag the character before point forward over the character at point, +moving point forward as well. +If point is at the end of the line, then this transposes +the two characters before point. +Negative arguments have no effect. +.TP +.B transpose\-words (M\-t) +Drag the word before point past the word after point, +moving point over that word as well. +If point is at the end of the line, this transposes +the last two words on the line. +.TP +.B upcase\-word (M\-u) +Uppercase the current (or following) word. With a negative argument, +uppercase the previous word, but do not move point. +.TP +.B downcase\-word (M\-l) +Lowercase the current (or following) word. With a negative argument, +lowercase the previous word, but do not move point. +.TP +.B capitalize\-word (M\-c) +Capitalize the current (or following) word. With a negative argument, +capitalize the previous word, but do not move point. +.TP +.B overwrite\-mode +Toggle overwrite mode. With an explicit positive numeric argument, +switches to overwrite mode. With an explicit non-positive numeric +argument, switches to insert mode. This command affects only +\fBemacs\fP mode; \fBvi\fP mode does overwrite differently. +Each call to \fIreadline()\fP starts in insert mode. +In overwrite mode, characters bound to \fBself\-insert\fP replace +the text at point rather than pushing the text to the right. +Characters bound to \fBbackward\-delete\-char\fP replace the character +before point with a space. By default, this command is unbound. +.PD +.SS Killing and Yanking +.PP +.PD 0 +.TP +.B kill\-line (C\-k) +Kill the text from point to the end of the line. +.TP +.B backward\-kill\-line (C\-x Rubout) +Kill backward to the beginning of the line. +.TP +.B unix\-line\-discard (C\-u) +Kill backward from point to the beginning of the line. +The killed text is saved on the kill-ring. +.\" There is no real difference between this and backward-kill-line +.TP +.B kill\-whole\-line +Kill all characters on the current line, no matter where point is. +.TP +.B kill\-word (M\-d) +Kill from point to the end of the current word, or if between +words, to the end of the next word. +Word boundaries are the same as those used by \fBforward\-word\fP. +.TP +.B backward\-kill\-word (M\-Rubout) +Kill the word behind point. +Word boundaries are the same as those used by \fBbackward\-word\fP. +.TP +.B shell\-kill\-word (M\-d) +Kill from point to the end of the current word, or if between +words, to the end of the next word. +Word boundaries are the same as those used by \fBshell\-forward\-word\fP. +.TP +.B shell\-backward\-kill\-word (M\-Rubout) +Kill the word behind point. +Word boundaries are the same as those used by \fBshell\-backward\-word\fP. +.TP +.B unix\-word\-rubout (C\-w) +Kill the word behind point, using white space as a word boundary. +The killed text is saved on the kill-ring. +.TP +.B unix\-filename\-rubout +Kill the word behind point, using white space and the slash character +as the word boundaries. +The killed text is saved on the kill-ring. +.TP +.B delete\-horizontal\-space (M\-\e) +Delete all spaces and tabs around point. +.TP +.B kill\-region +Kill the text in the current region. +.TP +.B copy\-region\-as\-kill +Copy the text in the region to the kill buffer. +.TP +.B copy\-backward\-word +Copy the word before point to the kill buffer. +The word boundaries are the same as \fBbackward\-word\fP. +.TP +.B copy\-forward\-word +Copy the word following point to the kill buffer. +The word boundaries are the same as \fBforward\-word\fP. +.TP +.B yank (C\-y) +Yank the top of the kill ring into the buffer at point. +.TP +.B yank\-pop (M\-y) +Rotate the kill ring, and yank the new top. Only works following +.B yank +or +.BR yank\-pop . +.PD +.SS Numeric Arguments +.PP +.PD 0 +.TP +.B digit\-argument (M\-0, M\-1, ..., M\-\-) +Add this digit to the argument already accumulating, or start a new +argument. M\-\- starts a negative argument. +.TP +.B universal\-argument +This is another way to specify an argument. +If this command is followed by one or more digits, optionally with a +leading minus sign, those digits define the argument. +If the command is followed by digits, executing +.B universal\-argument +again ends the numeric argument, but is otherwise ignored. +As a special case, if this command is immediately followed by a +character that is neither a digit or minus sign, the argument count +for the next command is multiplied by four. +The argument count is initially one, so executing this function the +first time makes the argument count four, a second time makes the +argument count sixteen, and so on. +.PD +.SS Completing +.PP +.PD 0 +.TP +.B complete (TAB) +Attempt to perform completion on the text before point. +.B Bash +attempts completion treating the text as a variable (if the +text begins with \fB$\fP), username (if the text begins with +\fB~\fP), hostname (if the text begins with \fB@\fP), or +command (including aliases and functions) in turn. If none +of these produces a match, filename completion is attempted. +.TP +.B possible\-completions (M\-?) +List the possible completions of the text before point. +.TP +.B insert\-completions (M\-*) +Insert all completions of the text before point +that would have been generated by +\fBpossible\-completions\fP. +.TP +.B menu\-complete +Similar to \fBcomplete\fP, but replaces the word to be completed +with a single match from the list of possible completions. +Repeated execution of \fBmenu\-complete\fP steps through the list +of possible completions, inserting each match in turn. +At the end of the list of completions, the bell is rung +(subject to the setting of \fBbell\-style\fP) +and the original text is restored. +An argument of \fIn\fP moves \fIn\fP positions forward in the list +of matches; a negative argument may be used to move backward +through the list. +This command is intended to be bound to \fBTAB\fP, but is unbound +by default. +.TP +.B menu\-complete\-backward +Identical to \fBmenu\-complete\fP, but moves backward through the list +of possible completions, as if \fBmenu\-complete\fP had been given a +negative argument. This command is unbound by default. +.TP +.B delete\-char\-or\-list +Deletes the character under the cursor if not at the beginning or +end of the line (like \fBdelete\-char\fP). +If at the end of the line, behaves identically to +\fBpossible\-completions\fP. +This command is unbound by default. +.TP +.B complete\-filename (M\-/) +Attempt filename completion on the text before point. +.TP +.B possible\-filename\-completions (C\-x /) +List the possible completions of the text before point, +treating it as a filename. +.TP +.B complete\-username (M\-~) +Attempt completion on the text before point, treating +it as a username. +.TP +.B possible\-username\-completions (C\-x ~) +List the possible completions of the text before point, +treating it as a username. +.TP +.B complete\-variable (M\-$) +Attempt completion on the text before point, treating +it as a shell variable. +.TP +.B possible\-variable\-completions (C\-x $) +List the possible completions of the text before point, +treating it as a shell variable. +.TP +.B complete\-hostname (M\-@) +Attempt completion on the text before point, treating +it as a hostname. +.TP +.B possible\-hostname\-completions (C\-x @) +List the possible completions of the text before point, +treating it as a hostname. +.TP +.B complete\-command (M\-!) +Attempt completion on the text before point, treating +it as a command name. Command completion attempts to +match the text against aliases, reserved words, shell +functions, shell builtins, and finally executable filenames, +in that order. +.TP +.B possible\-command\-completions (C\-x !) +List the possible completions of the text before point, +treating it as a command name. +.TP +.B dynamic\-complete\-history (M\-TAB) +Attempt completion on the text before point, comparing +the text against lines from the history list for possible +completion matches. +.TP +.B dabbrev\-expand +Attempt menu completion on the text before point, comparing +the text against lines from the history list for possible +completion matches. +.TP +.B complete\-into\-braces (M\-{) +Perform filename completion and insert the list of possible completions +enclosed within braces so the list is available to the shell (see +.B Brace Expansion +above). +.PD +.SS Keyboard Macros +.PP +.PD 0 +.TP +.B start\-kbd\-macro (C\-x (\^) +Begin saving the characters typed into the current keyboard macro. +.TP +.B end\-kbd\-macro (C\-x )\^) +Stop saving the characters typed into the current keyboard macro +and store the definition. +.TP +.B call\-last\-kbd\-macro (C\-x e) +Re-execute the last keyboard macro defined, by making the characters +in the macro appear as if typed at the keyboard. +.B print\-last\-kbd\-macro () +Print the last keyboard macro defined in a format suitable for the +\fIinputrc\fP file. +.PD +.SS Miscellaneous +.PP +.PD 0 +.TP +.B re\-read\-init\-file (C\-x C\-r) +Read in the contents of the \fIinputrc\fP file, and incorporate +any bindings or variable assignments found there. +.TP +.B abort (C\-g) +Abort the current editing command and +ring the terminal's bell (subject to the setting of +.BR bell\-style ). +.TP +.B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...) +If the metafied character \fIx\fP is lowercase, run the command +that is bound to the corresponding uppercase character. +.TP +.B prefix\-meta (ESC) +Metafy the next character typed. +.SM +.B ESC +.B f +is equivalent to +.BR Meta\-f . +.TP +.B undo (C\-_, C\-x C\-u) +Incremental undo, separately remembered for each line. +.TP +.B revert\-line (M\-r) +Undo all changes made to this line. This is like executing the +.B undo +command enough times to return the line to its initial state. +.TP +.B tilde\-expand (M\-&) +Perform tilde expansion on the current word. +.TP +.B set\-mark (C\-@, M\-) +Set the mark to the point. If a +numeric argument is supplied, the mark is set to that position. +.TP +.B exchange\-point\-and\-mark (C\-x C\-x) +Swap the point with the mark. The current cursor position is set to +the saved position, and the old cursor position is saved as the mark. +.TP +.B character\-search (C\-]) +A character is read and point is moved to the next occurrence of that +character. A negative count searches for previous occurrences. +.TP +.B character\-search\-backward (M\-C\-]) +A character is read and point is moved to the previous occurrence of that +character. A negative count searches for subsequent occurrences. +.TP +.B skip\-csi\-sequence +Read enough characters to consume a multi-key sequence such as those +defined for keys like Home and End. Such sequences begin with a +Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is +bound to "\e[", keys producing such sequences will have no effect +unless explicitly bound to a readline command, instead of inserting +stray characters into the editing buffer. This is unbound by default, +but usually bound to ESC\-[. +.TP +.B insert\-comment (M\-#) +Without a numeric argument, the value of the readline +.B comment\-begin +variable is inserted at the beginning of the current line. +If a numeric argument is supplied, this command acts as a toggle: if +the characters at the beginning of the line do not match the value +of \fBcomment\-begin\fP, the value is inserted, otherwise +the characters in \fBcomment\-begin\fP are deleted from the beginning of +the line. +In either case, the line is accepted as if a newline had been typed. +The default value of +\fBcomment\-begin\fP causes this command to make the current line +a shell comment. +If a numeric argument causes the comment character to be removed, the line +will be executed by the shell. +.TP +.B glob\-complete\-word (M\-g) +The word before point is treated as a pattern for pathname expansion, +with an asterisk implicitly appended. This pattern is used to +generate a list of matching filenames for possible completions. +.TP +.B glob\-expand\-word (C\-x *) +The word before point is treated as a pattern for pathname expansion, +and the list of matching filenames is inserted, replacing the word. +If a numeric argument is supplied, an asterisk is appended before +pathname expansion. +.TP +.B glob\-list\-expansions (C\-x g) +The list of expansions that would have been generated by +.B glob\-expand\-word +is displayed, and the line is redrawn. +If a numeric argument is supplied, an asterisk is appended before +pathname expansion. +.TP +.B dump\-functions +Print all of the functions and their key bindings to the +readline output stream. If a numeric argument is supplied, +the output is formatted in such a way that it can be made part +of an \fIinputrc\fP file. +.TP +.B dump\-variables +Print all of the settable readline variables and their values to the +readline output stream. If a numeric argument is supplied, +the output is formatted in such a way that it can be made part +of an \fIinputrc\fP file. +.TP +.B dump\-macros +Print all of the readline key sequences bound to macros and the +strings they output. If a numeric argument is supplied, +the output is formatted in such a way that it can be made part +of an \fIinputrc\fP file. +.TP +.B display\-shell\-version (C\-x C\-v) +Display version information about the current instance of +.BR bash . +.PD +.SS Programmable Completion +.PP +When word completion is attempted for an argument to a command for +which a completion specification (a \fIcompspec\fP) has been defined +using the \fBcomplete\fP builtin (see +.SM +.B "SHELL BUILTIN COMMANDS" +below), the programmable completion facilities are invoked. +.PP +First, the command name is identified. +If the command word is the empty string (completion attempted at the +beginning of an empty line), any compspec defined with +the \fB\-E\fP option to \fBcomplete\fP is used. +If a compspec has been defined for that command, the +compspec is used to generate the list of possible completions for the word. +If the command word is a full pathname, a compspec for the full +pathname is searched for first. +If no compspec is found for the full pathname, an attempt is made to +find a compspec for the portion following the final slash. +If those searches do not result in a compspec, any compspec defined with +the \fB\-D\fP option to \fBcomplete\fP is used as the default. +.PP +Once a compspec has been found, it is used to generate the list of +matching words. +If a compspec is not found, the default \fBbash\fP completion as +described above under \fBCompleting\fP is performed. +.PP +First, the actions specified by the compspec are used. +Only matches which are prefixed by the word being completed are +returned. +When the +.B \-f +or +.B \-d +option is used for filename or directory name completion, the shell +variable +.SM +.B FIGNORE +is used to filter the matches. +.PP +Any completions specified by a pathname expansion pattern to the +\fB\-G\fP option are generated next. +The words generated by the pattern need not match the word +being completed. +The +.SM +.B GLOBIGNORE +shell variable is not used to filter the matches, but the +.SM +.B FIGNORE +variable is used. +.PP +Next, the string specified as the argument to the \fB\-W\fP option +is considered. +The string is first split using the characters in the +.SM +.B IFS +special variable as delimiters. +Shell quoting is honored. +Each word is then expanded using +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, and arithmetic expansion, +as described above under +.SM +.BR EXPANSION . +The results are split using the rules described above under +\fBWord Splitting\fP. +The results of the expansion are prefix-matched against the word being +completed, and the matching words become the possible completions. +.PP +After these matches have been generated, any shell function or command +specified with the \fB\-F\fP and \fB\-C\fP options is invoked. +When the command or function is invoked, the +.SM +.BR COMP_LINE , +.SM +.BR COMP_POINT , +.SM +.BR COMP_KEY , +and +.SM +.B COMP_TYPE +variables are assigned values as described above under +\fBShell Variables\fP. +If a shell function is being invoked, the +.SM +.B COMP_WORDS +and +.SM +.B COMP_CWORD +variables are also set. +When the function or command is invoked, +the first argument (\fB$1\fP) is the name of the command whose arguments are +being completed, +the second argument (\fB$2\fP) is the word being completed, +and the third argument (\fB$3\fP) is the word preceding the word being +completed on the current command line. +No filtering of the generated completions against the word being completed +is performed; the function or command has complete freedom in generating +the matches. +.PP +Any function specified with \fB\-F\fP is invoked first. +The function may use any of the shell facilities, including the +\fBcompgen\fP builtin described below, to generate the matches. +It must put the possible completions in the +.SM +.B COMPREPLY +array variable, one per array element. +.PP +Next, any command specified with the \fB\-C\fP option is invoked +in an environment equivalent to command substitution. +It should print a list of completions, one per line, to the +standard output. +Backslash may be used to escape a newline, if necessary. +.PP +After all of the possible completions are generated, any filter +specified with the \fB\-X\fP option is applied to the list. +The filter is a pattern as used for pathname expansion; a \fB&\fP +in the pattern is replaced with the text of the word being completed. +A literal \fB&\fP may be escaped with a backslash; the backslash +is removed before attempting a match. +Any completion that matches the pattern will be removed from the list. +A leading \fB!\fP negates the pattern; in this case any completion +not matching the pattern will be removed. +.PP +Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP +options are added to each member of the completion list, and the result is +returned to the readline completion code as the list of possible +completions. +.PP +If the previously-applied actions do not generate any matches, and the +\fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the +compspec was defined, directory name completion is attempted. +.PP +If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the +compspec was defined, directory name completion is attempted and any +matches are added to the results of the other actions. +.PP +By default, if a compspec is found, whatever it generates is returned +to the completion code as the full set of possible completions. +The default \fBbash\fP completions are not attempted, and the readline +default of filename completion is disabled. +If the \fB\-o bashdefault\fP option was supplied to \fBcomplete\fP when +the compspec was defined, the \fBbash\fP default completions are attempted +if the compspec generates no matches. +If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the +compspec was defined, readline's default completion will be performed +if the compspec (and, if attempted, the default \fBbash\fP completions) +generate no matches. +.PP +When a compspec indicates that directory name completion is desired, +the programmable completion functions force readline to append a slash +to completed names which are symbolic links to directories, subject to +the value of the \fBmark\-directories\fP readline variable, regardless +of the setting of the \fBmark-symlinked\-directories\fP readline variable. +.PP +There is some support for dynamically modifying completions. This is +most useful when used in combination with a default completion specified +with \fBcomplete -D\fP. +It's possible for shell functions executed as completion +handlers to indicate that completion should be retried by returning an +exit status of 124. If a shell function returns 124, and changes +the compspec associated with the command on which completion is being +attempted (supplied as the first argument when the function is executed), +programmable completion restarts from the beginning, with an +attempt to find a new compspec for that command. This allows a set of +completions to be built dynamically as completion is attempted, rather than +being loaded all at once. +.PP +For instance, assuming that there is a library of compspecs, each kept in a +file corresponding to the name of the command, the following default +completion function would load completions dynamically: +.PP +\f(CW_completion_loader() +.br +{ +.br + . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 +.br +} +.br +complete -D -F _completion_loader +.br +\fP +.SH HISTORY +When the +.B \-o history +option to the +.B set +builtin is enabled, the shell provides access to the +\fIcommand history\fP, +the list of commands previously typed. +The value of the +.SM +.B HISTSIZE +variable is used as the +number of commands to save in a history list. +The text of the last +.SM +.B HISTSIZE +commands (default 500) is saved. The shell +stores each command in the history list prior to parameter and +variable expansion (see +.SM +.B EXPANSION +above) but after history expansion is performed, subject to the +values of the shell variables +.SM +.B HISTIGNORE +and +.SM +.BR HISTCONTROL . +.PP +On startup, the history is initialized from the file named by +the variable +.SM +.B HISTFILE +(default \fI~/.bash_history\fP). +The file named by the value of +.SM +.B HISTFILE +is truncated, if necessary, to contain no more than +the number of lines specified by the value of +.SM +.BR HISTFILESIZE . +If \fBHISTFILESIZE\fP is unset, or set to null, a non-numeric value, +or a numeric value less than zero, the history file is not truncated. +When the history file is read, +lines beginning with the history comment character followed immediately +by a digit are interpreted as timestamps for the preceding history line. +These timestamps are optionally displayed depending on the value of the +.SM +.B HISTTIMEFORMAT +variable. +When a shell with history enabled exits, the last +.SM +.B $HISTSIZE +lines are copied from the history list to +.SM +.BR $HISTFILE . +If the +.B histappend +shell option is enabled +(see the description of +.B shopt +under +.SM +.B "SHELL BUILTIN COMMANDS" +below), the lines are appended to the history file, +otherwise the history file is overwritten. +If +.SM +.B HISTFILE +is unset, or if the history file is unwritable, the history is +not saved. +If the +.SM +.B HISTTIMEFORMAT +variable is set, time stamps are written to the history file, marked +with the history comment character, so +they may be preserved across shell sessions. +This uses the history comment character to distinguish timestamps from +other history lines. +After saving the history, the history file is truncated +to contain no more than +.SM +.B HISTFILESIZE +lines. If +.SM +.B HISTFILESIZE +is unset, or set to null, a non-numeric value, +or a numeric value less than zero, the history file is not truncated. +.PP +The builtin command +.B fc +(see +.SM +.B SHELL BUILTIN COMMANDS +below) may be used to list or edit and re-execute a portion of +the history list. +The +.B history +builtin may be used to display or modify the history list and +manipulate the history file. +When using command-line editing, search commands +are available in each editing mode that provide access to the +history list. +.PP +The shell allows control over which commands are saved on the history +list. The +.SM +.B HISTCONTROL +and +.SM +.B HISTIGNORE +variables may be set to cause the shell to save only a subset of the +commands entered. +The +.B cmdhist +shell option, if enabled, causes the shell to attempt to save each +line of a multi-line command in the same history entry, adding +semicolons where necessary to preserve syntactic correctness. +The +.B lithist +shell option causes the shell to save the command with embedded newlines +instead of semicolons. See the description of the +.B shopt +builtin below under +.SM +.B "SHELL BUILTIN COMMANDS" +for information on setting and unsetting shell options. +.SH "HISTORY EXPANSION" +.PP +The shell supports a history expansion feature that +is similar to the history expansion in +.BR csh. +This section describes what syntax features are available. This +feature is enabled by default for interactive shells, and can be +disabled using the +.B +H +option to the +.B set +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). Non-interactive shells do not perform history expansion +by default. +.PP +History expansions introduce words from the history list into +the input stream, making it easy to repeat commands, insert the +arguments to a previous command into the current input line, or +fix errors in previous commands quickly. +.PP +History expansion is performed immediately after a complete line +is read, before the shell breaks it into words. +It takes place in two parts. +The first is to determine which line from the history list +to use during substitution. +The second is to select portions of that line for inclusion into +the current one. +The line selected from the history is the \fIevent\fP, +and the portions of that line that are acted upon are \fIwords\fP. +Various \fImodifiers\fP are available to manipulate the selected words. +The line is broken into words in the same fashion as when reading input, +so that several \fImetacharacter\fP-separated words surrounded by +quotes are considered one word. +History expansions are introduced by the appearance of the +history expansion character, which is \^\fB!\fP\^ by default. +Only backslash (\^\fB\e\fP\^) and single quotes can quote +the history expansion character. +.PP +Several characters inhibit history expansion if found immediately +following the history expansion character, even if it is unquoted: +space, tab, newline, carriage return, and \fB=\fP. +If the \fBextglob\fP shell option is enabled, \fB(\fP will also +inhibit expansion. +.PP +Several shell options settable with the +.B shopt +builtin may be used to tailor the behavior of history expansion. +If the +.B histverify +shell option is enabled (see the description of the +.B shopt +builtin below), and +.B readline +is being used, history substitutions are not immediately passed to +the shell parser. +Instead, the expanded line is reloaded into the +.B readline +editing buffer for further modification. +If +.B readline +is being used, and the +.B histreedit +shell option is enabled, a failed history substitution will be reloaded +into the +.B readline +editing buffer for correction. +The +.B \-p +option to the +.B history +builtin command may be used to see what a history expansion will +do before using it. +The +.B \-s +option to the +.B history +builtin may be used to add commands to the end of the history list +without actually executing them, so that they are available for +subsequent recall. +.PP +The shell allows control of the various characters used by the +history expansion mechanism (see the description of +.B histchars +above under +.BR "Shell Variables" ). +The shell uses +the history comment character to mark history timestamps when +writing the history file. +.SS Event Designators +.PP +An event designator is a reference to a command line entry in the +history list. +Unless the reference is absolute, events are relative to the current +position in the history list. +.PP +.PD 0 +.TP +.B ! +Start a history substitution, except when followed by a +.BR blank , +newline, carriage return, = +or ( (when the \fBextglob\fP shell option is enabled using +the \fBshopt\fP builtin). +.TP +.B !\fIn\fR +Refer to command line +.IR n . +.TP +.B !\-\fIn\fR +Refer to the current command minus +.IR n . +.TP +.B !! +Refer to the previous command. This is a synonym for `!\-1'. +.TP +.B !\fIstring\fR +Refer to the most recent command preceding the current position in the +history list starting with +.IR string . +.TP +.B !?\fIstring\fR\fB[?]\fR +Refer to the most recent command preceding the current position in the +history list containing +.IR string . +The trailing \fB?\fP may be omitted if +.I string +is followed immediately by a newline. +.TP +.B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u +Quick substitution. Repeat the previous command, replacing +.I string1 +with +.IR string2 . +Equivalent to +``!!:s/\fIstring1\fP/\fIstring2\fP/'' +(see \fBModifiers\fP below). +.TP +.B !# +The entire command line typed so far. +.PD +.SS Word Designators +.PP +Word designators are used to select desired words from the event. +A +.B : +separates the event specification from the word designator. +It may be omitted if the word designator begins with a +.BR ^ , +.BR $ , +.BR * , +.BR \- , +or +.BR % . +Words are numbered from the beginning of the line, +with the first word being denoted by 0 (zero). +Words are inserted into the current line separated by single spaces. +.PP +.PD 0 +.TP +.B 0 (zero) +The zeroth word. For the shell, this is the command +word. +.TP +.I n +The \fIn\fRth word. +.TP +.B ^ +The first argument. That is, word 1. +.TP +.B $ +The last argument. +.TP +.B % +The word matched by the most recent `?\fIstring\fR?' search. +.TP +.I x\fB\-\fPy +A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'. +.TP +.B * +All of the words but the zeroth. This is a synonym +for `\fI1\-$\fP'. It is not an error to use +.B * +if there is just one +word in the event; the empty string is returned in that case. +.TP +.B x* +Abbreviates \fIx\-$\fP. +.TP +.B x\- +Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word. +.PD +.PP +If a word designator is supplied without an event specification, the +previous command is used as the event. +.SS Modifiers +.PP +After the optional word designator, there may appear a sequence of +one or more of the following modifiers, each preceded by a `:'. +.PP +.PD 0 +.PP +.TP +.B h +Remove a trailing filename component, leaving only the head. +.TP +.B t +Remove all leading filename components, leaving the tail. +.TP +.B r +Remove a trailing suffix of the form \fI.xxx\fP, leaving the +basename. +.TP +.B e +Remove all but the trailing suffix. +.TP +.B p +Print the new command but do not execute it. +.TP +.B q +Quote the substituted words, escaping further substitutions. +.TP +.B x +Quote the substituted words as with +.BR q , +but break into words at +.B blanks +and newlines. +.TP +.B s/\fIold\fP/\fInew\fP/ +Substitute +.I new +for the first occurrence of +.I old +in the event line. Any delimiter can be used in place of /. The +final delimiter is optional if it is the last character of the +event line. The delimiter may be quoted in +.I old +and +.I new +with a single backslash. If & appears in +.IR new , +it is replaced by +.IR old . +A single backslash will quote the &. If +.I old +is null, it is set to the last +.I old +substituted, or, if no previous history substitutions took place, +the last +.I string +in a +.B !?\fIstring\fR\fB[?]\fR +search. +.TP +.B & +Repeat the previous substitution. +.TP +.B g +Cause changes to be applied over the entire event line. This is +used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR') +or `\fB:&\fP'. If used with +`\fB:s\fP', any delimiter can be used +in place of /, and the final delimiter is optional +if it is the last character of the event line. +An \fBa\fP may be used as a synonym for \fBg\fP. +.TP +.B G +Apply the following `\fBs\fP' modifier once to each word in the event line. +.PD +.SH "SHELL BUILTIN COMMANDS" +.\" start of bash_builtins +.zZ +.PP +Unless otherwise noted, each builtin command documented in this +section as accepting options preceded by +.B \- +accepts +.B \-\- +to signify the end of the options. +The \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP builtins +do not accept options and do not treat \fB\-\-\fP specially. +The \fBexit\fP, \fBlogout\fP, \fBbreak\fP, \fBcontinue\fP, \fBlet\fP, +and \fBshift\fP builtins accept and process arguments beginning with +\fB\-\fP without requiring \fB\-\-\fP. +Other builtins that accept arguments but are not specified as accepting +options interpret arguments beginning with \fB\-\fP as invalid options and +require \fB\-\-\fP to prevent this interpretation. +.sp .5 +.PD 0 +.TP +\fB:\fP [\fIarguments\fP] +.PD +No effect; the command does nothing beyond expanding +.I arguments +and performing any specified +redirections. A zero exit code is returned. +.TP +\fB .\| \fP \fIfilename\fP [\fIarguments\fP] +.PD 0 +.TP +\fBsource\fP \fIfilename\fP [\fIarguments\fP] +.PD +Read and execute commands from +.I filename +in the current +shell environment and return the exit status of the last command +executed from +.IR filename . +If +.I filename +does not contain a slash, filenames in +.SM +.B PATH +are used to find the directory containing +.IR filename . +The file searched for in +.SM +.B PATH +need not be executable. +When \fBbash\fP is not in \fIposix mode\fP, the current directory is +searched if no file is found in +.SM +.BR PATH . +If the +.B sourcepath +option to the +.B shopt +builtin command is turned off, the +.SM +.B PATH +is not searched. +If any \fIarguments\fP are supplied, they become the positional +parameters when \fIfilename\fP is executed. Otherwise the positional +parameters are unchanged. +The return status is the status of the last command exited within +the script (0 if no commands are executed), and false if +.I filename +is not found or cannot be read. +.TP +\fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] +\fBAlias\fP with no arguments or with the +.B \-p +option prints the list of aliases in the form +\fBalias\fP \fIname\fP=\fIvalue\fP on standard output. +When arguments are supplied, an alias is defined for +each \fIname\fP whose \fIvalue\fP is given. +A trailing space in \fIvalue\fP causes the next word to be +checked for alias substitution when the alias is expanded. +For each \fIname\fP in the argument list for which no \fIvalue\fP +is supplied, the name and value of the alias is printed. +\fBAlias\fP returns true unless a \fIname\fP is given for which +no alias has been defined. +.TP +\fBbg\fP [\fIjobspec\fP ...] +Resume each suspended job \fIjobspec\fP in the background, as if it +had been started with +.BR & . +If +.I jobspec +is not present, the shell's notion of the \fIcurrent job\fP is used. +.B bg +.I jobspec +returns 0 unless run when job control is disabled or, when run with +job control enabled, any specified \fIjobspec\fP was not found +or was started without job control. +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSVX\fP] +.PD 0 +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP] +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP +.TP +\fBbind\fP \fIreadline\-command\fP +.PD +Display current +.B readline +key and function bindings, bind a key sequence to a +.B readline +function or macro, or set a +.B readline +variable. +Each non-option argument is a command as it would appear in +.IR .inputrc , +but each binding or command must be passed as a separate argument; +e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. +Options, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-m \fIkeymap\fP +Use +.I keymap +as the keymap to be affected by the subsequent bindings. +Acceptable +.I keymap +names are +\fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, +vi\-move, vi\-command\fP, and +.IR vi\-insert . +\fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is +equivalent to \fIemacs\-standard\fP. +.TP +.B \-l +List the names of all \fBreadline\fP functions. +.TP +.B \-p +Display \fBreadline\fP function names and bindings in such a way +that they can be re-read. +.TP +.B \-P +List current \fBreadline\fP function names and bindings. +.TP +.B \-s +Display \fBreadline\fP key sequences bound to macros and the strings +they output in such a way that they can be re-read. +.TP +.B \-S +Display \fBreadline\fP key sequences bound to macros and the strings +they output. +.TP +.B \-v +Display \fBreadline\fP variable names and values in such a way that they +can be re-read. +.TP +.B \-V +List current \fBreadline\fP variable names and values. +.TP +.B \-f \fIfilename\fP +Read key bindings from \fIfilename\fP. +.TP +.B \-q \fIfunction\fP +Query about which keys invoke the named \fIfunction\fP. +.TP +.B \-u \fIfunction\fP +Unbind all keys bound to the named \fIfunction\fP. +.TP +.B \-r \fIkeyseq\fP +Remove any current binding for \fIkeyseq\fP. +.TP +.B \-x \fIkeyseq\fP:\fIshell\-command\fP +Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is +entered. +When \fIshell\-command\fP is executed, the shell sets the +.SM +.B READLINE_LINE +variable to the contents of the \fBreadline\fP line buffer and the +.SM +.B READLINE_POINT +variable to the current location of the insertion point. +If the executed command changes the value of +.SM +.B READLINE_LINE +or +.SM +.BR READLINE_POINT , +those new values will be reflected in the editing state. +.TP +.B \-X +List all key sequences bound to shell commands and the associated commands +in a format that can be reused as input. +.PD +.PP +The return value is 0 unless an unrecognized option is given or an +error occurred. +.RE +.TP +\fBbreak\fP [\fIn\fP] +Exit from within a +.BR for , +.BR while , +.BR until , +or +.B select +loop. If \fIn\fP is specified, break \fIn\fP levels. +.I n +must be \(>= 1. If +.I n +is greater than the number of enclosing loops, all enclosing loops +are exited. +The return value is 0 unless \fIn\fP is not greater than or equal to 1. +.TP +\fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP] +Execute the specified shell builtin, passing it +.IR arguments , +and return its exit status. +This is useful when defining a +function whose name is the same as a shell builtin, +retaining the functionality of the builtin within the function. +The \fBcd\fP builtin is commonly redefined this way. +The return status is false if +.I shell\-builtin +is not a shell builtin command. +.TP +\fBcaller\fP [\fIexpr\fP] +Returns the context of any active subroutine call (a shell function or +a script executed with the \fB.\fP or \fBsource\fP builtins). +Without \fIexpr\fP, \fBcaller\fP displays the line number and source +filename of the current subroutine call. +If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP +displays the line number, subroutine name, and source file corresponding +to that position in the current execution call stack. This extra +information may be used, for example, to print a stack trace. The +current frame is frame 0. +The return value is 0 unless the shell is not executing a subroutine +call or \fIexpr\fP does not correspond to a valid position in the +call stack. +.TP +\fBcd\fP [\fB\-L\fP|[\fB\-P\fP [\fB\-e\fP]]] [\fIdir\fP] +Change the current directory to \fIdir\fP. +if \fIdir\fP is not supplied, the value of the +.SM +.B HOME +shell variable is the default. +Any additional arguments following \fIdir\fP are ignored. +The variable +.SM +.B CDPATH +defines the search path for the directory containing +.IR dir : +each directory name in +.SM +.B CDPATH +is searched for \fIdir\fP. +Alternative directory names in +.SM +.B CDPATH +are separated by a colon (:). A null directory name in +.SM +.B CDPATH +is the same as the current directory, i.e., ``\fB.\fP''. If +.I dir +begins with a slash (/), +then +.SM +.B CDPATH +is not used. The +.B \-P +option causes \fBcd\fP to use the physical directory structure +by resolving symbolic links while traversing \fIdir\fP and +before processing instances of \fI..\fP in \fIdir\fP (see also the +.B \-P +option to the +.B set +builtin command); the +.B \-L +option forces symbolic links to be followed by resolving the link +after processing instances of \fI..\fP in \fIdir\fP. +If \fI..\fP appears in \fIdir\fP, it is processed by removing the +immediately previous pathname component from \fIdir\fP, back to a slash +or the beginning of \fIdir\fP. +If the +.B \-e +option is supplied with +.BR \-P , +and the current working directory cannot be successfully determined +after a successful directory change, \fBcd\fP will return an unsuccessful +status. +An argument of +.B \- +is converted to +.SM +.B $OLDPWD +before the directory change is attempted. +If a non-empty directory name from +.SM +.B CDPATH +is used, or if +\fB\-\fP is the first argument, and the directory change is +successful, the absolute pathname of the new working directory is +written to the standard output. +The return value is true if the directory was successfully changed; +false otherwise. +.TP +\fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...] +Run +.I command +with +.I args +suppressing the normal shell function lookup. Only builtin +commands or commands found in the +.SM +.B PATH +are executed. If the +.B \-p +option is given, the search for +.I command +is performed using a default value for +.SM +.B PATH +that is guaranteed to find all of the standard utilities. +If either the +.B \-V +or +.B \-v +option is supplied, a description of +.I command +is printed. The +.B \-v +option causes a single word indicating the command or filename +used to invoke +.I command +to be displayed; the +.B \-V +option produces a more verbose description. +If the +.B \-V +or +.B \-v +option is supplied, the exit status is 0 if +.I command +was found, and 1 if not. If neither option is supplied and +an error occurred or +.I command +cannot be found, the exit status is 127. Otherwise, the exit status of the +.B command +builtin is the exit status of +.IR command . +.TP +\fBcompgen\fP [\fIoption\fP] [\fIword\fP] +Generate possible completion matches for \fIword\fP according to +the \fIoption\fPs, which may be any option accepted by the +.B complete +builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write +the matches to the standard output. +When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables +set by the programmable completion facilities, while available, will not +have useful values. +.sp 1 +The matches will be generated in the same way as if the programmable +completion code had generated them directly from a completion specification +with the same flags. +If \fIword\fP is specified, only those completions matching \fIword\fP +will be displayed. +.sp 1 +The return value is true unless an invalid option is supplied, or no +matches were generated. +.TP +\fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-DE\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] +.br +[\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname ...\fP] +.PD 0 +.TP +\fBcomplete\fP \fB\-pr\fP [\fB\-DE\fP] [\fIname\fP ...] +.PD +Specify how arguments to each \fIname\fP should be completed. +If the \fB\-p\fP option is supplied, or if no options are supplied, +existing completion specifications are printed in a way that allows +them to be reused as input. +The \fB\-r\fP option removes a completion specification for +each \fIname\fP, or, if no \fIname\fPs are supplied, all +completion specifications. +The \fB\-D\fP option indicates that the remaining options and actions should +apply to the ``default'' command completion; that is, completion attempted +on a command for which no completion has previously been defined. +The \fB\-E\fP option indicates that the remaining options and actions should +apply to ``empty'' command completion; that is, completion attempted on a +blank line. +.sp 1 +The process of applying these completion specifications when word completion +is attempted is described above under \fBProgrammable Completion\fP. +.sp 1 +Other options, if specified, have the following meanings. +The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options +(and, if necessary, the \fB\-P\fP and \fB\-S\fP options) +should be quoted to protect them from expansion before the +.B complete +builtin is invoked. +.RS +.PD 0 +.TP 8 +\fB\-o\fP \fIcomp-option\fP +The \fIcomp-option\fP controls several aspects of the compspec's behavior +beyond the simple generation of completions. +\fIcomp-option\fP may be one of: +.RS +.TP 8 +.B bashdefault +Perform the rest of the default \fBbash\fP completions if the compspec +generates no matches. +.TP 8 +.B default +Use readline's default filename completion if the compspec generates +no matches. +.TP 8 +.B dirnames +Perform directory name completion if the compspec generates no matches. +.TP 8 +.B filenames +Tell readline that the compspec generates filenames, so it can perform any +filename\-specific processing (like adding a slash to directory names, +quoting special characters, or suppressing trailing spaces). +Intended to be used with shell functions. +.TP 8 +.B noquote +Tell readline not to quote the completed words if they are filenames +(quoting filenames is the default). +.TP 8 +.B nospace +Tell readline not to append a space (the default) to words completed at +the end of the line. +.TP 8 +.B plusdirs +After any matches defined by the compspec are generated, +directory name completion is attempted and any +matches are added to the results of the other actions. +.RE +.TP 8 +\fB\-A\fP \fIaction\fP +The \fIaction\fP may be one of the following to generate a list of possible +completions: +.RS +.TP 8 +.B alias +Alias names. May also be specified as \fB\-a\fP. +.TP 8 +.B arrayvar +Array variable names. +.TP 8 +.B binding +\fBReadline\fP key binding names. +.TP 8 +.B builtin +Names of shell builtin commands. May also be specified as \fB\-b\fP. +.TP 8 +.B command +Command names. May also be specified as \fB\-c\fP. +.TP 8 +.B directory +Directory names. May also be specified as \fB\-d\fP. +.TP 8 +.B disabled +Names of disabled shell builtins. +.TP 8 +.B enabled +Names of enabled shell builtins. +.TP 8 +.B export +Names of exported shell variables. May also be specified as \fB\-e\fP. +.TP 8 +.B file +File names. May also be specified as \fB\-f\fP. +.TP 8 +.B function +Names of shell functions. +.TP 8 +.B group +Group names. May also be specified as \fB\-g\fP. +.TP 8 +.B helptopic +Help topics as accepted by the \fBhelp\fP builtin. +.TP 8 +.B hostname +Hostnames, as taken from the file specified by the +.SM +.B HOSTFILE +shell variable. +.TP 8 +.B job +Job names, if job control is active. May also be specified as \fB\-j\fP. +.TP 8 +.B keyword +Shell reserved words. May also be specified as \fB\-k\fP. +.TP 8 +.B running +Names of running jobs, if job control is active. +.TP 8 +.B service +Service names. May also be specified as \fB\-s\fP. +.TP 8 +.B setopt +Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin. +.TP 8 +.B shopt +Shell option names as accepted by the \fBshopt\fP builtin. +.TP 8 +.B signal +Signal names. +.TP 8 +.B stopped +Names of stopped jobs, if job control is active. +.TP 8 +.B user +User names. May also be specified as \fB\-u\fP. +.TP 8 +.B variable +Names of all shell variables. May also be specified as \fB\-v\fP. +.RE +.TP 8 +\fB\-C\fP \fIcommand\fP +\fIcommand\fP is executed in a subshell environment, and its output is +used as the possible completions. +.TP 8 +\fB\-F\fP \fIfunction\fP +The shell function \fIfunction\fP is executed in the current shell +environment. +When the function is executed, +the first argument (\fB$1\fP) is the name of the command whose arguments are +being completed, +the second argument (\fB$2\fP) is the word being completed, +and the third argument (\fB$3\fP) is the word preceding the word being +completed on the current command line. +When it finishes, the possible completions are retrieved from the value +of the +.SM +.B COMPREPLY +array variable. +.TP 8 +\fB\-G\fP \fIglobpat\fP +The pathname expansion pattern \fIglobpat\fP is expanded to generate +the possible completions. +.TP 8 +\fB\-P\fP \fIprefix\fP +\fIprefix\fP is added at the beginning of each possible completion +after all other options have been applied. +.TP 8 +\fB\-S\fP \fIsuffix\fP +\fIsuffix\fP is appended to each possible completion +after all other options have been applied. +.TP 8 +\fB\-W\fP \fIwordlist\fP +The \fIwordlist\fP is split using the characters in the +.SM +.B IFS +special variable as delimiters, and each resultant word is expanded. +The possible completions are the members of the resultant list which +match the word being completed. +.TP 8 +\fB\-X\fP \fIfilterpat\fP +\fIfilterpat\fP is a pattern as used for pathname expansion. +It is applied to the list of possible completions generated by the +preceding options and arguments, and each completion matching +\fIfilterpat\fP is removed from the list. +A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this +case, any completion not matching \fIfilterpat\fP is removed. +.PD +.PP +The return value is true unless an invalid option is supplied, an option +other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP +argument, an attempt is made to remove a completion specification for +a \fIname\fP for which no specification exists, or +an error occurs adding a completion specification. +.RE +.TP +\fBcompopt\fP [\fB\-o\fP \fIoption\fP] [\fB\-DE\fP] [\fB+o\fP \fIoption\fP] [\fIname\fP] +Modify completion options for each \fIname\fP according to the +\fIoption\fPs, or for the +currently-executing completion if no \fIname\fPs are supplied. +If no \fIoption\fPs are given, display the completion options for each +\fIname\fP or the current completion. +The possible values of \fIoption\fP are those valid for the \fBcomplete\fP +builtin described above. +The \fB\-D\fP option indicates that the remaining options should +apply to the ``default'' command completion; that is, completion attempted +on a command for which no completion has previously been defined. +The \fB\-E\fP option indicates that the remaining options should +apply to ``empty'' command completion; that is, completion attempted on a +blank line. +.sp 1 +The return value is true unless an invalid option is supplied, an attempt +is made to modify the options for a \fIname\fP for which no completion +specification exists, or an output error occurs. +.TP +\fBcontinue\fP [\fIn\fP] +Resume the next iteration of the enclosing +.BR for , +.BR while , +.BR until , +or +.B select +loop. +If +.I n +is specified, resume at the \fIn\fPth enclosing loop. +.I n +must be \(>= 1. If +.I n +is greater than the number of enclosing loops, the last enclosing loop +(the ``top-level'' loop) is resumed. +The return value is 0 unless \fIn\fP is not greater than or equal to 1. +.TP +\fBdeclare\fP [\fB\-aAfFgilnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] +.PD 0 +.TP +\fBtypeset\fP [\fB\-aAfFgilnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] +.PD +Declare variables and/or give them attributes. +If no \fIname\fPs are given then display the values of variables. +The +.B \-p +option will display the attributes and values of each +.IR name . +When +.B \-p +is used with \fIname\fP arguments, additional options are ignored. +When +.B \-p +is supplied without \fIname\fP arguments, it will display the attributes +and values of all variables having the attributes specified by the +additional options. +If no other options are supplied with \fB\-p\fP, \fBdeclare\fP will display +the attributes and values of all shell variables. The \fB\-f\fP option +will restrict the display to shell functions. +The +.B \-F +option inhibits the display of function definitions; only the +function name and attributes are printed. +If the \fBextdebug\fP shell option is enabled using \fBshopt\fP, +the source file name and line number where the function is defined +are displayed as well. The +.B \-F +option implies +.BR \-f . +The +.B \-g +option forces variables to be created or modified at the global scope, +even when \fBdeclare\fP is executed in a shell function. +It is ignored in all other cases. +The following options can +be used to restrict output to variables with the specified attribute or +to give variables attributes: +.RS +.PD 0 +.TP +.B \-a +Each \fIname\fP is an indexed array variable (see +.B Arrays +above). +.TP +.B \-A +Each \fIname\fP is an associative array variable (see +.B Arrays +above). +.TP +.B \-f +Use function names only. +.TP +.B \-i +The variable is treated as an integer; arithmetic evaluation (see +.SM +.B "ARITHMETIC EVALUATION" +above) is performed when the variable is assigned a value. +.TP +.B \-l +When the variable is assigned a value, all upper-case characters are +converted to lower-case. +The upper-case attribute is disabled. +.TP +.B \-n +Give each \fIname\fP the \fInameref\fP attribute, making +it a name reference to another variable. +That other variable is defined by the value of \fIname\fP. +All references and assignments to \fIname\fP, except for changing the +\fB\-n\fP attribute itself, are performed on the variable referenced by +\fIname\fP's value. +The \fB\-n\fP attribute cannot be applied to array variables. +.TP +.B \-r +Make \fIname\fPs readonly. These names cannot then be assigned values +by subsequent assignment statements or unset. +.TP +.B \-t +Give each \fIname\fP the \fItrace\fP attribute. +Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from +the calling shell. +The trace attribute has no special meaning for variables. +.TP +.B \-u +When the variable is assigned a value, all lower-case characters are +converted to upper-case. +The lower-case attribute is disabled. +.TP +.B \-x +Mark \fIname\fPs for export to subsequent commands via the environment. +.PD +.PP +Using `+' instead of `\-' +turns off the attribute instead, +with the exceptions that \fB+a\fP +may not be used to destroy an array variable and \fB+r\fP will not +remove the readonly attribute. +When used in a function, +.B declare +and +.B typeset +make each +\fIname\fP local, as with the +.B local +command, +unless the \fB\-g\fP option is supplied. +If a variable name is followed by =\fIvalue\fP, the value of +the variable is set to \fIvalue\fP. +The return value is 0 unless an invalid option is encountered, +an attempt is made to define a function using +.if n ``\-f foo=bar'', +.if t \f(CW\-f foo=bar\fP, +an attempt is made to assign a value to a readonly variable, +an attempt is made to assign a value to an array variable without +using the compound assignment syntax (see +.B Arrays +above), one of the \fInames\fP is not a valid shell variable name, +an attempt is made to turn off readonly status for a readonly variable, +an attempt is made to turn off array status for an array variable, +or an attempt is made to display a non-existent function with \fB\-f\fP. +.RE +.TP +.B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP] +Without options, displays the list of currently remembered directories. +The default display is on a single line with directory names separated +by spaces. +Directories are added to the list with the +.B pushd +command; the +.B popd +command removes entries from the list. +.RS +.PD 0 +.TP +.B \-c +Clears the directory stack by deleting all of the entries. +.TP +.B \-l +Produces a listing using full pathnames; +the default listing format uses a tilde to denote the home directory. +.TP +.B \-p +Print the directory stack with one entry per line. +.TP +.B \-v +Print the directory stack with one entry per line, +prefixing each entry with its index in the stack. +.TP +\fB+\fP\fIn\fP +Displays the \fIn\fPth entry counting from the left of the list +shown by +.B dirs +when invoked without options, starting with zero. +.TP +\fB\-\fP\fIn\fP +Displays the \fIn\fPth entry counting from the right of the list +shown by +.B dirs +when invoked without options, starting with zero. +.PD +.PP +The return value is 0 unless an +invalid option is supplied or \fIn\fP indexes beyond the end +of the directory stack. +.RE +.TP +\fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...] +Without options, remove each +.I jobspec +from the table of active jobs. +If +.I jobspec +is not present, and neither \fB\-a\fP nor \fB\-r\fP is supplied, +the shell's notion of the \fIcurrent job\fP is used. +If the \fB\-h\fP option is given, each +.I jobspec +is not removed from the table, but is marked so that +.SM +.B SIGHUP +is not sent to the job if the shell receives a +.SM +.BR SIGHUP . +If no +.I jobspec +is present, and neither the +.B \-a +nor the +.B \-r +option is supplied, the \fIcurrent job\fP is used. +If no +.I jobspec +is supplied, the +.B \-a +option means to remove or mark all jobs; the +.B \-r +option without a +.I jobspec +argument restricts operation to running jobs. +The return value is 0 unless a +.I jobspec +does not specify a valid job. +.TP +\fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...] +Output the \fIarg\fPs, separated by spaces, followed by a newline. +The return status is 0 unless a write error occurs. +If \fB\-n\fP is specified, the trailing newline is +suppressed. If the \fB\-e\fP option is given, interpretation of +the following backslash-escaped characters is enabled. The +.B \-E +option disables the interpretation of these escape characters, +even on systems where they are interpreted by default. +The \fBxpg_echo\fP shell option may be used to +dynamically determine whether or not \fBecho\fP expands these +escape characters by default. +.B echo +does not interpret \fB\-\-\fP to mean the end of options. +.B echo +interprets the following escape sequences: +.RS +.PD 0 +.TP +.B \ea +alert (bell) +.TP +.B \eb +backspace +.TP +.B \ec +suppress further output +.TP +.B \ee +.TP +.B \eE +an escape character +.TP +.B \ef +form feed +.TP +.B \en +new line +.TP +.B \er +carriage return +.TP +.B \et +horizontal tab +.TP +.B \ev +vertical tab +.TP +.B \e\e +backslash +.TP +.B \e0\fInnn\fP +the eight-bit character whose value is the octal value \fInnn\fP +(zero to three octal digits) +.TP +.B \ex\fIHH\fP +the eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits) +.TP +.B \eu\fIHHHH\fP +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHH\fP (one to four hex digits) +.TP +.B \eU\fIHHHHHHHH\fP +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHHHHHH\fP (one to eight hex digits) +.PD +.RE +.TP +\fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...] +Enable and disable builtin shell commands. +Disabling a builtin allows a disk command which has the same name +as a shell builtin to be executed without specifying a full pathname, +even though the shell normally searches for builtins before disk commands. +If \fB\-n\fP is used, each \fIname\fP +is disabled; otherwise, +\fInames\fP are enabled. For example, to use the +.B test +binary found via the +.SM +.B PATH +instead of the shell builtin version, run +.if t \f(CWenable -n test\fP. +.if n ``enable -n test''. +The +.B \-f +option means to load the new builtin command +.I name +from shared object +.IR filename , +on systems that support dynamic loading. The +.B \-d +option will delete a builtin previously loaded with +.BR \-f . +If no \fIname\fP arguments are given, or if the +.B \-p +option is supplied, a list of shell builtins is printed. +With no other option arguments, the list consists of all enabled +shell builtins. +If \fB\-n\fP is supplied, only disabled builtins are printed. +If \fB\-a\fP is supplied, the list printed includes all builtins, with an +indication of whether or not each is enabled. +If \fB\-s\fP is supplied, the output is restricted to the POSIX +\fIspecial\fP builtins. +The return value is 0 unless a +.I name +is not a shell builtin or there is an error loading a new builtin +from a shared object. +.TP +\fBeval\fP [\fIarg\fP ...] +The \fIarg\fPs are read and concatenated together into a single +command. This command is then read and executed by the shell, and +its exit status is returned as the value of +.BR eval . +If there are no +.IR args , +or only null arguments, +.B eval +returns 0. +.TP +\fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]] +If +.I command +is specified, it replaces the shell. +No new process is created. The +.I arguments +become the arguments to \fIcommand\fP. +If the +.B \-l +option is supplied, +the shell places a dash at the beginning of the zeroth argument passed to +.IR command . +This is what +.IR login (1) +does. The +.B \-c +option causes +.I command +to be executed with an empty environment. If +.B \-a +is supplied, the shell passes +.I name +as the zeroth argument to the executed command. +If +.I command +cannot be executed for some reason, a non-interactive shell exits, +unless the +.B execfail +shell option +is enabled. In that case, it returns failure. +An interactive shell returns failure if the file cannot be executed. +If +.I command +is not specified, any redirections take effect in the current shell, +and the return status is 0. If there is a redirection error, the +return status is 1. +.TP +\fBexit\fP [\fIn\fP] +Cause the shell to exit +with a status of \fIn\fP. If +.I n +is omitted, the exit status +is that of the last command executed. +A trap on +.SM +.B EXIT +is executed before the shell terminates. +.TP +\fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ... +.PD 0 +.TP +.B export \-p +.PD +The supplied +.I names +are marked for automatic export to the environment of +subsequently executed commands. If the +.B \-f +option is given, +the +.I names +refer to functions. +If no +.I names +are given, or if the +.B \-p +option is supplied, a list +of names of all exported variables is printed. +The +.B \-n +option causes the export property to be removed from each +\fIname\fP. +If a variable name is followed by =\fIword\fP, the value of +the variable is set to \fIword\fP. +.B export +returns an exit status of 0 unless an invalid option is +encountered, +one of the \fInames\fP is not a valid shell variable name, or +.B \-f +is supplied with a +.I name +that is not a function. +.TP +\fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP] +.PD 0 +.TP +\fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP] +.PD +The first form selects a range of commands from +.I first +to +.I last +from the history list and displays or edits and re-executes them. +.I First +and +.I last +may be specified as a string (to locate the last command beginning +with that string) or as a number (an index into the history list, +where a negative number is used as an offset from the current +command number). If +.I last +is not specified it is set to +the current command for listing (so that +.if n ``fc \-l \-10'' +.if t \f(CWfc \-l \-10\fP +prints the last 10 commands) and to +.I first +otherwise. +If +.I first +is not specified it is set to the previous +command for editing and \-16 for listing. +.sp 1 +The +.B \-n +option suppresses +the command numbers when listing. The +.B \-r +option reverses the order of +the commands. If the +.B \-l +option is given, +the commands are listed on +standard output. Otherwise, the editor given by +.I ename +is invoked +on a file containing those commands. If +.I ename +is not given, the +value of the +.SM +.B FCEDIT +variable is used, and +the value of +.SM +.B EDITOR +if +.SM +.B FCEDIT +is not set. If neither variable is set, +.FN vi +is used. When editing is complete, the edited commands are +echoed and executed. +.sp 1 +In the second form, \fIcommand\fP is re-executed after each instance +of \fIpat\fP is replaced by \fIrep\fP. +\fICommand\fP is intepreted the same as \fIfirst\fP above. +A useful alias to use with this is +.if n ``r="fc -s"'', +.if t \f(CWr='fc \-s'\fP, +so that typing +.if n ``r cc'' +.if t \f(CWr cc\fP +runs the last command beginning with +.if n ``cc'' +.if t \f(CWcc\fP +and typing +.if n ``r'' +.if t \f(CWr\fP +re-executes the last command. +.sp 1 +If the first form is used, the return value is 0 unless an invalid +option is encountered or +.I first +or +.I last +specify history lines out of range. +If the +.B \-e +option is supplied, the return value is the value of the last +command executed or failure if an error occurs with the temporary +file of commands. If the second form is used, the return status +is that of the command re-executed, unless +.I cmd +does not specify a valid history line, in which case +.B fc +returns failure. +.TP +\fBfg\fP [\fIjobspec\fP] +Resume +.I jobspec +in the foreground, and make it the current job. +If +.I jobspec +is not present, the shell's notion of the \fIcurrent job\fP is used. +The return value is that of the command placed into the foreground, +or failure if run when job control is disabled or, when run with +job control enabled, if +.I jobspec +does not specify a valid job or +.I jobspec +specifies a job that was started without job control. +.TP +\fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP] +.B getopts +is used by shell procedures to parse positional parameters. +.I optstring +contains the option characters to be recognized; if a character +is followed by a colon, the option is expected to have an +argument, which should be separated from it by white space. +The colon and question mark characters may not be used as +option characters. +Each time it is invoked, +.B getopts +places the next option in the shell variable +.IR name , +initializing +.I name +if it does not exist, +and the index of the next argument to be processed into the +variable +.SM +.BR OPTIND . +.SM +.B OPTIND +is initialized to 1 each time the shell or a shell script +is invoked. When an option requires an argument, +.B getopts +places that argument into the variable +.SM +.BR OPTARG . +The shell does not reset +.SM +.B OPTIND +automatically; it must be manually reset between multiple +calls to +.B getopts +within the same shell invocation if a new set of parameters +is to be used. +.sp 1 +When the end of options is encountered, \fBgetopts\fP exits with a +return value greater than zero. +.SM +.B OPTIND +is set to the index of the first non-option argument, +and \fIname\fP is set to ?. +.sp 1 +.B getopts +normally parses the positional parameters, but if more arguments are +given in +.IR args , +.B getopts +parses those instead. +.sp 1 +.B getopts +can report errors in two ways. If the first character of +.I optstring +is a colon, +.I silent +error reporting is used. In normal operation, diagnostic messages +are printed when invalid options or missing option arguments are +encountered. +If the variable +.SM +.B OPTERR +is set to 0, no error messages will be displayed, even if the first +character of +.I optstring +is not a colon. +.sp 1 +If an invalid option is seen, +.B getopts +places ? into +.I name +and, if not silent, +prints an error message and unsets +.SM +.BR OPTARG . +If +.B getopts +is silent, +the option character found is placed in +.SM +.B OPTARG +and no diagnostic message is printed. +.sp 1 +If a required argument is not found, and +.B getopts +is not silent, +a question mark (\^\fB?\fP\^) is placed in +.IR name , +.SM +.B OPTARG +is unset, and a diagnostic message is printed. +If +.B getopts +is silent, then a colon (\^\fB:\fP\^) is placed in +.I name +and +.SM +.B OPTARG +is set to the option character found. +.sp 1 +.B getopts +returns true if an option, specified or unspecified, is found. +It returns false if the end of options is encountered or an +error occurs. +.TP +\fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP] +Each time \fBhash\fP is invoked, +the full pathname of the command +.I name +is determined by searching +the directories in +.B $PATH +and remembered. Any previously-remembered pathname is discarded. +If the +.B \-p +option is supplied, no path search is performed, and +.I filename +is used as the full filename of the command. +The +.B \-r +option causes the shell to forget all +remembered locations. +The +.B \-d +option causes the shell to forget the remembered location of each \fIname\fP. +If the +.B \-t +option is supplied, the full pathname to which each \fIname\fP corresponds +is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP, +the \fIname\fP is printed before the hashed full pathname. +The +.B \-l +option causes output to be displayed in a format that may be reused as input. +If no arguments are given, or if only \fB\-l\fP is supplied, +information about remembered commands is printed. +The return status is true unless a +.I name +is not found or an invalid option is supplied. +.TP +\fBhelp\fP [\fB\-dms\fP] [\fIpattern\fP] +Display helpful information about builtin commands. If +.I pattern +is specified, +.B help +gives detailed help on all commands matching +.IR pattern ; +otherwise help for all the builtins and shell control structures +is printed. +.RS +.PD 0 +.TP +.B \-d +Display a short description of each \fIpattern\fP +.TP +.B \-m +Display the description of each \fIpattern\fP in a manpage-like format +.TP +.B \-s +Display only a short usage synopsis for each \fIpattern\fP +.PD +.PP +The return status is 0 unless no command matches +.IR pattern . +.RE +.TP +\fBhistory [\fIn\fP] +.PD 0 +.TP +\fBhistory\fP \fB\-c\fP +.TP +\fBhistory \-d\fP \fIoffset\fP +.TP +\fBhistory\fP \fB\-anrw\fP [\fIfilename\fP] +.TP +\fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP] +.TP +\fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP] +.PD +With no options, display the command +history list with line numbers. Lines listed +with a +.B * +have been modified. An argument of +.I n +lists only the last +.I n +lines. +If the shell variable +.SM +.B HISTTIMEFORMAT +is set and not null, +it is used as a format string for \fIstrftime\fP(3) to display +the time stamp associated with each displayed history entry. +No intervening blank is printed between the formatted time stamp +and the history line. +If \fIfilename\fP is supplied, it is used as the +name of the history file; if not, the value of +.SM +.B HISTFILE +is used. Options, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-c +Clear the history list by deleting all the entries. +.TP +\fB\-d\fP \fIoffset\fP +Delete the history entry at position \fIoffset\fP. +.TP +.B \-a +Append the ``new'' history lines (history lines entered since the +beginning of the current \fBbash\fP session) to the history file. +.TP +.B \-n +Read the history lines not already read from the history +file into the current history list. These are lines +appended to the history file since the beginning of the +current \fBbash\fP session. +.TP +.B \-r +Read the contents of the history file +and append them to the current history list. +.TP +.B \-w +Write the current history list to the history file, overwriting the +history file's contents. +.TP +.B \-p +Perform history substitution on the following \fIargs\fP and display +the result on the standard output. +Does not store the results in the history list. +Each \fIarg\fP must be quoted to disable normal history expansion. +.TP +.B \-s +Store the +.I args +in the history list as a single entry. The last command in the +history list is removed before the +.I args +are added. +.PD +.PP +If the +.SM +.B HISTTIMEFORMAT +variable is set, the time stamp information +associated with each history entry is written to the history file, +marked with the history comment character. +When the history file is read, lines beginning with the history +comment character followed immediately by a digit are interpreted +as timestamps for the previous history line. +The return value is 0 unless an invalid option is encountered, an +error occurs while reading or writing the history file, an invalid +\fIoffset\fP is supplied as an argument to \fB\-d\fP, or the +history expansion supplied as an argument to \fB\-p\fP fails. +.RE +.TP +\fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ] +.PD 0 +.TP +\fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ] +.PD +The first form lists the active jobs. The options have the following +meanings: +.RS +.PD 0 +.TP +.B \-l +List process IDs +in addition to the normal information. +.TP +.B \-n +Display information only about jobs that have changed status since +the user was last notified of their status. +.TP +.B \-p +List only the process ID of the job's process group +leader. +.TP +.B \-r +Display only running jobs. +.TP +.B \-s +Display only stopped jobs. +.PD +.PP +If +.I jobspec +is given, output is restricted to information about that job. +The return status is 0 unless an invalid option is encountered +or an invalid +.I jobspec +is supplied. +.PP +If the +.B \-x +option is supplied, +.B jobs +replaces any +.I jobspec +found in +.I command +or +.I args +with the corresponding process group ID, and executes +.I command +passing it +.IR args , +returning its exit status. +.RE +.TP +\fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ... +.PD 0 +.TP +\fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP] +.PD +Send the signal named by +.I sigspec +or +.I signum +to the processes named by +.I pid +or +.IR jobspec . +.I sigspec +is either a case-insensitive signal name such as +.SM +.B SIGKILL +(with or without the +.SM +.B SIG +prefix) or a signal number; +.I signum +is a signal number. +If +.I sigspec +is not present, then +.SM +.B SIGTERM +is assumed. +An argument of +.B \-l +lists the signal names. +If any arguments are supplied when +.B \-l +is given, the names of the signals corresponding to the arguments are +listed, and the return status is 0. +The \fIexit_status\fP argument to +.B \-l +is a number specifying either a signal number or the exit status of +a process terminated by a signal. +.B kill +returns true if at least one signal was successfully sent, or false +if an error occurs or an invalid option is encountered. +.TP +\fBlet\fP \fIarg\fP [\fIarg\fP ...] +Each +.I arg +is an arithmetic expression to be evaluated (see +.SM +.B "ARITHMETIC EVALUATION" +above). +If the last +.I arg +evaluates to 0, +.B let +returns 1; 0 is returned otherwise. +.TP +\fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ...] +For each argument, a local variable named +.I name +is created, and assigned +.IR value . +The \fIoption\fP can be any of the options accepted by \fBdeclare\fP. +When +.B local +is used within a function, it causes the variable +.I name +to have a visible scope restricted to that function and its children. +With no operands, +.B local +writes a list of local variables to the standard output. It is +an error to use +.B local +when not within a function. The return status is 0 unless +.B local +is used outside a function, an invalid +.I name +is supplied, or +\fIname\fP is a readonly variable. +.TP +.B logout +Exit a login shell. +.TP +\fBmapfile\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] +.PD 0 +.TP +\fBreadarray\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] +.PD +Read lines from the standard input into the indexed array variable +.IR array , +or from file descriptor +.IR fd +if the +.B \-u +option is supplied. +The variable +.SM +.B MAPFILE +is the default \fIarray\fP. +Options, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-n +Copy at most +.I count +lines. If \fIcount\fP is 0, all lines are copied. +.TP +.B \-O +Begin assigning to +.I array +at index +.IR origin . +The default index is 0. +.TP +.B \-s +Discard the first \fIcount\fP lines read. +.TP +.B \-t +Remove a trailing newline from each line read. +.TP +.B \-u +Read lines from file descriptor \fIfd\fP instead of the standard input. +.TP +.B \-C +Evaluate +.I callback +each time \fIquantum\fP lines are read. The \fB\-c\fP option specifies +.IR quantum . +.TP +.B \-c +Specify the number of lines read between each call to +.IR callback . +.PD +.PP +If +.B \-C +is specified without +.BR \-c , +the default quantum is 5000. +When \fIcallback\fP is evaluated, it is supplied the index of the next +array element to be assigned and the line to be assigned to that element +as additional arguments. +\fIcallback\fP is evaluated after the line is read but before the +array element is assigned. +.PP +If not supplied with an explicit origin, \fBmapfile\fP will clear \fIarray\fP +before assigning to it. +.PP +\fBmapfile\fP returns successfully unless an invalid option or option +argument is supplied, \fIarray\fP is invalid or unassignable, or if +\fIarray\fP is not an indexed array. +.RE +.TP +\fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP] +Removes entries from the directory stack. With no arguments, +removes the top directory from the stack, and performs a +.B cd +to the new top directory. +Arguments, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-n +Suppresses the normal change of directory when removing directories +from the stack, so that only the stack is manipulated. +.TP +\fB+\fP\fIn\fP +Removes the \fIn\fPth entry counting from the left of the list +shown by +.BR dirs , +starting with zero. For example: +.if n ``popd +0'' +.if t \f(CWpopd +0\fP +removes the first directory, +.if n ``popd +1'' +.if t \f(CWpopd +1\fP +the second. +.TP +\fB\-\fP\fIn\fP +Removes the \fIn\fPth entry counting from the right of the list +shown by +.BR dirs , +starting with zero. For example: +.if n ``popd -0'' +.if t \f(CWpopd -0\fP +removes the last directory, +.if n ``popd -1'' +.if t \f(CWpopd -1\fP +the next to last. +.PD +.PP +If the +.B popd +command is successful, a +.B dirs +is performed as well, and the return status is 0. +.B popd +returns false if an invalid option is encountered, the directory stack +is empty, a non-existent directory stack entry is specified, or the +directory change fails. +.RE +.TP +\fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP] +Write the formatted \fIarguments\fP to the standard output under the +control of the \fIformat\fP. +The \fB\-v\fP option causes the output to be assigned to the variable +\fIvar\fP rather than being printed to the standard output. +.sp 1 +The \fIformat\fP is a character string which contains three types of objects: +plain characters, which are simply copied to standard output, character +escape sequences, which are converted and copied to the standard output, and +format specifications, each of which causes printing of the next successive +\fIargument\fP. +In addition to the standard \fIprintf\fP(1) format specifications, +\fBprintf\fP interprets the following extensions: +.RS +.PD 0 +.TP +.B %b +causes +\fBprintf\fP to expand backslash escape sequences in the corresponding +\fIargument\fP (except that \fB\ec\fP terminates output, backslashes in +\fB\e\(aq\fP, \fB\e"\fP, and \fB\e?\fP are not removed, and octal escapes +beginning with \fB\e0\fP may contain up to four digits). +.TP +.B %q +causes \fBprintf\fP to output the corresponding +\fIargument\fP in a format that can be reused as shell input. +.TP +.B %(\fIdatefmt\fP)T +causes \fBprintf\fP to output the date-time string resulting from using +\fIdatefmt\fP as a format string for \fIstrftime\fP(3). +The corresponding \fIargument\fP is an integer representing the number of +seconds since the epoch. +Two special argument values may be used: -1 represents the current +time, and -2 represents the time the shell was invoked. +If no argument is specified, conversion behaves as if -1 had been given. +This is an exception to the usual \fBprintf\fP behavior. +.PD +.PP +Arguments to non-string format specifiers are treated as C constants, +except that a leading plus or minus sign is allowed, and if the leading +character is a single or double quote, the value is the ASCII value of +the following character. +.PP +The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP. +If the \fIformat\fP requires more \fIarguments\fP than are supplied, the +extra format specifications behave as if a zero value or null string, as +appropriate, had been supplied. +The return value is zero on success, non-zero on failure. +.RE +.TP +\fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP] +.PD 0 +.TP +\fBpushd\fP [\fB\-n\fP] [\fIdir\fP] +.PD +Adds a directory to the top of the directory stack, or rotates +the stack, making the new top of the stack the current working +directory. With no arguments, exchanges the top two directories +and returns 0, unless the directory stack is empty. +Arguments, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-n +Suppresses the normal change of directory when adding directories +to the stack, so that only the stack is manipulated. +.TP +\fB+\fP\fIn\fP +Rotates the stack so that the \fIn\fPth directory +(counting from the left of the list shown by +.BR dirs , +starting with zero) +is at the top. +.TP +\fB\-\fP\fIn\fP +Rotates the stack so that the \fIn\fPth directory +(counting from the right of the list shown by +.BR dirs , +starting with zero) is at the top. +.TP +.I dir +Adds +.I dir +to the directory stack at the top, making it the +new current working directory as if it had been supplied as the argument +to the \fBcd\fP builtin. +.PD +.PP +If the +.B pushd +command is successful, a +.B dirs +is performed as well. +If the first form is used, +.B pushd +returns 0 unless the cd to +.I dir +fails. With the second form, +.B pushd +returns 0 unless the directory stack is empty, +a non-existent directory stack element is specified, +or the directory change to the specified new current directory +fails. +.RE +.TP +\fBpwd\fP [\fB\-LP\fP] +Print the absolute pathname of the current working directory. +The pathname printed contains no symbolic links if the +.B \-P +option is supplied or the +.B \-o physical +option to the +.B set +builtin command is enabled. +If the +.B \-L +option is used, the pathname printed may contain symbolic links. +The return status is 0 unless an error occurs while +reading the name of the current directory or an +invalid option is supplied. +.TP +\fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fB\-i\fP \fItext\fP] [\fB\-n\fP \fInchars\fP] [\fB\-N\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...] +One line is read from the standard input, or from the file descriptor +\fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word +is assigned to the first +.IR name , +the second word to the second +.IR name , +and so on, with leftover words and their intervening separators assigned +to the last +.IR name . +If there are fewer words read from the input stream than names, +the remaining names are assigned empty values. +The characters in +.SM +.B IFS +are used to split the line into words. +The backslash character (\fB\e\fP) may be used to remove any special +meaning for the next character read and for line continuation. +Options, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-a \fIaname\fP +The words are assigned to sequential indices +of the array variable +.IR aname , +starting at 0. +.I aname +is unset before any new values are assigned. +Other \fIname\fP arguments are ignored. +.TP +.B \-d \fIdelim\fP +The first character of \fIdelim\fP is used to terminate the input line, +rather than newline. +.TP +.B \-e +If the standard input +is coming from a terminal, +.B readline +(see +.SM +.B READLINE +above) is used to obtain the line. +Readline uses the current (or default, if line editing was not previously +active) editing settings. +.TP +.B \-i \fItext\fP +If +.B readline +is being used to read the line, \fItext\fP is placed into the editing +buffer before editing begins. +.TP +.B \-n \fInchars\fP +\fBread\fP returns after reading \fInchars\fP characters rather than +waiting for a complete line of input, but honor a delimiter if fewer +than \fInchars\fP characters are read before the delimiter. +.TP +.B \-N \fInchars\fP +\fBread\fP returns after reading exactly \fInchars\fP characters rather +than waiting for a complete line of input, unless EOF is encountered or +\fBread\fP times out. +Delimiter characters encountered in the input are +not treated specially and do not cause \fBread\fP to return until +\fInchars\fP characters are read. +.TP +.B \-p \fIprompt\fP +Display \fIprompt\fP on standard error, without a +trailing newline, before attempting to read any input. The prompt +is displayed only if input is coming from a terminal. +.TP +.B \-r +Backslash does not act as an escape character. +The backslash is considered to be part of the line. +In particular, a backslash-newline pair may not be used as a line +continuation. +.TP +.B \-s +Silent mode. If input is coming from a terminal, characters are +not echoed. +.TP +.B \-t \fItimeout\fP +Cause \fBread\fP to time out and return failure if a complete line of +input (or a specified number of characters) +is not read within \fItimeout\fP seconds. +\fItimeout\fP may be a decimal number with a fractional portion following +the decimal point. +This option is only effective if \fBread\fP is reading input from a +terminal, pipe, or other special file; it has no effect when reading +from regular files. +If \fBread\fP times out, \fBread\fP saves any partial input read into +the specified variable \fIname\fP. +If \fItimeout\fP is 0, \fBread\fP returns immediately, without trying to +read any data. The exit status is 0 if input is available on +the specified file descriptor, non-zero otherwise. +The exit status is greater than 128 if the timeout is exceeded. +.TP +.B \-u \fIfd\fP +Read input from file descriptor \fIfd\fP. +.PD +.PP +If no +.I names +are supplied, the line read is assigned to the variable +.SM +.BR REPLY . +The return code is zero, unless end-of-file is encountered, \fBread\fP +times out (in which case the return code is greater than 128), +a variable assignment error (such as assigning to a readonly variable) occurs, +or an invalid file descriptor is supplied as the argument to \fB\-u\fP. +.RE +.TP +\fBreadonly\fP [\fB\-aAf\fP] [\fB\-p\fP] [\fIname\fP[=\fIword\fP] ...] +.PD +The given +\fInames\fP are marked readonly; the values of these +.I names +may not be changed by subsequent assignment. +If the +.B \-f +option is supplied, the functions corresponding to the +\fInames\fP are so +marked. +The +.B \-a +option restricts the variables to indexed arrays; the +.B \-A +option restricts the variables to associative arrays. +If both options are supplied, +.B \-A +takes precedence. +If no +.I name +arguments are given, or if the +.B \-p +option is supplied, a list of all readonly names is printed. +The other options may be used to restrict the output to a subset of +the set of readonly names. +The +.B \-p +option causes output to be displayed in a format that +may be reused as input. +If a variable name is followed by =\fIword\fP, the value of +the variable is set to \fIword\fP. +The return status is 0 unless an invalid option is encountered, +one of the +.I names +is not a valid shell variable name, or +.B \-f +is supplied with a +.I name +that is not a function. +.TP +\fBreturn\fP [\fIn\fP] +Causes a function to stop executing and return the value specified by +.I n +to its caller. +If +.I n +is omitted, the return status is that of the last command +executed in the function body. If +.B return +is used outside a function, +but during execution of a script by the +.B . +(\fBsource\fP) command, it causes the shell to stop executing +that script and return either +.I n +or the exit status of the last command executed within the +script as the exit status of the script. +If \fIn\fP is supplied, the return value is its least significant +8 bits. +The return status is non-zero if +.B return +is supplied a non-numeric argument, or +is used outside a +function and not during execution of a script by \fB.\fP\^ or \fBsource\fP. +Any command associated with the \fBRETURN\fP trap is executed +before execution resumes after the function or script. +.TP +\fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\-name\fP] [\fIarg\fP ...] +.PD 0 +.TP +\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\-name\fP] [\fIarg\fP ...] +.PD +Without options, the name and value of each shell variable are displayed +in a format that can be reused as input +for setting or resetting the currently-set variables. +Read-only variables cannot be reset. +In \fIposix mode\fP, only shell variables are listed. +The output is sorted according to the current locale. +When options are specified, they set or unset shell attributes. +Any arguments remaining after option processing are treated +as values for the positional parameters and are assigned, in order, to +.BR $1 , +.BR $2 , +.B ... +.BR $\fIn\fP . +Options, if specified, have the following meanings: +.RS +.PD 0 +.TP 8 +.B \-a +Automatically mark variables and functions which are modified or +created for export to the environment of subsequent commands. +.TP 8 +.B \-b +Report the status of terminated background jobs +immediately, rather than before the next primary prompt. This is +effective only when job control is enabled. +.TP 8 +.B \-e +Exit immediately if a +\fIpipeline\fP (which may consist of a single \fIsimple command\fP), +a \fIlist\fP, +or a \fIcompound command\fP +(see +.SM +.B SHELL GRAMMAR +above), exits with a non-zero status. +The shell does not exit if the +command that fails is part of the command list immediately following a +.B while +or +.B until +keyword, +part of the test following the +.B if +or +.B elif +reserved words, part of any command executed in a +.B && +or +.B || +list except the command following the final \fB&&\fP or \fB||\fP, +any command in a pipeline but the last, +or if the command's return value is +being inverted with +.BR ! . +If a compound command other than a subshell +returns a non-zero status because a command failed +while \fB\-e\fP was being ignored, the shell does not exit. +A trap on \fBERR\fP, if set, is executed before the shell exits. +This option applies to the shell environment and each subshell environment +separately (see +.SM +.B "COMMAND EXECUTION ENVIRONMENT" +above), and may cause +subshells to exit before executing all the commands in the subshell. +If a shell function executes in a context where \fB\-e\fP is being ignored, +even if \fB\-e\fP is set, none of the commands executed within the function +body will be affected by the \fB\-e\fP setting. +If a shell function sets \fB\-e\fP while executing in a context where +\fB\-e\fP is ignored, that setting will not have any effect until the +command containing the function call completes. +.TP 8 +.B \-f +Disable pathname expansion. +.TP 8 +.B \-h +Remember the location of commands as they are looked up for execution. +This is enabled by default. +.TP 8 +.B \-k +All arguments in the form of assignment statements +are placed in the environment for a command, not just +those that precede the command name. +.TP 8 +.B \-m +Monitor mode. Job control is enabled. This option is on +by default for interactive shells on systems that support +it (see +.SM +.B JOB CONTROL +above). +All processes run in a separate process group. +When a background job completes, the shell prints a line +containing its exit status. +.TP 8 +.B \-n +Read commands but do not execute them. This may be used to +check a shell script for syntax errors. This is ignored by +interactive shells. +.TP 8 +.B \-o \fIoption\-name\fP +The \fIoption\-name\fP can be one of the following: +.RS +.TP 8 +.B allexport +Same as +.BR \-a . +.TP 8 +.B braceexpand +Same as +.BR \-B . +.TP 8 +.B emacs +Use an emacs-style command line editing interface. This is enabled +by default when the shell is interactive, unless the shell is started +with the +.B \-\-noediting +option. +This also affects the editing interface used for \fBread \-e\fP. +.TP 8 +.B errexit +Same as +.BR \-e . +.TP 8 +.B errtrace +Same as +.BR \-E . +.TP 8 +.B functrace +Same as +.BR \-T . +.TP 8 +.B hashall +Same as +.BR \-h . +.TP 8 +.B histexpand +Same as +.BR \-H . +.TP 8 +.B history +Enable command history, as described above under +.SM +.BR HISTORY . +This option is on by default in interactive shells. +.TP 8 +.B ignoreeof +The effect is as if the shell command +.if t \f(CWIGNOREEOF=10\fP +.if n ``IGNOREEOF=10'' +had been executed +(see +.B Shell Variables +above). +.TP 8 +.B keyword +Same as +.BR \-k . +.TP 8 +.B monitor +Same as +.BR \-m . +.TP 8 +.B noclobber +Same as +.BR \-C . +.TP 8 +.B noexec +Same as +.BR \-n . +.TP 8 +.B noglob +Same as +.BR \-f . +.TP 8 +.B nolog +Currently ignored. +.TP 8 +.B notify +Same as +.BR \-b . +.TP 8 +.B nounset +Same as +.BR \-u . +.TP 8 +.B onecmd +Same as +.BR \-t . +.TP 8 +.B physical +Same as +.BR \-P . +.TP 8 +.B pipefail +If set, the return value of a pipeline is the value of the last +(rightmost) command to exit with a non-zero status, or zero if all +commands in the pipeline exit successfully. +This option is disabled by default. +.TP 8 +.B posix +Change the behavior of +.B bash +where the default operation differs +from the POSIX standard to match the standard (\fIposix mode\fP). +.TP 8 +.B privileged +Same as +.BR \-p . +.TP 8 +.B verbose +Same as +.BR \-v . +.TP 8 +.B vi +Use a vi-style command line editing interface. +This also affects the editing interface used for \fBread \-e\fP. +.TP 8 +.B xtrace +Same as +.BR \-x . +.sp .5 +.PP +If +.B \-o +is supplied with no \fIoption\-name\fP, the values of the current options are +printed. +If +.B +o +is supplied with no \fIoption\-name\fP, a series of +.B set +commands to recreate the current option settings is displayed on +the standard output. +.RE +.TP 8 +.B \-p +Turn on +.I privileged +mode. In this mode, the +.SM +.B $ENV +and +.SM +.B $BASH_ENV +files are not processed, shell functions are not inherited from the +environment, and the +.SM +.BR SHELLOPTS , +.SM +.BR BASHOPTS , +.SM +.BR CDPATH , +and +.SM +.B GLOBIGNORE +variables, if they appear in the environment, are ignored. +If the shell is started with the effective user (group) id not equal to the +real user (group) id, and the \fB\-p\fP option is not supplied, these actions +are taken and the effective user id is set to the real user id. +If the \fB\-p\fP option is supplied at startup, the effective user id is +not reset. +Turning this option off causes the effective user +and group ids to be set to the real user and group ids. +.TP 8 +.B \-t +Exit after reading and executing one command. +.TP 8 +.B \-u +Treat unset variables and parameters other than the special +parameters "@" and "*" as an error when performing +parameter expansion. If expansion is attempted on an +unset variable or parameter, the shell prints an error message, and, +if not interactive, exits with a non-zero status. +.TP 8 +.B \-v +Print shell input lines as they are read. +.TP 8 +.B \-x +After expanding each \fIsimple command\fP, +\fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or +arithmetic \fBfor\fP command, display the expanded value of +.SM +.BR PS4 , +followed by the command and its expanded arguments +or associated word list. +.TP 8 +.B \-B +The shell performs brace expansion (see +.B Brace Expansion +above). This is on by default. +.TP 8 +.B \-C +If set, +.B bash +does not overwrite an existing file with the +.BR > , +.BR >& , +and +.B <> +redirection operators. This may be overridden when +creating output files by using the redirection operator +.B >| +instead of +.BR > . +.TP 8 +.B \-E +If set, any trap on \fBERR\fP is inherited by shell functions, command +substitutions, and commands executed in a subshell environment. +The \fBERR\fP trap is normally not inherited in such cases. +.TP 8 +.B \-H +Enable +.B ! +style history substitution. This option is on by +default when the shell is interactive. +.TP 8 +.B \-P +If set, the shell does not resolve symbolic links when executing +commands such as +.B cd +that change the current working directory. It uses the +physical directory structure instead. By default, +.B bash +follows the logical chain of directories when performing commands +which change the current directory. +.TP 8 +.B \-T +If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell +functions, command substitutions, and commands executed in a +subshell environment. +The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited +in such cases. +.TP 8 +.B \-\- +If no arguments follow this option, then the positional parameters are +unset. Otherwise, the positional parameters are set to the +\fIarg\fPs, even if some of them begin with a +.BR \- . +.TP 8 +.B \- +Signal the end of options, cause all remaining \fIarg\fPs to be +assigned to the positional parameters. The +.B \-x +and +.B \-v +options are turned off. +If there are no \fIarg\fPs, +the positional parameters remain unchanged. +.PD +.PP +The options are off by default unless otherwise noted. +Using + rather than \- causes these options to be turned off. +The options can also be specified as arguments to an invocation of +the shell. +The current set of options may be found in +.BR $\- . +The return status is always true unless an invalid option is encountered. +.RE +.TP +\fBshift\fP [\fIn\fP] +The positional parameters from \fIn\fP+1 ... are renamed to +.B $1 +.B .... +Parameters represented by the numbers \fB$#\fP +down to \fB$#\fP\-\fIn\fP+1 are unset. +.I n +must be a non-negative number less than or equal to \fB$#\fP. +If +.I n +is 0, no parameters are changed. +If +.I n +is not given, it is assumed to be 1. +If +.I n +is greater than \fB$#\fP, the positional parameters are not changed. +The return status is greater than zero if +.I n +is greater than +.B $# +or less than zero; otherwise 0. +.TP +\fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...] +Toggle the values of variables controlling optional shell behavior. +With no options, or with the +.B \-p +option, a list of all settable options is displayed, with +an indication of whether or not each is set. +The \fB\-p\fP option causes output to be displayed in a form that +may be reused as input. +Other options have the following meanings: +.RS +.PD 0 +.TP +.B \-s +Enable (set) each \fIoptname\fP. +.TP +.B \-u +Disable (unset) each \fIoptname\fP. +.TP +.B \-q +Suppresses normal output (quiet mode); the return status indicates +whether the \fIoptname\fP is set or unset. +If multiple \fIoptname\fP arguments are given with +.BR \-q , +the return status is zero if all \fIoptnames\fP are enabled; non-zero +otherwise. +.TP +.B \-o +Restricts the values of \fIoptname\fP to be those defined for the +.B \-o +option to the +.B set +builtin. +.PD +.PP +If either +.B \-s +or +.B \-u +is used with no \fIoptname\fP arguments, +.B shopt +shows only those options which are set or unset, respectively. +Unless otherwise noted, the \fBshopt\fP options are disabled (unset) +by default. +.PP +The return status when listing options is zero if all \fIoptnames\fP +are enabled, non-zero otherwise. When setting or unsetting options, +the return status is zero unless an \fIoptname\fP is not a valid shell +option. +.PP +The list of \fBshopt\fP options is: +.if t .sp .5v +.if n .sp 1v +.PD 0 +.TP 8 +.B autocd +If set, a command name that is the name of a directory is executed as if +it were the argument to the \fBcd\fP command. +This option is only used by interactive shells. +.TP 8 +.B cdable_vars +If set, an argument to the +.B cd +builtin command that +is not a directory is assumed to be the name of a variable whose +value is the directory to change to. +.TP 8 +.B cdspell +If set, minor errors in the spelling of a directory component in a +.B cd +command will be corrected. +The errors checked for are transposed characters, +a missing character, and one character too many. +If a correction is found, the corrected filename is printed, +and the command proceeds. +This option is only used by interactive shells. +.TP 8 +.B checkhash +If set, \fBbash\fP checks that a command found in the hash +table exists before trying to execute it. If a hashed command no +longer exists, a normal path search is performed. +.TP 8 +.B checkjobs +If set, \fBbash\fP lists the status of any stopped and running jobs before +exiting an interactive shell. If any jobs are running, this causes +the exit to be deferred until a second exit is attempted without an +intervening command (see +.SM +.B "JOB CONTROL" +above). The shell always +postpones exiting if any jobs are stopped. +.TP 8 +.B checkwinsize +If set, \fBbash\fP checks the window size after each command +and, if necessary, updates the values of +.SM +.B LINES +and +.SM +.BR COLUMNS . +.TP 8 +.B cmdhist +If set, +.B bash +attempts to save all lines of a multiple-line +command in the same history entry. This allows +easy re-editing of multi-line commands. +.TP 8 +.B compat31 +If set, +.B bash +changes its behavior to that of version 3.1 with respect to quoted +arguments to the \fB[[\fP conditional command's \fB=~\fP operator +and locale-specific string comparison when using the \fB[[\fP +conditional command's \fB<\fP and \fB>\fP operators. +Bash versions prior to bash-4.1 use ASCII collation and +.IR strcmp (3); +bash-4.1 and later use the current locale's collation sequence and +.IR strcoll (3). +.TP 8 +.B compat32 +If set, +.B bash +changes its behavior to that of version 3.2 with respect to +locale-specific string comparison when using the \fB[[\fP +conditional command's \fB<\fP and \fB>\fP operators (see previous item). +.TP 8 +.B compat40 +If set, +.B bash +changes its behavior to that of version 4.0 with respect to locale-specific +string comparison when using the \fB[[\fP +conditional command's \fB<\fP and \fB>\fP operators (see description of +\fBcompat31\fP) +and the effect of interrupting a command list. +Bash versions 4.0 and later interrupt the list as if the shell received the +interrupt; previous versions continue with the next command in the list. +.TP 8 +.B compat41 +If set, +.BR bash , +when in posix mode, treats a single quote in a double-quoted +parameter expansion as a special character. The single quotes must match +(an even number) and the characters between the single quotes are considered +quoted. This is the behavior of posix mode through version 4.1. +The default bash behavior remains as in previous versions. +.TP 8 +.B complete_fullquote +If set, +.B bash +quotes all shell metacharacters in filenames and directory names when +performing completion. +If not set, +.B bash +removes metacharacters such as the dollar sign from the set of +characters that will be quoted in completed filenames +when these metacharacters appear in shell variable references in words to be +completed. +This means that dollar signs in variable names that expand to directories +will not be quoted; +however, any dollar signs appearing in filenames will not be quoted, either. +This is active only when bash is using backslashes to quote completed +filenames. +This variable is set by default, which is the default bash behavior in +versions through 4.2. +.TP 8 +.B direxpand +If set, +.B bash +replaces directory names with the results of word expansion when performing +filename completion. This changes the contents of the readline editing +buffer. +If not set, +.B bash +attempts to preserve what the user typed. +.TP 8 +.B dirspell +If set, +.B bash +attempts spelling correction on directory names during word completion +if the directory name initially supplied does not exist. +.TP 8 +.B dotglob +If set, +.B bash +includes filenames beginning with a `.' in the results of pathname +expansion. +.TP 8 +.B execfail +If set, a non-interactive shell will not exit if +it cannot execute the file specified as an argument to the +.B exec +builtin command. An interactive shell does not exit if +.B exec +fails. +.TP 8 +.B expand_aliases +If set, aliases are expanded as described above under +.SM +.BR ALIASES . +This option is enabled by default for interactive shells. +.TP 8 +.B extdebug +If set, behavior intended for use by debuggers is enabled: +.RS +.TP +.B 1. +The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source +file name and line number corresponding to each function name supplied +as an argument. +.TP +.B 2. +If the command run by the \fBDEBUG\fP trap returns a non-zero value, the +next command is skipped and not executed. +.TP +.B 3. +If the command run by the \fBDEBUG\fP trap returns a value of 2, and the +shell is executing in a subroutine (a shell function or a shell script +executed by the \fB.\fP or \fBsource\fP builtins), a call to +\fBreturn\fP is simulated. +.TP +.B 4. +.SM +.B BASH_ARGC +and +.SM +.B BASH_ARGV +are updated as described in their descriptions above. +.TP +.B 5. +Function tracing is enabled: command substitution, shell functions, and +subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the +\fBDEBUG\fP and \fBRETURN\fP traps. +.TP +.B 6. +Error tracing is enabled: command substitution, shell functions, and +subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the +\fBERR\fP trap. +.RE +.TP 8 +.B extglob +If set, the extended pattern matching features described above under +\fBPathname Expansion\fP are enabled. +.TP 8 +.B extquote +If set, \fB$\fP\(aq\fIstring\fP\(aq and \fB$\fP"\fIstring\fP" quoting is +performed within \fB${\fP\fIparameter\fP\fB}\fP expansions +enclosed in double quotes. This option is enabled by default. +.TP 8 +.B failglob +If set, patterns which fail to match filenames during pathname expansion +result in an expansion error. +.TP 8 +.B force_fignore +If set, the suffixes specified by the +.SM +.B FIGNORE +shell variable +cause words to be ignored when performing word completion even if +the ignored words are the only possible completions. +See +.SM +\fBSHELL VARIABLES\fP +above for a description of +.SM +.BR FIGNORE . +This option is enabled by default. +.TP 8 +.B globasciiranges +If set, range expressions used in pattern matching (see +.SM +.B Pattern Matching +above) behave as if in the traditional C locale when performing +comparisons. That is, the current locale's collating sequence +is not taken into account, so +.B b +will not collate between +.B A +and +.BR B , +and upper-case and lower-case ASCII characters will collate together. +.TP 8 +.B globstar +If set, the pattern \fB**\fP used in a pathname expansion context will +match all files and zero or more directories and subdirectories. +If the pattern is followed by a \fB/\fP, only directories and +subdirectories match. +.TP 8 +.B gnu_errfmt +If set, shell error messages are written in the standard GNU error +message format. +.TP 8 +.B histappend +If set, the history list is appended to the file named by the value +of the +.SM +.B HISTFILE +variable when the shell exits, rather than overwriting the file. +.TP 8 +.B histreedit +If set, and +.B readline +is being used, a user is given the opportunity to re-edit a +failed history substitution. +.TP 8 +.B histverify +If set, and +.B readline +is being used, the results of history substitution are not immediately +passed to the shell parser. Instead, the resulting line is loaded into +the \fBreadline\fP editing buffer, allowing further modification. +.TP 8 +.B hostcomplete +If set, and +.B readline +is being used, \fBbash\fP will attempt to perform hostname completion when a +word containing a \fB@\fP is being completed (see +.B Completing +under +.SM +.B READLINE +above). +This is enabled by default. +.TP 8 +.B huponexit +If set, \fBbash\fP will send +.SM +.B SIGHUP +to all jobs when an interactive login shell exits. +.TP 8 +.B interactive_comments +If set, allow a word beginning with +.B # +to cause that word and all remaining characters on that +line to be ignored in an interactive shell (see +.SM +.B COMMENTS +above). This option is enabled by default. +.TP 8 +.B lastpipe +If set, and job control is not active, the shell runs the last command of +a pipeline not executed in the background in the current shell environment. +.TP 8 +.B lithist +If set, and the +.B cmdhist +option is enabled, multi-line commands are saved to the history with +embedded newlines rather than using semicolon separators where possible. +.TP 8 +.B login_shell +The shell sets this option if it is started as a login shell (see +.SM +.B "INVOCATION" +above). +The value may not be changed. +.TP 8 +.B mailwarn +If set, and a file that \fBbash\fP is checking for mail has been +accessed since the last time it was checked, the message ``The mail in +\fImailfile\fP has been read'' is displayed. +.TP 8 +.B no_empty_cmd_completion +If set, and +.B readline +is being used, +.B bash +will not attempt to search the +.SM +.B PATH +for possible completions when +completion is attempted on an empty line. +.TP 8 +.B nocaseglob +If set, +.B bash +matches filenames in a case\-insensitive fashion when performing pathname +expansion (see +.B Pathname Expansion +above). +.TP 8 +.B nocasematch +If set, +.B bash +matches patterns in a case\-insensitive fashion when performing matching +while executing \fBcase\fP or \fB[[\fP conditional commands. +.TP 8 +.B nullglob +If set, +.B bash +allows patterns which match no +files (see +.B Pathname Expansion +above) +to expand to a null string, rather than themselves. +.TP 8 +.B progcomp +If set, the programmable completion facilities (see +\fBProgrammable Completion\fP above) are enabled. +This option is enabled by default. +.TP 8 +.B promptvars +If set, prompt strings undergo +parameter expansion, command substitution, arithmetic +expansion, and quote removal after being expanded as described in +.SM +.B PROMPTING +above. This option is enabled by default. +.TP 8 +.B restricted_shell +The shell sets this option if it is started in restricted mode (see +.SM +.B "RESTRICTED SHELL" +below). +The value may not be changed. +This is not reset when the startup files are executed, allowing +the startup files to discover whether or not a shell is restricted. +.TP 8 +.B shift_verbose +If set, the +.B shift +builtin prints an error message when the shift count exceeds the +number of positional parameters. +.TP 8 +.B sourcepath +If set, the +\fBsource\fP (\fB.\fP) builtin uses the value of +.SM +.B PATH +to find the directory containing the file supplied as an argument. +This option is enabled by default. +.TP 8 +.B xpg_echo +If set, the \fBecho\fP builtin expands backslash-escape sequences +by default. +.RE +.PD +.TP +\fBsuspend\fP [\fB\-f\fP] +Suspend the execution of this shell until it receives a +.SM +.B SIGCONT +signal. A login shell cannot be suspended; the +.B \-f +option can be used to override this and force the suspension. +The return status is 0 unless the shell is a login shell and +.B \-f +is not supplied, or if job control is not enabled. +.TP +\fBtest\fP \fIexpr\fP +.PD 0 +.TP +\fB[\fP \fIexpr\fP \fB]\fP +Return a status of 0 (true) or 1 (false) depending on +the evaluation of the conditional expression +.IR expr . +Each operator and operand must be a separate argument. +Expressions are composed of the primaries described above under +.SM +.BR "CONDITIONAL EXPRESSIONS" . +\fBtest\fP does not accept any options, nor does it accept and ignore +an argument of \fB\-\-\fP as signifying the end of options. +.if t .sp 0.5 +.if n .sp 1 +Expressions may be combined using the following operators, listed +in decreasing order of precedence. +The evaluation depends on the number of arguments; see below. +Operator precedence is used when there are five or more arguments. +.RS +.PD 0 +.TP +.B ! \fIexpr\fP +True if +.I expr +is false. +.TP +.B ( \fIexpr\fP ) +Returns the value of \fIexpr\fP. +This may be used to override the normal precedence of operators. +.TP +\fIexpr1\fP \-\fBa\fP \fIexpr2\fP +True if both +.I expr1 +and +.I expr2 +are true. +.TP +\fIexpr1\fP \-\fBo\fP \fIexpr2\fP +True if either +.I expr1 +or +.I expr2 +is true. +.PD +.PP +\fBtest\fP and \fB[\fP evaluate conditional +expressions using a set of rules based on the number of arguments. +.if t .sp 0.5 +.if n .sp 1 +.PD 0 +.TP +0 arguments +The expression is false. +.TP +1 argument +The expression is true if and only if the argument is not null. +.TP +2 arguments +If the first argument is \fB!\fP, the expression is true if and +only if the second argument is null. +If the first argument is one of the unary conditional operators listed above +under +.SM +.BR "CONDITIONAL EXPRESSIONS" , +the expression is true if the unary test is true. +If the first argument is not a valid unary conditional operator, the expression +is false. +.TP +3 arguments +The following conditions are applied in the order listed. +If the second argument is one of the binary conditional operators listed above +under +.SM +.BR "CONDITIONAL EXPRESSIONS" , +the result of the expression is the result of the binary test using +the first and third arguments as operands. +The \fB\-a\fP and \fB\-o\fP operators are considered binary operators +when there are three arguments. +If the first argument is \fB!\fP, the value is the negation of +the two-argument test using the second and third arguments. +If the first argument is exactly \fB(\fP and the third argument is +exactly \fB)\fP, the result is the one-argument test of the second +argument. +Otherwise, the expression is false. +.TP +4 arguments +If the first argument is \fB!\fP, the result is the negation of +the three-argument expression composed of the remaining arguments. +Otherwise, the expression is parsed and evaluated according to +precedence using the rules listed above. +.TP +5 or more arguments +The expression is parsed and evaluated according to precedence +using the rules listed above. +.if t .sp 0.5 +.if n .sp 1 +.LP +When used with \fBtest\fP or \fB[\fP, the \fB<\fP and \fB>\fP operators +sort lexicographically using ASCII ordering. +.RE +.PD +.TP +.B times +Print the accumulated user and system times for the shell and +for processes run from the shell. The return status is 0. +.TP +\fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...] +The command +.I arg +is to be read and executed when the shell receives +signal(s) +.IR sigspec . +If +.I arg +is absent (and there is a single \fIsigspec\fP) or +.BR \- , +each specified signal is +reset to its original disposition (the value it had +upon entrance to the shell). +If +.I arg +is the null string the signal specified by each +.I sigspec +is ignored by the shell and by the commands it invokes. +If +.I arg +is not present and +.B \-p +has been supplied, then the trap commands associated with each +.I sigspec +are displayed. +If no arguments are supplied or if only +.B \-p +is given, +.B trap +prints the list of commands associated with each signal. +The +.B \-l +option causes the shell to print a list of signal names and +their corresponding numbers. +Each +.I sigspec +is either +a signal name defined in <\fIsignal.h\fP>, or a signal number. +Signal names are case insensitive and the +.SM +.B SIG +prefix is optional. +.if t .sp 0.5 +.if n .sp 1 +If a +.I sigspec +is +.SM +.B EXIT +(0) the command +.I arg +is executed on exit from the shell. +If a +.I sigspec +is +.SM +.BR DEBUG , +the command +.I arg +is executed before every \fIsimple command\fP, \fIfor\fP command, +\fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP +command, and before the first command executes in a shell function (see +.SM +.B SHELL GRAMMAR +above). +Refer to the description of the \fBextdebug\fP option to the +\fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap. +If a +.I sigspec +is +.SM +.BR RETURN , +the command +.I arg +is executed each time a shell function or a script executed with +the \fB.\fP or \fBsource\fP builtins finishes executing. +.if t .sp 0.5 +.if n .sp 1 +If a +.I sigspec +is +.SM +.BR ERR , +the command +.I arg +is executed whenever a simple command has a non\-zero exit status, +subject to the following conditions. +The +.SM +.B ERR +trap is not executed if the failed +command is part of the command list immediately following a +.B while +or +.B until +keyword, +part of the test in an +.I if +statement, part of a command executed in a +.B && +or +.B || +list, or if the command's return value is +being inverted via +.BR ! . +These are the same conditions obeyed by the \fBerrexit\fP option. +.if t .sp 0.5 +.if n .sp 1 +Signals ignored upon entry to the shell cannot be trapped or reset. +Trapped signals that are not being ignored are reset to their original +values in a subshell or subshell environment when one is created. +The return status is false if any +.I sigspec +is invalid; otherwise +.B trap +returns true. +.TP +\fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...] +With no options, +indicate how each +.I name +would be interpreted if used as a command name. +If the +.B \-t +option is used, +.B type +prints a string which is one of +.IR alias , +.IR keyword , +.IR function , +.IR builtin , +or +.I file +if +.I name +is an alias, shell reserved word, function, builtin, or disk file, +respectively. +If the +.I name +is not found, then nothing is printed, and an exit status of false +is returned. +If the +.B \-p +option is used, +.B type +either returns the name of the disk file +that would be executed if +.I name +were specified as a command name, +or nothing if +.if t \f(CWtype -t name\fP +.if n ``type -t name'' +would not return +.IR file . +The +.B \-P +option forces a +.SM +.B PATH +search for each \fIname\fP, even if +.if t \f(CWtype -t name\fP +.if n ``type -t name'' +would not return +.IR file . +If a command is hashed, +.B \-p +and +.B \-P +print the hashed value, which is not necessarily the file that appears +first in +.SM +.BR PATH . +If the +.B \-a +option is used, +.B type +prints all of the places that contain +an executable named +.IR name . +This includes aliases and functions, +if and only if the +.B \-p +option is not also used. +The table of hashed commands is not consulted +when using +.BR \-a . +The +.B \-f +option suppresses shell function lookup, as with the \fBcommand\fP builtin. +.B type +returns true if all of the arguments are found, false if +any are not found. +.TP +\fBulimit\fP [\fB\-HSTabcdefilmnpqrstuvx\fP [\fIlimit\fP]] +Provides control over the resources available to the shell and to +processes started by it, on systems that allow such control. +The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is +set for the given resource. +A hard limit cannot be increased by a non-root user once it is set; +a soft limit may be increased up to the value of the hard limit. +If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard +limits are set. +The value of +.I limit +can be a number in the unit specified for the resource +or one of the special values +.BR hard , +.BR soft , +or +.BR unlimited , +which stand for the current hard limit, the current soft limit, and +no limit, respectively. +If +.I limit +is omitted, the current value of the soft limit of the resource is +printed, unless the \fB\-H\fP option is given. When more than one +resource is specified, the limit name and unit are printed before the value. +Other options are interpreted as follows: +.RS +.PD 0 +.TP +.B \-a +All current limits are reported +.TP +.B \-b +The maximum socket buffer size +.TP +.B \-c +The maximum size of core files created +.TP +.B \-d +The maximum size of a process's data segment +.TP +.B \-e +The maximum scheduling priority ("nice") +.TP +.B \-f +The maximum size of files written by the shell and its children +.TP +.B \-i +The maximum number of pending signals +.TP +.B \-l +The maximum size that may be locked into memory +.TP +.B \-m +The maximum resident set size (many systems do not honor this limit) +.TP +.B \-n +The maximum number of open file descriptors (most systems do not +allow this value to be set) +.TP +.B \-p +The pipe size in 512-byte blocks (this may not be set) +.TP +.B \-q +The maximum number of bytes in POSIX message queues +.TP +.B \-r +The maximum real-time scheduling priority +.TP +.B \-s +The maximum stack size +.TP +.B \-t +The maximum amount of cpu time in seconds +.TP +.B \-u +The maximum number of processes available to a single user +.TP +.B \-v +The maximum amount of virtual memory available to the shell and, on +some systems, to its children +.TP +.B \-x +The maximum number of file locks +.TP +.B \-T +The maximum number of threads +.PD +.PP +If +.I limit +is given, and the +.B \-a +option is not used, +\fIlimit\fP is the new value of the specified resource. +If no option is given, then +.B \-f +is assumed. Values are in 1024-byte increments, except for +.BR \-t , +which is in seconds; +.BR \-p , +which is in units of 512-byte blocks; +and +.BR \-T , +.BR \-b , +.BR \-n , +and +.BR \-u , +which are unscaled values. +The return status is 0 unless an invalid option or argument is supplied, +or an error occurs while setting a new limit. +.RE +.TP +\fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP] +The user file-creation mask is set to +.IR mode . +If +.I mode +begins with a digit, it +is interpreted as an octal number; otherwise +it is interpreted as a symbolic mode mask similar +to that accepted by +.IR chmod (1). +If +.I mode +is omitted, the current value of the mask is printed. +The +.B \-S +option causes the mask to be printed in symbolic form; the +default output is an octal number. +If the +.B \-p +option is supplied, and +.I mode +is omitted, the output is in a form that may be reused as input. +The return status is 0 if the mode was successfully changed or if +no \fImode\fP argument was supplied, and false otherwise. +.TP +\fBunalias\fP [\-\fBa\fP] [\fIname\fP ...] +Remove each \fIname\fP from the list of defined aliases. If +.B \-a +is supplied, all alias definitions are removed. The return +value is true unless a supplied +.I name +is not a defined alias. +.TP +\fBunset\fP [\-\fBfv\fP] [\-\fBn\fP] [\fIname\fP ...] +For each +.IR name , +remove the corresponding variable or function. +If the +.B \-v +option is given, each +.I name +refers to a shell variable, and that variable is removed. +Read-only variables may not be unset. +If +.B \-f +is specified, each +.I name +refers to a shell function, and the function definition +is removed. +If the +.B \-n +option is supplied, and \fIname\fP is a variable with the \fInameref\fP +attribute, \fIname\fP will be unset rather than the variable it +references. +\fB\-n\fP has no effect if the \fB\-f\fP option is supplied. +If no options are supplied, each \fIname\fP refers to a variable; if +there is no variable by that name, any function with that name is +unset. +Each unset variable or function is removed from the environment +passed to subsequent commands. +If any of +.SM +.BR COMP_WORDBREAKS , +.SM +.BR RANDOM , +.SM +.BR SECONDS , +.SM +.BR LINENO , +.SM +.BR HISTCMD , +.SM +.BR FUNCNAME , +.SM +.BR GROUPS , +or +.SM +.B DIRSTACK +are unset, they lose their special properties, even if they are +subsequently reset. The exit status is true unless a +.I name +is readonly. +.TP +\fBwait\fP [\fB\--n\fP] [\fIn ...\fP] +Wait for each specified process and return its termination status. +Each +.I n +may be a process +ID or a job specification; if a job spec is given, all processes +in that job's pipeline are waited for. If +.I n +is not given, all currently active child processes +are waited for, and the return status is zero. +If the \fB\--n\fP option is supplied, \fBwait\fP waits for any job to +terminate and returns its exit status. +If +.I n +specifies a non-existent process or job, the return status is +127. Otherwise, the return status is the exit status of the last +process or job waited for. +.\" bash_builtins +.if \n(zZ=1 .ig zZ +.SH "RESTRICTED SHELL" +.\" rbash.1 +.zY +.PP +If +.B bash +is started with the name +.BR rbash , +or the +.B \-r +option is supplied at invocation, +the shell becomes restricted. +A restricted shell is used to +set up an environment more controlled than the standard shell. +It behaves identically to +.B bash +with the exception that the following are disallowed or not performed: +.IP \(bu +changing directories with \fBcd\fP +.IP \(bu +setting or unsetting the values of +.SM +.BR SHELL , +.SM +.BR PATH , +.SM +.BR ENV , +or +.SM +.B BASH_ENV +.IP \(bu +specifying command names containing +.B / +.IP \(bu +specifying a filename containing a +.B / +as an argument to the +.B . +builtin command +.IP \(bu +specifying a filename containing a slash as an argument to the +.B \-p +option to the +.B hash +builtin command +.IP \(bu +importing function definitions from the shell environment at startup +.IP \(bu +parsing the value of +.SM +.B SHELLOPTS +from the shell environment at startup +.IP \(bu +redirecting output using the >, >|, <>, >&, &>, and >> redirection operators +.IP \(bu +using the +.B exec +builtin command to replace the shell with another command +.IP \(bu +adding or deleting builtin commands with the +.B \-f +and +.B \-d +options to the +.B enable +builtin command +.IP \(bu +using the \fBenable\fP builtin command to enable disabled shell builtins +.IP \(bu +specifying the +.B \-p +option to the +.B command +builtin command +.IP \(bu +turning off restricted mode with +\fBset +r\fP or \fBset +o restricted\fP. +.PP +These restrictions are enforced after any startup files are read. +.PP +.ie \n(zY=1 When a command that is found to be a shell script is executed, +.el \{ When a command that is found to be a shell script is executed +(see +.SM +.B "COMMAND EXECUTION" +above), +\} +.B rbash +turns off any restrictions in the shell spawned to execute the +script. +.\" end of rbash.1 +.if \n(zY=1 .ig zY +.SH "SEE ALSO" +.PD 0 +.TP +\fIBash Reference Manual\fP, Brian Fox and Chet Ramey +.TP +\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey +.TP +\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey +.TP +\fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE +.TP +\fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1) +.TP +\fIemacs\fP(1), \fIvi\fP(1) +.TP +\fIreadline\fP(3) +.PD +.SH FILES +.PD 0 +.TP +.FN /bin/bash +The \fBbash\fP executable +.TP +.FN /etc/profile +The systemwide initialization file, executed for login shells +.TP +.FN ~/.bash_profile +The personal initialization file, executed for login shells +.TP +.FN ~/.bashrc +The individual per-interactive-shell startup file +.TP +.FN ~/.bash_logout +The individual login shell cleanup file, executed when a login shell exits +.TP +.FN ~/.inputrc +Individual \fIreadline\fP initialization file +.PD +.SH AUTHORS +Brian Fox, Free Software Foundation +.br +bfox@gnu.org +.PP +Chet Ramey, Case Western Reserve University +.br +chet.ramey@case.edu +.SH BUG REPORTS +If you find a bug in +.B bash, +you should report it. But first, you should +make sure that it really is a bug, and that it appears in the latest +version of +.BR bash . +The latest version is always available from +\fIftp://ftp.gnu.org/pub/gnu/bash/\fP. +.PP +Once you have determined that a bug actually exists, use the +.I bashbug +command to submit a bug report. +If you have a fix, you are encouraged to mail that as well! +Suggestions and `philosophical' bug reports may be mailed +to \fIbug-bash@gnu.org\fP or posted to the Usenet +newsgroup +.BR gnu.bash.bug . +.PP +ALL bug reports should include: +.PP +.PD 0 +.TP 20 +The version number of \fBbash\fR +.TP +The hardware and operating system +.TP +The compiler used to compile +.TP +A description of the bug behaviour +.TP +A short script or `recipe' which exercises the bug +.PD +.PP +.I bashbug +inserts the first three items automatically into the template +it provides for filing a bug report. +.PP +Comments and bug reports concerning +this manual page should be directed to +.IR chet.ramey@case.edu . +.SH BUGS +.PP +It's too big and too slow. +.PP +There are some subtle differences between +.B bash +and traditional versions of +.BR sh , +mostly because of the +.SM +.B POSIX +specification. +.PP +Aliases are confusing in some uses. +.PP +Shell builtin commands and functions are not stoppable/restartable. +.PP +Compound commands and command sequences of the form `a ; b ; c' +are not handled gracefully when process suspension is attempted. +When a process is stopped, the shell immediately executes the next +command in the sequence. +It suffices to place the sequence of commands between +parentheses to force it into a subshell, which may be stopped as +a unit. +.PP +Array variables may not (yet) be exported. +.PP +There may be only one active coprocess at a time. +.zZ +.zY diff --git a/doc/bash.pdf b/doc/bash.pdf index b16e04527..7cabc2d26 100644 Binary files a/doc/bash.pdf and b/doc/bash.pdf differ diff --git a/doc/bash.ps b/doc/bash.ps index cde00bc92..0311ac02f 100644 --- a/doc/bash.ps +++ b/doc/bash.ps @@ -1,6 +1,6 @@ %!PS-Adobe-3.0 %%Creator: groff version 1.19.2 -%%CreationDate: Mon Jul 16 16:12:24 2012 +%%CreationDate: Fri Dec 14 09:30:37 2012 %%DocumentNeededResources: font Times-Roman %%+ font Times-Bold %%+ font Times-Italic @@ -328,8 +328,8 @@ F .474(xtended deb)-.15 F(ug-)-.2 E 1.598(instead of the standard personal initialization \214le)4.278 F F3 (~/.bashr)3.599 E(c)-.37 E F0 1.599(if the)4.409 F(shell is interacti) 144 698.4 Q .3 -.15(ve \()-.25 H(see).15 E F4(INV)2.5 E(OCA)-.405 E -(TION)-.855 E F0(belo)2.25 E(w\).)-.25 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(1)203.165 E 0 Cg EP +(TION)-.855 E F0(belo)2.25 E(w\).)-.25 E(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(1)190.545 E 0 Cg EP %%Page: 2 2 %%BeginPageSetup BP @@ -447,8 +447,8 @@ F(ariable)-.25 E F3 -.27(BA)108 708 S(SH_ENV).27 E F0 1.011(in the en) 1.01(alue as the)-.25 F(name of a \214le to read and e)108 720 Q -.15 (xe)-.15 G(cute.).15 E F1(Bash)5 E F0(beha)2.5 E -.15(ve)-.2 G 2.5(sa) .15 G 2.5(si)-2.5 G 2.5(ft)-2.5 G(he follo)-2.5 E(wing command were e) --.25 E -.15(xe)-.15 G(cuted:).15 E(GNU Bash 4.2)72 768 Q(2012 July 14) -149.005 E(2)203.165 E 0 Cg EP +-.25 E -.15(xe)-.15 G(cuted:).15 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 +E -.15(ve)-.15 G(mber 24).15 E(2)190.545 E 0 Cg EP %%Page: 3 3 %%BeginPageSetup BP @@ -580,7 +580,8 @@ F .388(wed by)-.25 F F3(blank)2.888 E F0 .388(-separated w)B .388 (simple command)2.676 F F0 .175(is its e)2.676 F .175 (xit status, or 128+)-.15 F F4(n)A F0 .175 (if the command is terminated by signal)3.508 F F4(n)2.675 E F0(.).24 E -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(3)203.165 E 0 Cg EP +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(3) +190.545 E 0 Cg EP %%Page: 4 4 %%BeginPageSetup BP @@ -688,7 +689,8 @@ Q F2 1.054(compound command)3.554 F F0 1.054(is one of the follo)3.554 F -3.553 F 1.026(separated from the rest of the command by one or more ne) 108 698.4 R 1.026(wlines, and may be follo)-.25 F 1.027(wed by a ne)-.25 F 1.027(wline in)-.25 F(place of a semicolon.)108 710.4 Q(GNU Bash 4.2) -72 768 Q(2012 July 14)149.005 E(4)203.165 E 0 Cg EP +72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(4)190.545 E 0 Cg +EP %%Page: 5 5 %%BeginPageSetup BP @@ -750,21 +752,24 @@ F0(and)2.5 E F3(>)2.5 E F0(operators sort le)2.5 E (xicographically using the current locale.)-.15 E .502(When the)144 350.4 R F3(==)3.002 E F0(and)3.002 E F3(!=)3.002 E F0 .502(operators ar\ e used, the string to the right of the operator is considered a pat-) -3.002 F 1.225(tern and matched according to the rules described belo)144 -362.4 R 3.724(wu)-.25 G(nder)-3.724 E F3 -.1(Pa)3.724 G(tter).1 E 3.724 -(nM)-.15 G(atching)-3.724 E F0 6.224(.I)C 3.724(ft)-6.224 G 1.224 -(he shell)-3.724 F(option)144 374.4 Q F3(nocasematch)3.404 E F0 .904 -(is enabled, the match is performed without re)3.404 F -.05(ga)-.15 G -.905(rd to the case of alphabetic).05 F 2.752(characters. The)144 386.4 -R .251(return v)2.752 F .251(alue is 0 if the string matches \()-.25 F -F3(==)A F0 2.751(\)o)C 2.751(rd)-2.751 G .251(oes not match \()-2.751 F -F3(!=)A F0 2.751(\)t)C .251(he pattern, and)-2.751 F 2.725(1o)144 398.4 -S 2.725(therwise. An)-2.725 F 2.725(yp)-.15 G .225(art of the pattern m\ -ay be quoted to force the quoted portion to be matched as a)-2.725 F -(string.)144 410.4 Q .243(An additional binary operator)144 428.4 R(,) --.4 E F3(=~)2.743 E F0 2.743(,i)C 2.743(sa)-2.743 G -.25(va)-2.943 G -.243(ilable, with the same precedence as).25 F F3(==)2.743 E F0(and) -2.743 E F3(!=)2.743 E F0 5.243(.W)C .243(hen it is)-5.243 F 1.953 +3.002 F .025(tern and matched according to the rules described belo)144 +362.4 R 2.524(wu)-.25 G(nder)-2.524 E F3 -.1(Pa)2.524 G(tter).1 E 2.524 +(nM)-.15 G(atching)-2.524 E F0 5.024(.T)C(he)-5.024 E F3(=)2.524 E F0 +(operator)2.524 E .824(is equi)144 374.4 R -.25(va)-.25 G .824(lent to) +.25 F F3(==)3.324 E F0 5.824(.I)C 3.324(ft)-5.824 G .824 +(he shell option)-3.324 F F3(nocasematch)3.324 E F0 .824 +(is enabled, the match is performed without)3.324 F(re)144 386.4 Q -.05 +(ga)-.15 G .133(rd to the case of alphabetic characters.).05 F .132 +(The return v)5.132 F .132(alue is 0 if the string matches \()-.25 F F3 +(==)A F0 2.632(\)o)C 2.632(rd)-2.632 G(oes)-2.632 E .94(not match \()144 +398.4 R F3(!=)A F0 3.44(\)t)C .94(he pattern, and 1 otherwise.)-3.44 F +(An)5.94 E 3.44(yp)-.15 G .94 +(art of the pattern may be quoted to force the)-3.44 F +(quoted portion to be matched as a string.)144 410.4 Q .243 +(An additional binary operator)144 428.4 R(,)-.4 E F3(=~)2.743 E F0 +2.743(,i)C 2.743(sa)-2.743 G -.25(va)-2.943 G .243 +(ilable, with the same precedence as).25 F F3(==)2.743 E F0(and)2.743 E +F3(!=)2.743 E F0 5.243(.W)C .243(hen it is)-5.243 F 1.953 (used, the string to the right of the operator is considered an e)144 440.4 R 1.954(xtended re)-.15 F 1.954(gular e)-.15 F 1.954 (xpression and)-.15 F .207(matched accordingly \(as in)144 452.4 R F1 @@ -815,8 +820,8 @@ E F0(th parenthesized sube)A(xpression.)-.15 E .786 2.52 E F1 -.2(ex)144 704.4 S(pr).2 E(ession1)-.37 E F3(||)2.5 E F1 -.2 (ex)2.5 G(pr).2 E(ession2)-.37 E F0 -.35(Tr)180 716.4 S(ue if either).35 E F1 -.2(ex)2.5 G(pr).2 E(ession1)-.37 E F0(or)2.5 E F1 -.2(ex)2.5 G(pr) -.2 E(ession2)-.37 E F0(is true.)2.52 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(5)203.165 E 0 Cg EP +.2 E(ession2)-.37 E F0(is true.)2.52 E(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(5)190.545 E 0 Cg EP %%Page: 6 6 %%BeginPageSetup BP @@ -971,8 +976,8 @@ F .204(The e)5.204 F .204(xit status of the)-.15 F F1(while)2.704 E F0 (and)2.704 E F1(until)2.704 E F0 .205(commands is the e)2.704 F .205 (xit status of the last command)-.15 F -.15(exe)144 700.8 S(cuted in).15 E F2(list-2)2.5 E F0 2.5(,o)C 2.5(rz)-2.5 G(ero if none w)-2.5 E(as e) --.1 E -.15(xe)-.15 G(cuted.).15 E(GNU Bash 4.2)72 768 Q(2012 July 14) -149.005 E(6)203.165 E 0 Cg EP +-.1 E -.15(xe)-.15 G(cuted.).15 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 +E -.15(ve)-.15 G(mber 24).15 E(6)190.545 E 0 Cg EP %%Page: 7 7 %%BeginPageSetup BP @@ -1027,458 +1032,463 @@ F 1.137(wned to e)-.15 F -.15(xe)-.15 G 1.137(cute the coprocess is a) -.25(va)108 290.4 S(riable).25 E F2 -.27(NA)2.5 G(ME).27 E F0 2.5 (_PID. The)B F1(wait)2.5 E F0 -.2(bu)2.5 G (iltin command may be used to w).2 E -(ait for the coprocess to terminate.)-.1 E -(The return status of a coprocess is the e)108 307.2 Q(xit status of) --.15 E F2(command)2.5 E F0(.)A F1(Shell Function De\214nitions)87 324 Q -F0 2.698(As)108 336 S .198 -(hell function is an object that is called lik)-2.698 F 2.698(eas)-.1 G -.198(imple command and e)-2.698 F -.15(xe)-.15 G .197 -(cutes a compound command with).15 F 2.5(an)108 348 S .5 -.25(ew s)-2.5 +(ait for the coprocess to terminate.)-.1 E .336 +(Since the coprocess is created as an asynchronous command, the)108 +307.2 R F1(copr)2.836 E(oc)-.18 E F0 .335(command al)2.835 F -.1(wa)-.1 +G .335(ys returns success.).1 F +(The return status of a coprocess is the e)108 319.2 Q(xit status of) +-.15 E F2(command)2.5 E F0(.)A F1(Shell Function De\214nitions)87 336 Q +F0 2.697(As)108 348 S .198 +(hell function is an object that is called lik)-2.697 F 2.698(eas)-.1 G +.198(imple command and e)-2.698 F -.15(xe)-.15 G .198 +(cutes a compound command with).15 F 2.5(an)108 360 S .5 -.25(ew s)-2.5 H(et of positional parameters.).25 E -(Shell functions are declared as follo)5 E(ws:)-.25 E F2(name)108 364.8 +(Shell functions are declared as follo)5 E(ws:)-.25 E F2(name)108 376.8 Q F0(\(\))2.5 E F2(compound\255command)2.5 E F0([)2.5 E F2 -.37(re)C -(dir).37 E(ection)-.37 E F0(])A F1(function)108 376.8 Q F2(name)2.5 E F0 +(dir).37 E(ection)-.37 E F0(])A F1(function)108 388.8 Q F2(name)2.5 E F0 ([\(\)])2.5 E F2(compound\255command)2.5 E F0([)2.5 E F2 -.37(re)C(dir) -.37 E(ection)-.37 E F0(])A 1.402(This de\214nes a function named)144 -388.8 R F2(name)3.902 E F0 6.402(.T)C 1.402(he reserv)-6.402 F 1.402 +.37 E(ection)-.37 E F0(])A 1.403(This de\214nes a function named)144 +400.8 R F2(name)3.902 E F0 6.402(.T)C 1.402(he reserv)-6.402 F 1.402 (ed w)-.15 F(ord)-.1 E F1(function)3.902 E F0 1.402(is optional.)3.902 F -1.403(If the)6.402 F F1(function)3.903 E F0(reserv)144 400.8 Q .162 +1.402(If the)6.402 F F1(function)3.902 E F0(reserv)144 412.8 Q .162 (ed w)-.15 F .162(ord is supplied, the parentheses are optional.)-.1 F (The)5.162 E F2(body)2.662 E F0 .162(of the function is the compound) -2.662 F(command)144 412.8 Q F2(compound\255command)2.784 E F0(\(see) +2.662 F(command)144 424.8 Q F2(compound\255command)2.784 E F0(\(see) 3.354 E F1 .084(Compound Commands)2.584 F F0(abo)2.584 E -.15(ve)-.15 G -2.584(\). That).15 F .084(command is usually a)2.584 F F2(list)144 424.8 +2.584(\). That).15 F .084(command is usually a)2.584 F F2(list)144 436.8 Q F0 .044(of commands between { and }, b)2.544 F .044(ut may be an)-.2 F 2.544(yc)-.15 G .044(ommand listed under)-2.544 F F1 .044 -(Compound Commands)2.544 F F0(abo)144 436.8 Q -.15(ve)-.15 G(.).15 E F2 -(compound\255command)6.67 E F0 1.67(is e)4.17 F -.15(xe)-.15 G 1.671 +(Compound Commands)2.544 F F0(abo)144 448.8 Q -.15(ve)-.15 G(.).15 E F2 +(compound\255command)6.671 E F0 1.671(is e)4.171 F -.15(xe)-.15 G 1.671 (cuted whene).15 F -.15(ve)-.25 G(r).15 E F2(name)4.171 E F0 1.671 -(is speci\214ed as the name of a simple)4.171 F 2.753(command. When)144 -448.8 R(in)2.753 E F2 .253(posix mode)2.753 F F0(,)A F2(name)2.753 E F0 -.253(may not be the name of one of the POSIX)2.753 F F2 .252(special b) -2.753 F(uiltins)-.2 E F0(.)A(An)144 460.8 Q 3.241(yr)-.15 G .741 -(edirections \(see)-3.241 F F3(REDIRECTION)3.241 E F0(belo)2.991 E .742 -(w\) speci\214ed when a function is de\214ned are performed)-.25 F .171 -(when the function is e)144 472.8 R -.15(xe)-.15 G 2.671(cuted. The).15 -F -.15(ex)2.671 G .17 +(is speci\214ed as the name of a simple)4.171 F 2.752(command. When)144 +460.8 R(in)2.753 E F2 .253(posix mode)2.753 F F0(,)A F2(name)2.753 E F0 +.253(may not be the name of one of the POSIX)2.753 F F2 .253(special b) +2.753 F(uiltins)-.2 E F0(.)A(An)144 472.8 Q 3.242(yr)-.15 G .742 +(edirections \(see)-3.242 F F3(REDIRECTION)3.242 E F0(belo)2.992 E .741 +(w\) speci\214ed when a function is de\214ned are performed)-.25 F .17 +(when the function is e)144 484.8 R -.15(xe)-.15 G 2.67(cuted. The).15 F +-.15(ex)2.67 G .171 (it status of a function de\214nition is zero unless a syntax error).15 -F .704(occurs or a readonly function with the same name already e)144 -484.8 R 3.205(xists. When)-.15 F -.15(exe)3.205 G .705(cuted, the e).15 -F .705(xit status)-.15 F 1.822(of a function is the e)144 496.8 R 1.821 +F .705(occurs or a readonly function with the same name already e)144 +496.8 R 3.204(xists. When)-.15 F -.15(exe)3.204 G .704(cuted, the e).15 +F .704(xit status)-.15 F 1.821(of a function is the e)144 508.8 R 1.821 (xit status of the last command e)-.15 F -.15(xe)-.15 G 1.821 -(cuted in the body).15 F 6.821(.\()-.65 G(See)-6.821 E F3(FUNCTIONS) -4.321 E F0(belo)144 508.8 Q -.65(w.)-.25 G(\)).65 E/F4 10.95 -/Times-Bold@0 SF(COMMENTS)72 525.6 Q F0 .982(In a non-interacti)108 -537.6 R 1.282 -.15(ve s)-.25 H .982(hell, or an interacti).15 F 1.282 +(cuted in the body).15 F 6.822(.\()-.65 G(See)-6.822 E F3(FUNCTIONS) +4.322 E F0(belo)144 520.8 Q -.65(w.)-.25 G(\)).65 E/F4 10.95 +/Times-Bold@0 SF(COMMENTS)72 537.6 Q F0 .982(In a non-interacti)108 +549.6 R 1.282 -.15(ve s)-.25 H .982(hell, or an interacti).15 F 1.282 -.15(ve s)-.25 H .982(hell in which the).15 F F1(interacti)3.482 E -.1 (ve)-.1 G(_comments).1 E F0 .982(option to the)3.482 F F1(shopt)3.482 E -F0 -.2(bu)108 549.6 S .952(iltin is enabled \(see).2 F F3 .952(SHELL B) -3.452 F(UIL)-.09 E .952(TIN COMMANDS)-.828 F F0(belo)3.202 E .952 -(w\), a w)-.25 F .952(ord be)-.1 F .952(ginning with)-.15 F F1(#)3.451 E -F0 .951(causes that w)3.451 F(ord)-.1 E .604 -(and all remaining characters on that line to be ignored.)108 561.6 R -.605(An interacti)5.605 F .905 -.15(ve s)-.25 H .605(hell without the) -.15 F F1(interacti)3.105 E -.1(ve)-.1 G(_com-).1 E(ments)108 573.6 Q F0 -1.337(option enabled does not allo)3.837 F 3.837(wc)-.25 G 3.836 -(omments. The)-3.837 F F1(interacti)3.836 E -.1(ve)-.1 G(_comments).1 E -F0 1.336(option is on by def)3.836 F 1.336(ault in)-.1 F(interacti)108 -585.6 Q .3 -.15(ve s)-.25 H(hells.).15 E F4 -.11(QU)72 602.4 S -.438(OT) -.11 G(ING).438 E F2(Quoting)108 614.4 Q F0 .477(is used to remo)2.977 F +F0 -.2(bu)108 561.6 S .951(iltin is enabled \(see).2 F F3 .952(SHELL B) +3.451 F(UIL)-.09 E .952(TIN COMMANDS)-.828 F F0(belo)3.202 E .952 +(w\), a w)-.25 F .952(ord be)-.1 F .952(ginning with)-.15 F F1(#)3.452 E +F0 .952(causes that w)3.452 F(ord)-.1 E .605 +(and all remaining characters on that line to be ignored.)108 573.6 R +.604(An interacti)5.605 F .904 -.15(ve s)-.25 H .604(hell without the) +.15 F F1(interacti)3.104 E -.1(ve)-.1 G(_com-).1 E(ments)108 585.6 Q F0 +1.336(option enabled does not allo)3.836 F 3.836(wc)-.25 G 3.836 +(omments. The)-3.836 F F1(interacti)3.836 E -.1(ve)-.1 G(_comments).1 E +F0 1.337(option is on by def)3.837 F 1.337(ault in)-.1 F(interacti)108 +597.6 Q .3 -.15(ve s)-.25 H(hells.).15 E F4 -.11(QU)72 614.4 S -.438(OT) +.11 G(ING).438 E F2(Quoting)108 626.4 Q F0 .478(is used to remo)2.978 F .777 -.15(ve t)-.15 H .477 (he special meaning of certain characters or w).15 F .477 -(ords to the shell.)-.1 F .478(Quoting can be)5.478 F .185 +(ords to the shell.)-.1 F .477(Quoting can be)5.477 F .184 (used to disable special treatment for special characters, to pre)108 -626.4 R -.15(ve)-.25 G .185(nt reserv).15 F .184(ed w)-.15 F .184 -(ords from being recognized as)-.1 F(such, and to pre)108 638.4 Q -.15 -(ve)-.25 G(nt parameter e).15 E(xpansion.)-.15 E .288(Each of the)108 -655.2 R F2(metac)2.788 E(har)-.15 E(acter)-.15 E(s)-.1 E F0 .288 -(listed abo)2.788 F .588 -.15(ve u)-.15 H(nder).15 E F3(DEFINITIONS) +638.4 R -.15(ve)-.25 G .185(nt reserv).15 F .185(ed w)-.15 F .185 +(ords from being recognized as)-.1 F(such, and to pre)108 650.4 Q -.15 +(ve)-.25 G(nt parameter e).15 E(xpansion.)-.15 E .289(Each of the)108 +667.2 R F2(metac)2.789 E(har)-.15 E(acter)-.15 E(s)-.1 E F0 .288 +(listed abo)2.789 F .588 -.15(ve u)-.15 H(nder).15 E F3(DEFINITIONS) 2.788 E F0 .288(has special meaning to the shell and must be)2.538 F -(quoted if it is to represent itself.)108 667.2 Q 1.345 -(When the command history e)108 684 R 1.344(xpansion f)-.15 F 1.344 +(quoted if it is to represent itself.)108 679.2 Q 1.344 +(When the command history e)108 696 R 1.344(xpansion f)-.15 F 1.344 (acilities are being used \(see)-.1 F F3(HIST)3.844 E(OR)-.162 E 3.594 -(YE)-.315 G(XP)-3.594 E(ANSION)-.666 E F0(belo)3.594 E 1.344(w\), the) --.25 F F2(history e)108 696 Q(xpansion)-.2 E F0(character)2.5 E 2.5(,u) +(YE)-.315 G(XP)-3.594 E(ANSION)-.666 E F0(belo)3.595 E 1.345(w\), the) +-.25 F F2(history e)108 708 Q(xpansion)-.2 E F0(character)2.5 E 2.5(,u) -.4 G(sually)-2.5 E F1(!)2.5 E F0 2.5(,m)C(ust be quoted to pre)-2.5 E -.15(ve)-.25 G(nt history e).15 E(xpansion.)-.15 E -(There are three quoting mechanisms: the)108 712.8 Q F2(escape c)2.5 E +(There are three quoting mechanisms: the)108 724.8 Q F2(escape c)2.5 E (har)-.15 E(acter)-.15 E F0 2.5(,s).73 G -(ingle quotes, and double quotes.)-2.5 E 2.974(An)108 729.6 S .474 -(on-quoted backslash \()-2.974 F F1(\\)A F0 2.974(\)i)C 2.974(st)-2.974 -G(he)-2.974 E F2 .474(escape c)2.974 F(har)-.15 E(acter)-.15 E F0 5.474 -(.I).73 G 2.974(tp)-5.474 G(reserv)-2.974 E .474(es the literal v)-.15 F -.474(alue of the ne)-.25 F .475(xt character that)-.15 F(GNU Bash 4.2)72 -768 Q(2012 July 14)149.005 E(7)203.165 E 0 Cg EP +(ingle quotes, and double quotes.)-2.5 E(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(7)190.545 E 0 Cg EP %%Page: 8 8 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E(follo)108 84 Q 1.554(ws, with the e)-.25 F 1.553(xception of . If)-.25 F(a)4.053 E/F1 10/Times-Bold@0 SF(\\)4.053 -E F0( pair appears, and the backslash is not itself) --.25 F 1.122(quoted, the)108 96 R F1(\\)3.622 E F0(. If)-.25 F(a)4.053 E F1(\\)4.053 E F0( pair appears, and the backslash is not itself)-.25 F 1.123 +(quoted, the)108 108 R F1(\\)3.623 E F0( is treated as a line continuation \(that is, it is remo)-.25 F --.15(ve)-.15 G 3.622(df).15 G 1.123(rom the input stream and)-3.622 F -(ef)108 108 Q(fecti)-.25 E -.15(ve)-.25 G(ly ignored\).).15 E .295 -(Enclosing characters in single quotes preserv)108 124.8 R .295 +-.15(ve)-.15 G 3.622(df).15 G 1.122(rom the input stream and)-3.622 F +(ef)108 120 Q(fecti)-.25 E -.15(ve)-.25 G(ly ignored\).).15 E .295 +(Enclosing characters in single quotes preserv)108 136.8 R .295 (es the literal v)-.15 F .295(alue of each character within the quotes.) -.25 F 2.795(As)5.295 G(in-)-2.795 E -(gle quote may not occur between single quotes, e)108 136.8 Q -.15(ve) --.25 G 2.5(nw).15 G(hen preceded by a backslash.)-2.5 E .033 -(Enclosing characters in double quotes preserv)108 153.6 R .034 +(gle quote may not occur between single quotes, e)108 148.8 Q -.15(ve) +-.25 G 2.5(nw).15 G(hen preceded by a backslash.)-2.5 E .034 +(Enclosing characters in double quotes preserv)108 165.6 R .034 (es the literal v)-.15 F .034 (alue of all characters within the quotes, with the)-.25 F -.15(ex)108 -165.6 S .828(ception of).15 F F1($)3.328 E F0(,)A F1<92>3.328 E F0(,)A +177.6 S .827(ception of).15 F F1($)3.327 E F0(,)A F1<92>3.328 E F0(,)A F1(\\)3.328 E F0 3.328(,a)C .828(nd, when history e)-3.328 F .828 (xpansion is enabled,)-.15 F F1(!)3.328 E F0 5.828(.T)C .828 (he characters)-5.828 F F1($)3.328 E F0(and)3.328 E F1<92>3.328 E F0 -.827(retain their special)3.328 F .074(meaning within double quotes.)108 -177.6 R .074(The backslash retains its special meaning only when follo) -5.074 F .075(wed by one of the)-.25 F(follo)108 189.6 Q .205 -(wing characters:)-.25 F F1($)2.705 E F0(,)A F1<92>2.705 E F0(,)A F1(") -3.538 E F0(,).833 E F1(\\)2.705 E F0 2.705(,o)C(r)-2.705 E F1() -2.705 E F0 5.205(.A)C .204 -(double quote may be quoted within double quotes by pre-)-2.5 F .081 -(ceding it with a backslash.)108 201.6 R .082(If enabled, history e) -5.082 F .082(xpansion will be performed unless an)-.15 F F1(!)2.582 E F0 -.082(appearing in double)5.082 F(quotes is escaped using a backslash.) -108 213.6 Q(The backslash preceding the)5 E F1(!)2.5 E F0(is not remo)5 -E -.15(ve)-.15 G(d.).15 E(The special parameters)108 230.4 Q F1(*)2.5 E +.828(retain their special)3.328 F .075(meaning within double quotes.)108 +189.6 R .074(The backslash retains its special meaning only when follo) +5.075 F .074(wed by one of the)-.25 F(follo)108 201.6 Q .204 +(wing characters:)-.25 F F1($)2.704 E F0(,)A F1<92>2.704 E F0(,)A F1(") +3.537 E F0(,).833 E F1(\\)2.704 E F0 2.704(,o)C(r)-2.704 E F1() +2.705 E F0 5.205(.A)C .205 +(double quote may be quoted within double quotes by pre-)-2.5 F .082 +(ceding it with a backslash.)108 213.6 R .082(If enabled, history e) +5.082 F .082(xpansion will be performed unless an)-.15 F F1(!)2.581 E F0 +.081(appearing in double)5.081 F(quotes is escaped using a backslash.) +108 225.6 Q(The backslash preceding the)5 E F1(!)2.5 E F0(is not remo)5 +E -.15(ve)-.15 G(d.).15 E(The special parameters)108 242.4 Q F1(*)2.5 E F0(and)2.5 E F1(@)2.5 E F0(ha)2.5 E .3 -.15(ve s)-.2 H -(pecial meaning when in double quotes \(see).15 E/F2 9/Times-Bold@0 SF +(pecial meaning when in double quotes \(see).15 E/F3 9/Times-Bold@0 SF -.666(PA)2.5 G(RAMETERS).666 E F0(belo)2.25 E(w\).)-.25 E -.8(Wo)108 -247.2 S .212(rds of the form).8 F F1($)2.712 E F0<08>A/F3 10 -/Times-Italic@0 SF(string)A F0 2.712<0861>C .211(re treated specially) --2.712 F 5.211(.T)-.65 G .211(he w)-5.211 F .211(ord e)-.1 F .211 -(xpands to)-.15 F F3(string)2.711 E F0 2.711(,w)C .211 -(ith backslash-escaped char)-2.711 F(-)-.2 E .604 -(acters replaced as speci\214ed by the ANSI C standard.)108 259.2 R .605 +259.2 S .211(rds of the form).8 F F1($)2.711 E F0<08>A F2(string)A F0 +2.711<0861>C .211(re treated specially)-2.711 F 5.211(.T)-.65 G .211 +(he w)-5.211 F .211(ord e)-.1 F .212(xpands to)-.15 F F2(string)2.712 E +F0 2.712(,w)C .212(ith backslash-escaped char)-2.712 F(-)-.2 E .605 +(acters replaced as speci\214ed by the ANSI C standard.)108 271.2 R .604 (Backslash escape sequences, if present, are decoded)5.605 F(as follo) -108 271.2 Q(ws:)-.25 E F1(\\a)144 283.2 Q F0(alert \(bell\))28.22 E F1 -(\\b)144 295.2 Q F0(backspace)27.66 E F1(\\e)144 307.2 Q(\\E)144 319.2 Q -F0(an escape character)26.55 E F1(\\f)144 331.2 Q F0(form feed)29.89 E -F1(\\n)144 343.2 Q F0(ne)27.66 E 2.5(wl)-.25 G(ine)-2.5 E F1(\\r)144 -355.2 Q F0(carriage return)28.78 E F1(\\t)144 367.2 Q F0(horizontal tab) -29.89 E F1(\\v)144 379.2 Q F0 -.15(ve)28.22 G(rtical tab).15 E F1(\\\\) -144 391.2 Q F0(backslash)30.44 E F1<5c08>144 403.2 Q F0(single quote) -30.44 E F1(\\")144 415.2 Q F0(double quote)27.67 E F1(\\)144 427.2 Q F3 +108 283.2 Q(ws:)-.25 E F1(\\a)144 295.2 Q F0(alert \(bell\))28.22 E F1 +(\\b)144 307.2 Q F0(backspace)27.66 E F1(\\e)144 319.2 Q(\\E)144 331.2 Q +F0(an escape character)26.55 E F1(\\f)144 343.2 Q F0(form feed)29.89 E +F1(\\n)144 355.2 Q F0(ne)27.66 E 2.5(wl)-.25 G(ine)-2.5 E F1(\\r)144 +367.2 Q F0(carriage return)28.78 E F1(\\t)144 379.2 Q F0(horizontal tab) +29.89 E F1(\\v)144 391.2 Q F0 -.15(ve)28.22 G(rtical tab).15 E F1(\\\\) +144 403.2 Q F0(backslash)30.44 E F1<5c08>144 415.2 Q F0(single quote) +30.44 E F1(\\")144 427.2 Q F0(double quote)27.67 E F1(\\)144 439.2 Q F2 (nnn)A F0(the eight-bit character whose v)18.22 E(alue is the octal v) --.25 E(alue)-.25 E F3(nnn)2.5 E F0(\(one to three digits\))2.5 E F1(\\x) -144 439.2 Q F3(HH)A F0(the eight-bit character whose v)13.78 E -(alue is the he)-.25 E(xadecimal v)-.15 E(alue)-.25 E F3(HH)2.5 E F0 +-.25 E(alue)-.25 E F2(nnn)2.5 E F0(\(one to three digits\))2.5 E F1(\\x) +144 451.2 Q F2(HH)A F0(the eight-bit character whose v)13.78 E +(alue is the he)-.25 E(xadecimal v)-.15 E(alue)-.25 E F2(HH)2.5 E F0 (\(one or tw)2.5 E 2.5(oh)-.1 G .3 -.15(ex d)-2.5 H(igits\)).15 E F1 -(\\u)144 451.2 Q F3(HHHH)A F0 1.507 -(the Unicode \(ISO/IEC 10646\) character whose v)180 463.2 R 1.506 -(alue is the he)-.25 F 1.506(xadecimal v)-.15 F(alue)-.25 E F3(HHHH) -4.006 E F0(\(one to four he)180 475.2 Q 2.5(xd)-.15 G(igits\))-2.5 E F1 -(\\U)144 487.2 Q F3(HHHHHHHH)A F0 .547 -(the Unicode \(ISO/IEC 10646\) character whose v)180 499.2 R .547 -(alue is the he)-.25 F .548(xadecimal v)-.15 F(alue)-.25 E F3(HHHHH-) -3.048 E(HHH)180 511.2 Q F0(\(one to eight he)2.5 E 2.5(xd)-.15 G -(igits\))-2.5 E F1(\\c)144 523.2 Q F3(x)A F0 2.5(ac)24.34 G(ontrol-)-2.5 -E F3(x)A F0(character)2.5 E(The e)108 540 Q(xpanded result is single-qu\ +(\\u)144 463.2 Q F2(HHHH)A F0 1.506 +(the Unicode \(ISO/IEC 10646\) character whose v)180 475.2 R 1.507 +(alue is the he)-.25 F 1.507(xadecimal v)-.15 F(alue)-.25 E F2(HHHH) +4.007 E F0(\(one to four he)180 487.2 Q 2.5(xd)-.15 G(igits\))-2.5 E F1 +(\\U)144 499.2 Q F2(HHHHHHHH)A F0 .548 +(the Unicode \(ISO/IEC 10646\) character whose v)180 511.2 R .547 +(alue is the he)-.25 F .547(xadecimal v)-.15 F(alue)-.25 E F2(HHHHH-) +3.047 E(HHH)180 523.2 Q F0(\(one to eight he)2.5 E 2.5(xd)-.15 G +(igits\))-2.5 E F1(\\c)144 535.2 Q F2(x)A F0 2.5(ac)24.34 G(ontrol-)-2.5 +E F2(x)A F0(character)2.5 E(The e)108 552 Q(xpanded result is single-qu\ oted, as if the dollar sign had not been present.)-.15 E 2.64(Ad)108 -556.8 S .14(ouble-quoted string preceded by a dollar sign \()-2.64 F F1 -($)A F0(")A F3(string)A F0 .14 -("\) will cause the string to be translated according)B .495 -(to the current locale.)108 568.8 R .495(If the current locale is)5.495 +568.8 S .14(ouble-quoted string preceded by a dollar sign \()-2.64 F F1 +($)A F0(")A F2(string)A F0 .14 +("\) will cause the string to be translated according)B .496 +(to the current locale.)108 580.8 R .495(If the current locale is)5.496 F F1(C)2.995 E F0(or)2.995 E F1(POSIX)2.995 E F0 2.995(,t)C .495 -(he dollar sign is ignored.)-2.995 F .496(If the string is trans-)5.496 -F(lated and replaced, the replacement is double-quoted.)108 580.8 Q/F4 -10.95/Times-Bold@0 SF -.81(PA)72 597.6 S(RAMETERS).81 E F0(A)108 609.6 Q -F3(par)4.593 E(ameter)-.15 E F0 .843(is an entity that stores v)4.073 F -3.343(alues. It)-.25 F .843(can be a)3.343 F F3(name)3.342 E F0 3.342 -(,an).18 G(umber)-3.342 E 3.342(,o)-.4 G 3.342(ro)-3.342 G .842 -(ne of the special characters)-3.342 F .822(listed belo)108 621.6 R +(he dollar sign is ignored.)-2.995 F .495(If the string is trans-)5.495 +F(lated and replaced, the replacement is double-quoted.)108 592.8 Q/F4 +10.95/Times-Bold@0 SF -.81(PA)72 609.6 S(RAMETERS).81 E F0(A)108 621.6 Q +F2(par)4.592 E(ameter)-.15 E F0 .842(is an entity that stores v)4.072 F +3.342(alues. It)-.25 F .842(can be a)3.342 F F2(name)3.343 E F0 3.343 +(,an).18 G(umber)-3.343 E 3.343(,o)-.4 G 3.343(ro)-3.343 G .843 +(ne of the special characters)-3.343 F .823(listed belo)108 633.6 R 3.323(wu)-.25 G(nder)-3.323 E F1 .823(Special P)3.323 F(arameters)-.1 E -F0 5.823(.A)C F3(variable)-2.21 E F0 .823(is a parameter denoted by a) -3.503 F F3(name)3.323 E F0 5.823(.A).18 G -.25(va)-2.5 G .823 -(riable has a).25 F F3(value)108 633.6 Q F0 .369(and zero or more)2.869 -F F3(attrib)2.869 E(utes)-.2 E F0 5.369(.A)C(ttrib)-5.369 E .369 -(utes are assigned using the)-.2 F F1(declar)2.868 E(e)-.18 E F0 -.2(bu) -2.868 G .368(iltin command \(see).2 F F1(declar)2.868 E(e)-.18 E F0 -(belo)108 645.6 Q 2.5(wi)-.25 G(n)-2.5 E F2(SHELL B)2.5 E(UIL)-.09 E -(TIN COMMANDS)-.828 E/F5 9/Times-Roman@0 SF(\).)A F0 2.754(Ap)108 662.4 -S .254(arameter is set if it has been assigned a v)-2.754 F 2.754 -(alue. The)-.25 F .254(null string is a v)2.754 F .255(alid v)-.25 F -2.755(alue. Once)-.25 F 2.755(av)2.755 G .255(ariable is set, it)-3.005 -F(may be unset only by using the)108 674.4 Q F1(unset)2.5 E F0 -.2(bu) -2.5 G(iltin command \(see).2 E F2(SHELL B)2.5 E(UIL)-.09 E(TIN COMMANDS) --.828 E F0(belo)2.25 E(w\).)-.25 E(A)108 691.2 Q F3(variable)2.79 E F0 -(may be assigned to by a statement of the form)2.68 E F3(name)144 708 Q -F0(=[)A F3(value)A F0(])A(If)108 724.8 Q F3(value)3.023 E F0 .233 -(is not gi)2.913 F -.15(ve)-.25 G .233(n, the v).15 F .232 -(ariable is assigned the null string.)-.25 F(All)5.232 E F3(values)3.022 -E F0(under)3.002 E .232(go tilde e)-.18 F .232(xpansion, parameter)-.15 -F(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(8)203.165 E 0 Cg EP +F0 5.823(.A)C F2(variable)-2.21 E F0 .823(is a parameter denoted by a) +3.503 F F2(name)3.323 E F0 5.823(.A).18 G -.25(va)-2.5 G .823 +(riable has a).25 F F2(value)108 645.6 Q F0 .368(and zero or more)2.868 +F F2(attrib)2.868 E(utes)-.2 E F0 5.369(.A)C(ttrib)-5.369 E .369 +(utes are assigned using the)-.2 F F1(declar)2.869 E(e)-.18 E F0 -.2(bu) +2.869 G .369(iltin command \(see).2 F F1(declar)2.869 E(e)-.18 E F0 +(belo)108 657.6 Q 2.5(wi)-.25 G(n)-2.5 E F3(SHELL B)2.5 E(UIL)-.09 E +(TIN COMMANDS)-.828 E/F5 9/Times-Roman@0 SF(\).)A F0 2.755(Ap)108 674.4 +S .255(arameter is set if it has been assigned a v)-2.755 F 2.754 +(alue. The)-.25 F .254(null string is a v)2.754 F .254(alid v)-.25 F +2.754(alue. Once)-.25 F 2.754(av)2.754 G .254(ariable is set, it)-3.004 +F(may be unset only by using the)108 686.4 Q F1(unset)2.5 E F0 -.2(bu) +2.5 G(iltin command \(see).2 E F3(SHELL B)2.5 E(UIL)-.09 E(TIN COMMANDS) +-.828 E F0(belo)2.25 E(w\).)-.25 E(A)108 703.2 Q F2(variable)2.79 E F0 +(may be assigned to by a statement of the form)2.68 E F2(name)144 720 Q +F0(=[)A F2(value)A F0(])A(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15 +(ve)-.15 G(mber 24).15 E(8)190.545 E 0 Cg EP %%Page: 9 9 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E .515(and v)108 84 R .515(ariable e)-.25 F .515 +-.35 E(If)108 84 Q/F1 10/Times-Italic@0 SF(value)3.022 E F0 .232 +(is not gi)2.912 F -.15(ve)-.25 G .232(n, the v).15 F .232 +(ariable is assigned the null string.)-.25 F(All)5.233 E F1(values)3.023 +E F0(under)3.003 E .233(go tilde e)-.18 F .233(xpansion, parameter)-.15 +F .515(and v)108 96 R .515(ariable e)-.25 F .515 (xpansion, command substitution, arithmetic e)-.15 F .515 (xpansion, and quote remo)-.15 F -.25(va)-.15 G 3.015(l\().25 G(see) --3.015 E/F1 9/Times-Bold@0 SF(EXP)3.015 E(ANSION)-.666 E F0(belo)108 96 -Q 2.699(w\). If)-.25 F .199(the v)2.699 F .199(ariable has its)-.25 F/F2 +-3.015 E/F2 9/Times-Bold@0 SF(EXP)3.015 E(ANSION)-.666 E F0(belo)108 108 +Q 2.698(w\). If)-.25 F .198(the v)2.698 F .198(ariable has its)-.25 F/F3 10/Times-Bold@0 SF(integer)2.698 E F0(attrib)2.698 E .198(ute set, then) --.2 F/F3 10/Times-Italic@0 SF(value)2.988 E F0 .198(is e)2.878 F -.25 -(va)-.25 G .198(luated as an arithmetic e).25 F .198(xpression e)-.15 F --.15(ve)-.25 G(n).15 E .901(if the $\(\(...\)\) e)108 108 R .901 -(xpansion is not used \(see)-.15 F F2 .901(Arithmetic Expansion)3.401 F -F0(belo)3.401 E 3.402(w\). W)-.25 F .902 -(ord splitting is not performed,)-.8 F 1.179(with the e)108 120 R 1.179 -(xception of)-.15 F F2("$@")3.679 E F0 1.179(as e)3.679 F 1.179 -(xplained belo)-.15 F 3.679(wu)-.25 G(nder)-3.679 E F2 1.178(Special P) -3.678 F(arameters)-.1 E F0 6.178(.P)C 1.178(athname e)-6.328 F 1.178 -(xpansion is not)-.15 F 3.648(performed. Assignment)108 132 R 1.148 -(statements may also appear as ar)3.648 F 1.149(guments to the)-.18 F F2 -(alias)3.649 E F0(,)A F2(declar)3.649 E(e)-.18 E F0(,)A F2(typeset)3.649 -E F0(,)A F2(export)3.649 E F0(,)A F2 -.18(re)108 144 S(adonly).18 E F0 -2.63(,a)C(nd)-2.63 E F2(local)2.63 E F0 -.2(bu)2.63 G .13 -(iltin commands.).2 F .13(When in)5.13 F F3 .129(posix mode)2.629 F F0 -2.629(,t)C .129(hese b)-2.629 F .129 +-.2 F F1(value)2.988 E F0 .198(is e)2.878 F -.25(va)-.25 G .199 +(luated as an arithmetic e).25 F .199(xpression e)-.15 F -.15(ve)-.25 G +(n).15 E .902(if the $\(\(...\)\) e)108 120 R .902 +(xpansion is not used \(see)-.15 F F3 .901(Arithmetic Expansion)3.401 F +F0(belo)3.401 E 3.401(w\). W)-.25 F .901 +(ord splitting is not performed,)-.8 F 1.178(with the e)108 132 R 1.178 +(xception of)-.15 F F3("$@")3.678 E F0 1.178(as e)3.678 F 1.179 +(xplained belo)-.15 F 3.679(wu)-.25 G(nder)-3.679 E F3 1.179(Special P) +3.679 F(arameters)-.1 E F0 6.179(.P)C 1.179(athname e)-6.329 F 1.179 +(xpansion is not)-.15 F 3.649(performed. Assignment)108 144 R 1.149 +(statements may also appear as ar)3.649 F 1.148(guments to the)-.18 F F3 +(alias)3.648 E F0(,)A F3(declar)3.648 E(e)-.18 E F0(,)A F3(typeset)3.648 +E F0(,)A F3(export)3.648 E F0(,)A F3 -.18(re)108 156 S(adonly).18 E F0 +2.629(,a)C(nd)-2.629 E F3(local)2.629 E F0 -.2(bu)2.629 G .129 +(iltin commands.).2 F .129(When in)5.129 F F1 .129(posix mode)2.629 F F0 +2.629(,t)C .129(hese b)-2.629 F .13 (uiltins may appear in a command after)-.2 F -(one or more instances of the)108 156 Q F2(command)2.5 E F0 -.2(bu)2.5 G -(iltin and retain these assignment statement properties.).2 E .376 -(In the conte)108 172.8 R .376 +(one or more instances of the)108 168 Q F3(command)2.5 E F0 -.2(bu)2.5 G +(iltin and retain these assignment statement properties.).2 E .377 +(In the conte)108 184.8 R .377 (xt where an assignment statement is assigning a v)-.15 F .376 -(alue to a shell v)-.25 F .377(ariable or array inde)-.25 F .377 +(alue to a shell v)-.25 F .376(ariable or array inde)-.25 F .376 (x, the +=)-.15 F .257 -(operator can be used to append to or add to the v)108 184.8 R(ariable') +(operator can be used to append to or add to the v)108 196.8 R(ariable') -.25 E 2.757(sp)-.55 G(re)-2.757 E .257(vious v)-.25 F 2.757(alue. When) --.25 F .257(+= is applied to a v)2.757 F(ariable)-.25 E .36 -(for which the)108 196.8 R F3(inte)2.86 E -.1(ge)-.4 G(r).1 E F0(attrib) -2.86 E .36(ute has been set,)-.2 F F3(value)2.86 E F0 .361(is e)2.861 F --.25(va)-.25 G .361(luated as an arithmetic e).25 F .361 -(xpression and added to the)-.15 F -.25(va)108 208.8 S(riable').25 E -2.889(sc)-.55 G .389(urrent v)-2.889 F .389(alue, which is also e)-.25 F +-.25 F .257(+= is applied to a v)2.757 F(ariable)-.25 E .361 +(for which the)108 208.8 R F1(inte)2.861 E -.1(ge)-.4 G(r).1 E F0 +(attrib)2.861 E .361(ute has been set,)-.2 F F1(value)2.861 E F0 .361 +(is e)2.861 F -.25(va)-.25 G .36(luated as an arithmetic e).25 F .36 +(xpression and added to the)-.15 F -.25(va)108 220.8 S(riable').25 E +2.888(sc)-.55 G .388(urrent v)-2.888 F .388(alue, which is also e)-.25 F -.25(va)-.25 G 2.889(luated. When).25 F .389 -(+= is applied to an array v)2.889 F .388(ariable using compound)-.25 F -.185(assignment \(see)108 220.8 R F2(Arrays)2.685 E F0(belo)2.685 E .185 +(+= is applied to an array v)2.889 F .389(ariable using compound)-.25 F +.186(assignment \(see)108 232.8 R F3(Arrays)2.686 E F0(belo)2.686 E .186 (w\), the v)-.25 F(ariable')-.25 E 2.685(sv)-.55 G .185 -(alue is not unset \(as it is when using =\), and ne)-2.935 F 2.686(wv) --.25 G .186(alues are)-2.936 F 1.385(appended to the array be)108 232.8 -R 1.384(ginning at one greater than the array')-.15 F 3.884(sm)-.55 G -1.384(aximum inde)-3.884 F 3.884(x\()-.15 G 1.384(for inde)-3.884 F -.15 -(xe)-.15 G 3.884(da).15 G 1.384(rrays\) or)-3.884 F .122 -(added as additional k)108 244.8 R -.15(ey)-.1 G.15 E .122 +(alue is not unset \(as it is when using =\), and ne)-2.935 F 2.685(wv) +-.25 G .185(alues are)-2.935 F 1.384(appended to the array be)108 244.8 +R 1.384(ginning at one greater than the array')-.15 F 3.885(sm)-.55 G +1.385(aximum inde)-3.885 F 3.885(x\()-.15 G 1.385(for inde)-3.885 F -.15 +(xe)-.15 G 3.885(da).15 G 1.385(rrays\) or)-3.885 F .123 +(added as additional k)108 256.8 R -.15(ey)-.1 G.15 E .123 (alue pairs in an associati)-.25 F .423 -.15(ve a)-.25 H(rray).15 E -5.123(.W)-.65 G .123(hen applied to a string-v)-5.123 F .123(alued v) --.25 F(ariable,)-.25 E F3(value)2.623 E F0(is e)108 256.8 Q +5.123(.W)-.65 G .122(hen applied to a string-v)-5.123 F .122(alued v) +-.25 F(ariable,)-.25 E F1(value)2.622 E F0(is e)108 268.8 Q (xpanded and appended to the v)-.15 E(ariable')-.25 E 2.5(sv)-.55 G -(alue.)-2.75 E 3.383(Av)108 273.6 S .883(ariable can be assigned the) --3.633 F F3(namer)3.382 E(ef)-.37 E F0(attrib)3.382 E .882 -(ute using the)-.2 F F23.382 E F0 .882(option to the)3.382 F F2 -(declar)3.382 E(e)-.18 E F0(or)3.382 E F2(local)3.382 E F0 -.2(bu)3.382 -G .882(iltin com-).2 F .315(mands \(see the descriptions of)108 285.6 R -F2(declar)2.815 E(e)-.18 E F0(and)2.815 E F2(local)2.815 E F0(belo)2.815 -E .316(w\) to create a)-.25 F F3(namer)2.816 E(ef)-.37 E F0 2.816(,o)C -2.816(rar)-2.816 G .316(eference to another v)-2.816 F(ari-)-.25 E 3.335 -(able. This)108 297.6 R(allo)3.335 E .835(ws v)-.25 F .835 +(alue.)-2.75 E 3.382(Av)108 285.6 S .882(ariable can be assigned the) +-3.632 F F1(namer)3.382 E(ef)-.37 E F0(attrib)3.382 E .882 +(ute using the)-.2 F F33.382 E F0 .882(option to the)3.382 F F3 +(declar)3.382 E(e)-.18 E F0(or)3.383 E F3(local)3.383 E F0 -.2(bu)3.383 +G .883(iltin com-).2 F .316(mands \(see the descriptions of)108 297.6 R +F3(declar)2.816 E(e)-.18 E F0(and)2.816 E F3(local)2.816 E F0(belo)2.816 +E .316(w\) to create a)-.25 F F1(namer)2.815 E(ef)-.37 E F0 2.815(,o)C +2.815(rar)-2.815 G .315(eference to another v)-2.815 F(ari-)-.25 E 3.335 +(able. This)108 309.6 R(allo)3.335 E .835(ws v)-.25 F .835 (ariables to be manipulated indirectly)-.25 F 5.835(.W)-.65 G(hene) -5.835 E -.15(ve)-.25 G 3.335(rt).15 G .835(he nameref v)-3.335 F .835 (ariable is referenced or)-.25 F .021 -(assigned to, the operation is actually performed on the v)108 309.6 R -.021(ariable speci\214ed by the nameref v)-.25 F(ariable')-.25 E 2.522 -(sv)-.55 G 2.522(alue. A)-2.772 F .819 +(assigned to, the operation is actually performed on the v)108 321.6 R +.021(ariable speci\214ed by the nameref v)-.25 F(ariable')-.25 E 2.521 +(sv)-.55 G 2.521(alue. A)-2.771 F .818 (nameref is commonly used within shell functions to refer to a v)108 -321.6 R .818(ariable whose name is passed as an ar)-.25 F(gu-)-.18 E -.131(ment to the function.)108 333.6 R -.15(Fo)5.131 G 2.631(ri).15 G -.131(nstance, if a v)-2.631 F .132 +333.6 R .819(ariable whose name is passed as an ar)-.25 F(gu-)-.18 E +.132(ment to the function.)108 345.6 R -.15(Fo)5.132 G 2.632(ri).15 G +.132(nstance, if a v)-2.632 F .131 (ariable name is passed to a shell function as its \214rst ar)-.25 F -.132(gument, run-)-.18 F(ning)108 345.6 Q/F4 10/Courier@0 SF -(declare -n ref=$1)144 363.6 Q F0 .303 -(inside the function creates a nameref v)108 381.6 R(ariable)-.25 E F2 +.131(gument, run-)-.18 F(ning)108 357.6 Q/F4 10/Courier@0 SF +(declare -n ref=$1)144 375.6 Q F0 .302 +(inside the function creates a nameref v)108 393.6 R(ariable)-.25 E F3 -.18(re)2.803 G(f).18 E F0 .303(whose v)2.803 F .303(alue is the v)-.25 -F .302(ariable name passed as the \214rst ar)-.25 F(gu-)-.18 E 3.318 -(ment. References)108 393.6 R .818(and assignments to)3.318 F F2 -.18 +F .303(ariable name passed as the \214rst ar)-.25 F(gu-)-.18 E 3.318 +(ment. References)108 405.6 R .818(and assignments to)3.318 F F3 -.18 (re)3.318 G(f).18 E F0 .818 (are treated as references and assignments to the v)3.318 F .818 -(ariable whose)-.25 F .275(name w)108 405.6 R .275(as passed as)-.1 F F2 -($1)2.775 E F0 5.275(.I)C 2.775(ft)-5.275 G .275(he control v)-2.775 F -.275(ariable in a)-.25 F F2 -.25(fo)2.775 G(r).25 E F0 .275 -(loop has the nameref attrib)2.775 F .274(ute, the list of w)-.2 F .274 -(ords can)-.1 F .354(be a list of shell v)108 417.6 R .354 +(ariable whose)-.25 F .274(name w)108 417.6 R .274(as passed as)-.1 F F3 +($1)2.774 E F0 5.274(.I)C 2.775(ft)-5.274 G .275(he control v)-2.775 F +.275(ariable in a)-.25 F F3 -.25(fo)2.775 G(r).25 E F0 .275 +(loop has the nameref attrib)2.775 F .275(ute, the list of w)-.2 F .275 +(ords can)-.1 F .355(be a list of shell v)108 429.6 R .354 (ariables, and a name reference will be established for each w)-.25 F -.355(ord in the list, in turn, when)-.1 F .086(the loop is e)108 429.6 R --.15(xe)-.15 G 2.586(cuted. Array).15 F -.25(va)2.586 G .086 -(riables cannot be gi).25 F -.15(ve)-.25 G 2.586(nt).15 G(he)-2.586 E F2 -2.586 E F0(attrib)2.585 E 2.585(ute. Ho)-.2 F(we)-.25 E -.15(ve) --.25 G .885 -.4(r, n).15 H .085(ameref v).4 F .085(ariables can ref-) --.25 F .883(erence array v)108 441.6 R .883 +.354(ord in the list, in turn, when)-.1 F .085(the loop is e)108 441.6 R +-.15(xe)-.15 G 2.585(cuted. Array).15 F -.25(va)2.585 G .086 +(riables cannot be gi).25 F -.15(ve)-.25 G 2.586(nt).15 G(he)-2.586 E F3 +2.586 E F0(attrib)2.586 E 2.586(ute. Ho)-.2 F(we)-.25 E -.15(ve) +-.25 G .886 -.4(r, n).15 H .086(ameref v).4 F .086(ariables can ref-) +-.25 F .884(erence array v)108 453.6 R .883 (ariables and subscripted array v)-.25 F 3.383(ariables. Namerefs)-.25 F -.883(can be unset using the)3.383 F F23.383 E F0 .884 -(option to the)3.383 F F2(unset)108 453.6 Q F0 -.2(bu)2.558 G 2.558 -(iltin. Otherwise,).2 F(if)2.558 E F2(unset)2.558 E F0 .058(is e)2.558 F --.15(xe)-.15 G .058(cuted with the name of a nameref v).15 F .057 -(ariable as an ar)-.25 F .057(gument, the v)-.18 F(ari-)-.25 E -(able referenced by the nameref v)108 465.6 Q(ariable will be unset.) --.25 E F2 -.2(Po)87 482.4 S(sitional P).2 E(arameters)-.1 E F0(A)108 -494.4 Q F3 .705(positional par)4.455 F(ameter)-.15 E F0 .706(is a param\ -eter denoted by one or more digits, other than the single digit 0.)3.935 -F(Posi-)5.706 E .445(tional parameters are assigned from the shell')108 -506.4 R 2.944(sa)-.55 G -.18(rg)-2.944 G .444(uments when it is in).18 F --.2(vo)-.4 G -.1(ke).2 G .444(d, and may be reassigned using).1 F(the) -108 518.4 Q F2(set)3.333 E F0 -.2(bu)3.333 G .833(iltin command.).2 F -.834(Positional parameters may not be assigned to with assignment state\ -ments.)5.833 F(The)5.834 E .334(positional parameters are temporarily r\ -eplaced when a shell function is e)108 530.4 R -.15(xe)-.15 G .333 -(cuted \(see).15 F F1(FUNCTIONS)2.833 E F0(belo)2.583 E(w\).)-.25 E -1.403(When a positional parameter consisting of more than a single digi\ -t is e)108 547.2 R 1.404(xpanded, it must be enclosed in)-.15 F -(braces \(see)108 559.2 Q F1(EXP)2.5 E(ANSION)-.666 E F0(belo)2.25 E -(w\).)-.25 E F2(Special P)87 576 Q(arameters)-.1 E F0 1.675 -(The shell treats se)108 588 R -.15(ve)-.25 G 1.675 -(ral parameters specially).15 F 6.675(.T)-.65 G 1.674 +.883(can be unset using the)3.383 F F33.383 E F0 .883 +(option to the)3.383 F F3(unset)108 465.6 Q F0 -.2(bu)2.557 G 2.557 +(iltin. Otherwise,).2 F(if)2.557 E F3(unset)2.557 E F0 .058(is e)2.558 F +-.15(xe)-.15 G .058(cuted with the name of a nameref v).15 F .058 +(ariable as an ar)-.25 F .058(gument, the v)-.18 F(ari-)-.25 E +(able referenced by the nameref v)108 477.6 Q(ariable will be unset.) +-.25 E F3 -.2(Po)87 494.4 S(sitional P).2 E(arameters)-.1 E F0(A)108 +506.4 Q F1 .706(positional par)4.456 F(ameter)-.15 E F0 .706(is a param\ +eter denoted by one or more digits, other than the single digit 0.)3.936 +F(Posi-)5.705 E .444(tional parameters are assigned from the shell')108 +518.4 R 2.944(sa)-.55 G -.18(rg)-2.944 G .444(uments when it is in).18 F +-.2(vo)-.4 G -.1(ke).2 G .445(d, and may be reassigned using).1 F(the) +108 530.4 Q F3(set)3.334 E F0 -.2(bu)3.334 G .834(iltin command.).2 F +.833(Positional parameters may not be assigned to with assignment state\ +ments.)5.834 F(The)5.833 E .334(positional parameters are temporarily r\ +eplaced when a shell function is e)108 542.4 R -.15(xe)-.15 G .334 +(cuted \(see).15 F F2(FUNCTIONS)2.834 E F0(belo)2.584 E(w\).)-.25 E +1.404(When a positional parameter consisting of more than a single digi\ +t is e)108 559.2 R 1.403(xpanded, it must be enclosed in)-.15 F +(braces \(see)108 571.2 Q F2(EXP)2.5 E(ANSION)-.666 E F0(belo)2.25 E +(w\).)-.25 E F3(Special P)87 588 Q(arameters)-.1 E F0 1.674 +(The shell treats se)108 600 R -.15(ve)-.25 G 1.674 +(ral parameters specially).15 F 6.675(.T)-.65 G 1.675 (hese parameters may only be referenced; assignment to)-6.675 F -(them is not allo)108 600 Q(wed.)-.25 E F2(*)108 612 Q F0 .605 -(Expands to the positional parameters, starting from one.)31 F .606 -(When the e)5.605 F .606(xpansion occurs within dou-)-.15 F .084 -(ble quotes, it e)144 624 R .084(xpands to a single w)-.15 F .084 +(them is not allo)108 612 Q(wed.)-.25 E F3(*)108 624 Q F0 .606 +(Expands to the positional parameters, starting from one.)31 F .605 +(When the e)5.605 F .605(xpansion occurs within dou-)-.15 F .083 +(ble quotes, it e)144 636 R .084(xpands to a single w)-.15 F .084 (ord with the v)-.1 F .084 (alue of each parameter separated by the \214rst char)-.25 F(-)-.2 E -.003(acter of the)144 636 R F1(IFS)2.503 E F0 .003(special v)2.253 F -2.503(ariable. That)-.25 F .003(is, ")2.503 F F2($*)A F0 2.503("i)C -2.503(se)-2.503 G(qui)-2.503 E -.25(va)-.25 G .003(lent to ").25 F F2 -($1)A F3(c)A F2($2)A F3(c)A F2(...)A F0 .003(", where)B F3(c)2.703 E F0 -.004(is the \214rst char)2.813 F(-)-.2 E .769(acter of the v)144 648 R -.769(alue of the)-.25 F F1(IFS)3.269 E F0 -.25(va)3.019 G 3.269 -(riable. If).25 F F1(IFS)3.268 E F0 .768 -(is unset, the parameters are separated by spaces.)3.018 F(If)5.768 E F1 -(IFS)144 660 Q F0(is null, the parameters are joined without interv)2.25 -E(ening separators.)-.15 E F2(@)108 672 Q F0 .605 -(Expands to the positional parameters, starting from one.)26.7 F .606 -(When the e)5.605 F .606(xpansion occurs within dou-)-.15 F .114 -(ble quotes, each parameter e)144 684 R .114(xpands to a separate w)-.15 -F 2.614(ord. That)-.1 F .113(is, ")2.613 F F2($@)A F0 2.613("i)C 2.613 -(se)-2.613 G(qui)-2.613 E -.25(va)-.25 G .113(lent to ").25 F F2($1)A F0 -2.613("")C F2($2)-2.613 E F0 2.613(".)C(..)-2.613 E .134 -(If the double-quoted e)144 696 R .134(xpansion occurs within a w)-.15 F -.135(ord, the e)-.1 F .135(xpansion of the \214rst parameter is joined) --.15 F .151(with the be)144 708 R .151(ginning part of the original w) --.15 F .151(ord, and the e)-.1 F .15 -(xpansion of the last parameter is joined with)-.15 F .337 -(the last part of the original w)144 720 R 2.837(ord. When)-.1 F .338 -(there are no positional parameters, ")2.837 F F2($@)A F0 2.838("a)C(nd) --2.838 E F2($@)2.838 E F0 -.15(ex)2.838 G(pand).15 E(GNU Bash 4.2)72 768 -Q(2012 July 14)149.005 E(9)203.165 E 0 Cg EP +.004(acter of the)144 648 R F2(IFS)2.503 E F0 .003(special v)2.253 F +2.503(ariable. That)-.25 F .003(is, ")2.503 F F3($*)A F0 2.503("i)C +2.503(se)-2.503 G(qui)-2.503 E -.25(va)-.25 G .003(lent to ").25 F F3 +($1)A F1(c)A F3($2)A F1(c)A F3(...)A F0 .003(", where)B F1(c)2.703 E F0 +.003(is the \214rst char)2.813 F(-)-.2 E .768(acter of the v)144 660 R +.768(alue of the)-.25 F F2(IFS)3.268 E F0 -.25(va)3.018 G 3.268 +(riable. If).25 F F2(IFS)3.268 E F0 .769 +(is unset, the parameters are separated by spaces.)3.018 F(If)5.769 E F2 +(IFS)144 672 Q F0(is null, the parameters are joined without interv)2.25 +E(ening separators.)-.15 E F3(@)108 684 Q F0 .606 +(Expands to the positional parameters, starting from one.)26.7 F .605 +(When the e)5.605 F .605(xpansion occurs within dou-)-.15 F .113 +(ble quotes, each parameter e)144 696 R .113(xpands to a separate w)-.15 +F 2.614(ord. That)-.1 F .114(is, ")2.614 F F3($@)A F0 2.614("i)C 2.614 +(se)-2.614 G(qui)-2.614 E -.25(va)-.25 G .114(lent to ").25 F F3($1)A F0 +2.614("")C F3($2)-2.614 E F0 2.614(".)C(..)-2.614 E .135 +(If the double-quoted e)144 708 R .135(xpansion occurs within a w)-.15 F +.135(ord, the e)-.1 F .134(xpansion of the \214rst parameter is joined) +-.15 F .15(with the be)144 720 R .15(ginning part of the original w)-.15 +F .151(ord, and the e)-.1 F .151 +(xpansion of the last parameter is joined with)-.15 F(GNU Bash 4.2)72 +768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(9)190.545 E 0 Cg EP %%Page: 10 10 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E(to nothing \(i.e., the)144 84 Q 2.5(ya)-.15 G(re remo)-2.5 E -.15 -(ve)-.15 G(d\).).15 E/F1 10/Times-Bold@0 SF(#)108 96 Q F0 +-.35 E .338(the last part of the original w)144 84 R 2.838(ord. When)-.1 +F .337(there are no positional parameters, ")2.838 F/F1 10/Times-Bold@0 +SF($@)A F0 2.837("a)C(nd)-2.837 E F1($@)2.837 E F0 -.15(ex)2.837 G(pand) +.15 E(to nothing \(i.e., the)144 96 Q 2.5(ya)-.15 G(re remo)-2.5 E -.15 +(ve)-.15 G(d\).).15 E F1(#)108 108 Q F0 (Expands to the number of positional parameters in decimal.)31 E F1(?) -108 108 Q F0(Expands to the e)31 E(xit status of the most recently e) +108 120 Q F0(Expands to the e)31 E(xit status of the most recently e) -.15 E -.15(xe)-.15 G(cuted fore).15 E(ground pipeline.)-.15 E F1108 -120 Q F0 .882 +132 Q F0 .881 (Expands to the current option \215ags as speci\214ed upon in)30.3 F -.2 -(vo)-.4 G .881(cation, by the).2 F F1(set)3.381 E F0 -.2(bu)3.381 G .881 +(vo)-.4 G .881(cation, by the).2 F F1(set)3.382 E F0 -.2(bu)3.382 G .882 (iltin command, or).2 F(those set by the shell itself \(such as the)144 -132 Q F12.5 E F0(option\).)2.5 E F1($)108 144 Q F0 .214 +144 Q F12.5 E F0(option\).)2.5 E F1($)108 156 Q F0 .214 (Expands to the process ID of the shell.)31 F .214 (In a \(\) subshell, it e)5.214 F .214 (xpands to the process ID of the current)-.15 F -(shell, not the subshell.)144 156 Q F1(!)108 168 Q F0 +(shell, not the subshell.)144 168 Q F1(!)108 180 Q F0 (Expands to the process ID of the most recently e)32.67 E -.15(xe)-.15 G -(cuted background \(asynchronous\) command.).15 E F1(0)108 180 Q F0 -1.692(Expands to the name of the shell or shell script.)31 F 1.691 -(This is set at shell initialization.)6.692 F(If)6.691 E F1(bash)4.191 E -F0(is)4.191 E(in)144 192 Q -.2(vo)-.4 G -.1(ke).2 G 3.077(dw).1 G .577 -(ith a \214le of commands,)-3.077 F F1($0)3.077 E F0 .578 -(is set to the name of that \214le.)3.077 F(If)5.578 E F1(bash)3.078 E -F0 .578(is started with the)3.078 F F13.078 E F0 .369 -(option, then)144 204 R F1($0)2.869 E F0 .369(is set to the \214rst ar) +(cuted background \(asynchronous\) command.).15 E F1(0)108 192 Q F0 +1.691(Expands to the name of the shell or shell script.)31 F 1.692 +(This is set at shell initialization.)6.692 F(If)6.692 E F1(bash)4.192 E +F0(is)4.192 E(in)144 204 Q -.2(vo)-.4 G -.1(ke).2 G 3.078(dw).1 G .578 +(ith a \214le of commands,)-3.078 F F1($0)3.078 E F0 .578 +(is set to the name of that \214le.)3.078 F(If)5.577 E F1(bash)3.077 E +F0 .577(is started with the)3.077 F F13.077 E F0 .368 +(option, then)144 216 R F1($0)2.869 E F0 .369(is set to the \214rst ar) 2.869 F .369(gument after the string to be e)-.18 F -.15(xe)-.15 G .369 -(cuted, if one is present.).15 F(Other)5.368 E(-)-.2 E -(wise, it is set to the \214lename used to in)144 216 Q -.2(vo)-.4 G -.1 +(cuted, if one is present.).15 F(Other)5.369 E(-)-.2 E +(wise, it is set to the \214lename used to in)144 228 Q -.2(vo)-.4 G -.1 (ke).2 G F1(bash)2.6 E F0 2.5(,a)C 2.5(sg)-2.5 G -2.15 -.25(iv e)-2.5 H -2.5(nb).25 G 2.5(ya)-2.5 G -.18(rg)-2.5 G(ument zero.).18 E F1(_)108 228 -Q F0 .054(At shell startup, set to the absolute pathname used to in)31 F --.2(vo)-.4 G .255 -.1(ke t).2 H .055(he shell or shell script being e).1 -F -.15(xe)-.15 G(cuted).15 E .692(as passed in the en)144 240 R .692 +2.5(nb).25 G 2.5(ya)-2.5 G -.18(rg)-2.5 G(ument zero.).18 E F1(_)108 240 +Q F0 .055(At shell startup, set to the absolute pathname used to in)31 F +-.2(vo)-.4 G .255 -.1(ke t).2 H .054(he shell or shell script being e).1 +F -.15(xe)-.15 G(cuted).15 E .691(as passed in the en)144 252 R .691 (vironment or ar)-.4 F .691(gument list.)-.18 F(Subsequently)5.691 E -3.191(,e)-.65 G .691(xpands to the last ar)-3.341 F .691(gument to the) --.18 F(pre)144 252 Q .57(vious command, after e)-.25 F 3.07 +3.191(,e)-.65 G .692(xpands to the last ar)-3.341 F .692(gument to the) +-.18 F(pre)144 264 Q .571(vious command, after e)-.25 F 3.071 (xpansion. Also)-.15 F .571(set to the full pathname used to in)3.071 F --.2(vo)-.4 G .771 -.1(ke e).2 H .571(ach command).1 F -.15(exe)144 264 S +-.2(vo)-.4 G .77 -.1(ke e).2 H .57(ach command).1 F -.15(exe)144 276 S 1.6(cuted and placed in the en).15 F 1.6(vironment e)-.4 F 1.6 (xported to that command.)-.15 F 1.6(When checking mail, this)6.6 F (parameter holds the name of the mail \214le currently being check)144 -276 Q(ed.)-.1 E F1(Shell V)87 292.8 Q(ariables)-.92 E F0(The follo)108 -304.8 Q(wing v)-.25 E(ariables are set by the shell:)-.25 E F1 -.3(BA) -108 321.6 S(SH).3 E F0(Expands to the full \214lename used to in)9.07 E +288 Q(ed.)-.1 E F1(Shell V)87 304.8 Q(ariables)-.92 E F0(The follo)108 +316.8 Q(wing v)-.25 E(ariables are set by the shell:)-.25 E F1 -.3(BA) +108 333.6 S(SH).3 E F0(Expands to the full \214lename used to in)9.07 E -.2(vo)-.4 G .2 -.1(ke t).2 H(his instance of).1 E F1(bash)2.5 E F0(.)A -F1 -.3(BA)108 333.6 S(SHOPTS).3 E F0 2.548(Ac)144 345.6 S .049 -(olon-separated list of enabled shell options.)-2.548 F .049(Each w) +F1 -.3(BA)108 345.6 S(SHOPTS).3 E F0 2.549(Ac)144 357.6 S .049 +(olon-separated list of enabled shell options.)-2.549 F .049(Each w) 5.049 F .049(ord in the list is a v)-.1 F .049(alid ar)-.25 F .049 -(gument for the)-.18 F F12.549 E F0 1.398(option to the)144 357.6 +(gument for the)-.18 F F12.548 E F0 1.398(option to the)144 369.6 R F1(shopt)3.898 E F0 -.2(bu)3.898 G 1.398(iltin command \(see).2 F/F2 9 /Times-Bold@0 SF 1.398(SHELL B)3.898 F(UIL)-.09 E 1.398(TIN COMMANDS) --.828 F F0(belo)3.648 E 3.898(w\). The)-.25 F(options)3.898 E .476 -(appearing in)144 369.6 R F2 -.27(BA)2.976 G(SHOPTS).27 E F0 .476 -(are those reported as)2.726 F/F3 10/Times-Italic@0 SF(on)3.206 E F0(by) -3.217 E F1(shopt)2.977 E F0 5.477(.I)C 2.977(ft)-5.477 G .477(his v) --2.977 F .477(ariable is in the en)-.25 F(vironment)-.4 E(when)144 381.6 -Q F1(bash)3.142 E F0 .642(starts up, each shell option in the list will\ - be enabled before reading an)3.142 F 3.141(ys)-.15 G .641 -(tartup \214les.)-3.141 F(This v)144 393.6 Q(ariable is read-only)-.25 E -(.)-.65 E F1 -.3(BA)108 405.6 S(SHPID).3 E F0 .187 -(Expands to the process ID of the current)144 417.6 R F1(bash)2.687 E F0 -2.688(process. This)2.688 F(dif)2.688 E .188(fers from)-.25 F F1($$) -2.688 E F0 .188(under certain circum-)2.688 F -(stances, such as subshells that do not require)144 429.6 Q F1(bash)2.5 -E F0(to be re-initialized.)2.5 E F1 -.3(BA)108 441.6 S(SH_ALIASES).3 E -F0 1.195(An associati)144 453.6 R 1.495 -.15(ve a)-.25 H 1.195(rray v) +-.828 F F0(belo)3.648 E 3.898(w\). The)-.25 F(options)3.898 E .477 +(appearing in)144 381.6 R F2 -.27(BA)2.977 G(SHOPTS).27 E F0 .477 +(are those reported as)2.727 F/F3 10/Times-Italic@0 SF(on)3.207 E F0(by) +3.217 E F1(shopt)2.977 E F0 5.476(.I)C 2.976(ft)-5.476 G .476(his v) +-2.976 F .476(ariable is in the en)-.25 F(vironment)-.4 E(when)144 393.6 +Q F1(bash)3.141 E F0 .642(starts up, each shell option in the list will\ + be enabled before reading an)3.141 F 3.142(ys)-.15 G .642 +(tartup \214les.)-3.142 F(This v)144 405.6 Q(ariable is read-only)-.25 E +(.)-.65 E F1 -.3(BA)108 417.6 S(SHPID).3 E F0 .188 +(Expands to the process ID of the current)144 429.6 R F1(bash)2.688 E F0 +2.687(process. This)2.687 F(dif)2.687 E .187(fers from)-.25 F F1($$) +2.687 E F0 .187(under certain circum-)2.687 F +(stances, such as subshells that do not require)144 441.6 Q F1(bash)2.5 +E F0(to be re-initialized.)2.5 E F1 -.3(BA)108 453.6 S(SH_ALIASES).3 E +F0 1.195(An associati)144 465.6 R 1.495 -.15(ve a)-.25 H 1.195(rray v) .15 F 1.195(ariable whose members correspond to the internal list of al\ -iases as main-)-.25 F .024(tained by the)144 465.6 R F1(alias)2.524 E F0 +iases as main-)-.25 F .025(tained by the)144 477.6 R F1(alias)2.524 E F0 -.2(bu)2.524 G 2.524(iltin. Elements).2 F .024 (added to this array appear in the alias list; unsetting array ele-) -2.524 F(ments cause aliases to be remo)144 477.6 Q -.15(ve)-.15 G 2.5 -(df).15 G(rom the alias list.)-2.5 E F1 -.3(BA)108 489.6 S(SH_ARGC).3 E -F0 .935(An array v)144 501.6 R .935(ariable whose v)-.25 F .934 +2.524 F(ments cause aliases to be remo)144 489.6 Q -.15(ve)-.15 G 2.5 +(df).15 G(rom the alias list.)-2.5 E F1 -.3(BA)108 501.6 S(SH_ARGC).3 E +F0 .934(An array v)144 513.6 R .934(ariable whose v)-.25 F .934 (alues are the number of parameters in each frame of the current)-.25 F -F1(bash)3.434 E F0 -.15(exe)144 513.6 S .535(cution call stack.).15 F +F1(bash)3.435 E F0 -.15(exe)144 525.6 S .535(cution call stack.).15 F .535(The number of parameters to the current subroutine \(shell functio\ -n or script)5.535 F -.15(exe)144 525.6 S .142(cuted with).15 F F1(.) -2.642 E F0(or)2.642 E F1(sour)2.642 E(ce)-.18 E F0 2.642(\)i)C 2.642(sa) --2.642 G 2.642(tt)-2.642 G .142(he top of the stack.)-2.642 F .141 -(When a subroutine is e)5.141 F -.15(xe)-.15 G .141 -(cuted, the number of).15 F 2.63(parameters passed is pushed onto)144 -537.6 R F2 -.27(BA)5.13 G(SH_ARGC).27 E/F4 9/Times-Roman@0 SF(.)A F0 -2.63(The shell sets)7.13 F F2 -.27(BA)5.131 G(SH_ARGC).27 E F0 2.631 -(only when in)4.881 F -.15(ex)144 549.6 S(tended deb).15 E +n or script)5.535 F -.15(exe)144 537.6 S .141(cuted with).15 F F1(.) +2.641 E F0(or)2.641 E F1(sour)2.641 E(ce)-.18 E F0 2.641(\)i)C 2.641(sa) +-2.641 G 2.641(tt)-2.641 G .142(he top of the stack.)-2.641 F .142 +(When a subroutine is e)5.142 F -.15(xe)-.15 G .142 +(cuted, the number of).15 F 2.631(parameters passed is pushed onto)144 +549.6 R F2 -.27(BA)5.13 G(SH_ARGC).27 E/F4 9/Times-Roman@0 SF(.)A F0 +2.63(The shell sets)7.13 F F2 -.27(BA)5.13 G(SH_ARGC).27 E F0 2.63 +(only when in)4.88 F -.15(ex)144 561.6 S(tended deb).15 E (ugging mode \(see the description of the)-.2 E F1(extdeb)2.5 E(ug)-.2 E F0(option to the)2.5 E F1(shopt)2.5 E F0 -.2(bu)2.5 G(iltin belo).2 E -(w\))-.25 E F1 -.3(BA)108 561.6 S(SH_ARGV).3 E F0 .98(An array v)144 -573.6 R .979(ariable containing all of the parameters in the current) --.25 F F1(bash)3.479 E F0 -.15(exe)3.479 G .979(cution call stack.).15 F -(The)5.979 E .275(\214nal parameter of the last subroutine call is at t\ -he top of the stack; the \214rst parameter of the initial)144 585.6 R -1.424(call is at the bottom.)144 597.6 R 1.424(When a subroutine is e) +(w\))-.25 E F1 -.3(BA)108 573.6 S(SH_ARGV).3 E F0 .979(An array v)144 +585.6 R .979(ariable containing all of the parameters in the current) +-.25 F F1(bash)3.48 E F0 -.15(exe)3.48 G .98(cution call stack.).15 F +(The)5.98 E .275(\214nal parameter of the last subroutine call is at th\ +e top of the stack; the \214rst parameter of the initial)144 597.6 R +1.424(call is at the bottom.)144 609.6 R 1.424(When a subroutine is e) 6.424 F -.15(xe)-.15 G 1.424 (cuted, the parameters supplied are pushed onto).15 F F2 -.27(BA)144 -609.6 S(SH_ARGV).27 E F4(.)A F0 2.197(The shell sets)6.697 F F2 -.27(BA) +621.6 S(SH_ARGV).27 E F4(.)A F0 2.197(The shell sets)6.697 F F2 -.27(BA) 4.697 G(SH_ARGV).27 E F0 2.197(only when in e)4.447 F 2.197(xtended deb) --.15 F 2.197(ugging mode \(see the)-.2 F(description of the)144 621.6 Q +-.15 F 2.197(ugging mode \(see the)-.2 F(description of the)144 633.6 Q F1(extdeb)2.5 E(ug)-.2 E F0(option to the)2.5 E F1(shopt)2.5 E F0 -.2 -(bu)2.5 G(iltin belo).2 E(w\))-.25 E F1 -.3(BA)108 633.6 S(SH_CMDS).3 E -F0 .668(An associati)144 645.6 R .968 -.15(ve a)-.25 H .668(rray v).15 F +(bu)2.5 G(iltin belo).2 E(w\))-.25 E F1 -.3(BA)108 645.6 S(SH_CMDS).3 E +F0 .667(An associati)144 657.6 R .967 -.15(ve a)-.25 H .667(rray v).15 F .668(ariable whose members correspond to the internal hash table of com\ -mands)-.25 F .146(as maintained by the)144 657.6 R F1(hash)2.646 E F0 +mands)-.25 F .147(as maintained by the)144 669.6 R F1(hash)2.647 E F0 -.2(bu)2.646 G 2.646(iltin. Elements).2 F .146 (added to this array appear in the hash table; unsetting)2.646 F -(array elements cause commands to be remo)144 669.6 Q -.15(ve)-.15 G 2.5 -(df).15 G(rom the hash table.)-2.5 E F1 -.3(BA)108 681.6 S(SH_COMMAND).3 -E F0 1.243(The command currently being e)144 693.6 R -.15(xe)-.15 G -1.243(cuted or about to be e).15 F -.15(xe)-.15 G 1.242 -(cuted, unless the shell is e).15 F -.15(xe)-.15 G 1.242(cuting a).15 F +(array elements cause commands to be remo)144 681.6 Q -.15(ve)-.15 G 2.5 +(df).15 G(rom the hash table.)-2.5 E F1 -.3(BA)108 693.6 S(SH_COMMAND).3 +E F0 1.242(The command currently being e)144 705.6 R -.15(xe)-.15 G +1.243(cuted or about to be e).15 F -.15(xe)-.15 G 1.243 +(cuted, unless the shell is e).15 F -.15(xe)-.15 G 1.243(cuting a).15 F (command as the result of a trap, in which case it is the command e)144 -705.6 Q -.15(xe)-.15 G(cuting at the time of the trap.).15 E -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(10)198.165 E 0 Cg EP +717.6 Q -.15(xe)-.15 G(cuting at the time of the trap.).15 E +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(10)185.545 E 0 Cg EP %%Page: 11 11 %%BeginPageSetup BP @@ -1487,45 +1497,44 @@ BP -.35 E/F1 10/Times-Bold@0 SF -.3(BA)108 84 S(SH_EXECUTION_STRING).3 E F0 (The command ar)144 96 Q(gument to the)-.18 E F12.5 E F0(in)2.5 E -.2(vo)-.4 G(cation option.).2 E F1 -.3(BA)108 108 S(SH_LINENO).3 E F0 -.692(An array v)144 120 R .692(ariable whose members are the line numbe\ -rs in source \214les where each corresponding)-.25 F .97(member of)144 -132 R/F2 9/Times-Bold@0 SF(FUNCN)3.47 E(AME)-.18 E F0 -.1(wa)3.22 G 3.47 -(si).1 G -1.9 -.4(nv o)-3.47 H -.1(ke).4 G(d.).1 E F1(${B)5.969 E -(ASH_LINENO[)-.3 E/F3 10/Times-Italic@0 SF($i)A F1(]})A F0 .969 -(is the line number in the source)3.469 F 14.671(\214le \()144 144 R F1 -(${B)A(ASH_SOURCE[)-.3 E F3($i+1)A F1(]})A F0 17.171(\)w)C(here)-17.171 +.693(An array v)144 120 R .692(ariable whose members are the line numbe\ +rs in source \214les where each corresponding)-.25 F .969(member of)144 +132 R/F2 9/Times-Bold@0 SF(FUNCN)3.469 E(AME)-.18 E F0 -.1(wa)3.219 G +3.469(si).1 G -1.9 -.4(nv o)-3.469 H -.1(ke).4 G(d.).1 E F1(${B)5.969 E +(ASH_LINENO[)-.3 E/F3 10/Times-Italic@0 SF($i)A F1(]})A F0 .97 +(is the line number in the source)3.469 F 14.672(\214le \()144 144 R F1 +(${B)A(ASH_SOURCE[)-.3 E F3($i+1)A F1(]})A F0 17.172(\)w)C(here)-17.172 E F1(${FUNCN)17.172 E(AME[)-.2 E F3($i)A F1(]})A F0 -.1(wa)17.172 G -17.172(sc).1 G 14.672(alled \(or)-17.172 F F1(${B)144 156 Q(ASH_LINENO[) +17.171(sc).1 G 14.671(alled \(or)-17.171 F F1(${B)144 156 Q(ASH_LINENO[) -.3 E F3($i-1)A F1(]})A F0 .115 (if referenced within another shell function\).)2.615 F(Use)5.115 E F2 (LINENO)2.615 E F0 .115(to obtain the)2.365 F(current line number)144 -168 Q(.)-.55 E F1 -.3(BA)108 180 S(SH_REMA).3 E(TCH)-.95 E F0 .005 -(An array v)144 192 R .005(ariable whose members are assigned by the) --.25 F F1(=~)2.506 E F0 .006(binary operator to the)2.506 F F1([[)2.506 -E F0 .006(conditional com-)2.506 F 2.507(mand. The)144 204 R .007 -(element with inde)2.507 F 2.507(x0i)-.15 G 2.507(st)-2.507 G .007 -(he portion of the string matching the entire re)-2.507 F .006(gular e) --.15 F(xpression.)-.15 E .997(The element with inde)144 216 R(x)-.15 E -F3(n)3.497 E F0 .997(is the portion of the string matching the)3.497 F -F3(n)3.498 E F0 .998(th parenthesized sube)B(xpres-)-.15 E 2.5 +168 Q(.)-.55 E F1 -.3(BA)108 180 S(SH_REMA).3 E(TCH)-.95 E F0 .006 +(An array v)144 192 R .006(ariable whose members are assigned by the) +-.25 F F1(=~)2.506 E F0 .005(binary operator to the)2.506 F F1([[)2.505 +E F0 .005(conditional com-)2.505 F 2.506(mand. The)144 204 R .007 +(element with inde)2.506 F 2.507(x0i)-.15 G 2.507(st)-2.507 G .007 +(he portion of the string matching the entire re)-2.507 F .007(gular e) +-.15 F(xpression.)-.15 E .998(The element with inde)144 216 R(x)-.15 E +F3(n)3.498 E F0 .997(is the portion of the string matching the)3.498 F +F3(n)3.497 E F0 .997(th parenthesized sube)B(xpres-)-.15 E 2.5 (sion. This)144 228 R -.25(va)2.5 G(riable is read-only).25 E(.)-.65 E -F1 -.3(BA)108 240 S(SH_SOURCE).3 E F0 .126(An array v)144 252 R .125(ar\ +F1 -.3(BA)108 240 S(SH_SOURCE).3 E F0 .125(An array v)144 252 R .125(ar\ iable whose members are the source \214lenames where the corresponding \ -shell function)-.25 F .78(names in the)144 264 R F2(FUNCN)3.28 E(AME) +shell function)-.25 F .781(names in the)144 264 R F2(FUNCN)3.28 E(AME) -.18 E F0 .78(array v)3.03 F .78(ariable are de\214ned.)-.25 F .78 -(The shell function)5.78 F F1(${FUNCN)3.281 E(AME[)-.2 E F3($i)A F1(]})A -F0(is)3.281 E(de\214ned in the \214le)144 276 Q F1(${B)2.5 E -(ASH_SOURCE[)-.3 E F3($i)A F1(]})A F0(and called from)2.5 E F1(${B)2.5 E -(ASH_SOURCE[)-.3 E F3($i+1)A F1(]})A F0(.)A F1 -.3(BA)108 288 S -(SH_SUBSHELL).3 E F0 .296 -(Incremented by one within each subshell or subshell en)144 300 R .296 -(vironment when the shell be)-.4 F .296(gins e)-.15 F -.15(xe)-.15 G +(The shell function)5.78 F F1(${FUNCN)3.28 E(AME[)-.2 E F3($i)A F1(]})A +F0(is)3.28 E(de\214ned in the \214le)144 276 Q F1(${B)2.5 E(ASH_SOURCE[) +-.3 E F3($i)A F1(]})A F0(and called from)2.5 E F1(${B)2.5 E(ASH_SOURCE[) +-.3 E F3($i+1)A F1(]})A F0(.)A F1 -.3(BA)108 288 S(SH_SUBSHELL).3 E F0 +.296(Incremented by one within each subshell or subshell en)144 300 R +.296(vironment when the shell be)-.4 F .297(gins e)-.15 F -.15(xe)-.15 G (cuting).15 E(in that en)144 312 Q 2.5(vironment. The)-.4 F(initial v) -2.5 E(alue is 0.)-.25 E F1 -.3(BA)108 324 S(SH_VERSINFO).3 E F0 2.644 -(Ar)144 336 S .144(eadonly array v)-2.644 F .144 +2.5 E(alue is 0.)-.25 E F1 -.3(BA)108 324 S(SH_VERSINFO).3 E F0 2.645 +(Ar)144 336 S .145(eadonly array v)-2.645 F .144 (ariable whose members hold v)-.25 F .144 -(ersion information for this instance of)-.15 F F1(bash)2.645 E F0 5.145 -(.T)C(he)-5.145 E -.25(va)144 348 S +(ersion information for this instance of)-.15 F F1(bash)2.644 E F0 5.144 +(.T)C(he)-5.144 E -.25(va)144 348 S (lues assigned to the array members are as follo).25 E(ws:)-.25 E F1 -.3 (BA)144 366 S(SH_VERSINFO[).3 E F0(0)A F1(])A F0(The major v)24.74 E (ersion number \(the)-.15 E F3 -.37(re)2.5 G(lease).37 E F0(\).)A F1 -.3 @@ -1540,80 +1549,80 @@ F3(beta1)2.5 E F0(\).)A F1 -.3(BA)144 426 S(SH_VERSINFO[).3 E F0(5)A F1 /Times-Roman@0 SF(.)A F1 -.3(BA)108 438 S(SH_VERSION).3 E F0 (Expands to a string describing the v)144 450 Q (ersion of this instance of)-.15 E F1(bash)2.5 E F0(.)A F1(COMP_CW)108 -462 Q(ORD)-.1 E F0 .397(An inde)144 474 R 2.897(xi)-.15 G(nto)-2.897 E +462 Q(ORD)-.1 E F0 .396(An inde)144 474 R 2.896(xi)-.15 G(nto)-2.896 E F1(${COMP_W)2.896 E(ORDS})-.1 E F0 .396(of the w)2.896 F .396 -(ord containing the current cursor position.)-.1 F .396(This v)5.396 F -(ari-)-.25 E 1.18(able is a)144 486 R -.25(va)-.2 G 1.181 +(ord containing the current cursor position.)-.1 F .397(This v)5.397 F +(ari-)-.25 E 1.181(able is a)144 486 R -.25(va)-.2 G 1.181 (ilable only in shell functions in).25 F -.2(vo)-.4 G -.1(ke).2 G 3.681 -(db).1 G 3.681(yt)-3.681 G 1.181(he programmable completion f)-3.681 F -1.181(acilities \(see)-.1 F F1(Pr)144 498 Q(ogrammable Completion)-.18 E +(db).1 G 3.681(yt)-3.681 G 1.18(he programmable completion f)-3.681 F +1.18(acilities \(see)-.1 F F1(Pr)144 498 Q(ogrammable Completion)-.18 E F0(belo)2.5 E(w\).)-.25 E F1(COMP_KEY)108 510 Q F0(The k)144 522 Q .3 -.15(ey \()-.1 H(or \214nal k).15 E .3 -.15(ey o)-.1 H 2.5(fak).15 G .3 -.15(ey s)-2.6 H(equence\) used to in).15 E -.2(vo)-.4 G .2 -.1(ke t).2 -H(he current completion function.).1 E F1(COMP_LINE)108 534 Q F0 1.208 +H(he current completion function.).1 E F1(COMP_LINE)108 534 Q F0 1.207 (The current command line.)144 546 R 1.208(This v)6.208 F 1.208 (ariable is a)-.25 F -.25(va)-.2 G 1.208 -(ilable only in shell functions and e).25 F 1.207(xternal com-)-.15 F -2.848(mands in)144 558 R -.2(vo)-.4 G -.1(ke).2 G 5.349(db).1 G 5.349 +(ilable only in shell functions and e).25 F 1.208(xternal com-)-.15 F +2.849(mands in)144 558 R -.2(vo)-.4 G -.1(ke).2 G 5.349(db).1 G 5.349 (yt)-5.349 G 2.849(he programmable completion f)-5.349 F 2.849 -(acilities \(see)-.1 F F1(Pr)5.349 E 2.849(ogrammable Completion)-.18 F -F0(belo)144 570 Q(w\).)-.25 E F1(COMP_POINT)108 582 Q F0 .667(The inde) -144 594 R 3.167(xo)-.15 G 3.167(ft)-3.167 G .666 -(he current cursor position relati)-3.167 F .966 -.15(ve t)-.25 H 3.166 +(acilities \(see)-.1 F F1(Pr)5.349 E 2.848(ogrammable Completion)-.18 F +F0(belo)144 570 Q(w\).)-.25 E F1(COMP_POINT)108 582 Q F0 .666(The inde) +144 594 R 3.166(xo)-.15 G 3.166(ft)-3.166 G .666 +(he current cursor position relati)-3.166 F .966 -.15(ve t)-.25 H 3.166 (ot).15 G .666(he be)-3.166 F .666(ginning of the current command.)-.15 -F .666(If the)5.666 F .534 +F .667(If the)5.667 F .535 (current cursor position is at the end of the current command, the v)144 -606 R .535(alue of this v)-.25 F .535(ariable is equal to)-.25 F F1 -(${#COMP_LINE})144 618 Q F0 7.006(.T)C 2.006(his v)-7.006 F 2.006 -(ariable is a)-.25 F -.25(va)-.2 G 2.005 -(ilable only in shell functions and e).25 F 2.005(xternal commands)-.15 +606 R .534(alue of this v)-.25 F .534(ariable is equal to)-.25 F F1 +(${#COMP_LINE})144 618 Q F0 7.005(.T)C 2.005(his v)-7.005 F 2.005 +(ariable is a)-.25 F -.25(va)-.2 G 2.006 +(ilable only in shell functions and e).25 F 2.006(xternal commands)-.15 F(in)144 630 Q -.2(vo)-.4 G -.1(ke).2 G 2.5(db).1 G 2.5(yt)-2.5 G (he programmable completion f)-2.5 E(acilities \(see)-.1 E F1(Pr)2.5 E (ogrammable Completion)-.18 E F0(belo)2.5 E(w\).)-.25 E F1(COMP_TYPE)108 -642 Q F0 .041(Set to an inte)144 654 R .041(ger v)-.15 F .041(alue corr\ +642 Q F0 .042(Set to an inte)144 654 R .042(ger v)-.15 F .041(alue corr\ esponding to the type of completion attempted that caused a completion) --.25 F .338(function to be called:)144 666 R F3 -.5(TA)2.837 G(B).5 E F0 +-.25 F .337(function to be called:)144 666 R F3 -.5(TA)2.837 G(B).5 E F0 2.837(,f)C .337(or normal completion,)-2.837 F F3(?)2.837 E F0 2.837(,f) -C .337(or listing completions after successi)-2.837 F .637 -.15(ve t) --.25 H(abs,).15 E F3(!)144 678 Q F0 4.091(,f)C 1.591 -(or listing alternati)-4.091 F -.15(ve)-.25 G 4.092(so).15 G 4.092(np) +C .337(or listing completions after successi)-2.837 F .638 -.15(ve t) +-.25 H(abs,).15 E F3(!)144 678 Q F0 4.092(,f)C 1.592 +(or listing alternati)-4.092 F -.15(ve)-.25 G 4.092(so).15 G 4.092(np) -4.092 G 1.592(artial w)-4.092 F 1.592(ord completion,)-.1 F F3(@)4.092 E F0 4.092(,t)C 4.092(ol)-4.092 G 1.592(ist completions if the w)-4.092 -F 1.592(ord is not)-.1 F 1.553(unmodi\214ed, or)144 690 R F3(%)4.053 E +F 1.591(ord is not)-.1 F 1.552(unmodi\214ed, or)144 690 R F3(%)4.052 E F0 4.052(,f)C 1.552(or menu completion.)-4.052 F 1.552(This v)6.552 F 1.552(ariable is a)-.25 F -.25(va)-.2 G 1.552 -(ilable only in shell functions and).25 F -.15(ex)144 702 S 2.928 +(ilable only in shell functions and).25 F -.15(ex)144 702 S 2.929 (ternal commands in).15 F -.2(vo)-.4 G -.1(ke).2 G 5.429(db).1 G 5.429 (yt)-5.429 G 2.929(he programmable completion f)-5.429 F 2.929 -(acilities \(see)-.1 F F1(Pr)5.429 E(ogrammable)-.18 E(Completion)144 -714 Q F0(belo)2.5 E(w\).)-.25 E(GNU Bash 4.2)72 768 Q(2012 July 14) -149.005 E(11)198.165 E 0 Cg EP +(acilities \(see)-.1 F F1(Pr)5.428 E(ogrammable)-.18 E(Completion)144 +714 Q F0(belo)2.5 E(w\).)-.25 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E +-.15(ve)-.15 G(mber 24).15 E(11)185.545 E 0 Cg EP %%Page: 12 12 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(COMP_W)108 84 Q(ORDBREAKS)-.1 E F0 1.336 +-.35 E/F1 10/Times-Bold@0 SF(COMP_W)108 84 Q(ORDBREAKS)-.1 E F0 1.335 (The set of characters that the)144 96 R F1 -.18(re)3.836 G(adline).18 E -F0 1.336(library treats as w)3.836 F 1.335 -(ord separators when performing w)-.1 F(ord)-.1 E 3.125(completion. If) -144 108 R/F2 9/Times-Bold@0 SF(COMP_W)3.125 E(ORDBREAKS)-.09 E F0 .626 -(is unset, it loses its special properties, e)2.875 F -.15(ve)-.25 G -3.126(ni).15 G 3.126(fi)-3.126 G 3.126(ti)-3.126 G 3.126(ss)-3.126 G -(ubse-)-3.126 E(quently reset.)144 120 Q F1(COMP_W)108 132 Q(ORDS)-.1 E -F0 .654(An array v)144 144 R .654(ariable \(see)-.25 F F1(Arrays)3.154 E -F0(belo)3.154 E .654(w\) consisting of the indi)-.25 F .653(vidual w) --.25 F .653(ords in the current command)-.1 F 4.332(line. The)144 156 R +F0 1.336(library treats as w)3.836 F 1.336 +(ord separators when performing w)-.1 F(ord)-.1 E 3.126(completion. If) +144 108 R/F2 9/Times-Bold@0 SF(COMP_W)3.126 E(ORDBREAKS)-.09 E F0 .626 +(is unset, it loses its special properties, e)2.876 F -.15(ve)-.25 G +3.125(ni).15 G 3.125(fi)-3.125 G 3.125(ti)-3.125 G 3.125(ss)-3.125 G +(ubse-)-3.125 E(quently reset.)144 120 Q F1(COMP_W)108 132 Q(ORDS)-.1 E +F0 .653(An array v)144 144 R .653(ariable \(see)-.25 F F1(Arrays)3.153 E +F0(belo)3.153 E .654(w\) consisting of the indi)-.25 F .654(vidual w) +-.25 F .654(ords in the current command)-.1 F 4.333(line. The)144 156 R 1.832(line is split into w)4.332 F 1.832(ords as)-.1 F F1 -.18(re)4.332 G(adline).18 E F0 -.1(wo)4.332 G 1.832(uld split it, using).1 F F2 -(COMP_W)4.332 E(ORDBREAKS)-.09 E F0(as)4.083 E .832(described abo)144 -168 R -.15(ve)-.15 G 5.832(.T).15 G .832(his v)-5.832 F .832 -(ariable is a)-.25 F -.25(va)-.2 G .831 -(ilable only in shell functions in).25 F -.2(vo)-.4 G -.1(ke).2 G 3.331 -(db).1 G 3.331(yt)-3.331 G .831(he programmable)-3.331 F(completion f) +(COMP_W)4.332 E(ORDBREAKS)-.09 E F0(as)4.082 E .831(described abo)144 +168 R -.15(ve)-.15 G 5.831(.T).15 G .831(his v)-5.831 F .831 +(ariable is a)-.25 F -.25(va)-.2 G .832 +(ilable only in shell functions in).25 F -.2(vo)-.4 G -.1(ke).2 G 3.332 +(db).1 G 3.332(yt)-3.332 G .832(he programmable)-3.332 F(completion f) 144 180 Q(acilities \(see)-.1 E F1(Pr)2.5 E(ogrammable Completion)-.18 E -F0(belo)2.5 E(w\).)-.25 E F1(COPR)108 192 Q(OC)-.3 E F0 .168(An array v) -144 204 R .168(ariable \(see)-.25 F F1(Arrays)2.668 E F0(belo)2.669 E +F0(belo)2.5 E(w\).)-.25 E F1(COPR)108 192 Q(OC)-.3 E F0 .169(An array v) +144 204 R .169(ariable \(see)-.25 F F1(Arrays)2.669 E F0(belo)2.669 E .169 (w\) created to hold the \214le descriptors for output from and input) -.25 F(to an unnamed coprocess \(see)144 216 Q F1(Copr)2.5 E(ocesses) @@ -1621,109 +1630,109 @@ F0(belo)2.5 E(w\).)-.25 E F1(COPR)108 192 Q(OC)-.3 E F0 .168(An array v) -.9 G(K).55 E F0 2.26(An array v)144 240 R 2.26(ariable \(see)-.25 F F1 (Arrays)4.76 E F0(belo)4.76 E 2.26 (w\) containing the current contents of the directory stack.)-.25 F -1.094(Directories appear in the stack in the order the)144 252 R 3.594 -(ya)-.15 G 1.095(re displayed by the)-3.594 F F1(dirs)3.595 E F0 -.2(bu) -3.595 G 3.595(iltin. Assigning).2 F(to)3.595 E 1.432 +1.095(Directories appear in the stack in the order the)144 252 R 3.594 +(ya)-.15 G 1.094(re displayed by the)-3.594 F F1(dirs)3.594 E F0 -.2(bu) +3.594 G 3.594(iltin. Assigning).2 F(to)3.594 E 1.431 (members of this array v)144 264 R 1.432 (ariable may be used to modify directories already in the stack, b)-.25 -F 1.431(ut the)-.2 F F1(pushd)144 276 Q F0(and)2.746 E F1(popd)2.746 E +F 1.432(ut the)-.2 F F1(pushd)144 276 Q F0(and)2.746 E F1(popd)2.746 E F0 -.2(bu)2.746 G .246(iltins must be used to add and remo).2 F .546 -.15(ve d)-.15 H 2.746(irectories. Assignment).15 F .246(to this v)2.746 -F(ariable)-.25 E .351(will not change the current directory)144 288 R +F(ariable)-.25 E .35(will not change the current directory)144 288 R 5.35(.I)-.65 G(f)-5.35 E F2(DIRST)2.85 E -.495(AC)-.81 G(K).495 E F0 .35 -(is unset, it loses its special properties, e)2.6 F -.15(ve)-.25 G 2.85 -(ni).15 G(f)-2.85 E(it is subsequently reset.)144 300 Q F1(EUID)108 312 -Q F0 1.103(Expands to the ef)11 F(fecti)-.25 E 1.403 -.15(ve u)-.25 H +(is unset, it loses its special properties, e)2.6 F -.15(ve)-.25 G 2.851 +(ni).15 G(f)-2.851 E(it is subsequently reset.)144 300 Q F1(EUID)108 312 +Q F0 1.104(Expands to the ef)11 F(fecti)-.25 E 1.403 -.15(ve u)-.25 H 1.103(ser ID of the current user).15 F 3.603(,i)-.4 G 1.103 -(nitialized at shell startup.)-3.603 F 1.104(This v)6.103 F 1.104 +(nitialized at shell startup.)-3.603 F 1.103(This v)6.103 F 1.103 (ariable is)-.25 F(readonly)144 324 Q(.)-.65 E F1(FUNCN)108 336 Q(AME) --.2 E F0 .479(An array v)144 348 R .479 +-.2 E F0 .478(An array v)144 348 R .479 (ariable containing the names of all shell functions currently in the e) --.25 F -.15(xe)-.15 G .478(cution call stack.).15 F .276 -(The element with inde)144 360 R 2.776(x0i)-.15 G 2.776(st)-2.776 G .276 -(he name of an)-2.776 F 2.777(yc)-.15 G(urrently-e)-2.777 E -.15(xe)-.15 -G .277(cuting shell function.).15 F .277(The bottom-most)5.277 F .385 +-.25 F -.15(xe)-.15 G .479(cution call stack.).15 F .277 +(The element with inde)144 360 R 2.777(x0i)-.15 G 2.777(st)-2.777 G .276 +(he name of an)-2.777 F 2.776(yc)-.15 G(urrently-e)-2.776 E -.15(xe)-.15 +G .276(cuting shell function.).15 F .276(The bottom-most)5.276 F .384 (element \(the one with the highest inde)144 372 R .384(x\) is)-.15 F/F3 -10/Courier@0 SF("main")2.884 E F0 5.384(.T)C .384(his v)-5.384 F .384 -(ariable e)-.25 F .384(xists only when a shell func-)-.15 F .034 -(tion is e)144 384 R -.15(xe)-.15 G 2.534(cuting. Assignments).15 F(to) +10/Courier@0 SF("main")2.884 E F0 5.384(.T)C .384(his v)-5.384 F .385 +(ariable e)-.25 F .385(xists only when a shell func-)-.15 F .035 +(tion is e)144 384 R -.15(xe)-.15 G 2.535(cuting. Assignments).15 F(to) 2.535 E F2(FUNCN)2.535 E(AME)-.18 E F0(ha)2.285 E .335 -.15(ve n)-.2 H 2.535(oe).15 G -.25(ff)-2.535 G .035(ect and return an error status.).25 -F(If)5.035 E F2(FUNC-)2.535 E -.18(NA)144 396 S(ME).18 E F0 +F(If)5.034 E F2(FUNC-)2.534 E -.18(NA)144 396 S(ME).18 E F0 (is unset, it loses its special properties, e)2.25 E -.15(ve)-.25 G 2.5 (ni).15 G 2.5(fi)-2.5 G 2.5(ti)-2.5 G 2.5(ss)-2.5 G(ubsequently reset.) --2.5 E .111(This v)144 414 R .111(ariable can be used with)-.25 F F1 -.3 +-2.5 E .11(This v)144 414 R .111(ariable can be used with)-.25 F F1 -.3 (BA)2.611 G(SH_LINENO).3 E F0(and)2.611 E F1 -.3(BA)2.611 G(SH_SOURCE).3 -E F0 5.111(.E)C .111(ach element of)-5.111 F F1(FUNC-)2.61 E -.2(NA)144 +E F0 5.111(.E)C .111(ach element of)-5.111 F F1(FUNC-)2.611 E -.2(NA)144 426 S(ME).2 E F0 1.404(has corresponding elements in)3.904 F F1 -.3(BA) 3.904 G(SH_LINENO).3 E F0(and)3.904 E F1 -.3(BA)3.904 G(SH_SOURCE).3 E F0 1.404(to describe the)3.904 F .012(call stack.)144 438 R -.15(Fo) 5.012 G 2.512(ri).15 G(nstance,)-2.512 E F1(${FUNCN)2.512 E(AME[)-.2 E /F4 10/Times-Italic@0 SF($i)A F1(]})A F0 -.1(wa)2.512 G 2.512(sc).1 G .012(alled from the \214le)-2.512 F F1(${B)2.512 E(ASH_SOURCE[)-.3 E F4 -($i+1)A F1(]})A F0 1.183(at line number)144 450 R F1(${B)3.683 E -(ASH_LINENO[)-.3 E F4($i)A F1(]})A F0 6.183(.T)C(he)-6.183 E F1(caller) -3.683 E F0 -.2(bu)3.683 G 1.184 +($i+1)A F1(]})A F0 1.184(at line number)144 450 R F1(${B)3.684 E +(ASH_LINENO[)-.3 E F4($i)A F1(]})A F0 6.184(.T)C(he)-6.184 E F1(caller) +3.683 E F0 -.2(bu)3.683 G 1.183 (iltin displays the current call stack using).2 F(this information.)144 -462 Q F1(GR)108 474 Q(OUPS)-.3 E F0 1.229(An array v)144 486 R 1.228(ar\ +462 Q F1(GR)108 474 Q(OUPS)-.3 E F0 1.228(An array v)144 486 R 1.228(ar\ iable containing the list of groups of which the current user is a memb\ -er)-.25 F 6.228(.A)-.55 G(ssign-)-6.228 E .596(ments to)144 498 R F2(GR) -3.096 E(OUPS)-.27 E F0(ha)2.847 E .897 -.15(ve n)-.2 H 3.097(oe).15 G +er)-.25 F 6.229(.A)-.55 G(ssign-)-6.229 E .597(ments to)144 498 R F2(GR) +3.097 E(OUPS)-.27 E F0(ha)2.847 E .897 -.15(ve n)-.2 H 3.097(oe).15 G -.25(ff)-3.097 G .597(ect and return an error status.).25 F(If)5.597 E F2(GR)3.097 E(OUPS)-.27 E F0 .597(is unset, it loses its spe-)2.847 F (cial properties, e)144 510 Q -.15(ve)-.25 G 2.5(ni).15 G 2.5(fi)-2.5 G 2.5(ti)-2.5 G 2.5(ss)-2.5 G(ubsequently reset.)-2.5 E F1(HISTCMD)108 522 -Q F0 .356(The history number)144 534 R 2.856(,o)-.4 G 2.856(ri)-2.856 G -(nde)-2.856 E 2.856(xi)-.15 G 2.856(nt)-2.856 G .356 +Q F0 .355(The history number)144 534 R 2.855(,o)-.4 G 2.855(ri)-2.855 G +(nde)-2.855 E 2.856(xi)-.15 G 2.856(nt)-2.856 G .356 (he history list, of the current command.)-2.856 F(If)5.356 E F2 -(HISTCMD)2.855 E F0 .355(is unset, it)2.605 F +(HISTCMD)2.856 E F0 .356(is unset, it)2.606 F (loses its special properties, e)144 546 Q -.15(ve)-.25 G 2.5(ni).15 G 2.5(fi)-2.5 G 2.5(ti)-2.5 G 2.5(ss)-2.5 G(ubsequently reset.)-2.5 E F1 (HOSTN)108 558 Q(AME)-.2 E F0 (Automatically set to the name of the current host.)144 570 Q F1 -(HOSTTYPE)108 582 Q F0 .222(Automatically set to a string that uniquely\ - describes the type of machine on which)144 594 R F1(bash)2.723 E F0 -.223(is e)2.723 F -.15(xe)-.15 G(cut-).15 E 2.5(ing. The)144 606 R(def) +(HOSTTYPE)108 582 Q F0 .223(Automatically set to a string that uniquely\ + describes the type of machine on which)144 594 R F1(bash)2.722 E F0 +.222(is e)2.722 F -.15(xe)-.15 G(cut-).15 E 2.5(ing. The)144 606 R(def) 2.5 E(ault is system-dependent.)-.1 E F1(LINENO)108 618 Q F0 1.408(Each\ time this parameter is referenced, the shell substitutes a decimal num\ ber representing the)144 630 R .078(current sequential line number \(st\ -arting with 1\) within a script or function.)144 642 R .079 -(When not in a script or)5.078 F .307(function, the v)144 654 R .307 -(alue substituted is not guaranteed to be meaningful.)-.25 F(If)5.306 E -F2(LINENO)2.806 E F0 .306(is unset, it loses its)2.556 F +arting with 1\) within a script or function.)144 642 R .078 +(When not in a script or)5.078 F .306(function, the v)144 654 R .306 +(alue substituted is not guaranteed to be meaningful.)-.25 F(If)5.307 E +F2(LINENO)2.807 E F0 .307(is unset, it loses its)2.557 F (special properties, e)144 666 Q -.15(ve)-.25 G 2.5(ni).15 G 2.5(fi)-2.5 G 2.5(ti)-2.5 G 2.5(ss)-2.5 G(ubsequently reset.)-2.5 E F1(MA)108 678 Q (CHTYPE)-.55 E F0 .898(Automatically set to a string that fully describ\ -es the system type on which)144 690 R F1(bash)3.398 E F0 .899(is e)3.398 -F -.15(xe)-.15 G .899(cuting, in).15 F(the standard GNU)144 702 Q F4 +es the system type on which)144 690 R F1(bash)3.398 E F0 .898(is e)3.398 +F -.15(xe)-.15 G .898(cuting, in).15 F(the standard GNU)144 702 Q F4 (cpu-company-system)2.5 E F0 2.5(format. The)2.5 F(def)2.5 E -(ault is system-dependent.)-.1 E(GNU Bash 4.2)72 768 Q(2012 July 14) -149.005 E(12)198.165 E 0 Cg EP +(ault is system-dependent.)-.1 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E +-.15(ve)-.15 G(mber 24).15 E(12)185.545 E 0 Cg EP %%Page: 13 13 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(MAPFILE)108 84 Q F0 .294(An array v)144 96 -R .294(ariable \(see)-.25 F F1(Arrays)2.794 E F0(belo)2.794 E .294 -(w\) created to hold the te)-.25 F .293(xt read by the)-.15 F F1 -(map\214le)2.793 E F0 -.2(bu)2.793 G .293(iltin when no).2 F -.25(va)144 +-.35 E/F1 10/Times-Bold@0 SF(MAPFILE)108 84 Q F0 .293(An array v)144 96 +R .293(ariable \(see)-.25 F F1(Arrays)2.793 E F0(belo)2.793 E .293 +(w\) created to hold the te)-.25 F .294(xt read by the)-.15 F F1 +(map\214le)2.794 E F0 -.2(bu)2.794 G .294(iltin when no).2 F -.25(va)144 108 S(riable name is supplied.).25 E F1(OLDPWD)108 120 Q F0(The pre)144 132 Q(vious w)-.25 E(orking directory as set by the)-.1 E F1(cd)2.5 E F0 -(command.)2.5 E F1(OPT)108 144 Q(ARG)-.9 E F0 1.626(The v)144 156 R +(command.)2.5 E F1(OPT)108 144 Q(ARG)-.9 E F0 1.627(The v)144 156 R 1.627(alue of the last option ar)-.25 F 1.627(gument processed by the) --.18 F F1(getopts)4.127 E F0 -.2(bu)4.127 G 1.627(iltin command \(see).2 -F/F2 9/Times-Bold@0 SF(SHELL)4.127 E -.09(BU)144 168 S(IL).09 E +-.18 F F1(getopts)4.127 E F0 -.2(bu)4.127 G 1.626(iltin command \(see).2 +F/F2 9/Times-Bold@0 SF(SHELL)4.126 E -.09(BU)144 168 S(IL).09 E (TIN COMMANDS)-.828 E F0(belo)2.25 E(w\).)-.25 E F1(OPTIND)108 180 Q F0 -1.652(The inde)144 192 R 4.152(xo)-.15 G 4.152(ft)-4.152 G 1.652(he ne) --4.152 F 1.652(xt ar)-.15 F 1.652(gument to be processed by the)-.18 F -F1(getopts)4.151 E F0 -.2(bu)4.151 G 1.651(iltin command \(see).2 F F2 -(SHELL)4.151 E -.09(BU)144 204 S(IL).09 E(TIN COMMANDS)-.828 E F0(belo) +1.651(The inde)144 192 R 4.151(xo)-.15 G 4.151(ft)-4.151 G 1.651(he ne) +-4.151 F 1.651(xt ar)-.15 F 1.652(gument to be processed by the)-.18 F +F1(getopts)4.152 E F0 -.2(bu)4.152 G 1.652(iltin command \(see).2 F F2 +(SHELL)4.152 E -.09(BU)144 204 S(IL).09 E(TIN COMMANDS)-.828 E F0(belo) 2.25 E(w\).)-.25 E F1(OSTYPE)108 216 Q F0 .329(Automatically set to a s\ tring that describes the operating system on which)144 228 R F1(bash) -2.83 E F0 .33(is e)2.83 F -.15(xe)-.15 G 2.83(cuting. The).15 F(def)144 -240 Q(ault is system-dependent.)-.1 E F1(PIPEST)108 252 Q -.95(AT)-.9 G -(US).95 E F0 .61(An array v)144 264 R .61(ariable \(see)-.25 F F1 +2.829 E F0 .329(is e)2.829 F -.15(xe)-.15 G 2.829(cuting. The).15 F(def) +144 240 Q(ault is system-dependent.)-.1 E F1(PIPEST)108 252 Q -.95(AT) +-.9 G(US).95 E F0 .61(An array v)144 264 R .61(ariable \(see)-.25 F F1 (Arrays)3.11 E F0(belo)3.11 E .61(w\) containing a list of e)-.25 F .61 (xit status v)-.15 F .61(alues from the processes in)-.25 F (the most-recently-e)144 276 Q -.15(xe)-.15 G(cuted fore).15 E @@ -1732,80 +1741,81 @@ tring that describes the operating system on which)144 228 R F1(bash) 2.5(arent. This)-2.5 F -.25(va)2.5 G(riable is readonly).25 E(.)-.65 E F1(PWD)108 300 Q F0(The current w)12.67 E (orking directory as set by the)-.1 E F1(cd)2.5 E F0(command.)2.5 E F1 -(RANDOM)108 312 Q F0 .565 -(Each time this parameter is referenced, a random inte)144 324 R .566 -(ger between 0 and 32767 is generated.)-.15 F(The)5.566 E .01 +(RANDOM)108 312 Q F0 .566 +(Each time this parameter is referenced, a random inte)144 324 R .565 +(ger between 0 and 32767 is generated.)-.15 F(The)5.565 E .01 (sequence of random numbers may be initialized by assigning a v)144 336 R .01(alue to)-.25 F F2(RANDOM)2.51 E/F3 9/Times-Roman@0 SF(.)A F0(If) 4.51 E F2(RANDOM)2.51 E F0(is)2.26 E (unset, it loses its special properties, e)144 348 Q -.15(ve)-.25 G 2.5 (ni).15 G 2.5(fi)-2.5 G 2.5(ti)-2.5 G 2.5(ss)-2.5 G(ubsequently reset.) --2.5 E F1(READLINE_LINE)108 360 Q F0 1.546(The contents of the)144 372 R +-2.5 E F1(READLINE_LINE)108 360 Q F0 1.547(The contents of the)144 372 R F1 -.18(re)4.047 G(adline).18 E F0 1.547(line b)4.047 F(uf)-.2 E(fer) -.25 E 4.047(,f)-.4 G 1.547(or use with)-4.047 F/F4 10/Courier@0 SF -1.547(bind -x)4.047 F F0(\(see)4.047 E F2 1.547(SHELL B)4.047 F(UIL)-.09 -E 1.547(TIN COM-)-.828 F(MANDS)144 384 Q F0(belo)2.25 E(w\).)-.25 E F1 -(READLINE_POINT)108 396 Q F0 .314 +1.547(bind -x)4.047 F F0(\(see)4.047 E F2 1.546(SHELL B)4.047 F(UIL)-.09 +E 1.546(TIN COM-)-.828 F(MANDS)144 384 Q F0(belo)2.25 E(w\).)-.25 E F1 +(READLINE_POINT)108 396 Q F0 .313 (The position of the insertion point in the)144 408 R F1 -.18(re)2.813 G (adline).18 E F0 .313(line b)2.813 F(uf)-.2 E(fer)-.25 E 2.813(,f)-.4 G -.313(or use with)-2.813 F F4 .313(bind -x)2.813 F F0(\(see)2.813 E F2 -(SHELL)2.813 E -.09(BU)144 420 S(IL).09 E(TIN COMMANDS)-.828 E F0(belo) +.313(or use with)-2.813 F F4 .314(bind -x)2.814 F F0(\(see)2.814 E F2 +(SHELL)2.814 E -.09(BU)144 420 S(IL).09 E(TIN COMMANDS)-.828 E F0(belo) 2.25 E(w\).)-.25 E F1(REPL)108 432 Q(Y)-.92 E F0 (Set to the line of input read by the)144 444 Q F1 -.18(re)2.5 G(ad).18 E F0 -.2(bu)2.5 G(iltin command when no ar).2 E(guments are supplied.) -.18 E F1(SECONDS)108 456 Q F0 .795(Each time this parameter is referen\ ced, the number of seconds since shell in)144 468 R -.2(vo)-.4 G .795 -(cation is returned.).2 F .713(If a v)144 480 R .712 +(cation is returned.).2 F .712(If a v)144 480 R .712 (alue is assigned to)-.25 F F2(SECONDS)3.212 E F3(,)A F0 .712(the v) 2.962 F .712(alue returned upon subsequent references is the number)-.25 -F .407(of seconds since the assignment plus the v)144 492 R .408 -(alue assigned.)-.25 F(If)5.408 E F2(SECONDS)2.908 E F0 .408 +F .408(of seconds since the assignment plus the v)144 492 R .408 +(alue assigned.)-.25 F(If)5.408 E F2(SECONDS)2.908 E F0 .407 (is unset, it loses its special)2.658 F(properties, e)144 504 Q -.15(ve) -.25 G 2.5(ni).15 G 2.5(fi)-2.5 G 2.5(ti)-2.5 G 2.5(ss)-2.5 G -(ubsequently reset.)-2.5 E F1(SHELLOPTS)108 516 Q F0 3.263(Ac)144 528 S -.763(olon-separated list of enabled shell options.)-3.263 F .763(Each w) +(ubsequently reset.)-2.5 E F1(SHELLOPTS)108 516 Q F0 3.262(Ac)144 528 S +.763(olon-separated list of enabled shell options.)-3.262 F .763(Each w) 5.763 F .763(ord in the list is a v)-.1 F .763(alid ar)-.25 F .763 -(gument for the)-.18 F F1144 540 Q F0 1.173(option to the)3.673 F -F1(set)3.673 E F0 -.2(bu)3.673 G 1.173(iltin command \(see).2 F F2 1.174 -(SHELL B)3.674 F(UIL)-.09 E 1.174(TIN COMMANDS)-.828 F F0(belo)3.424 E -3.674(w\). The)-.25 F(options)3.674 E .02(appearing in)144 552 R F2 -(SHELLOPTS)2.52 E F0 .019(are those reported as)2.27 F/F5 10 +(gument for the)-.18 F F1144 540 Q F0 1.174(option to the)3.674 F +F1(set)3.674 E F0 -.2(bu)3.674 G 1.174(iltin command \(see).2 F F2 1.173 +(SHELL B)3.673 F(UIL)-.09 E 1.173(TIN COMMANDS)-.828 F F0(belo)3.423 E +3.673(w\). The)-.25 F(options)3.673 E .019(appearing in)144 552 R F2 +(SHELLOPTS)2.519 E F0 .019(are those reported as)2.269 F/F5 10 /Times-Italic@0 SF(on)2.749 E F0(by)2.759 E F1 .019(set \255o)2.519 F F0 -5.019(.I)C 2.519(ft)-5.019 G .019(his v)-2.519 F .019 +5.019(.I)C 2.519(ft)-5.019 G .019(his v)-2.519 F .02 (ariable is in the en)-.25 F(vironment)-.4 E(when)144 564 Q F1(bash) -3.141 E F0 .642(starts up, each shell option in the list will be enable\ -d before reading an)3.141 F 3.142(ys)-.15 G .642(tartup \214les.)-3.142 +3.142 E F0 .642(starts up, each shell option in the list will be enable\ +d before reading an)3.142 F 3.141(ys)-.15 G .641(tartup \214les.)-3.141 F(This v)144 576 Q(ariable is read-only)-.25 E(.)-.65 E F1(SHL)108 588 Q (VL)-.92 E F0(Incremented by one each time an instance of)144 600 Q F1 (bash)2.5 E F0(is started.)2.5 E F1(UID)108 612 Q F0 (Expands to the user ID of the current user)17.67 E 2.5(,i)-.4 G (nitialized at shell startup.)-2.5 E(This v)5 E(ariable is readonly)-.25 -E(.)-.65 E .994(The follo)108 628.8 R .994(wing v)-.25 F .994 +E(.)-.65 E .993(The follo)108 628.8 R .993(wing v)-.25 F .994 (ariables are used by the shell.)-.25 F .994(In some cases,)5.994 F F1 -(bash)3.494 E F0 .994(assigns a def)3.494 F .994(ault v)-.1 F .993 +(bash)3.494 E F0 .994(assigns a def)3.494 F .994(ault v)-.1 F .994 (alue to a v)-.25 F(ariable;)-.25 E(these cases are noted belo)108 640.8 -Q -.65(w.)-.25 G F1 -.3(BA)108 657.6 S(SH_ENV).3 E F0 .505 -(If this parameter is set when)144 669.6 R F1(bash)3.005 E F0 .505(is e) -3.005 F -.15(xe)-.15 G .506(cuting a shell script, its v).15 F .506 -(alue is interpreted as a \214lename)-.25 F .355 +Q -.65(w.)-.25 G F1 -.3(BA)108 657.6 S(SH_ENV).3 E F0 .506 +(If this parameter is set when)144 669.6 R F1(bash)3.006 E F0 .506(is e) +3.006 F -.15(xe)-.15 G .505(cuting a shell script, its v).15 F .505 +(alue is interpreted as a \214lename)-.25 F .354 (containing commands to initialize the shell, as in)144 681.6 R F5 -(~/.bashr)2.855 E(c)-.37 E F0 5.354(.T).31 G .354(he v)-5.354 F .354 -(alue of)-.25 F F2 -.27(BA)2.854 G(SH_ENV).27 E F0 .354(is subjected) -2.604 F .525(to parameter e)144 693.6 R .525 +(~/.bashr)2.855 E(c)-.37 E F0 5.355(.T).31 G .355(he v)-5.355 F .355 +(alue of)-.25 F F2 -.27(BA)2.855 G(SH_ENV).27 E F0 .355(is subjected) +2.605 F .525(to parameter e)144 693.6 R .525 (xpansion, command substitution, and arithmetic e)-.15 F .525 (xpansion before being interpreted)-.15 F(as a \214lename.)144 705.6 Q F2 -.666(PA)5 G(TH)-.189 E F0 (is not used to search for the resultant \214lename.)2.25 E -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(13)198.165 E 0 Cg EP +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(13)185.545 E 0 Cg EP %%Page: 14 14 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) -.35 E/F1 10/Times-Bold@0 SF -.3(BA)108 84 S(SH_XTRA).3 E(CEFD)-.55 E F0 -.481(If set to an inte)144 96 R .481(ger corresponding to a v)-.15 F -.481(alid \214le descriptor)-.25 F(,)-.4 E F1(bash)2.98 E F0 .48 -(will write the trace output gener)2.98 F(-)-.2 E 3.114(ated when)144 +.48(If set to an inte)144 96 R .48(ger corresponding to a v)-.15 F .481 +(alid \214le descriptor)-.25 F(,)-.4 E F1(bash)2.981 E F0 .481 +(will write the trace output gener)2.981 F(-)-.2 E 3.114(ated when)144 108 R/F2 10/Courier@0 SF 3.114(set -x)5.614 F F0 3.114 (is enabled to that \214le descriptor)5.614 F 8.114(.T)-.55 G 3.114 (he \214le descriptor is closed when)-8.114 F/F3 9/Times-Bold@0 SF -.27 @@ -1813,6916 +1823,6975 @@ BP (is unset or assigned a ne)2.388 F 2.638(wv)-.25 G 2.638 (alue. Unsetting)-2.888 F F3 -.27(BA)2.638 G(SH_XTRA).27 E(CEFD)-.495 E F0 .138(or assigning it)2.388 F 2.531(the empty string causes the trace\ - output to be sent to the standard error)144 132 R 7.531(.N)-.55 G 2.531 -(ote that setting)-7.531 F F3 -.27(BA)144 144 S(SH_XTRA).27 E(CEFD)-.495 + output to be sent to the standard error)144 132 R 7.53(.N)-.55 G 2.53 +(ote that setting)-7.53 F F3 -.27(BA)144 144 S(SH_XTRA).27 E(CEFD)-.495 E F0 .74(to 2 \(the standard error \214le descriptor\) and then unsetti\ -ng it will result in the)2.991 F(standard error being closed.)144 156 Q -F1(CDP)108 168 Q -.95(AT)-.74 G(H).95 E F0 1.247 -(The search path for the)144 180 R F1(cd)3.747 E F0 3.747(command. This) -3.747 F 1.248(is a colon-separated list of directories in which the) -3.747 F 3.796 +ng it will result in the)2.99 F(standard error being closed.)144 156 Q +F1(CDP)108 168 Q -.95(AT)-.74 G(H).95 E F0 1.248 +(The search path for the)144 180 R F1(cd)3.748 E F0 3.748(command. This) +3.748 F 1.247(is a colon-separated list of directories in which the) +3.748 F 3.795 (shell looks for destination directories speci\214ed by the)144 192 R F1 -(cd)6.295 E F0 6.295(command. A)6.295 F 3.795(sample v)6.295 F 3.795 -(alue is)-.25 F F2(".:~:/usr")144 204 Q F0(.)A F1(COLUMNS)108 216 Q F0 -.828(Used by the)144 228 R F1(select)3.328 E F0 .829(compound command t\ -o determine the terminal width when printing selection)3.328 F 2.5 -(lists. Automatically)144 240 R(set in an interacti)2.5 E .3 -.15(ve s) --.25 H(hell upon receipt of a).15 E F3(SIGWINCH)2.5 E/F4 9/Times-Roman@0 -SF(.)A F1(COMPREPL)108 252 Q(Y)-.92 E F0 .848(An array v)144 264 R .848 -(ariable from which)-.25 F F1(bash)3.348 E F0 .848 -(reads the possible completions generated by a shell function)3.348 F -(in)144 276 Q -.2(vo)-.4 G -.1(ke).2 G 2.785(db).1 G 2.785(yt)-2.785 G +(cd)6.295 E F0 6.296(command. A)6.296 F 3.796(sample v)6.296 F 3.796 +(alue is)-.25 F F2(".:~:/usr")144 204 Q F0(.)A F1(CHILD_MAX)108 216 Q F0 +.997(Set the number of e)144 228 R .997(xited child status v)-.15 F .997 +(alues for the shell to remember)-.25 F 5.997(.B)-.55 G .997 +(ash will not allo)-5.997 F 3.497(wt)-.25 G(his)-3.497 E -.25(va)144 240 +S .11(lue to be decreased belo).25 F 2.61(waP)-.25 G .11 +(osix-mandated minimum, and there is a maximum v)-2.61 F .11 +(alue \(currently)-.25 F(8192\) that this may not e)144 252 Q 2.5 +(xceed. The)-.15 F(minimum v)2.5 E(alue is system-dependent.)-.25 E F1 +(COLUMNS)108 264 Q F0 .829(Used by the)144 276 R F1(select)3.329 E F0 +.828(compound command to determine the terminal width when printing sel\ +ection)3.329 F 2.5(lists. Automatically)144 288 R(set in an interacti) +2.5 E .3 -.15(ve s)-.25 H(hell upon receipt of a).15 E F3(SIGWINCH)2.5 E +/F4 9/Times-Roman@0 SF(.)A F1(COMPREPL)108 300 Q(Y)-.92 E F0 .847 +(An array v)144 312 R .848(ariable from which)-.25 F F1(bash)3.348 E F0 +.848(reads the possible completions generated by a shell function)3.348 +F(in)144 324 Q -.2(vo)-.4 G -.1(ke).2 G 2.785(db).1 G 2.785(yt)-2.785 G .285(he programmable completion f)-2.785 F .285(acility \(see)-.1 F F1 (Pr)2.785 E .285(ogrammable Completion)-.18 F F0(belo)2.785 E 2.785 (w\). Each)-.25 F(array element contains one possible completion.)144 -288 Q F1(EMA)108 300 Q(CS)-.55 E F0(If)144 312 Q F1(bash)2.536 E F0 .036 -(\214nds this v)2.536 F .036(ariable in the en)-.25 F .036 -(vironment when the shell starts with v)-.4 F(alue)-.25 E F2(t)2.535 E -F0 2.535(,i)C 2.535(ta)-2.535 G .035(ssumes that the)-2.535 F -(shell is running in an Emacs shell b)144 324 Q(uf)-.2 E -(fer and disables line editing.)-.25 E F1(ENV)108 336 Q F0(Similar to) +336 Q F1(EMA)108 348 Q(CS)-.55 E F0(If)144 360 Q F1(bash)2.535 E F0 .035 +(\214nds this v)2.535 F .035(ariable in the en)-.25 F .036 +(vironment when the shell starts with v)-.4 F(alue)-.25 E F2(t)2.536 E +F0 2.536(,i)C 2.536(ta)-2.536 G .036(ssumes that the)-2.536 F +(shell is running in an Emacs shell b)144 372 Q(uf)-.2 E +(fer and disables line editing.)-.25 E F1(ENV)108 384 Q F0(Similar to) 14.89 E F3 -.27(BA)2.5 G(SH_ENV).27 E F4(;)A F0 (used when the shell is in)2.25 E -.2(vo)-.4 G -.1(ke).2 G 2.5(di).1 G -2.5(nP)-2.5 G(OSIX mode.)-2.5 E F1(FCEDIT)108 348 Q F0(The def)144 360 Q +2.5(nP)-2.5 G(OSIX mode.)-2.5 E F1(FCEDIT)108 396 Q F0(The def)144 408 Q (ault editor for the)-.1 E F1(fc)2.5 E F0 -.2(bu)2.5 G(iltin command.).2 -E F1(FIGNORE)108 372 Q F0 2.598(Ac)144 384 S .098 -(olon-separated list of suf)-2.598 F<8c78>-.25 E .098 +E F1(FIGNORE)108 420 Q F0 2.599(Ac)144 432 S .098 +(olon-separated list of suf)-2.599 F<8c78>-.25 E .098 (es to ignore when performing \214lename completion \(see)-.15 F F3 -(READLINE)2.599 E F0(belo)144 396 Q 2.705(w\). A)-.25 F .205 -(\214lename whose suf)2.705 F .205(\214x matches one of the entries in) --.25 F F3(FIGNORE)2.705 E F0 .205(is e)2.455 F .204 -(xcluded from the list)-.15 F(of matched \214lenames.)144 408 Q 2.5(As)5 +(READLINE)2.598 E F0(belo)144 444 Q 2.704(w\). A)-.25 F .204 +(\214lename whose suf)2.704 F .205(\214x matches one of the entries in) +-.25 F F3(FIGNORE)2.705 E F0 .205(is e)2.455 F .205 +(xcluded from the list)-.15 F(of matched \214lenames.)144 456 Q 2.5(As)5 G(ample v)-2.5 E(alue is)-.25 E F2(".o:~")2.5 E F0(.)A F1(FUNCNEST)108 -420 Q F0 1.78(If set to a numeric v)144 432 R 1.78 +468 Q F0 1.78(If set to a numeric v)144 480 R 1.78 (alue greater than 0, de\214nes a maximum function nesting le)-.25 F --.15(ve)-.25 G 4.28(l. Function).15 F(in)144 444 Q -.2(vo)-.4 G +-.15(ve)-.25 G 4.28(l. Function).15 F(in)144 492 Q -.2(vo)-.4 G (cations that e).2 E(xceed this nesting le)-.15 E -.15(ve)-.25 G 2.5(lw) .15 G(ill cause the current command to abort.)-2.5 E F1(GLOBIGNORE)108 -456 Q F0 3.118(Ac)144 468 S .618(olon-separated list of patterns de\214\ +504 Q F0 3.118(Ac)144 516 S .618(olon-separated list of patterns de\214\ ning the set of \214lenames to be ignored by pathname e)-3.118 F(xpan-) --.15 E 3.131(sion. If)144 480 R 3.132<618c>3.131 G .632 +-.15 E 3.132(sion. If)144 528 R 3.132<618c>3.132 G .632 (lename matched by a pathname e)-3.132 F .632 (xpansion pattern also matches one of the patterns in)-.15 F F3 -(GLOBIGNORE)144 492 Q F4(,)A F0(it is remo)2.25 E -.15(ve)-.15 G 2.5(df) -.15 G(rom the list of matches.)-2.5 E F1(HISTCONTR)108 504 Q(OL)-.3 E F0 -2.654(Ac)144 516 S .153(olon-separated list of v)-2.654 F .153 +(GLOBIGNORE)144 540 Q F4(,)A F0(it is remo)2.25 E -.15(ve)-.15 G 2.5(df) +.15 G(rom the list of matches.)-2.5 E F1(HISTCONTR)108 552 Q(OL)-.3 E F0 +2.653(Ac)144 564 S .153(olon-separated list of v)-2.653 F .153 (alues controlling ho)-.25 F 2.653(wc)-.25 G .153(ommands are sa)-2.653 F -.15(ve)-.2 G 2.653(do).15 G 2.653(nt)-2.653 G .153(he history list.) --2.653 F .153(If the list)5.153 F .49(of v)144 528 R .49(alues includes) --.25 F/F5 10/Times-Italic@0 SF(ignor)2.99 E(espace)-.37 E F0 2.99(,l).18 -G .49(ines which be)-2.99 F .491(gin with a)-.15 F F1(space)2.991 E F0 -.491(character are not sa)2.991 F -.15(ve)-.2 G 2.991(di).15 G 2.991(nt) --2.991 G .491(he his-)-2.991 F .558(tory list.)144 540 R 3.058(Av)5.558 -G .558(alue of)-3.308 F F5(ignor)3.068 E(edups)-.37 E F0 .558 -(causes lines matching the pre)3.328 F .557 -(vious history entry to not be sa)-.25 F -.15(ve)-.2 G(d.).15 E 2.958 -(Av)144 552 S .458(alue of)-3.208 F F5(ignor)2.968 E(eboth)-.37 E F0 -.458(is shorthand for)3.238 F F5(ignor)2.959 E(espace)-.37 E F0(and) -2.959 E F5(ignor)2.959 E(edups)-.37 E F0 5.459(.A)C -.25(va)-2.5 G .459 -(lue of).25 F F5(er)2.959 E(asedups)-.15 E F0(causes)2.959 E .699 -(all pre)144 564 R .698 +-2.653 F .154(If the list)5.153 F .491(of v)144 576 R .491 +(alues includes)-.25 F/F5 10/Times-Italic@0 SF(ignor)2.991 E(espace)-.37 +E F0 2.991(,l).18 G .491(ines which be)-2.991 F .491(gin with a)-.15 F +F1(space)2.991 E F0 .49(character are not sa)2.991 F -.15(ve)-.2 G 2.99 +(di).15 G 2.99(nt)-2.99 G .49(he his-)-2.99 F .557(tory list.)144 588 R +3.057(Av)5.557 G .557(alue of)-3.307 F F5(ignor)3.067 E(edups)-.37 E F0 +.557(causes lines matching the pre)3.327 F .558 +(vious history entry to not be sa)-.25 F -.15(ve)-.2 G(d.).15 E 2.959 +(Av)144 600 S .459(alue of)-3.209 F F5(ignor)2.969 E(eboth)-.37 E F0 +.459(is shorthand for)3.239 F F5(ignor)2.959 E(espace)-.37 E F0(and) +2.959 E F5(ignor)2.958 E(edups)-.37 E F0 5.458(.A)C -.25(va)-2.5 G .458 +(lue of).25 F F5(er)2.958 E(asedups)-.15 E F0(causes)2.958 E .698 +(all pre)144 612 R .698 (vious lines matching the current line to be remo)-.25 F -.15(ve)-.15 G -3.198(df).15 G .698(rom the history list before that line is)-3.198 F -(sa)144 576 Q -.15(ve)-.2 G 2.763(d. An).15 F 2.763(yv)-.15 G .263 -(alue not in the abo)-3.013 F .563 -.15(ve l)-.15 H .263 -(ist is ignored.).15 F(If)5.263 E F3(HISTCONTR)2.763 E(OL)-.27 E F0 .264 -(is unset, or does not include)2.513 F 2.942(av)144 588 S .442(alid v) --3.192 F .442(alue, all lines read by the shell parser are sa)-.25 F --.15(ve)-.2 G 2.941(do).15 G 2.941(nt)-2.941 G .441 -(he history list, subject to the v)-2.941 F .441(alue of)-.25 F F3 -(HISTIGNORE)144 600 Q F4(.)A F0 1.981(The second and subsequent lines o\ -f a multi-line compound command are not)6.481 F -(tested, and are added to the history re)144 612 Q -.05(ga)-.15 G +3.198(df).15 G .699(rom the history list before that line is)-3.198 F +(sa)144 624 Q -.15(ve)-.2 G 2.764(d. An).15 F 2.764(yv)-.15 G .264 +(alue not in the abo)-3.014 F .563 -.15(ve l)-.15 H .263 +(ist is ignored.).15 F(If)5.263 E F3(HISTCONTR)2.763 E(OL)-.27 E F0 .263 +(is unset, or does not include)2.513 F 2.941(av)144 636 S .441(alid v) +-3.191 F .441(alue, all lines read by the shell parser are sa)-.25 F +-.15(ve)-.2 G 2.942(do).15 G 2.942(nt)-2.942 G .442 +(he history list, subject to the v)-2.942 F .442(alue of)-.25 F F3 +(HISTIGNORE)144 648 Q F4(.)A F0 1.981(The second and subsequent lines o\ +f a multi-line compound command are not)6.482 F +(tested, and are added to the history re)144 660 Q -.05(ga)-.15 G (rdless of the v).05 E(alue of)-.25 E F3(HISTCONTR)2.5 E(OL)-.27 E F4(.) -A F1(HISTFILE)108 624 Q F0 .181 -(The name of the \214le in which command history is sa)144 636 R -.15 +A F1(HISTFILE)108 672 Q F0 .181 +(The name of the \214le in which command history is sa)144 684 R -.15 (ve)-.2 G 2.681(d\().15 G(see)-2.681 E F3(HIST)2.681 E(OR)-.162 E(Y) --.315 E F0(belo)2.431 E 2.681(w\). The)-.25 F(def)2.681 E .181(ault v) --.1 F(alue)-.25 E(is)144 648 Q F5(~/.bash_history)2.5 E F0 5(.I)C 2.5 +-.315 E F0(belo)2.431 E 2.682(w\). The)-.25 F(def)2.682 E .182(ault v) +-.1 F(alue)-.25 E(is)144 696 Q F5(~/.bash_history)2.5 E F0 5(.I)C 2.5 (fu)-5 G(nset, the command history is not sa)-2.5 E -.15(ve)-.2 G 2.5 -(dw).15 G(hen a shell e)-2.5 E(xits.)-.15 E F1(HISTFILESIZE)108 660 Q F0 -1.622(The maximum number of lines contained in the history \214le.)144 -672 R 1.623(When this v)6.623 F 1.623(ariable is assigned a)-.25 F -.25 -(va)144 684 S .932(lue, the history \214le is truncated, if necessary) -.25 F 3.432(,t)-.65 G 3.432(oc)-3.432 G .932 -(ontain no more than that number of lines by)-3.432 F(remo)144 696 Q .87 -(ving the oldest entries.)-.15 F .871(The history \214le is also trunca\ -ted to this size after writing it when a)5.87 F 1.245(shell e)144 708 R -3.745(xits. If)-.15 F 1.244(the v)3.744 F 1.244 -(alue is 0, the history \214le is truncated to zero size.)-.25 F 1.244 -(Non-numeric v)6.244 F 1.244(alues and)-.25 F 1.021(numeric v)144 720 R -1.022(alues less than zero inhibit truncation.)-.25 F 1.022 -(The shell sets the def)6.022 F 1.022(ault v)-.1 F 1.022(alue to the v) --.25 F 1.022(alue of)-.25 F(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E -(14)198.165 E 0 Cg EP +(dw).15 G(hen a shell e)-2.5 E(xits.)-.15 E(GNU Bash 4.2)72 768 Q +(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(14)185.545 E 0 Cg EP %%Page: 15 15 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(HISTSIZE)144 84 Q F0(after reading an)2.5 E -2.5(ys)-.15 G(tartup \214les.)-2.5 E F1(HISTIGNORE)108 96 Q F0 2.658(Ac) -144 108 S .158(olon-separated list of patterns used to decide which com\ -mand lines should be sa)-2.658 F -.15(ve)-.2 G 2.657(do).15 G 2.657(nt) --2.657 G .157(he his-)-2.657 F .707(tory list.)144 120 R .707 -(Each pattern is anchored at the be)5.707 F .708 -(ginning of the line and must match the complete line)-.15 F .626 -(\(no implicit `)144 132 R F1(*)A F0 3.126('i)C 3.126(sa)-3.126 G 3.126 -(ppended\). Each)-3.126 F .626(pattern is tested ag)3.126 F .625 +-.35 E/F1 10/Times-Bold@0 SF(HISTFILESIZE)108 84 Q F0 1.623 +(The maximum number of lines contained in the history \214le.)144 96 R +1.622(When this v)6.623 F 1.622(ariable is assigned a)-.25 F -.25(va)144 +108 S .931(lue, the history \214le is truncated, if necessary).25 F +3.432(,t)-.65 G 3.432(oc)-3.432 G .932 +(ontain no more than that number of lines by)-3.432 F(remo)144 120 Q +.871(ving the oldest entries.)-.15 F .87(The history \214le is also tru\ +ncated to this size after writing it when a)5.871 F 1.244(shell e)144 +132 R 3.744(xits. If)-.15 F 1.244(the v)3.744 F 1.244 +(alue is 0, the history \214le is truncated to zero size.)-.25 F 1.245 +(Non-numeric v)6.244 F 1.245(alues and)-.25 F 1.022(numeric v)144 144 R +1.022(alues less than zero inhibit truncation.)-.25 F 1.022 +(The shell sets the def)6.022 F 1.022(ault v)-.1 F 1.022(alue to the v) +-.25 F 1.021(alue of)-.25 F F1(HISTSIZE)144 156 Q F0(after reading an) +2.5 E 2.5(ys)-.15 G(tartup \214les.)-2.5 E F1(HISTIGNORE)108 168 Q F0 +2.657(Ac)144 180 S .157(olon-separated list of patterns used to decide \ +which command lines should be sa)-2.657 F -.15(ve)-.2 G 2.658(do).15 G +2.658(nt)-2.658 G .158(he his-)-2.658 F .708(tory list.)144 192 R .708 +(Each pattern is anchored at the be)5.708 F .707 +(ginning of the line and must match the complete line)-.15 F .625 +(\(no implicit `)144 204 R F1(*)A F0 3.125('i)C 3.125(sa)-3.125 G 3.125 +(ppended\). Each)-3.125 F .626(pattern is tested ag)3.125 F .626 (ainst the line after the checks speci\214ed by)-.05 F/F2 9/Times-Bold@0 -SF(HISTCONTR)144 144 Q(OL)-.27 E F0 1.793(are applied.)4.043 F 1.793 +SF(HISTCONTR)144 216 Q(OL)-.27 E F0 1.793(are applied.)4.043 F 1.793 (In addition to the normal shell pattern matching characters, `)6.793 F -F1(&)A F0(')A 2.515(matches the pre)144 156 R 2.515(vious history line.) +F1(&)A F0(')A 2.514(matches the pre)144 228 R 2.514(vious history line.) -.25 F(`)7.514 E F1(&)A F0 5.014('m)C 2.514 -(ay be escaped using a backslash; the backslash is)-5.014 F(remo)144 168 -Q -.15(ve)-.15 G 3.352(db).15 G .852(efore attempting a match.)-3.352 F +(ay be escaped using a backslash; the backslash is)-5.014 F(remo)144 240 +Q -.15(ve)-.15 G 3.353(db).15 G .853(efore attempting a match.)-3.353 F .852(The second and subsequent lines of a multi-line compound)5.852 F -(command are not tested, and are added to the history re)144 180 Q -.05 +(command are not tested, and are added to the history re)144 252 Q -.05 (ga)-.15 G(rdless of the v).05 E(alue of)-.25 E F2(HISTIGNORE)2.5 E/F3 9 -/Times-Roman@0 SF(.)A F1(HISTSIZE)108 192 Q F0 1.387 -(The number of commands to remember in the command history \(see)144 204 +/Times-Roman@0 SF(.)A F1(HISTSIZE)108 264 Q F0 1.387 +(The number of commands to remember in the command history \(see)144 276 R F2(HIST)3.887 E(OR)-.162 E(Y)-.315 E F0(belo)3.637 E 3.887(w\). If) --.25 F(the)3.887 E -.25(va)144 216 S 1.32(lue is 0, commands are not sa) -.25 F -.15(ve)-.2 G 3.82(di).15 G 3.821(nt)-3.82 G 1.321 -(he history list.)-3.821 F 1.321(Numeric v)6.321 F 1.321 -(alues less than zero result in)-.25 F -2.15 -.25(ev e)144 228 T .437 -(ry command being sa).25 F -.15(ve)-.2 G 2.937(do).15 G 2.937(nt)-2.937 -G .437(he history list \(there is no limit\).)-2.937 F .436 -(The shell sets the def)5.436 F .436(ault v)-.1 F(alue)-.25 E -(to 500 after reading an)144 240 Q 2.5(ys)-.15 G(tartup \214les.)-2.5 E -F1(HISTTIMEFORMA)108 252 Q(T)-.95 E F0 .951(If this v)144 264 R .951 -(ariable is set and not null, its v)-.25 F .952 +-.25 F(the)3.888 E -.25(va)144 288 S 1.321 +(lue is 0, commands are not sa).25 F -.15(ve)-.2 G 3.821(di).15 G 3.821 +(nt)-3.821 G 1.321(he history list.)-3.821 F 1.32(Numeric v)6.32 F 1.32 +(alues less than zero result in)-.25 F -2.15 -.25(ev e)144 300 T .436 +(ry command being sa).25 F -.15(ve)-.2 G 2.936(do).15 G 2.936(nt)-2.936 +G .436(he history list \(there is no limit\).)-2.936 F .437 +(The shell sets the def)5.437 F .437(ault v)-.1 F(alue)-.25 E +(to 500 after reading an)144 312 Q 2.5(ys)-.15 G(tartup \214les.)-2.5 E +F1(HISTTIMEFORMA)108 324 Q(T)-.95 E F0 .952(If this v)144 336 R .952 +(ariable is set and not null, its v)-.25 F .951 (alue is used as a format string for)-.25 F/F4 10/Times-Italic@0 SF -(strftime)3.452 E F0 .952(\(3\) to print the)B .673 -(time stamp associated with each history entry displayed by the)144 276 -R F1(history)3.173 E F0 -.2(bu)3.172 G 3.172(iltin. If).2 F .672(this v) -3.172 F .672(ariable is)-.25 F .144 -(set, time stamps are written to the history \214le so the)144 288 R +(strftime)3.451 E F0 .951(\(3\) to print the)B .672 +(time stamp associated with each history entry displayed by the)144 348 +R F1(history)3.173 E F0 -.2(bu)3.173 G 3.173(iltin. If).2 F .673(this v) +3.173 F .673(ariable is)-.25 F .144 +(set, time stamps are written to the history \214le so the)144 360 R 2.644(ym)-.15 G .144(ay be preserv)-2.644 F .144 -(ed across shell sessions.)-.15 F(This)5.145 E(uses the history comment\ - character to distinguish timestamps from other history lines.)144 300 Q -F1(HOME)108 312 Q F0 1.27 -(The home directory of the current user; the def)144 324 R 1.27(ault ar) +(ed across shell sessions.)-.15 F(This)5.144 E(uses the history comment\ + character to distinguish timestamps from other history lines.)144 372 Q +F1(HOME)108 384 Q F0 1.27 +(The home directory of the current user; the def)144 396 R 1.27(ault ar) -.1 F 1.27(gument for the)-.18 F F1(cd)3.77 E F0 -.2(bu)3.77 G 1.27 -(iltin command.).2 F(The)6.27 E -.25(va)144 336 S(lue of this v).25 E +(iltin command.).2 F(The)6.27 E -.25(va)144 408 S(lue of this v).25 E (ariable is also used when performing tilde e)-.25 E(xpansion.)-.15 E F1 -(HOSTFILE)108 348 Q F0 1.015 -(Contains the name of a \214le in the same format as)144 360 R F4 +(HOSTFILE)108 420 Q F0 1.015 +(Contains the name of a \214le in the same format as)144 432 R F4 (/etc/hosts)5.181 E F0 1.015(that should be read when the shell)5.181 F -.551(needs to complete a hostname.)144 372 R .551 +.55(needs to complete a hostname.)144 444 R .551 (The list of possible hostname completions may be changed while)5.551 F -1.058(the shell is running; the ne)144 384 R 1.059 -(xt time hostname completion is attempted after the v)-.15 F 1.059 -(alue is changed,)-.25 F F1(bash)144 396 Q F0 .138 -(adds the contents of the ne)2.639 F 2.638<778c>-.25 G .138(le to the e) +1.059(the shell is running; the ne)144 456 R 1.059 +(xt time hostname completion is attempted after the v)-.15 F 1.058 +(alue is changed,)-.25 F F1(bash)144 468 Q F0 .138 +(adds the contents of the ne)2.638 F 2.638<778c>-.25 G .138(le to the e) -2.638 F .138(xisting list.)-.15 F(If)5.138 E F2(HOSTFILE)2.638 E F0 -.138(is set, b)2.388 F .138(ut has no v)-.2 F .138(alue, or)-.25 F .517 -(does not name a readable \214le,)144 408 R F1(bash)3.017 E F0 .517 -(attempts to read)3.017 F F4(/etc/hosts)4.684 E F0 .518 -(to obtain the list of possible host-)4.684 F(name completions.)144 420 +.138(is set, b)2.388 F .139(ut has no v)-.2 F .139(alue, or)-.25 F .518 +(does not name a readable \214le,)144 480 R F1(bash)3.018 E F0 .518 +(attempts to read)3.018 F F4(/etc/hosts)4.683 E F0 .517 +(to obtain the list of possible host-)4.683 F(name completions.)144 492 Q(When)5 E F2(HOSTFILE)2.5 E F0(is unset, the hostname list is cleared.) -2.25 E F1(IFS)108 432 Q F0(The)20.44 E F4 .556(Internal F)3.636 F .556 -(ield Separ)-.45 F(ator)-.15 E F0 .556(that is used for w)3.786 F .556 -(ord splitting after e)-.1 F .555(xpansion and to split lines into)-.15 -F -.1(wo)144 444 S(rds with the).1 E F1 -.18(re)2.5 G(ad).18 E F0 -.2 +2.25 E F1(IFS)108 504 Q F0(The)20.44 E F4 .555(Internal F)3.635 F .555 +(ield Separ)-.45 F(ator)-.15 E F0 .555(that is used for w)3.785 F .556 +(ord splitting after e)-.1 F .556(xpansion and to split lines into)-.15 +F -.1(wo)144 516 S(rds with the).1 E F1 -.18(re)2.5 G(ad).18 E F0 -.2 (bu)2.5 G(iltin command.).2 E(The def)5 E(ault v)-.1 E(alue is `)-.25 E -(`')-.25 E('.)-.74 E F1(IGNOREEOF)108 456 Q -F0 .503(Controls the action of an interacti)144 468 R .803 -.15(ve s) +(`')-.25 E('.)-.74 E F1(IGNOREEOF)108 528 Q +F0 .503(Controls the action of an interacti)144 540 R .803 -.15(ve s) -.25 H .503(hell on receipt of an).15 F F2(EOF)3.003 E F0 .503 -(character as the sole input.)2.753 F .504(If set,)5.504 F .426(the v) -144 480 R .426(alue is the number of consecuti)-.25 F -.15(ve)-.25 G F2 +(character as the sole input.)2.753 F .503(If set,)5.503 F .426(the v) +144 552 R .426(alue is the number of consecuti)-.25 F -.15(ve)-.25 G F2 (EOF)3.076 E F0 .426 -(characters which must be typed as the \214rst characters)2.676 F .302 -(on an input line before)144 492 R F1(bash)2.802 E F0 -.15(ex)2.802 G +(characters which must be typed as the \214rst characters)2.676 F .303 +(on an input line before)144 564 R F1(bash)2.802 E F0 -.15(ex)2.802 G 2.802(its. If).15 F .302(the v)2.802 F .302(ariable e)-.25 F .302 (xists b)-.15 F .302(ut does not ha)-.2 F .602 -.15(ve a n)-.2 H .302 -(umeric v).15 F .303(alue, or has)-.25 F(no v)144 504 Q(alue, the def) +(umeric v).15 F .302(alue, or has)-.25 F(no v)144 576 Q(alue, the def) -.25 E(ault v)-.1 E(alue is 10.)-.25 E(If it does not e)5 E(xist,)-.15 E F2(EOF)2.5 E F0(signi\214es the end of input to the shell.)2.25 E F1 -(INPUTRC)108 516 Q F0 1.436(The \214lename for the)144 528 R F1 -.18(re) +(INPUTRC)108 588 Q F0 1.435(The \214lename for the)144 600 R F1 -.18(re) 3.936 G(adline).18 E F0 1.436(startup \214le, o)3.936 F -.15(ve)-.15 G 1.436(rriding the def).15 F 1.436(ault of)-.1 F F4(~/.inputr)5.602 E(c) --.37 E F0(\(see)5.601 E F2(READLINE)3.935 E F0(belo)144 540 Q(w\).)-.25 -E F1(LANG)108 552 Q F0 1.239(Used to determine the locale cate)7.11 F -1.239(gory for an)-.15 F 3.739(yc)-.15 G(ate)-3.739 E 1.24 +-.37 E F0(\(see)5.602 E F2(READLINE)3.936 E F0(belo)144 612 Q(w\).)-.25 +E F1(LANG)108 624 Q F0 1.24(Used to determine the locale cate)7.11 F +1.239(gory for an)-.15 F 3.739(yc)-.15 G(ate)-3.739 E 1.239 (gory not speci\214cally selected with a v)-.15 F(ariable)-.25 E -(starting with)144 564 Q F1(LC_)2.5 E F0(.)A F1(LC_ALL)108 576 Q F0 .974 -(This v)144 588 R .974(ariable o)-.25 F -.15(ve)-.15 G .974 +(starting with)144 636 Q F1(LC_)2.5 E F0(.)A F1(LC_ALL)108 648 Q F0 .973 +(This v)144 660 R .973(ariable o)-.25 F -.15(ve)-.15 G .973 (rrides the v).15 F .973(alue of)-.25 F F2(LANG)3.473 E F0 .973(and an) 3.223 F 3.473(yo)-.15 G(ther)-3.473 E F1(LC_)3.473 E F0 -.25(va)3.473 G -.973(riable specifying a locale cate-).25 F(gory)144 600 Q(.)-.65 E F1 -(LC_COLLA)108 612 Q(TE)-.95 E F0 .411(This v)144 624 R .412(ariable det\ +.974(riable specifying a locale cate-).25 F(gory)144 672 Q(.)-.65 E F1 +(LC_COLLA)108 684 Q(TE)-.95 E F0 .412(This v)144 696 R .412(ariable det\ ermines the collation order used when sorting the results of pathname e) --.25 F(xpansion,)-.15 E 1.465(and determines the beha)144 636 R 1.465 -(vior of range e)-.2 F 1.464(xpressions, equi)-.15 F -.25(va)-.25 G -1.464(lence classes, and collating sequences).25 F(within pathname e)144 -648 Q(xpansion and pattern matching.)-.15 E F1(LC_CTYPE)108 660 Q F0 -1.935(This v)144 672 R 1.936 -(ariable determines the interpretation of characters and the beha)-.25 F -1.936(vior of character classes)-.2 F(within pathname e)144 684 Q -(xpansion and pattern matching.)-.15 E F1(LC_MESSA)108 696 Q(GES)-.55 E -F0(This v)144 708 Q(ariable determines the locale used to translate dou\ -ble-quoted strings preceded by a)-.25 E F1($)2.5 E F0(.)A(GNU Bash 4.2) -72 768 Q(2012 July 14)149.005 E(15)198.165 E 0 Cg EP +-.25 F(xpansion,)-.15 E 1.464(and determines the beha)144 708 R 1.464 +(vior of range e)-.2 F 1.465(xpressions, equi)-.15 F -.25(va)-.25 G +1.465(lence classes, and collating sequences).25 F(within pathname e)144 +720 Q(xpansion and pattern matching.)-.15 E(GNU Bash 4.2)72 768 Q +(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(15)185.545 E 0 Cg EP %%Page: 16 16 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(LC_NUMERIC)108 84 Q F0(This v)144 96 Q -(ariable determines the locale cate)-.25 E -(gory used for number formatting.)-.15 E F1(LINES)108 108 Q F0 .055 -(Used by the)5.99 F F1(select)2.555 E F0 .054(compound command to deter\ -mine the column length for printing selection lists.)2.555 F -(Automatically set by an interacti)144 120 Q .3 -.15(ve s)-.25 H +-.35 E/F1 10/Times-Bold@0 SF(LC_CTYPE)108 84 Q F0 1.936(This v)144 96 R +1.936(ariable determines the interpretation of characters and the beha) +-.25 F 1.935(vior of character classes)-.2 F(within pathname e)144 108 Q +(xpansion and pattern matching.)-.15 E F1(LC_MESSA)108 120 Q(GES)-.55 E +F0(This v)144 132 Q(ariable determines the locale used to translate dou\ +ble-quoted strings preceded by a)-.25 E F1($)2.5 E F0(.)A F1(LC_NUMERIC) +108 144 Q F0(This v)144 156 Q(ariable determines the locale cate)-.25 E +(gory used for number formatting.)-.15 E F1(LINES)108 168 Q F0 .054 +(Used by the)5.99 F F1(select)2.554 E F0 .054(compound command to deter\ +mine the column length for printing selection lists.)2.554 F +(Automatically set by an interacti)144 180 Q .3 -.15(ve s)-.25 H (hell upon receipt of a).15 E/F2 9/Times-Bold@0 SF(SIGWINCH)2.5 E/F3 9 -/Times-Roman@0 SF(.)A F1(MAIL)108 132 Q F0 1.201 +/Times-Roman@0 SF(.)A F1(MAIL)108 192 Q F0 1.201 (If this parameter is set to a \214le or directory name and the)8.78 F -F2(MAILP)3.701 E -.855(AT)-.666 G(H).855 E F0 -.25(va)3.451 G 1.202 -(riable is not set,).25 F F1(bash)3.702 E F0 -(informs the user of the arri)144 144 Q -.25(va)-.25 G 2.5(lo).25 G 2.5 +F2(MAILP)3.701 E -.855(AT)-.666 G(H).855 E F0 -.25(va)3.451 G 1.201 +(riable is not set,).25 F F1(bash)3.701 E F0 +(informs the user of the arri)144 204 Q -.25(va)-.25 G 2.5(lo).25 G 2.5 (fm)-2.5 G(ail in the speci\214ed \214le or Maildir)-2.5 E -(-format directory)-.2 E(.)-.65 E F1(MAILCHECK)108 156 Q F0 .099 -(Speci\214es ho)144 168 R 2.599(wo)-.25 G .099(ften \(in seconds\)) --2.599 F F1(bash)2.598 E F0 .098(checks for mail.)2.598 F .098(The def) -5.098 F .098(ault is 60 seconds.)-.1 F .098(When it is time)5.098 F .223 +(-format directory)-.2 E(.)-.65 E F1(MAILCHECK)108 216 Q F0 .098 +(Speci\214es ho)144 228 R 2.598(wo)-.25 G .098(ften \(in seconds\)) +-2.598 F F1(bash)2.598 E F0 .098(checks for mail.)2.598 F .098(The def) +5.098 F .098(ault is 60 seconds.)-.1 F .099(When it is time)5.099 F .224 (to check for mail, the shell does so before displaying the primary pro\ -mpt.)144 180 R .224(If this v)5.224 F .224(ariable is unset,)-.25 F .066 -(or set to a v)144 192 R .066(alue that is not a number greater than or\ +mpt.)144 240 R .223(If this v)5.223 F .223(ariable is unset,)-.25 F .066 +(or set to a v)144 252 R .066(alue that is not a number greater than or\ equal to zero, the shell disables mail checking.)-.25 F F1(MAILP)108 -204 Q -.95(AT)-.74 G(H).95 E F0 2.99(Ac)144 216 S .49 +264 Q -.95(AT)-.74 G(H).95 E F0 2.99(Ac)144 276 S .49 (olon-separated list of \214lenames to be check)-2.99 F .49 (ed for mail.)-.1 F .49(The message to be printed when mail)5.49 F(arri) -144 228 Q -.15(ve)-.25 G 2.62(si).15 G 2.62(nap)-2.62 G .12(articular \ +144 288 Q -.15(ve)-.25 G 2.62(si).15 G 2.62(nap)-2.62 G .12(articular \ \214le may be speci\214ed by separating the \214lename from the message\ - with a `?'.)-2.62 F(When used in the te)144 240 Q(xt of the message,) + with a `?'.)-2.62 F(When used in the te)144 300 Q(xt of the message,) -.15 E F1($_)2.5 E F0 -.15(ex)2.5 G (pands to the name of the current mail\214le.).15 E(Example:)5 E F1 -(MAILP)144 252 Q -.95(AT)-.74 G(H).95 E F0(=\010/v)A(ar/mail/bfox?"Y) +(MAILP)144 312 Q -.95(AT)-.74 G(H).95 E F0(=\010/v)A(ar/mail/bfox?"Y) -.25 E(ou ha)-1.1 E .3 -.15(ve m)-.2 H -(ail":~/shell\255mail?"$_ has mail!"\010).15 E F1(Bash)144 264 Q F0 .388 -(supplies a def)2.888 F .388(ault v)-.1 F .388(alue for this v)-.25 F -.388(ariable, b)-.25 F .389 +(ail":~/shell\255mail?"$_ has mail!"\010).15 E F1(Bash)144 324 Q F0 .389 +(supplies a def)2.889 F .389(ault v)-.1 F .389(alue for this v)-.25 F +.389(ariable, b)-.25 F .388 (ut the location of the user mail \214les that it uses is)-.2 F -(system dependent \(e.g., /v)144 276 Q(ar/mail/)-.25 E F1($USER)A F0 -(\).)A F1(OPTERR)108 288 Q F0 .39(If set to the v)144 300 R .39(alue 1,) --.25 F F1(bash)2.89 E F0 .389(displays error messages generated by the) -2.889 F F1(getopts)2.889 E F0 -.2(bu)2.889 G .389(iltin command \(see).2 -F F2 .359(SHELL B)144 312 R(UIL)-.09 E .359(TIN COMMANDS)-.828 F F0 -(belo)2.609 E(w\).)-.25 E F2(OPTERR)5.359 E F0 .36 -(is initialized to 1 each time the shell is in)2.609 F -.2(vo)-.4 G -.1 -(ke).2 G(d).1 E(or a shell script is e)144 324 Q -.15(xe)-.15 G(cuted.) -.15 E F1 -.74(PA)108 336 S(TH)-.21 E F0 .588 -(The search path for commands.)9.91 F .587 +(system dependent \(e.g., /v)144 336 Q(ar/mail/)-.25 E F1($USER)A F0 +(\).)A F1(OPTERR)108 348 Q F0 .389(If set to the v)144 360 R .389 +(alue 1,)-.25 F F1(bash)2.889 E F0 .389 +(displays error messages generated by the)2.889 F F1(getopts)2.89 E F0 +-.2(bu)2.89 G .39(iltin command \(see).2 F F2 .36(SHELL B)144 372 R(UIL) +-.09 E .36(TIN COMMANDS)-.828 F F0(belo)2.61 E(w\).)-.25 E F2(OPTERR) +5.36 E F0 .359(is initialized to 1 each time the shell is in)2.61 F -.2 +(vo)-.4 G -.1(ke).2 G(d).1 E(or a shell script is e)144 384 Q -.15(xe) +-.15 G(cuted.).15 E F1 -.74(PA)108 396 S(TH)-.21 E F0 .587 +(The search path for commands.)9.91 F .588 (It is a colon-separated list of directories in which the shell looks) -5.588 F .471(for commands \(see)144 348 R F2 .471(COMMAND EXECUTION) -2.971 F F0(belo)2.722 E 2.972(w\). A)-.25 F .472 -(zero-length \(null\) directory name in the)2.972 F -.25(va)144 360 S -.536(lue of).25 F F2 -.666(PA)3.036 G(TH)-.189 E F0 .535 -(indicates the current directory)2.786 F 5.535(.A)-.65 G .535 -(null directory name may appear as tw)-2.5 F 3.035(oa)-.1 G(djacent) --3.035 E .867(colons, or as an initial or trailing colon.)144 372 R .868 -(The def)5.868 F .868(ault path is system-dependent, and is set by the) --.1 F 26.329(administrator who installs)144 384 R F1(bash)28.829 E F0 -31.329(.A)C 26.328(common v)-2.501 F 26.328(alue is)-.25 F/F4 10 -/Courier@0 SF -(/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)144 396 Q -F0(.)A F1(POSIXL)108 408 Q(Y_CORRECT)-.92 E F0 .471(If this v)144 420 R -.471(ariable is in the en)-.25 F .471(vironment when)-.4 F F1(bash)2.971 -E F0 .471(starts, the shell enters)2.971 F/F5 10/Times-Italic@0 SF .472 -(posix mode)2.972 F F0 .472(before reading)2.972 F .011 -(the startup \214les, as if the)144 432 R F1(\255\255posix)2.511 E F0 +5.587 F .472(for commands \(see)144 408 R F2 .472(COMMAND EXECUTION) +2.972 F F0(belo)2.722 E 2.972(w\). A)-.25 F .471 +(zero-length \(null\) directory name in the)2.972 F -.25(va)144 420 S +.535(lue of).25 F F2 -.666(PA)3.035 G(TH)-.189 E F0 .535 +(indicates the current directory)2.785 F 5.535(.A)-.65 G .535 +(null directory name may appear as tw)-2.5 F 3.036(oa)-.1 G(djacent) +-3.036 E .868(colons, or as an initial or trailing colon.)144 432 R .868 +(The def)5.868 F .867(ault path is system-dependent, and is set by the) +-.1 F 26.328(administrator who installs)144 444 R F1(bash)28.828 E F0 +31.329(.A)C 26.329(common v)-2.5 F 26.329(alue is)-.25 F/F4 10/Courier@0 +SF(/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)144 456 +Q F0(.)A F1(POSIXL)108 468 Q(Y_CORRECT)-.92 E F0 .472(If this v)144 480 +R .472(ariable is in the en)-.25 F .471(vironment when)-.4 F F1(bash) +2.971 E F0 .471(starts, the shell enters)2.971 F/F5 10/Times-Italic@0 SF +.471(posix mode)2.971 F F0 .471(before reading)2.971 F .011 +(the startup \214les, as if the)144 492 R F1(\255\255posix)2.511 E F0 (in)2.511 E -.2(vo)-.4 G .011(cation option had been supplied.).2 F .011 -(If it is set while the shell is)5.011 F(running,)144 444 Q F1(bash)2.5 +(If it is set while the shell is)5.011 F(running,)144 504 Q F1(bash)2.5 E F0(enables)2.5 E F5(posix mode)2.5 E F0 2.5(,a)C 2.5(si)-2.5 G 2.5(ft) -2.5 G(he command)-2.5 E F4(set -o posix)2.5 E F0(had been e)2.5 E -.15 -(xe)-.15 G(cuted.).15 E F1(PR)108 456 Q(OMPT_COMMAND)-.3 E F0 -(If set, the v)144 468 Q(alue is e)-.25 E -.15(xe)-.15 G +(xe)-.15 G(cuted.).15 E F1(PR)108 516 Q(OMPT_COMMAND)-.3 E F0 +(If set, the v)144 528 Q(alue is e)-.25 E -.15(xe)-.15 G (cuted as a command prior to issuing each primary prompt.).15 E F1(PR) -108 480 Q(OMPT_DIR)-.3 E(TRIM)-.4 E F0 .676 -(If set to a number greater than zero, the v)144 492 R .676 +108 540 Q(OMPT_DIR)-.3 E(TRIM)-.4 E F0 .676 +(If set to a number greater than zero, the v)144 552 R .676 (alue is used as the number of trailing directory compo-)-.25 F .923 -(nents to retain when e)144 504 R .923(xpanding the)-.15 F F1(\\w)3.423 +(nents to retain when e)144 564 R .923(xpanding the)-.15 F F1(\\w)3.423 E F0(and)3.423 E F1(\\W)3.423 E F0 .923(prompt string escapes \(see) 3.423 F F2(PR)3.423 E(OMPTING)-.27 E F0(belo)3.173 E(w\).)-.25 E -(Characters remo)144 516 Q -.15(ve)-.15 G 2.5(da).15 G -(re replaced with an ellipsis.)-2.5 E F1(PS1)108 528 Q F0 .064(The v) +(Characters remo)144 576 Q -.15(ve)-.15 G 2.5(da).15 G +(re replaced with an ellipsis.)-2.5 E F1(PS1)108 588 Q F0 .065(The v) 19.33 F .065(alue of this parameter is e)-.25 F .065(xpanded \(see)-.15 F F2(PR)2.565 E(OMPTING)-.27 E F0(belo)2.315 E .065 -(w\) and used as the primary prompt)-.25 F 2.5(string. The)144 540 R +(w\) and used as the primary prompt)-.25 F 2.5(string. The)144 600 R (def)2.5 E(ault v)-.1 E(alue is `)-.25 E(`)-.74 E F1(\\s\255\\v\\$)A F0 --.74('')2.5 G(.).74 E F1(PS2)108 552 Q F0 .118(The v)19.33 F .118 -(alue of this parameter is e)-.25 F .118(xpanded as with)-.15 F F2(PS1) -2.617 E F0 .117(and used as the secondary prompt string.)2.367 F(The) -5.117 E(def)144 564 Q(ault is `)-.1 E(`)-.74 E F1(>)A F0 -.74('')2.5 G -(.).74 E F1(PS3)108 576 Q F0 1.115(The v)19.33 F 1.115 +-.74('')2.5 G(.).74 E F1(PS2)108 612 Q F0 .117(The v)19.33 F .117 +(alue of this parameter is e)-.25 F .117(xpanded as with)-.15 F F2(PS1) +2.617 E F0 .118(and used as the secondary prompt string.)2.368 F(The) +5.118 E(def)144 624 Q(ault is `)-.1 E(`)-.74 E F1(>)A F0 -.74('')2.5 G +(.).74 E F1(PS3)108 636 Q F0 1.116(The v)19.33 F 1.115 (alue of this parameter is used as the prompt for the)-.25 F F1(select) -3.615 E F0 1.116(command \(see)3.616 F F2 1.116(SHELL GRAM-)3.616 F(MAR) -144 588 Q F0(abo)2.25 E -.15(ve)-.15 G(\).).15 E F1(PS4)108 600 Q F0 -.101(The v)19.33 F .101(alue of this parameter is e)-.25 F .101 -(xpanded as with)-.15 F F2(PS1)2.6 E F0 .1(and the v)2.35 F .1 -(alue is printed before each command)-.25 F F1(bash)144 612 Q F0 .291 -(displays during an e)2.791 F -.15(xe)-.15 G .292(cution trace.).15 F -.292(The \214rst character of)5.292 F F2(PS4)2.792 E F0 .292 -(is replicated multiple times, as)2.542 F(necessary)144 624 Q 2.5(,t) +3.615 E F0 1.115(command \(see)3.615 F F2 1.115(SHELL GRAM-)3.615 F(MAR) +144 648 Q F0(abo)2.25 E -.15(ve)-.15 G(\).).15 E F1(PS4)108 660 Q F0 .1 +(The v)19.33 F .1(alue of this parameter is e)-.25 F .1(xpanded as with) +-.15 F F2(PS1)2.6 E F0 .101(and the v)2.35 F .101 +(alue is printed before each command)-.25 F F1(bash)144 672 Q F0 .292 +(displays during an e)2.792 F -.15(xe)-.15 G .292(cution trace.).15 F +.292(The \214rst character of)5.292 F F2(PS4)2.792 E F0 .291 +(is replicated multiple times, as)2.542 F(necessary)144 684 Q 2.5(,t) -.65 G 2.5(oi)-2.5 G(ndicate multiple le)-2.5 E -.15(ve)-.25 G (ls of indirection.).15 E(The def)5 E(ault is `)-.1 E(`)-.74 E F1(+)A F0 --.74('')2.5 G(.).74 E F1(SHELL)108 636 Q F0 .664 -(The full pathname to the shell is k)144 648 R .664(ept in this en)-.1 F -.664(vironment v)-.4 F 3.164(ariable. If)-.25 F .663 -(it is not set when the shell)3.164 F(starts,)144 660 Q F1(bash)2.5 E F0 +-.74('')2.5 G(.).74 E F1(SHELL)108 696 Q F0 .663 +(The full pathname to the shell is k)144 708 R .664(ept in this en)-.1 F +.664(vironment v)-.4 F 3.164(ariable. If)-.25 F .664 +(it is not set when the shell)3.164 F(starts,)144 720 Q F1(bash)2.5 E F0 (assigns to it the full pathname of the current user')2.5 E 2.5(sl)-.55 -G(ogin shell.)-2.5 E F1(TIMEFORMA)108 672 Q(T)-.95 E F0 .826(The v)144 -684 R .826 -(alue of this parameter is used as a format string specifying ho)-.25 F -3.327(wt)-.25 G .827(he timing information for)-3.327 F .649 -(pipelines pre\214x)144 696 R .649(ed with the)-.15 F F1(time)3.149 E F0 -(reserv)3.149 E .649(ed w)-.15 F .648(ord should be displayed.)-.1 F -(The)5.648 E F1(%)3.148 E F0 .648(character introduces)3.148 F .711 -(an escape sequence that is e)144 708 R .711(xpanded to a time v)-.15 F -.712(alue or other information.)-.25 F .712(The escape sequences)5.712 F -(and their meanings are as follo)144 720 Q -(ws; the braces denote optional portions.)-.25 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(16)198.165 E 0 Cg EP +G(ogin shell.)-2.5 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve) +-.15 G(mber 24).15 E(16)185.545 E 0 Cg EP %%Page: 17 17 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(%%)144 84 Q F0 2.5(Al)30 G(iteral)-2.5 E F1 -(%)2.5 E F0(.)A F1(%[)144 96 Q/F2 10/Times-Italic@0 SF(p)A F1(][l]R)A F0 -(The elapsed time in seconds.)11.68 E F1(%[)144 108 Q F2(p)A F1(][l]U)A -F0(The number of CPU seconds spent in user mode.)11.68 E F1(%[)144 120 Q +-.35 E/F1 10/Times-Bold@0 SF(TIMEFORMA)108 84 Q(T)-.95 E F0 .827(The v) +144 96 R .826 +(alue of this parameter is used as a format string specifying ho)-.25 F +3.326(wt)-.25 G .826(he timing information for)-3.326 F .648 +(pipelines pre\214x)144 108 R .648(ed with the)-.15 F F1(time)3.148 E F0 +(reserv)3.148 E .648(ed w)-.15 F .649(ord should be displayed.)-.1 F +(The)5.649 E F1(%)3.149 E F0 .649(character introduces)3.149 F .712 +(an escape sequence that is e)144 120 R .711(xpanded to a time v)-.15 F +.711(alue or other information.)-.25 F .711(The escape sequences)5.711 F +(and their meanings are as follo)144 132 Q +(ws; the braces denote optional portions.)-.25 E F1(%%)144 150 Q F0 2.5 +(Al)30 G(iteral)-2.5 E F1(%)2.5 E F0(.)A F1(%[)144 162 Q/F2 10 +/Times-Italic@0 SF(p)A F1(][l]R)A F0(The elapsed time in seconds.)11.68 +E F1(%[)144 174 Q F2(p)A F1(][l]U)A F0 +(The number of CPU seconds spent in user mode.)11.68 E F1(%[)144 186 Q F2(p)A F1(][l]S)A F0(The number of CPU seconds spent in system mode.) -13.34 E F1(%P)144 132 Q F0 +13.34 E F1(%P)144 198 Q F0 (The CPU percentage, computed as \(%U + %S\) / %R.)33.89 E .87 -(The optional)144 148.8 R F2(p)3.37 E F0 .87(is a digit specifying the) +(The optional)144 214.8 R F2(p)3.37 E F0 .87(is a digit specifying the) 3.37 F F2(pr)3.37 E(ecision)-.37 E F0 3.37(,t)C .87 -(he number of fractional digits after a decimal)-3.37 F 2.525(point. A) -144 160.8 R -.25(va)2.525 G .025 -(lue of 0 causes no decimal point or fraction to be output.).25 F .026 -(At most three places after the)5.025 F .538 -(decimal point may be speci\214ed; v)144 172.8 R .538(alues of)-.25 F F2 -(p)3.038 E F0 .537(greater than 3 are changed to 3.)3.037 F(If)5.537 E -F2(p)3.037 E F0 .537(is not speci\214ed,)3.037 F(the v)144 184.8 Q -(alue 3 is used.)-.25 E .667(The optional)144 201.6 R F1(l)3.167 E F0 +(he number of fractional digits after a decimal)-3.37 F 2.526(point. A) +144 226.8 R -.25(va)2.526 G .025 +(lue of 0 causes no decimal point or fraction to be output.).25 F .025 +(At most three places after the)5.025 F .537 +(decimal point may be speci\214ed; v)144 238.8 R .537(alues of)-.25 F F2 +(p)3.037 E F0 .537(greater than 3 are changed to 3.)3.037 F(If)5.538 E +F2(p)3.038 E F0 .538(is not speci\214ed,)3.038 F(the v)144 250.8 Q +(alue 3 is used.)-.25 E .668(The optional)144 267.6 R F1(l)3.168 E F0 .668(speci\214es a longer format, including minutes, of the form)3.168 F -F2(MM)3.168 E F0(m)A F2(SS)A F0(.)A F2(FF)A F0 3.168(s. The)B -.25(va) -3.168 G(lue).25 E(of)144 213.6 Q F2(p)2.5 E F0 -(determines whether or not the fraction is included.)2.5 E .001 -(If this v)144 230.4 R .001(ariable is not set,)-.25 F F1(bash)2.501 E -F0 .001(acts as if it had the v)2.501 F(alue)-.25 E F1($\010\\nr)2.5 E -(eal\\t%3lR\\nuser\\t%3lU\\nsys%3lS\010)-.18 E F0(.)A .494(If the v)144 -242.4 R .494(alue is null, no timing information is displayed.)-.25 F -2.994(At)5.494 G .494(railing ne)-2.994 F .494 -(wline is added when the for)-.25 F(-)-.2 E(mat string is displayed.)144 -254.4 Q F1(TMOUT)108 266.4 Q F0 .941(If set to a v)144 278.4 R .941 -(alue greater than zero,)-.25 F/F3 9/Times-Bold@0 SF(TMOUT)3.441 E F0 -.941(is treated as the def)3.191 F .941(ault timeout for the)-.1 F F1 --.18(re)3.441 G(ad).18 E F0 -.2(bu)3.441 G(iltin.).2 E(The)144 290.4 Q -F1(select)2.81 E F0 .31(command terminates if input does not arri)2.81 F -.611 -.15(ve a)-.25 H(fter).15 E F3(TMOUT)2.811 E F0 .311 -(seconds when input is com-)2.561 F .886(ing from a terminal.)144 302.4 -R .886(In an interacti)5.886 F 1.185 -.15(ve s)-.25 H .885(hell, the v) -.15 F .885(alue is interpreted as the number of seconds to)-.25 F -.1 -(wa)144 314.4 S 1.05 -(it for a line of input after issuing the primary prompt.).1 F F1(Bash) -6.05 E F0 1.05(terminates after w)3.55 F 1.05(aiting for that)-.1 F -(number of seconds if a complete line of input does not arri)144 326.4 Q --.15(ve)-.25 G(.).15 E F1(TMPDIR)108 338.4 Q F0 .391(If set,)144 350.4 R -F1(bash)2.891 E F0 .391(uses its v)2.891 F .391 -(alue as the name of a directory in which)-.25 F F1(bash)2.89 E F0 .39 -(creates temporary \214les for the)2.89 F(shell')144 362.4 Q 2.5(su)-.55 -G(se.)-2.5 E F1(auto_r)108 374.4 Q(esume)-.18 E F0 .53(This v)144 386.4 -R .53(ariable controls ho)-.25 F 3.03(wt)-.25 G .531 -(he shell interacts with the user and job control.)-3.03 F .531 -(If this v)5.531 F .531(ariable is set,)-.25 F .539(single w)144 398.4 R +F2(MM)3.168 E F0(m)A F2(SS)A F0(.)A F2(FF)A F0 3.167(s. The)B -.25(va) +3.167 G(lue).25 E(of)144 279.6 Q F2(p)2.5 E F0 +(determines whether or not the fraction is included.)2.5 E 13.364 +(If this v)144 296.4 R 13.364(ariable is not set,)-.25 F F1(bash)15.865 +E F0 13.365(acts as if it had the v)15.865 F(alue)-.25 E F1($\010\\nr) +144 308.4 Q(eal\\t%3lR\\nuser\\t%3lU\\nsys\\%3lS\010)-.18 E F0 7.446(.I) +C 4.946(ft)-7.446 G 2.446(he v)-4.946 F 2.446 +(alue is null, no timing information is dis-)-.25 F 2.5(played. A)144 +320.4 R(trailing ne)2.5 E +(wline is added when the format string is displayed.)-.25 E F1(TMOUT)108 +332.4 Q F0 .941(If set to a v)144 344.4 R .941(alue greater than zero,) +-.25 F/F3 9/Times-Bold@0 SF(TMOUT)3.441 E F0 .941(is treated as the def) +3.191 F .941(ault timeout for the)-.1 F F1 -.18(re)3.441 G(ad).18 E F0 +-.2(bu)3.441 G(iltin.).2 E(The)144 356.4 Q F1(select)2.811 E F0 .311 +(command terminates if input does not arri)2.811 F .61 -.15(ve a)-.25 H +(fter).15 E F3(TMOUT)2.81 E F0 .31(seconds when input is com-)2.56 F +.885(ing from a terminal.)144 368.4 R .885(In an interacti)5.885 F 1.185 +-.15(ve s)-.25 H .885(hell, the v).15 F .886 +(alue is interpreted as the number of seconds to)-.25 F -.1(wa)144 380.4 +S 1.05(it for a line of input after issuing the primary prompt.).1 F F1 +(Bash)6.05 E F0 1.05(terminates after w)3.55 F 1.05(aiting for that)-.1 +F(number of seconds if a complete line of input does not arri)144 392.4 +Q -.15(ve)-.25 G(.).15 E F1(TMPDIR)108 404.4 Q F0 .39(If set,)144 416.4 +R F1(bash)2.89 E F0 .39(uses its v)2.89 F .39 +(alue as the name of a directory in which)-.25 F F1(bash)2.891 E F0 .391 +(creates temporary \214les for the)2.891 F(shell')144 428.4 Q 2.5(su) +-.55 G(se.)-2.5 E F1(auto_r)108 440.4 Q(esume)-.18 E F0 .531(This v)144 +452.4 R .531(ariable controls ho)-.25 F 3.031(wt)-.25 G .531 +(he shell interacts with the user and job control.)-3.031 F .53 +(If this v)5.53 F .53(ariable is set,)-.25 F .538(single w)144 464.4 R .538(ord simple commands without redirections are treated as candidates\ - for resumption of an)-.1 F -.15(ex)144 410.4 S .366(isting stopped job) -.15 F 5.366(.T)-.4 G .366(here is no ambiguity allo)-5.366 F .366 -(wed; if there is more than one job be)-.25 F .367(ginning with)-.15 F -1.125(the string typed, the job most recently accessed is selected.)144 -422.4 R(The)6.125 E F2(name)3.985 E F0 1.124(of a stopped job, in this) -3.805 F(conte)144 434.4 Q 1.132 + for resumption of an)-.1 F -.15(ex)144 476.4 S .367(isting stopped job) +.15 F 5.367(.T)-.4 G .366(here is no ambiguity allo)-5.367 F .366 +(wed; if there is more than one job be)-.25 F .366(ginning with)-.15 F +1.124(the string typed, the job most recently accessed is selected.)144 +488.4 R(The)6.125 E F2(name)3.985 E F0 1.125(of a stopped job, in this) +3.805 F(conte)144 500.4 Q 1.133 (xt, is the command line used to start it.)-.15 F 1.133(If set to the v) -6.133 F(alue)-.25 E F2 -.2(ex)3.633 G(act).2 E F0 3.633(,t).68 G 1.133 -(he string supplied must)-3.633 F .625 -(match the name of a stopped job e)144 446.4 R .624(xactly; if set to) --.15 F F2(substring)3.124 E F0 3.124(,t).22 G .624 -(he string supplied needs to match a)-3.124 F .884 -(substring of the name of a stopped job)144 458.4 R 5.884(.T)-.4 G(he) --5.884 E F2(substring)3.724 E F0 -.25(va)3.604 G .885(lue pro).25 F .885 -(vides functionality analogous to)-.15 F(the)144 470.4 Q F1(%?)3.334 E -F0 .834(job identi\214er \(see)5.834 F F3 .834(JOB CONTR)3.334 F(OL)-.27 +6.133 F(alue)-.25 E F2 -.2(ex)3.633 G(act).2 E F0 3.632(,t).68 G 1.132 +(he string supplied must)-3.632 F .624 +(match the name of a stopped job e)144 512.4 R .624(xactly; if set to) +-.15 F F2(substring)3.125 E F0 3.125(,t).22 G .625 +(he string supplied needs to match a)-3.125 F .885 +(substring of the name of a stopped job)144 524.4 R 5.884(.T)-.4 G(he) +-5.884 E F2(substring)3.724 E F0 -.25(va)3.604 G .884(lue pro).25 F .884 +(vides functionality analogous to)-.15 F(the)144 536.4 Q F1(%?)3.333 E +F0 .833(job identi\214er \(see)5.833 F F3 .834(JOB CONTR)3.334 F(OL)-.27 E F0(belo)3.084 E 3.334(w\). If)-.25 F .834(set to an)3.334 F 3.334(yo) --.15 G .834(ther v)-3.334 F .833(alue, the supplied string)-.25 F .315 -(must be a pre\214x of a stopped job')144 482.4 R 2.816(sn)-.55 G .316 -(ame; this pro)-2.816 F .316(vides functionality analogous to the)-.15 F -F1(%)2.816 E F2(string)A F0(job)2.816 E(identi\214er)144 494.4 Q(.)-.55 -E F1(histchars)108 506.4 Q F0 2.07(The tw)144 518.4 R 4.57(oo)-.1 G 4.57 -(rt)-4.57 G 2.07(hree characters which control history e)-4.57 F 2.07 -(xpansion and tok)-.15 F 2.07(enization \(see)-.1 F F3(HIST)4.569 E(OR) --.162 E(Y)-.315 E(EXP)144 530.4 Q(ANSION)-.666 E F0(belo)3.465 E 3.715 -(w\). The)-.25 F 1.215(\214rst character is the)3.715 F F2 1.216 -(history e)3.715 F(xpansion)-.2 E F0(character)3.716 E 3.716(,t)-.4 G -1.216(he character which)-3.716 F .798(signals the start of a history e) -144 542.4 R .798(xpansion, normally `)-.15 F F1(!)A F0 3.298('. The)B +-.15 G .834(ther v)-3.334 F .834(alue, the supplied string)-.25 F .316 +(must be a pre\214x of a stopped job')144 548.4 R 2.816(sn)-.55 G .316 +(ame; this pro)-2.816 F .315(vides functionality analogous to the)-.15 F +F1(%)2.815 E F2(string)A F0(job)2.815 E(identi\214er)144 560.4 Q(.)-.55 +E F1(histchars)108 572.4 Q F0 2.069(The tw)144 584.4 R 4.57(oo)-.1 G +4.57(rt)-4.57 G 2.07(hree characters which control history e)-4.57 F +2.07(xpansion and tok)-.15 F 2.07(enization \(see)-.1 F F3(HIST)4.57 E +(OR)-.162 E(Y)-.315 E(EXP)144 596.4 Q(ANSION)-.666 E F0(belo)3.466 E +3.716(w\). The)-.25 F 1.216(\214rst character is the)3.716 F F2 1.215 +(history e)3.715 F(xpansion)-.2 E F0(character)3.715 E 3.715(,t)-.4 G +1.215(he character which)-3.715 F .798(signals the start of a history e) +144 608.4 R .798(xpansion, normally `)-.15 F F1(!)A F0 3.298('. The)B .798(second character is the)3.298 F F2(quic)3.298 E 3.298(ks)-.2 G -(ubstitu-)-3.298 E(tion)144 554.4 Q F0(character)2.739 E 2.739(,w)-.4 G -.239(hich is used as shorthand for re-running the pre)-2.739 F .24 -(vious command entered, substitut-)-.25 F .576 -(ing one string for another in the command.)144 566.4 R .575(The def) -5.575 F .575(ault is `)-.1 F F1(^)A F0 3.075('. The)B .575 -(optional third character is the)3.075 F .223(character which indicates\ +(ubstitu-)-3.298 E(tion)144 620.4 Q F0(character)2.74 E 2.74(,w)-.4 G +.239(hich is used as shorthand for re-running the pre)-2.74 F .239 +(vious command entered, substitut-)-.25 F .575 +(ing one string for another in the command.)144 632.4 R .575(The def) +5.575 F .575(ault is `)-.1 F F1(^)A F0 3.075('. The)B .576 +(optional third character is the)3.076 F .223(character which indicates\ that the remainder of the line is a comment when found as the \214rst \ -char)144 578.4 R(-)-.2 E 1.294(acter of a w)144 590.4 R 1.294 -(ord, normally `)-.1 F F1(#)A F0 3.794('. The)B 1.293 -(history comment character causes history substitution to be)3.794 F -.379(skipped for the remaining w)144 602.4 R .379(ords on the line.)-.1 -F .38(It does not necessarily cause the shell parser to treat)5.379 F -(the rest of the line as a comment.)144 614.4 Q F1(Arrays)87 631.2 Q -(Bash)108 643.2 Q F0(pro)3.391 E .891(vides one-dimensional inde)-.15 F --.15(xe)-.15 G 3.391(da).15 G .891(nd associati)-3.391 F 1.191 -.15 -(ve a)-.25 H .891(rray v).15 F 3.391(ariables. An)-.25 F 3.391(yv)-.15 G -.89(ariable may be used as an)-3.641 F(inde)108 655.2 Q -.15(xe)-.15 G -2.573(da).15 G .073(rray; the)-2.573 F F1(declar)2.573 E(e)-.18 E F0 -.2 -(bu)2.573 G .073(iltin will e).2 F .073(xplicitly declare an array)-.15 -F 5.073(.T)-.65 G .074(here is no maximum limit on the size of)-5.073 F -.329(an array)108 667.2 R 2.829(,n)-.65 G .329(or an)-2.829 F 2.829(yr) --.15 G .329(equirement that members be inde)-2.829 F -.15(xe)-.15 G -2.829(do).15 G 2.829(ra)-2.829 G .328(ssigned contiguously)-2.829 F -5.328(.I)-.65 G(nde)-5.328 E -.15(xe)-.15 G 2.828(da).15 G .328 -(rrays are refer)-2.828 F(-)-.2 E 1.386(enced using inte)108 679.2 R -1.386(gers \(including arithmetic e)-.15 F 3.887(xpressions\) and)-.15 F -1.387(are zero-based; associati)3.887 F 1.687 -.15(ve a)-.25 H 1.387 -(rrays are refer).15 F(-)-.2 E .22(enced using arbitrary strings.)108 -691.2 R .219(Unless otherwise noted, inde)5.219 F -.15(xe)-.15 G 2.719 -(da).15 G .219(rray indices must be non-ne)-2.719 F -.05(ga)-.15 G(ti) -.05 E .519 -.15(ve i)-.25 H(nte).15 E(gers.)-.15 E 2.462(An inde)108 708 -R -.15(xe)-.15 G 4.962(da).15 G 2.462 -(rray is created automatically if an)-4.962 F 4.963(yv)-.15 G 2.463 -(ariable is assigned to using the syntax)-5.213 F F2(name)4.963 E F0([)A -F2(sub-)A(script)108 720 Q F0(]=)A F2(value)A F0 6.549(.T)C(he)-6.549 E -F2(subscript)4.389 E F0 1.549(is treated as an arithmetic e)4.729 F -1.549(xpression that must e)-.15 F -.25(va)-.25 G 1.548 -(luate to a number).25 F 6.548(.T)-.55 G(o)-7.348 E(GNU Bash 4.2)72 768 -Q(2012 July 14)149.005 E(17)198.165 E 0 Cg EP +char)144 644.4 R(-)-.2 E 1.293(acter of a w)144 656.4 R 1.293 +(ord, normally `)-.1 F F1(#)A F0 3.793('. The)B 1.294 +(history comment character causes history substitution to be)3.794 F .38 +(skipped for the remaining w)144 668.4 R .38(ords on the line.)-.1 F +.379(It does not necessarily cause the shell parser to treat)5.379 F +(the rest of the line as a comment.)144 680.4 Q F1(Arrays)87 697.2 Q +(Bash)108 709.2 Q F0(pro)3.39 E .89(vides one-dimensional inde)-.15 F +-.15(xe)-.15 G 3.39(da).15 G .891(nd associati)-3.39 F 1.191 -.15(ve a) +-.25 H .891(rray v).15 F 3.391(ariables. An)-.25 F 3.391(yv)-.15 G .891 +(ariable may be used as an)-3.641 F(inde)108 721.2 Q -.15(xe)-.15 G +2.574(da).15 G .074(rray; the)-2.574 F F1(declar)2.574 E(e)-.18 E F0 -.2 +(bu)2.574 G .074(iltin will e).2 F .073(xplicitly declare an array)-.15 +F 5.073(.T)-.65 G .073(here is no maximum limit on the size of)-5.073 F +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(17)185.545 E 0 Cg EP %%Page: 18 18 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E -.15(ex)108 84 S 1.979(plicitly declare an inde).15 F -.15(xe) --.15 G 4.479(da).15 G(rray)-4.479 E 4.48(,u)-.65 G(se)-4.48 E/F1 10 -/Times-Bold@0 SF(declar)4.48 E 4.48<65ad>-.18 G(a)-4.48 E/F2 10 -/Times-Italic@0 SF(name)4.48 E F0(\(see)4.48 E/F3 9/Times-Bold@0 SF 1.98 -(SHELL B)4.48 F(UIL)-.09 E 1.98(TIN COMMANDS)-.828 F F0(belo)4.23 E -(w\).)-.25 E F1(declar)108 96 Q 2.5<65ad>-.18 G(a)-2.5 E F2(name)2.5 E -F1([)A F2(subscript)A F1(])A F0(is also accepted; the)2.5 E F2 -(subscript)2.5 E F0(is ignored.)2.5 E(Associati)108 112.8 Q .3 -.15 -(ve a)-.25 H(rrays are created using).15 E F1(declar)2.5 E 2.5<65ad>-.18 -G(A)-2.5 E F2(name)2.5 E F0(.)A(Attrib)108 129.6 Q .941 +-.35 E .328(an array)108 84 R 2.828(,n)-.65 G .328(or an)-2.828 F 2.828 +(yr)-.15 G .329(equirement that members be inde)-2.828 F -.15(xe)-.15 G +2.829(do).15 G 2.829(ra)-2.829 G .329(ssigned contiguously)-2.829 F +5.329(.I)-.65 G(nde)-5.329 E -.15(xe)-.15 G 2.829(da).15 G .329 +(rrays are refer)-2.829 F(-)-.2 E 1.387(enced using inte)108 96 R 1.387 +(gers \(including arithmetic e)-.15 F 3.887(xpressions\) and)-.15 F +1.387(are zero-based; associati)3.887 F 1.686 -.15(ve a)-.25 H 1.386 +(rrays are refer).15 F(-)-.2 E .219(enced using arbitrary strings.)108 +108 R .219(Unless otherwise noted, inde)5.219 F -.15(xe)-.15 G 2.719(da) +.15 G .219(rray indices must be non-ne)-2.719 F -.05(ga)-.15 G(ti).05 E +.52 -.15(ve i)-.25 H(nte).15 E(gers.)-.15 E 2.463(An inde)108 124.8 R +-.15(xe)-.15 G 4.963(da).15 G 2.463(rray is created automatically if an) +-4.963 F 4.963(yv)-.15 G 2.462(ariable is assigned to using the syntax) +-5.213 F/F1 10/Times-Italic@0 SF(name)4.962 E F0([)A F1(sub-)A(script) +108 136.8 Q F0(]=)A F1(value)A F0 6.548(.T)C(he)-6.548 E F1(subscript) +4.388 E F0 1.549(is treated as an arithmetic e)4.728 F 1.549 +(xpression that must e)-.15 F -.25(va)-.25 G 1.549(luate to a number).25 +F 6.549(.T)-.55 G(o)-7.349 E -.15(ex)108 148.8 S 1.98 +(plicitly declare an inde).15 F -.15(xe)-.15 G 4.48(da).15 G(rray)-4.48 +E 4.48(,u)-.65 G(se)-4.48 E/F2 10/Times-Bold@0 SF(declar)4.48 E 4.48 +<65ad>-.18 G(a)-4.48 E F1(name)4.48 E F0(\(see)4.48 E/F3 9/Times-Bold@0 +SF 1.979(SHELL B)4.479 F(UIL)-.09 E 1.979(TIN COMMANDS)-.828 F F0(belo) +4.229 E(w\).)-.25 E F2(declar)108 160.8 Q 2.5<65ad>-.18 G(a)-2.5 E F1 +(name)2.5 E F2([)A F1(subscript)A F2(])A F0(is also accepted; the)2.5 E +F1(subscript)2.5 E F0(is ignored.)2.5 E(Associati)108 177.6 Q .3 -.15 +(ve a)-.25 H(rrays are created using).15 E F2(declar)2.5 E 2.5<65ad>-.18 +G(A)-2.5 E F1(name)2.5 E F0(.)A(Attrib)108 194.4 Q .94 (utes may be speci\214ed for an array v)-.2 F .941(ariable using the) --.25 F F1(declar)3.441 E(e)-.18 E F0(and)3.44 E F1 -.18(re)3.44 G -(adonly).18 E F0 -.2(bu)3.44 G 3.44(iltins. Each).2 F(attrib)3.44 E(ute) --.2 E(applies to all members of an array)108 141.6 Q(.)-.65 E 1.647 -(Arrays are assigned to using compound assignments of the form)108 158.4 -R F2(name)4.147 E F0(=)A F1(\()A F0 -.25(va)C(lue).25 E F2(1)A F0 1.647 -(... v)4.147 F(alue)-.25 E F2(n)A F1(\))A F0 4.148(,w)C 1.648(here each) --4.148 F F2(value)108 170.4 Q F0 1.833(is of the form [)4.333 F F2 -(subscript)A F0(]=)A F2(string)A F0 6.833(.I)C(nde)-6.833 E -.15(xe)-.15 -G 4.333(da).15 G 1.833(rray assignments do not require an)-4.333 F 1.832 -(ything b)-.15 F(ut)-.2 E F2(string)4.332 E F0(.)A .163 -(When assigning to inde)108 182.4 R -.15(xe)-.15 G 2.663(da).15 G .163 +-.25 F F2(declar)3.441 E(e)-.18 E F0(and)3.441 E F2 -.18(re)3.441 G +(adonly).18 E F0 -.2(bu)3.441 G 3.441(iltins. Each).2 F(attrib)3.441 E +(ute)-.2 E(applies to all members of an array)108 206.4 Q(.)-.65 E 1.647 +(Arrays are assigned to using compound assignments of the form)108 223.2 +R F1(name)4.147 E F0(=)A F2(\()A F0 -.25(va)C(lue).25 E F1(1)A F0 1.647 +(... v)4.147 F(alue)-.25 E F1(n)A F2(\))A F0 4.147(,w)C 1.647(here each) +-4.147 F F1(value)108 235.2 Q F0 1.833(is of the form [)4.332 F F1 +(subscript)A F0(]=)A F1(string)A F0 6.833(.I)C(nde)-6.833 E -.15(xe)-.15 +G 4.333(da).15 G 1.833(rray assignments do not require an)-4.333 F 1.833 +(ything b)-.15 F(ut)-.2 E F1(string)4.333 E F0(.)A .164 +(When assigning to inde)108 247.2 R -.15(xe)-.15 G 2.663(da).15 G .163 (rrays, if the optional brack)-2.663 F .163 -(ets and subscript are supplied, that inde)-.1 F 2.664(xi)-.15 G 2.664 -(sa)-2.664 G(ssigned)-2.664 E 1.411(to; otherwise the inde)108 194.4 R -3.911(xo)-.15 G 3.911(ft)-3.911 G 1.411 -(he element assigned is the last inde)-3.911 F 3.91(xa)-.15 G 1.41 -(ssigned to by the statement plus one.)-3.91 F(Inde)108 206.4 Q -(xing starts at zero.)-.15 E(When assigning to an associati)108 223.2 Q -.3 -.15(ve a)-.25 H(rray).15 E 2.5(,t)-.65 G(he subscript is required.) --2.5 E .239(This syntax is also accepted by the)108 240 R F1(declar) -2.739 E(e)-.18 E F0 -.2(bu)2.739 G 2.739(iltin. Indi).2 F .24 -(vidual array elements may be assigned to using the)-.25 F F2(name)108 -252 Q F0([)A F2(subscript)A F0(]=)A F2(value)A F0(syntax introduced abo) -2.5 E -.15(ve)-.15 G(.).15 E(An)108 268.8 Q 3.576(ye)-.15 G 1.076 -(lement of an array may be referenced using ${)-3.576 F F2(name)A F0([)A -F2(subscript)A F0 3.575(]}. The)B 1.075(braces are required to a)3.575 F --.2(vo)-.2 G(id).2 E 1.541(con\215icts with pathname e)108 280.8 R 4.041 -(xpansion. If)-.15 F F2(subscript)4.041 E F0(is)4.041 E F1(@)4.041 E F0 -(or)4.041 E F1(*)4.041 E F0 4.041(,t)C 1.541(he w)-4.041 F 1.541(ord e) --.1 F 1.541(xpands to all members of)-.15 F F2(name)4.042 E F0(.)A 1.057 -(These subscripts dif)108 292.8 R 1.057(fer only when the w)-.25 F 1.057 +(ets and subscript are supplied, that inde)-.1 F 2.663(xi)-.15 G 2.663 +(sa)-2.663 G(ssigned)-2.663 E 1.41(to; otherwise the inde)108 259.2 R +3.91(xo)-.15 G 3.91(ft)-3.91 G 1.41 +(he element assigned is the last inde)-3.91 F 3.911(xa)-.15 G 1.411 +(ssigned to by the statement plus one.)-3.911 F(Inde)108 271.2 Q +(xing starts at zero.)-.15 E(When assigning to an associati)108 288 Q .3 +-.15(ve a)-.25 H(rray).15 E 2.5(,t)-.65 G(he subscript is required.)-2.5 +E .24(This syntax is also accepted by the)108 304.8 R F2(declar)2.74 E +(e)-.18 E F0 -.2(bu)2.739 G 2.739(iltin. Indi).2 F .239 +(vidual array elements may be assigned to using the)-.25 F F1(name)108 +316.8 Q F0([)A F1(subscript)A F0(]=)A F1(value)A F0 1.917 +(syntax introduced abo)4.416 F -.15(ve)-.15 G 6.917(.W).15 G 1.917 +(hen assigning to an inde)-6.917 F -.15(xe)-.15 G 4.417(da).15 G(rray) +-4.417 E 4.417(,i)-.65 G(f)-4.417 E F1(name)4.777 E F0 1.917(is sub-) +4.597 F .116(scripted by a ne)108 328.8 R -.05(ga)-.15 G(ti).05 E .416 +-.15(ve n)-.25 H(umber).15 E 2.616(,t)-.4 G .115 +(hat number is interpreted as relati)-2.616 F .415 -.15(ve t)-.25 H +2.615(oo).15 G .115(ne greater than the maximum inde)-2.615 F(x)-.15 E +(of)108 340.8 Q F1(name)3.338 E F0 3.338(,s)C 3.338(on)-3.338 G -2.25 +-.15(eg a)-3.338 H(ti).15 E 1.138 -.15(ve i)-.25 H .838 +(ndices count back from the end of the array).15 F 3.338(,a)-.65 G .838 +(nd an inde)-3.338 F 3.338(xo)-.15 G 3.338<66ad>-3.338 G 3.338(1r)-3.338 +G .838(eferences the last)-3.338 F(element.)108 352.8 Q(An)108 369.6 Q +3.576(ye)-.15 G 1.076(lement of an array may be referenced using ${) +-3.576 F F1(name)A F0([)A F1(subscript)A F0 3.575(]}. The)B 1.075 +(braces are required to a)3.575 F -.2(vo)-.2 G(id).2 E 1.541 +(con\215icts with pathname e)108 381.6 R 4.041(xpansion. If)-.15 F F1 +(subscript)4.041 E F0(is)4.041 E F2(@)4.041 E F0(or)4.041 E F2(*)4.041 E +F0 4.041(,t)C 1.541(he w)-4.041 F 1.541(ord e)-.1 F 1.541 +(xpands to all members of)-.15 F F1(name)4.042 E F0(.)A 1.057 +(These subscripts dif)108 393.6 R 1.057(fer only when the w)-.25 F 1.057 (ord appears within double quotes.)-.1 F 1.056(If the w)6.056 F 1.056 -(ord is double-quoted,)-.1 F(${)108 304.8 Q F2(name)A F0 .52([*]} e)B +(ord is double-quoted,)-.1 F(${)108 405.6 Q F1(name)A F0 .52([*]} e)B .52(xpands to a single w)-.15 F .52(ord with the v)-.1 F .521 (alue of each array member separated by the \214rst character)-.25 F -1.375(of the)108 316.8 R F3(IFS)3.875 E F0 1.375(special v)3.625 F 1.375 -(ariable, and ${)-.25 F F2(name)A F0 1.375([@]} e)B 1.375 -(xpands each element of)-.15 F F2(name)3.875 E F0 1.374(to a separate w) +1.375(of the)108 417.6 R F3(IFS)3.875 E F0 1.375(special v)3.625 F 1.375 +(ariable, and ${)-.25 F F1(name)A F0 1.375([@]} e)B 1.375 +(xpands each element of)-.15 F F1(name)3.875 E F0 1.374(to a separate w) 3.875 F 3.874(ord. When)-.1 F 2.027(there are no array members, ${)108 -328.8 R F2(name)A F0 2.028([@]} e)B 2.028(xpands to nothing.)-.15 F +429.6 R F1(name)A F0 2.028([@]} e)B 2.028(xpands to nothing.)-.15 F 2.028(If the double-quoted e)7.028 F 2.028(xpansion occurs)-.15 F .759 -(within a w)108 340.8 R .759(ord, the e)-.1 F .759 +(within a w)108 441.6 R .759(ord, the e)-.1 F .759 (xpansion of the \214rst parameter is joined with the be)-.15 F .759 (ginning part of the original w)-.15 F(ord,)-.1 E .515(and the e)108 -352.8 R .516(xpansion of the last parameter is joined with the last par\ +453.6 R .516(xpansion of the last parameter is joined with the last par\ t of the original w)-.15 F 3.016(ord. This)-.1 F .516(is analogous)3.016 -F .228(to the e)108 364.8 R .228(xpansion of the special parameters)-.15 -F F1(*)2.728 E F0(and)2.728 E F1(@)2.728 E F0(\(see)2.728 E F1 .228 +F .228(to the e)108 465.6 R .228(xpansion of the special parameters)-.15 +F F2(*)2.728 E F0(and)2.728 E F2(@)2.728 E F0(\(see)2.728 E F2 .228 (Special P)2.728 F(arameters)-.1 E F0(abo)2.727 E -.15(ve)-.15 G 2.727 -(\). ${#).15 F F2(name)A F0([)A F2(subscript)A F0(]})A -.15(ex)108 376.8 -S .886(pands to the length of ${).15 F F2(name)A F0([)A F2(subscript)A -F0 3.386(]}. If)B F2(subscript)3.386 E F0(is)3.386 E F1(*)3.386 E F0(or) -3.386 E F1(@)3.386 E F0 3.386(,t)C .886(he e)-3.386 F .886 -(xpansion is the number of ele-)-.15 F .463(ments in the array)108 388.8 +(\). ${#).15 F F1(name)A F0([)A F1(subscript)A F0(]})A -.15(ex)108 477.6 +S .886(pands to the length of ${).15 F F1(name)A F0([)A F1(subscript)A +F0 3.386(]}. If)B F1(subscript)3.386 E F0(is)3.386 E F2(*)3.386 E F0(or) +3.386 E F2(@)3.386 E F0 3.386(,t)C .886(he e)-3.386 F .886 +(xpansion is the number of ele-)-.15 F .463(ments in the array)108 489.6 R 5.463(.R)-.65 G .463(eferencing an array v)-5.463 F .462 (ariable without a subscript is equi)-.25 F -.25(va)-.25 G .462 (lent to referencing the array).25 F .233(with a subscript of 0.)108 -400.8 R .233(If the)5.233 F F2(subscript)3.073 E F0 .233 +501.6 R .233(If the)5.233 F F1(subscript)3.073 E F0 .233 (used to reference an element of an inde)3.413 F -.15(xe)-.15 G 2.733 (da).15 G .233(rray e)-2.733 F -.25(va)-.25 G .233(luates to a num-).25 -F .277(ber less than zero, it is used as an of)108 412.8 R .277 -(fset from one greater than the array')-.25 F 2.777(sm)-.55 G .277 -(aximum inde)-2.777 F 2.777(x\()-.15 G .277(so a subcript of)-2.777 F -(-1 refers to the last element of the array\).)108 424.8 Q .168 -(An array v)108 441.6 R .168 +F .617(ber less than zero, it is interpreted as relati)108 513.6 R .917 +-.15(ve t)-.25 H 3.117(oo).15 G .616(ne greater than the maximum inde) +-3.117 F 3.116(xo)-.15 G 3.116(ft)-3.116 G .616(he array)-3.116 F 3.116 +(,s)-.65 G 3.116(on)-3.116 G -.15(eg)-3.116 G(-).15 E(ati)108 525.6 Q .3 +-.15(ve i)-.25 H(ndices count back from the end of the array).15 E 2.5 +(,a)-.65 G(nd an inde)-2.5 E 2.5(xo)-.15 G 2.5<66ad>-2.5 G 2.5(1r)-2.5 G +(eferences the last element.)-2.5 E .168(An array v)108 542.4 R .168 (ariable is considered set if a subscript has been assigned a v)-.25 F 2.668(alue. The)-.25 F .168(null string is a v)2.668 F .168(alid v)-.25 -F(alue.)-.25 E(The)108 458.4 Q F1(unset)2.767 E F0 -.2(bu)2.767 G .267 -(iltin is used to destro).2 F 2.767(ya)-.1 G(rrays.)-2.767 E F1(unset) -5.267 E F2(name)2.767 E F0([)A F2(subscript)A F0 2.767(]d)C(estro)-2.767 -E .267(ys the array element at inde)-.1 F(x)-.15 E F2(sub-)2.766 E -(script)108 470.4 Q F0 6.204(.C)C 1.204(are must be tak)-6.204 F 1.204 -(en to a)-.1 F -.2(vo)-.2 G 1.205(id unw).2 F 1.205(anted side ef)-.1 F -1.205(fects caused by pathname e)-.25 F(xpansion.)-.15 E F1(unset)6.205 -E F2(name)3.705 E F0(,)A(where)108 482.4 Q F2(name)2.5 E F0(is an array) -2.5 E 2.5(,o)-.65 G(r)-2.5 E F1(unset)2.5 E F2(name)2.5 E F0([)A F2 -(subscript)A F0(], where)A F2(subscript)2.5 E F0(is)2.5 E F1(*)2.5 E F0 -(or)2.5 E F1(@)2.5 E F0 2.5(,r)C(emo)-2.5 E -.15(ve)-.15 G 2.5(st).15 G -(he entire array)-2.5 E(.)-.65 E(The)108 499.2 Q F1(declar)3.574 E(e) --.18 E F0(,)A F1(local)3.574 E F0 3.574(,a)C(nd)-3.574 E F1 -.18(re) -3.574 G(adonly).18 E F0 -.2(bu)3.574 G 1.073(iltins each accept a).2 F -F13.573 E F0 1.073(option to specify an inde)3.573 F -.15(xe)-.15 -G 3.573(da).15 G 1.073(rray and a)-3.573 F F13.573 E F0 .338 -(option to specify an associati)108 511.2 R .638 -.15(ve a)-.25 H(rray) -.15 E 5.338(.I)-.65 G 2.838(fb)-5.338 G .338(oth options are supplied,) --2.838 F F12.838 E F0(tak)2.838 E .338(es precedence.)-.1 F(The) -5.338 E F1 -.18(re)2.839 G(ad).18 E F0 -.2(bu)2.839 G(iltin).2 E .441 -(accepts a)108 523.2 R F12.941 E F0 .441 +F(alue.)-.25 E(The)108 559.2 Q F2(unset)2.767 E F0 -.2(bu)2.767 G .267 +(iltin is used to destro).2 F 2.767(ya)-.1 G(rrays.)-2.767 E F2(unset) +5.267 E F1(name)2.767 E F0([)A F1(subscript)A F0 2.767(]d)C(estro)-2.767 +E .267(ys the array element at inde)-.1 F(x)-.15 E F1(sub-)2.766 E +(script)108 571.2 Q F0 6.318(.N)C -2.25 -.15(eg a)-6.318 H(ti).15 E +1.618 -.15(ve s)-.25 H 1.318(ubscripts to inde).15 F -.15(xe)-.15 G +3.818(da).15 G 1.319(rrays are interpreted as described abo)-3.818 F +-.15(ve)-.15 G 6.319(.C).15 G 1.319(are must be tak)-6.319 F 1.319 +(en to)-.1 F -.2(avo)108 583.2 S .298(id unw).2 F .298(anted side ef)-.1 +F .298(fects caused by pathname e)-.25 F(xpansion.)-.15 E F2(unset)5.298 +E F1(name)2.797 E F0 2.797(,w)C(here)-2.797 E F1(name)2.797 E F0 .297 +(is an array)2.797 F 2.797(,o)-.65 G(r)-2.797 E F2(unset)2.797 E F1 +(name)108 595.2 Q F0([)A F1(subscript)A F0(], where)A F1(subscript)2.5 E +F0(is)2.5 E F2(*)2.5 E F0(or)2.5 E F2(@)2.5 E F0 2.5(,r)C(emo)-2.5 E +-.15(ve)-.15 G 2.5(st).15 G(he entire array)-2.5 E(.)-.65 E(The)108 612 +Q F2(declar)3.573 E(e)-.18 E F0(,)A F2(local)3.573 E F0 3.573(,a)C(nd) +-3.573 E F2 -.18(re)3.573 G(adonly).18 E F0 -.2(bu)3.573 G 1.073 +(iltins each accept a).2 F F23.573 E F0 1.073 +(option to specify an inde)3.573 F -.15(xe)-.15 G 3.574(da).15 G 1.074 +(rray and a)-3.574 F F23.574 E F0 .339 +(option to specify an associati)108 624 R .638 -.15(ve a)-.25 H(rray).15 +E 5.338(.I)-.65 G 2.838(fb)-5.338 G .338(oth options are supplied,) +-2.838 F F22.838 E F0(tak)2.838 E .338(es precedence.)-.1 F(The) +5.338 E F2 -.18(re)2.838 G(ad).18 E F0 -.2(bu)2.838 G(iltin).2 E .44 +(accepts a)108 636 R F22.941 E F0 .441 (option to assign a list of w)2.941 F .441 (ords read from the standard input to an array)-.1 F 5.441(.T)-.65 G(he) --5.441 E F1(set)2.941 E F0(and)2.941 E F1(declar)2.94 E(e)-.18 E F0 -.2 -(bu)108 535.2 S(iltins display array v).2 E(alues in a w)-.25 E +-5.441 E F2(set)2.941 E F0(and)2.941 E F2(declar)2.941 E(e)-.18 E F0 -.2 +(bu)108 648 S(iltins display array v).2 E(alues in a w)-.25 E (ay that allo)-.1 E(ws them to be reused as assignments.)-.25 E/F4 10.95 -/Times-Bold@0 SF(EXP)72 552 Q(ANSION)-.81 E F0 .76(Expansion is perform\ -ed on the command line after it has been split into w)108 564 R 3.26 +/Times-Bold@0 SF(EXP)72 664.8 Q(ANSION)-.81 E F0 .76(Expansion is perfo\ +rmed on the command line after it has been split into w)108 676.8 R 3.26 (ords. There)-.1 F .76(are se)3.26 F -.15(ve)-.25 G 3.26(nk).15 G .76 -(inds of)-3.26 F -.15(ex)108 576 S .37(pansion performed:).15 F F2(br) -2.869 E .369(ace e)-.15 F(xpansion)-.2 E F0(,).24 E F2 .369(tilde e) -2.869 F(xpansion)-.2 E F0(,).24 E F2(par)2.869 E .369 -(ameter and variable e)-.15 F(xpansion)-.2 E F0(,).24 E F2 .369 -(command sub-)2.869 F(stitution)108 588 Q F0(,).24 E F2(arithmetic e)2.5 -E(xpansion)-.2 E F0(,).24 E F2(wor)2.5 E 2.5(ds)-.37 G(plitting)-2.5 E -F0 2.5(,a).22 G(nd)-2.5 E F2(pathname e)2.5 E(xpansion)-.2 E F0(.).24 E -.47(The order of e)108 604.8 R .471(xpansions is: brace e)-.15 F .471 +(inds of)-3.26 F -.15(ex)108 688.8 S .369(pansion performed:).15 F F1 +(br)2.869 E .369(ace e)-.15 F(xpansion)-.2 E F0(,).24 E F1 .369(tilde e) +2.869 F(xpansion)-.2 E F0(,).24 E F1(par)2.869 E .369 +(ameter and variable e)-.15 F(xpansion)-.2 E F0(,).24 E F1 .37 +(command sub-)2.869 F(stitution)108 700.8 Q F0(,).24 E F1(arithmetic e) +2.5 E(xpansion)-.2 E F0(,).24 E F1(wor)2.5 E 2.5(ds)-.37 G(plitting)-2.5 +E F0 2.5(,a).22 G(nd)-2.5 E F1(pathname e)2.5 E(xpansion)-.2 E F0(.).24 +E .471(The order of e)108 717.6 R .471(xpansions is: brace e)-.15 F .471 (xpansion, tilde e)-.15 F .471(xpansion, parameter)-.15 F 2.971(,v)-.4 G -.471(ariable and arithmetic e)-3.221 F(xpansion)-.15 E -(and command substitution \(done in a left-to-right f)108 616.8 Q +.47(ariable and arithmetic e)-3.221 F(xpansion)-.15 E +(and command substitution \(done in a left-to-right f)108 729.6 Q (ashion\), w)-.1 E(ord splitting, and pathname e)-.1 E(xpansion.)-.15 E -(On systems that can support it, there is an additional e)108 633.6 Q -(xpansion a)-.15 E -.25(va)-.2 G(ilable:).25 E F2(pr)2.5 E -(ocess substitution)-.45 E F0(.)A 1.487(Only brace e)108 650.4 R 1.487 -(xpansion, w)-.15 F 1.487(ord splitting, and pathname e)-.1 F 1.487 -(xpansion can change the number of w)-.15 F 1.486(ords of the)-.1 F -.15 -(ex)108 662.4 S 1.164(pansion; other e).15 F 1.164(xpansions e)-.15 F -1.164(xpand a single w)-.15 F 1.165(ord to a single w)-.1 F 3.665 -(ord. The)-.1 F 1.165(only e)3.665 F 1.165(xceptions to this are the) --.15 F -.15(ex)108 674.4 S(pansions of ").15 E F1($@)A F0 2.5("a)C(nd ") --2.5 E F1(${)A F2(name)A F1([@]})A F0 2.5("a)C 2.5(se)-2.5 G -(xplained abo)-2.65 E .3 -.15(ve \()-.15 H(see).15 E F3 -.666(PA)2.5 G -(RAMETERS).666 E/F5 9/Times-Roman@0 SF(\).)A F1(Brace Expansion)87 691.2 -Q F2(Br)108.58 703.2 Q .606(ace e)-.15 F(xpansion)-.2 E F0 .606 -(is a mechanism by which arbitrary strings may be generated.)3.346 F -.606(This mechanism is similar)5.606 F(to)108 715.2 Q F2 .415 -(pathname e)2.915 F(xpansion)-.2 E F0 2.915(,b)C .415 -(ut the \214lenames generated need not e)-3.115 F 2.915(xist. P)-.15 F -.415(atterns to be brace e)-.15 F .415(xpanded tak)-.15 F 2.915(et)-.1 G -(he)-2.915 E 2.28(form of an optional)108 727.2 R F2(pr)4.78 E(eamble) --.37 E F0 4.78(,f).18 G(ollo)-4.78 E 2.28 -(wed by either a series of comma-separated strings or a sequence)-.25 F -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(18)198.165 E 0 Cg EP +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(18)185.545 E 0 Cg EP %%Page: 19 19 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E -.15(ex)108 84 S .556(pression between a pair of braces, follo) -.15 F .556(wed by an optional)-.25 F/F1 10/Times-Italic@0 SF(postscript) -3.056 E F0 5.556(.T).68 G .557(he preamble is pre\214x)-5.556 F .557 -(ed to each)-.15 F .758(string contained within the braces, and the pos\ -tscript is then appended to each resulting string, e)108 96 R(xpanding) --.15 E(left to right.)108 108 Q .718(Brace e)108 124.8 R .719 -(xpansions may be nested.)-.15 F .719(The results of each e)5.719 F .719 +-.35 E(On systems that can support it, there is an additional e)108 84 Q +(xpansion a)-.15 E -.25(va)-.2 G(ilable:).25 E/F1 10/Times-Italic@0 SF +(pr)2.5 E(ocess substitution)-.45 E F0(.)A 1.486(Only brace e)108 100.8 +R 1.486(xpansion, w)-.15 F 1.486(ord splitting, and pathname e)-.1 F +1.487(xpansion can change the number of w)-.15 F 1.487(ords of the)-.1 F +-.15(ex)108 112.8 S 1.165(pansion; other e).15 F 1.165(xpansions e)-.15 +F 1.165(xpand a single w)-.15 F 1.165(ord to a single w)-.1 F 3.665 +(ord. The)-.1 F 1.164(only e)3.665 F 1.164(xceptions to this are the) +-.15 F -.15(ex)108 124.8 S(pansions of ").15 E/F2 10/Times-Bold@0 SF($@) +A F0 2.5("a)C(nd ")-2.5 E F2(${)A F1(name)A F2([@]})A F0 2.5("a)C 2.5 +(se)-2.5 G(xplained abo)-2.65 E .3 -.15(ve \()-.15 H(see).15 E/F3 9 +/Times-Bold@0 SF -.666(PA)2.5 G(RAMETERS).666 E/F4 9/Times-Roman@0 SF +(\).)A F2(Brace Expansion)87 141.6 Q F1(Br)108.58 153.6 Q .606(ace e) +-.15 F(xpansion)-.2 E F0 .606 +(is a mechanism by which arbitrary strings may be generated.)3.346 F +.606(This mechanism is similar)5.606 F(to)108 165.6 Q F1 .415 +(pathname e)2.915 F(xpansion)-.2 E F0 2.915(,b)C .415 +(ut the \214lenames generated need not e)-3.115 F 2.915(xist. P)-.15 F +.415(atterns to be brace e)-.15 F .415(xpanded tak)-.15 F 2.915(et)-.1 G +(he)-2.915 E .151(form of an optional)108 177.6 R F1(pr)2.651 E(eamble) +-.37 E F0 2.651(,f).18 G(ollo)-2.651 E .151 +(wed by either a series of comma-separated strings or a sequence e)-.25 +F(xpres-)-.15 E .563(sion between a pair of braces, follo)108 189.6 R +.563(wed by an optional)-.25 F F1(postscript)3.063 E F0 5.563(.T).68 G +.563(he preamble is pre\214x)-5.563 F .563(ed to each string)-.15 F .659 +(contained within the braces, and the postscript is then appended to ea\ +ch resulting string, e)108 201.6 R .659(xpanding left to)-.15 F(right.) +108 213.6 Q .719(Brace e)108 230.4 R .719(xpansions may be nested.)-.15 +F .719(The results of each e)5.719 F .719 (xpanded string are not sorted; left to right order is)-.15 F(preserv) -108 136.8 Q 2.5(ed. F)-.15 F(or e)-.15 E(xample, a)-.15 E/F2 10 -/Times-Bold@0 SF({)A F0(d,c,b)A F2(})A F0 2.5(ee)C -(xpands into `ade ace abe'.)-2.65 E 3.243(As)108 153.6 S .743(equence e) --3.243 F .743(xpression tak)-.15 F .743(es the form)-.1 F F2({)3.243 E -F1(x)A F2(..)A F1(y)A F2([..)A F1(incr)A F2(]})A F0 3.243(,w)C(here) --3.243 E F1(x)3.243 E F0(and)3.242 E F1(y)3.242 E F0 .742 -(are either inte)3.242 F .742(gers or single characters,)-.15 F(and)108 -165.6 Q F1(incr)3.031 E F0 3.031(,a)C 3.032(no)-3.031 G .532 -(ptional increment, is an inte)-3.032 F(ger)-.15 E 5.532(.W)-.55 G .532 -(hen inte)-5.532 F .532(gers are supplied, the e)-.15 F .532 -(xpression e)-.15 F .532(xpands to each)-.15 F .078(number between)108 -177.6 R F1(x)2.578 E F0(and)2.578 E F1(y)2.578 E F0 2.578(,i)C(nclusi) --2.578 E -.15(ve)-.25 G 5.078(.S).15 G .078(upplied inte)-5.078 F .077 -(gers may be pre\214x)-.15 F .077(ed with)-.15 F F1(0)2.577 E F0 .077 -(to force each term to ha)2.577 F .377 -.15(ve t)-.2 H(he).15 E .014 -(same width.)108 189.6 R .014(When either)5.014 F F1(x)2.514 E F0(or) -2.514 E F1(y)2.514 E F0(be)2.514 E .015(gins with a zero, the shell att\ +108 242.4 Q 2.5(ed. F)-.15 F(or e)-.15 E(xample, a)-.15 E F2({)A F0 +(d,c,b)A F2(})A F0 2.5(ee)C(xpands into `ade ace abe'.)-2.65 E 3.242(As) +108 259.2 S .742(equence e)-3.242 F .742(xpression tak)-.15 F .742 +(es the form)-.1 F F2({)3.242 E F1(x)A F2(..)A F1(y)A F2([..)A F1(incr)A +F2(]})A F0 3.242(,w)C(here)-3.242 E F1(x)3.242 E F0(and)3.243 E F1(y) +3.243 E F0 .743(are either inte)3.243 F .743(gers or single characters,) +-.15 F(and)108 271.2 Q F1(incr)3.032 E F0 3.032(,a)C 3.032(no)-3.032 G +.532(ptional increment, is an inte)-3.032 F(ger)-.15 E 5.532(.W)-.55 G +.532(hen inte)-5.532 F .532(gers are supplied, the e)-.15 F .532 +(xpression e)-.15 F .531(xpands to each)-.15 F .077(number between)108 +283.2 R F1(x)2.577 E F0(and)2.577 E F1(y)2.577 E F0 2.577(,i)C(nclusi) +-2.577 E -.15(ve)-.25 G 5.077(.S).15 G .077(upplied inte)-5.077 F .077 +(gers may be pre\214x)-.15 F .077(ed with)-.15 F F1(0)2.577 E F0 .078 +(to force each term to ha)2.578 F .378 -.15(ve t)-.2 H(he).15 E .015 +(same width.)108 295.2 R .015(When either)5.015 F F1(x)2.515 E F0(or) +2.515 E F1(y)2.515 E F0(be)2.515 E .014(gins with a zero, the shell att\ empts to force all generated terms to contain)-.15 F 1.143 -(the same number of digits, zero-padding where necessary)108 201.6 R +(the same number of digits, zero-padding where necessary)108 307.2 R 6.143(.W)-.65 G 1.143(hen characters are supplied, the e)-6.143 F -(xpression)-.15 E -.15(ex)108 213.6 S .541(pands to each character le) -.15 F .541(xicographically between)-.15 F F1(x)3.041 E F0(and)3.042 E F1 -(y)3.042 E F0 3.042(,i)C(nclusi)-3.042 E -.15(ve)-.25 G 5.542(.N).15 G -.542(ote that both)-5.542 F F1(x)3.042 E F0(and)3.042 E F1(y)3.042 E F0 -.542(must be of)3.042 F .183(the same type.)108 225.6 R .182 -(When the increment is supplied, it is used as the dif)5.183 F .182 -(ference between each term.)-.25 F .182(The def)5.182 F(ault)-.1 E -(increment is 1 or -1 as appropriate.)108 237.6 Q .581(Brace e)108 254.4 -R .581(xpansion is performed before an)-.15 F 3.081(yo)-.15 G .581 -(ther e)-3.081 F .581(xpansions, and an)-.15 F 3.082(yc)-.15 G .582 -(haracters special to other e)-3.082 F(xpansions)-.15 E .016 -(are preserv)108 266.4 R .016(ed in the result.)-.15 F .016 -(It is strictly te)5.016 F(xtual.)-.15 E F2(Bash)5.016 E F0 .015 -(does not apply an)2.516 F 2.515(ys)-.15 G .015 -(yntactic interpretation to the con-)-2.515 F(te)108 278.4 Q -(xt of the e)-.15 E(xpansion or the te)-.15 E(xt between the braces.) --.15 E 3.632(Ac)108 295.2 S 1.132(orrectly-formed brace e)-3.632 F 1.132 -(xpansion must contain unquoted opening and closing braces, and at leas\ -t one)-.15 F 3.441(unquoted comma or a v)108 307.2 R 3.441 -(alid sequence e)-.25 F 5.941(xpression. An)-.15 F 5.941(yi)-.15 G 3.441 -(ncorrectly formed brace e)-5.941 F 3.44(xpansion is left)-.15 F 2.755 -(unchanged. A)108 319.2 R F2({)2.755 E F0(or)2.755 E F2(,)2.755 E F0 +(xpression)-.15 E -.15(ex)108 319.2 S 1.064(pands to each character le) +.15 F 1.064(xicographically between)-.15 F F1(x)3.564 E F0(and)3.564 E +F1(y)3.564 E F0 3.564(,i)C(nclusi)-3.564 E -.15(ve)-.25 G 3.564(,u).15 G +1.064(sing the def)-3.564 F 1.064(ault C locale.)-.1 F(Note)6.064 E .983 +(that both)108 331.2 R F1(x)3.483 E F0(and)3.483 E F1(y)3.483 E F0 .983 +(must be of the same type.)3.483 F .984 +(When the increment is supplied, it is used as the dif)5.983 F(ference) +-.25 E(between each term.)108 343.2 Q(The def)5 E +(ault increment is 1 or -1 as appropriate.)-.1 E .582(Brace e)108 360 R +.582(xpansion is performed before an)-.15 F 3.082(yo)-.15 G .581(ther e) +-3.082 F .581(xpansions, and an)-.15 F 3.081(yc)-.15 G .581 +(haracters special to other e)-3.081 F(xpansions)-.15 E .015 +(are preserv)108 372 R .015(ed in the result.)-.15 F .015 +(It is strictly te)5.015 F(xtual.)-.15 E F2(Bash)5.016 E F0 .016 +(does not apply an)2.516 F 2.516(ys)-.15 G .016 +(yntactic interpretation to the con-)-2.516 F(te)108 384 Q(xt of the e) +-.15 E(xpansion or the te)-.15 E(xt between the braces.)-.15 E 3.633(Ac) +108 400.8 S 1.133(orrectly-formed brace e)-3.633 F 1.132(xpansion must \ +contain unquoted opening and closing braces, and at least one)-.15 F +3.44(unquoted comma or a v)108 412.8 R 3.441(alid sequence e)-.25 F +5.941(xpression. An)-.15 F 5.941(yi)-.15 G 3.441 +(ncorrectly formed brace e)-5.941 F 3.441(xpansion is left)-.15 F 2.755 +(unchanged. A)108 424.8 R F2({)2.755 E F0(or)2.755 E F2(,)2.755 E F0 .255(may be quoted with a backslash to pre)2.755 F -.15(ve)-.25 G .255 -(nt its being considered part of a brace e).15 F(xpres-)-.15 E 2.911 -(sion. T)108 331.2 R 2.911(oa)-.8 G -.2(vo)-3.111 G .411 +(nt its being considered part of a brace e).15 F(xpres-)-.15 E 2.91 +(sion. T)108 436.8 R 2.91(oa)-.8 G -.2(vo)-3.11 G .41 (id con\215icts with parameter e).2 F .411(xpansion, the string)-.15 F -F2(${)2.911 E F0 .41(is not considered eligible for brace e)2.911 F -(xpan-)-.15 E(sion.)108 343.2 Q 1.476(This construct is typically used \ +F2(${)2.911 E F0 .411(is not considered eligible for brace e)2.911 F +(xpan-)-.15 E(sion.)108 448.8 Q 1.476(This construct is typically used \ as shorthand when the common pre\214x of the strings to be generated is) -108 360 R(longer than in the abo)108 372 Q .3 -.15(ve ex)-.15 H(ample:) -.15 E(mkdir /usr/local/src/bash/{old,ne)144 388.8 Q -.65(w,)-.25 G -(dist,b).65 E(ugs})-.2 E(or)108 400.8 Q(cho)144 412.8 Q +108 465.6 R(longer than in the abo)108 477.6 Q .3 -.15(ve ex)-.15 H +(ample:).15 E(mkdir /usr/local/src/bash/{old,ne)144 494.4 Q -.65(w,)-.25 +G(dist,b).65 E(ugs})-.2 E(or)108 506.4 Q(cho)144 518.4 Q (wn root /usr/{ucb/{e)-.25 E(x,edit},lib/{e)-.15 E(x?.?*,ho)-.15 E(w_e) --.25 E(x}})-.15 E .618(Brace e)108 429.6 R .618 +-.25 E(x}})-.15 E .618(Brace e)108 535.2 R .618 (xpansion introduces a slight incompatibility with historical v)-.15 F .618(ersions of)-.15 F F2(sh)3.118 E F0(.)A F2(sh)5.618 E F0 .618 -(does not treat open-)3.118 F .247 -(ing or closing braces specially when the)108 441.6 R 2.747(ya)-.15 G -.247(ppear as part of a w)-2.747 F .248(ord, and preserv)-.1 F .248 -(es them in the output.)-.15 F F2(Bash)5.248 E F0(remo)108 453.6 Q -.15 +(does not treat open-)3.118 F .248 +(ing or closing braces specially when the)108 547.2 R 2.748(ya)-.15 G +.247(ppear as part of a w)-2.748 F .247(ord, and preserv)-.1 F .247 +(es them in the output.)-.15 F F2(Bash)5.247 E F0(remo)108 559.2 Q -.15 (ve)-.15 G 3.53(sb).15 G 1.03(races from w)-3.53 F 1.03 (ords as a consequence of brace e)-.1 F 3.53(xpansion. F)-.15 F 1.03 (or e)-.15 F 1.03(xample, a w)-.15 F 1.03(ord entered to)-.1 F F2(sh) -3.53 E F0(as)3.53 E F1(\214le{1,2})108 465.6 Q F0 .514 -(appears identically in the output.)3.014 F .515(The same w)5.515 F .515 -(ord is output as)-.1 F F1 .515(\214le1 \214le2)4.925 F F0 .515(after e) -3.035 F .515(xpansion by)-.15 F F2(bash)3.015 E F0(.)A .437 -(If strict compatibility with)108 477.6 R F2(sh)2.936 E F0 .436 +3.53 E F0(as)3.53 E F1(\214le{1,2})108 571.2 Q F0 .515 +(appears identically in the output.)3.015 F .515(The same w)5.515 F .515 +(ord is output as)-.1 F F1 .514(\214le1 \214le2)4.925 F F0 .514(after e) +3.034 F .514(xpansion by)-.15 F F2(bash)3.014 E F0(.)A .436 +(If strict compatibility with)108 583.2 R F2(sh)2.936 E F0 .436 (is desired, start)2.936 F F2(bash)2.936 E F0 .436(with the)2.936 F F2 -(+B)2.936 E F0 .436(option or disable brace e)2.936 F .436 -(xpansion with the)-.15 F F2(+B)108 489.6 Q F0(option to the)2.5 E F2 -(set)2.5 E F0(command \(see)2.5 E/F3 9/Times-Bold@0 SF(SHELL B)2.5 E -(UIL)-.09 E(TIN COMMANDS)-.828 E F0(belo)2.25 E(w\).)-.25 E F2 -.18(Ti) -87 506.4 S(lde Expansion).18 E F0 1.086(If a w)108 518.4 R 1.086(ord be) --.1 F 1.086(gins with an unquoted tilde character \(`)-.15 F F2(~)A F0 -1.087('\), all of the characters preceding the \214rst unquoted)B .185(\ -slash \(or all characters, if there is no unquoted slash\) are consider\ -ed a)108 530.4 R F1(tilde-pr)2.685 E(e\214x)-.37 E F0 5.185(.I)C 2.685 -(fn)-5.185 G .185(one of the characters)-2.685 F .725(in the tilde-pre\ -\214x are quoted, the characters in the tilde-pre\214x follo)108 542.4 R -.726(wing the tilde are treated as a possible)-.25 F F1(lo)108 554.4 Q -.523(gin name)-.1 F F0 5.523(.I)C 3.023(ft)-5.523 G .523 +(+B)2.936 E F0 .436(option or disable brace e)2.936 F .437 +(xpansion with the)-.15 F F2(+B)108 595.2 Q F0(option to the)2.5 E F2 +(set)2.5 E F0(command \(see)2.5 E F3(SHELL B)2.5 E(UIL)-.09 E +(TIN COMMANDS)-.828 E F0(belo)2.25 E(w\).)-.25 E F2 -.18(Ti)87 612 S +(lde Expansion).18 E F0 1.087(If a w)108 624 R 1.087(ord be)-.1 F 1.087 +(gins with an unquoted tilde character \(`)-.15 F F2(~)A F0 1.086 +('\), all of the characters preceding the \214rst unquoted)B .185(slash\ + \(or all characters, if there is no unquoted slash\) are considered a) +108 636 R F1(tilde-pr)2.685 E(e\214x)-.37 E F0 5.185(.I)C 2.685(fn) +-5.185 G .185(one of the characters)-2.685 F .726(in the tilde-pre\214x\ + are quoted, the characters in the tilde-pre\214x follo)108 648 R .725 +(wing the tilde are treated as a possible)-.25 F F1(lo)108 660 Q .522 +(gin name)-.1 F F0 5.522(.I)C 3.022(ft)-5.522 G .522 (his login name is the null string, the tilde is replaced with the v) --3.023 F .522(alue of the shell parameter)-.25 F F3(HOME)108 566.4 Q/F4 -9/Times-Roman@0 SF(.)A F0(If)4.786 E F3(HOME)2.786 E F0 .287 -(is unset, the home directory of the user e)2.536 F -.15(xe)-.15 G .287 -(cuting the shell is substituted instead.).15 F(Other)5.287 E(-)-.2 E(w\ +-3.022 F .523(alue of the shell parameter)-.25 F F3(HOME)108 672 Q F4(.) +A F0(If)4.787 E F3(HOME)2.787 E F0 .287 +(is unset, the home directory of the user e)2.537 F -.15(xe)-.15 G .286 +(cuting the shell is substituted instead.).15 F(Other)5.286 E(-)-.2 E(w\ ise, the tilde-pre\214x is replaced with the home directory associated \ -with the speci\214ed login name.)108 578.4 Q .093 -(If the tilde-pre\214x is a `~+', the v)108 595.2 R .092 +with the speci\214ed login name.)108 684 Q .092 +(If the tilde-pre\214x is a `~+', the v)108 700.8 R .092 (alue of the shell v)-.25 F(ariable)-.25 E F3(PWD)2.592 E F0 .092 -(replaces the tilde-pre\214x.)2.342 F .092(If the tilde-pre\214x is) -5.092 F 3.403(a`)108 607.2 S .903(~\255', the v)-3.403 F .903 +(replaces the tilde-pre\214x.)2.342 F .093(If the tilde-pre\214x is) +5.093 F 3.404(a`)108 712.8 S .904(~\255', the v)-3.404 F .904 (alue of the shell v)-.25 F(ariable)-.25 E F3(OLDPWD)3.404 E F4(,)A F0 -.904(if it is set, is substituted.)3.154 F .904(If the characters follo) -5.904 F .904(wing the)-.25 F 1.642 -(tilde in the tilde-pre\214x consist of a number)108 619.2 R F1(N)4.142 -E F0 4.142(,o)C 1.642(ptionally pre\214x)-4.142 F 1.641 -(ed by a `+' or a `\255', the tilde-pre\214x is)-.15 F 1.437(replaced w\ -ith the corresponding element from the directory stack, as it w)108 -631.2 R 1.438(ould be displayed by the)-.1 F F2(dirs)3.938 E F0 -.2(bu) -108 643.2 S .455(iltin in).2 F -.2(vo)-.4 G -.1(ke).2 G 2.955(dw).1 G -.455(ith the tilde-pre\214x as an ar)-2.955 F 2.954(gument. If)-.18 F -.454(the characters follo)2.954 F .454 -(wing the tilde in the tilde-pre\214x)-.25 F -(consist of a number without a leading `+' or `\255', `+' is assumed.) -108 655.2 Q(If the login name is in)108 672 Q -.25(va)-.4 G -(lid, or the tilde e).25 E(xpansion f)-.15 E(ails, the w)-.1 E -(ord is unchanged.)-.1 E .166(Each v)108 688.8 R .167 -(ariable assignment is check)-.25 F .167(ed for unquoted tilde-pre\214x) --.1 F .167(es immediately follo)-.15 F .167(wing a)-.25 F F2(:)2.667 E -F0 .167(or the \214rst)2.667 F F2(=)2.667 E F0 5.167(.I)C(n)-5.167 E -.468(these cases, tilde e)108 700.8 R .468(xpansion is also performed.) --.15 F(Consequently)5.467 E 2.967(,o)-.65 G .467 -(ne may use \214lenames with tildes in assign-)-2.967 F(ments to)108 -712.8 Q F3 -.666(PA)2.5 G(TH)-.189 E F4(,)A F3(MAILP)2.25 E -.855(AT) --.666 G(H).855 E F4(,)A F0(and)2.25 E F3(CDP)2.5 E -.855(AT)-.666 G(H) -.855 E F4(,)A F0(and the shell assigns the e)2.25 E(xpanded v)-.15 E -(alue.)-.25 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(19)198.165 E -0 Cg EP +.904(if it is set, is substituted.)3.154 F .903(If the characters follo) +5.903 F .903(wing the)-.25 F 1.641 +(tilde in the tilde-pre\214x consist of a number)108 724.8 R F1(N)4.141 +E F0 4.142(,o)C 1.642(ptionally pre\214x)-4.142 F 1.642 +(ed by a `+' or a `\255', the tilde-pre\214x is)-.15 F(GNU Bash 4.2)72 +768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(19)185.545 E 0 Cg +EP %%Page: 20 20 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF -.1(Pa)87 84 S(rameter Expansion).1 E F0 -1.605(The `)108 96 R F1($)A F0 4.105('c)C 1.605 -(haracter introduces parameter e)-4.105 F 1.606 -(xpansion, command substitution, or arithmetic e)-.15 F 4.106 -(xpansion. The)-.15 F .407(parameter name or symbol to be e)108 108 R -.407(xpanded may be enclosed in braces, which are optional b)-.15 F .406 -(ut serv)-.2 F 2.906(et)-.15 G 2.906(op)-2.906 G(ro-)-2.906 E .032 -(tect the v)108 120 R .032(ariable to be e)-.25 F .032 -(xpanded from characters immediately follo)-.15 F .033 -(wing it which could be interpreted as part)-.25 F(of the name.)108 132 -Q 1.19(When braces are used, the matching ending brace is the \214rst `) -108 148.8 R F1(})A F0 3.689('n)C 1.189 -(ot escaped by a backslash or within a)-3.689 F 2.15 -(quoted string, and not within an embedded arithmetic e)108 160.8 R 2.15 -(xpansion, command substitution, or parameter)-.15 F -.15(ex)108 172.8 S -(pansion.).15 E(${)108 189.6 Q/F2 10/Times-Italic@0 SF(par)A(ameter)-.15 -E F0(})A 1.205(The v)144 201.6 R 1.205(alue of)-.25 F F2(par)3.705 E -(ameter)-.15 E F0 1.204(is substituted.)3.705 F 1.204 -(The braces are required when)6.204 F F2(par)4.954 E(ameter)-.15 E F0 -1.204(is a positional)4.434 F .264 -(parameter with more than one digit, or when)144 213.6 R F2(par)4.014 E +-.35 E 1.438(replaced with the corresponding element from the directory\ + stack, as it w)108 84 R 1.437(ould be displayed by the)-.1 F/F1 10 +/Times-Bold@0 SF(dirs)3.937 E F0 -.2(bu)108 96 S .454(iltin in).2 F -.2 +(vo)-.4 G -.1(ke).2 G 2.954(dw).1 G .454 +(ith the tilde-pre\214x as an ar)-2.954 F 2.954(gument. If)-.18 F .454 +(the characters follo)2.954 F .455(wing the tilde in the tilde-pre\214x) +-.25 F +(consist of a number without a leading `+' or `\255', `+' is assumed.) +108 108 Q(If the login name is in)108 124.8 Q -.25(va)-.4 G +(lid, or the tilde e).25 E(xpansion f)-.15 E(ails, the w)-.1 E +(ord is unchanged.)-.1 E .167(Each v)108 141.6 R .167 +(ariable assignment is check)-.25 F .167(ed for unquoted tilde-pre\214x) +-.1 F .167(es immediately follo)-.15 F .167(wing a)-.25 F F1(:)2.667 E +F0 .167(or the \214rst)2.667 F F1(=)2.666 E F0 5.166(.I)C(n)-5.166 E +.467(these cases, tilde e)108 153.6 R .467(xpansion is also performed.) +-.15 F(Consequently)5.467 E 2.967(,o)-.65 G .468 +(ne may use \214lenames with tildes in assign-)-2.967 F(ments to)108 +165.6 Q/F2 9/Times-Bold@0 SF -.666(PA)2.5 G(TH)-.189 E/F3 9 +/Times-Roman@0 SF(,)A F2(MAILP)2.25 E -.855(AT)-.666 G(H).855 E F3(,)A +F0(and)2.25 E F2(CDP)2.5 E -.855(AT)-.666 G(H).855 E F3(,)A F0 +(and the shell assigns the e)2.25 E(xpanded v)-.15 E(alue.)-.25 E F1 -.1 +(Pa)87 182.4 S(rameter Expansion).1 E F0 1.606(The `)108 194.4 R F1($)A +F0 4.106('c)C 1.606(haracter introduces parameter e)-4.106 F 1.605 +(xpansion, command substitution, or arithmetic e)-.15 F 4.105 +(xpansion. The)-.15 F .406(parameter name or symbol to be e)108 206.4 R +.407(xpanded may be enclosed in braces, which are optional b)-.15 F .407 +(ut serv)-.2 F 2.907(et)-.15 G 2.907(op)-2.907 G(ro-)-2.907 E .033 +(tect the v)108 218.4 R .033(ariable to be e)-.25 F .033 +(xpanded from characters immediately follo)-.15 F .032 +(wing it which could be interpreted as part)-.25 F(of the name.)108 +230.4 Q 1.189 +(When braces are used, the matching ending brace is the \214rst `)108 +247.2 R F1(})A F0 3.69('n)C 1.19(ot escaped by a backslash or within a) +-3.69 F 2.15(quoted string, and not within an embedded arithmetic e)108 +259.2 R 2.15(xpansion, command substitution, or parameter)-.15 F -.15 +(ex)108 271.2 S(pansion.).15 E(${)108 288 Q/F4 10/Times-Italic@0 SF(par) +A(ameter)-.15 E F0(})A 1.204(The v)144 300 R 1.204(alue of)-.25 F F4 +(par)3.704 E(ameter)-.15 E F0 1.204(is substituted.)3.704 F 1.204 +(The braces are required when)6.204 F F4(par)4.955 E(ameter)-.15 E F0 +1.205(is a positional)4.435 F .264 +(parameter with more than one digit, or when)144 312 R F4(par)4.014 E (ameter)-.15 E F0 .264(is follo)3.494 F .264 -(wed by a character which is not to)-.25 F 2.677 -(be interpreted as part of its name.)144 225.6 R(The)7.677 E F2(par) -5.177 E(ameter)-.15 E F0 2.676(is a shell parameter as described abo) -5.177 F -.15(ve)-.15 G F1 -.74(PA)144 237.6 S(RAMETERS).74 E F0 2.5(\)o) -C 2.5(ra)-2.5 G 2.5(na)-2.5 G(rray reference \()-2.5 E F1(Arrays)A F0 -(\).)A .815(If the \214rst character of)108 254.4 R F2(par)3.316 E -(ameter)-.15 E F0 .816(is an e)3.316 F .816(xclamation point \()-.15 F -F1(!)A F0 .816(\), it introduces a le)B -.15(ve)-.25 G 3.316(lo).15 G -3.316(fv)-3.316 G .816(ariable indirection.)-3.566 F F1(Bash)108 266.4 Q -F0 .106(uses the v)2.606 F .106(alue of the v)-.25 F .106 -(ariable formed from the rest of)-.25 F F2(par)2.606 E(ameter)-.15 E F0 +(wed by a character which is not to)-.25 F 2.676 +(be interpreted as part of its name.)144 324 R(The)7.677 E F4(par)5.177 +E(ameter)-.15 E F0 2.677(is a shell parameter as described abo)5.177 F +-.15(ve)-.15 G F1 -.74(PA)144 336 S(RAMETERS).74 E F0 2.5(\)o)C 2.5(ra) +-2.5 G 2.5(na)-2.5 G(rray reference \()-2.5 E F1(Arrays)A F0(\).)A .816 +(If the \214rst character of)108 352.8 R F4(par)3.316 E(ameter)-.15 E F0 +.816(is an e)3.316 F .816(xclamation point \()-.15 F F1(!)A F0 .816 +(\), it introduces a le)B -.15(ve)-.25 G 3.316(lo).15 G 3.315(fv)-3.316 +G .815(ariable indirection.)-3.565 F F1(Bash)108 364.8 Q F0 .106 +(uses the v)2.606 F .106(alue of the v)-.25 F .106 +(ariable formed from the rest of)-.25 F F4(par)2.606 E(ameter)-.15 E F0 .106(as the name of the v)2.606 F .106(ariable; this v)-.25 F(ari-)-.25 -E .351(able is then e)108 278.4 R .351(xpanded and that v)-.15 F .352 +E .352(able is then e)108 376.8 R .352(xpanded and that v)-.15 F .351 (alue is used in the rest of the substitution, rather than the v)-.25 F -.352(alue of)-.25 F F2(par)2.852 E(ame-)-.15 E(ter)108 290.4 Q F0 2.52 -(itself. This)2.52 F .02(is kno)2.52 F .02(wn as)-.25 F F2(indir)2.52 E -.02(ect e)-.37 F(xpansion)-.2 E F0 5.019(.T)C .019(he e)-5.019 F .019 -(xceptions to this are the e)-.15 F .019(xpansions of ${)-.15 F F1(!)A -F2(pr)A(e\214x)-.37 E F1(*)A F0 2.519(}a)C(nd)-2.519 E(${)108 302.4 Q F1 -(!)A F2(name)A F0([)A F2(@)A F0 .762(]} described belo)B 4.563 -.65 +.351(alue of)-.25 F F4(par)2.851 E(ame-)-.15 E(ter)108 388.8 Q F0 2.519 +(itself. This)2.519 F .019(is kno)2.519 F .019(wn as)-.25 F F4(indir) +2.519 E .019(ect e)-.37 F(xpansion)-.2 E F0 5.019(.T)C .019(he e)-5.019 +F .02(xceptions to this are the e)-.15 F .02(xpansions of ${)-.15 F F1 +(!)A F4(pr)A(e\214x)-.37 E F1(*)A F0 2.52(}a)C(nd)-2.52 E(${)108 400.8 Q +F1(!)A F4(name)A F0([)A F4(@)A F0 .763(]} described belo)B 4.563 -.65 (w. T)-.25 H .763(he e).65 F .763 (xclamation point must immediately follo)-.15 F 3.263(wt)-.25 G .763 -(he left brace in order to)-3.263 F(introduce indirection.)108 314.4 Q -.334(In each of the cases belo)108 331.2 R -.65(w,)-.25 G F2(wor)3.484 E +(he left brace in order to)-3.263 F(introduce indirection.)108 412.8 Q +.334(In each of the cases belo)108 429.6 R -.65(w,)-.25 G F4(wor)3.484 E (d)-.37 E F0 .334(is subject to tilde e)2.834 F .334 (xpansion, parameter e)-.15 F .334(xpansion, command substitution,)-.15 -F(and arithmetic e)108 343.2 Q(xpansion.)-.15 E 1.089 -(When not performing substring e)108 360 R 1.089 +F(and arithmetic e)108 441.6 Q(xpansion.)-.15 E 1.09 +(When not performing substring e)108 458.4 R 1.089 (xpansion, using the forms documented belo)-.15 F 3.589(w\()-.25 G -(e.g.,)-3.589 E F1(:-)3.59 E F0(\),)A F1(bash)3.59 E F0 1.09 -(tests for a)3.59 F(parameter that is unset or null.)108 372 Q(Omitting\ - the colon results in a test only for a parameter that is unset.)5 E(${) -108 388.8 Q F2(par)A(ameter)-.15 E F1<3aad>A F2(wor)A(d)-.37 E F0(})A F1 -.723(Use Default V)144 400.8 R(alues)-.92 E F0 5.723(.I)C(f)-5.723 E F2 -(par)4.473 E(ameter)-.15 E F0 .723(is unset or null, the e)3.953 F .722 -(xpansion of)-.15 F F2(wor)3.562 E(d)-.37 E F0 .722(is substituted.) -3.992 F(Other)5.722 E(-)-.2 E(wise, the v)144 412.8 Q(alue of)-.25 E F2 -(par)3.75 E(ameter)-.15 E F0(is substituted.)3.23 E(${)108 424.8 Q F2 -(par)A(ameter)-.15 E F1(:=)A F2(wor)A(d)-.37 E F0(})A F1 2.004 -(Assign Default V)144 436.8 R(alues)-.92 E F0 7.004(.I)C(f)-7.004 E F2 -(par)5.754 E(ameter)-.15 E F0 2.005(is unset or null, the e)5.234 F -2.005(xpansion of)-.15 F F2(wor)4.845 E(d)-.37 E F0 2.005 -(is assigned to)5.275 F F2(par)144 448.8 Q(ameter)-.15 E F0 5.279(.T).73 -G .279(he v)-5.279 F .279(alue of)-.25 F F2(par)4.029 E(ameter)-.15 E F0 -.278(is then substituted.)3.508 F .278 +(e.g.,)-3.589 E F1(:-)3.589 E F0(\),)A F1(bash)3.589 E F0 1.089 +(tests for a)3.589 F(parameter that is unset or null.)108 470.4 Q(Omitt\ +ing the colon results in a test only for a parameter that is unset.)5 E +(${)108 487.2 Q F4(par)A(ameter)-.15 E F1<3aad>A F4(wor)A(d)-.37 E F0(}) +A F1 .722(Use Default V)144 499.2 R(alues)-.92 E F0 5.722(.I)C(f)-5.722 +E F4(par)4.472 E(ameter)-.15 E F0 .723(is unset or null, the e)3.952 F +.723(xpansion of)-.15 F F4(wor)3.563 E(d)-.37 E F0 .723(is substituted.) +3.993 F(Other)5.723 E(-)-.2 E(wise, the v)144 511.2 Q(alue of)-.25 E F4 +(par)3.75 E(ameter)-.15 E F0(is substituted.)3.23 E(${)108 523.2 Q F4 +(par)A(ameter)-.15 E F1(:=)A F4(wor)A(d)-.37 E F0(})A F1 2.005 +(Assign Default V)144 535.2 R(alues)-.92 E F0 7.005(.I)C(f)-7.005 E F4 +(par)5.755 E(ameter)-.15 E F0 2.005(is unset or null, the e)5.235 F +2.004(xpansion of)-.15 F F4(wor)4.844 E(d)-.37 E F0 2.004 +(is assigned to)5.274 F F4(par)144 547.2 Q(ameter)-.15 E F0 5.278(.T).73 +G .278(he v)-5.278 F .278(alue of)-.25 F F4(par)4.028 E(ameter)-.15 E F0 +.278(is then substituted.)3.508 F .279 (Positional parameters and special param-)5.278 F -(eters may not be assigned to in this w)144 460.8 Q(ay)-.1 E(.)-.65 E -(${)108 472.8 Q F2(par)A(ameter)-.15 E F1(:?)A F2(wor)A(d)-.37 E F0(})A -F1 .535(Display Err)144 484.8 R .535(or if Null or Unset)-.18 F F0 5.535 -(.I)C(f)-5.535 E F2(par)4.285 E(ameter)-.15 E F0 .535 -(is null or unset, the e)3.765 F .535(xpansion of)-.15 F F2(wor)3.035 E -(d)-.37 E F0 .535(\(or a mes-)3.035 F .662(sage to that ef)144 496.8 R -.662(fect if)-.25 F F2(wor)3.502 E(d)-.37 E F0 .661(is not present\) is\ - written to the standard error and the shell, if it is not)3.932 F -(interacti)144 508.8 Q -.15(ve)-.25 G 2.5(,e).15 G 2.5(xits. Otherwise,) --2.65 F(the v)2.5 E(alue of)-.25 E F2(par)2.5 E(ameter)-.15 E F0 -(is substituted.)2.5 E(${)108 520.8 Q F2(par)A(ameter)-.15 E F1(:+)A F2 -(wor)A(d)-.37 E F0(})A F1 .745(Use Alter)144 532.8 R .745(nate V)-.15 F -(alue)-.92 E F0 5.745(.I)C(f)-5.745 E F2(par)4.495 E(ameter)-.15 E F0 +(eters may not be assigned to in this w)144 559.2 Q(ay)-.1 E(.)-.65 E +(${)108 571.2 Q F4(par)A(ameter)-.15 E F1(:?)A F4(wor)A(d)-.37 E F0(})A +F1 .535(Display Err)144 583.2 R .535(or if Null or Unset)-.18 F F0 5.535 +(.I)C(f)-5.535 E F4(par)4.285 E(ameter)-.15 E F0 .535 +(is null or unset, the e)3.765 F .535(xpansion of)-.15 F F4(wor)3.035 E +(d)-.37 E F0 .535(\(or a mes-)3.035 F .661(sage to that ef)144 595.2 R +.661(fect if)-.25 F F4(wor)3.501 E(d)-.37 E F0 .662(is not present\) is\ + written to the standard error and the shell, if it is not)3.931 F +(interacti)144 607.2 Q -.15(ve)-.25 G 2.5(,e).15 G 2.5(xits. Otherwise,) +-2.65 F(the v)2.5 E(alue of)-.25 E F4(par)2.5 E(ameter)-.15 E F0 +(is substituted.)2.5 E(${)108 619.2 Q F4(par)A(ameter)-.15 E F1(:+)A F4 +(wor)A(d)-.37 E F0(})A F1 .745(Use Alter)144 631.2 R .745(nate V)-.15 F +(alue)-.92 E F0 5.745(.I)C(f)-5.745 E F4(par)4.495 E(ameter)-.15 E F0 .745(is null or unset, nothing is substituted, otherwise the e)3.975 F -(xpan-)-.15 E(sion of)144 544.8 Q F2(wor)2.84 E(d)-.37 E F0 -(is substituted.)3.27 E(${)108 556.8 Q F2(par)A(ameter)-.15 E F1(:)A F2 -(of)A(fset)-.18 E F0(})A(${)108 568.8 Q F2(par)A(ameter)-.15 E F1(:)A F2 -(of)A(fset)-.18 E F1(:)A F2(length)A F0(})A F1 .002(Substring Expansion) -144 580.8 R F0 5.002(.E)C .002(xpands to up to)-5.002 F F2(length)2.502 -E F0 .002(characters of the v)2.502 F .002(alue of)-.25 F F2(par)2.502 E -(ameter)-.15 E F0 .002(starting at the)2.502 F 1.081 -(character speci\214ed by)144 592.8 R F2(of)3.581 E(fset)-.18 E F0 6.081 -(.I)C(f)-6.081 E F2(par)3.582 E(ameter)-.15 E F0(is)3.582 E F1(@)3.582 E +(xpan-)-.15 E(sion of)144 643.2 Q F4(wor)2.84 E(d)-.37 E F0 +(is substituted.)3.27 E(${)108 655.2 Q F4(par)A(ameter)-.15 E F1(:)A F4 +(of)A(fset)-.18 E F0(})A(${)108 667.2 Q F4(par)A(ameter)-.15 E F1(:)A F4 +(of)A(fset)-.18 E F1(:)A F4(length)A F0(})A F1 .002(Substring Expansion) +144 679.2 R F0 5.002(.E)C .002(xpands to up to)-5.002 F F4(length)2.502 +E F0 .002(characters of the v)2.502 F .002(alue of)-.25 F F4(par)2.502 E +(ameter)-.15 E F0 .002(starting at the)2.502 F 1.082 +(character speci\214ed by)144 691.2 R F4(of)3.582 E(fset)-.18 E F0 6.082 +(.I)C(f)-6.082 E F4(par)3.582 E(ameter)-.15 E F0(is)3.582 E F1(@)3.582 E F0 3.582(,a)C 3.582(ni)-3.582 G(nde)-3.582 E -.15(xe)-.15 G 3.582(da).15 -G 1.082(rray subscripted by)-3.582 F F1(@)3.582 E F0(or)3.582 E F1(*) -3.582 E F0 3.582(,o)C 3.582(ra)-3.582 G(n)-3.582 E(associati)144 604.8 Q +G 1.082(rray subscripted by)-3.582 F F1(@)3.582 E F0(or)3.581 E F1(*) +3.581 E F0 3.581(,o)C 3.581(ra)-3.581 G(n)-3.581 E(associati)144 703.2 Q 1.022 -.15(ve a)-.25 H .722(rray name, the results dif).15 F .722 -(fer as described belo)-.25 F 4.522 -.65(w. I)-.25 H(f).65 E F2(length) -3.222 E F0 .722(is omitted, e)3.222 F .722(xpands to the)-.15 F .042 -(substring of the v)144 616.8 R .042(alue of)-.25 F F2(par)2.542 E -(ameter)-.15 E F0 .043(starting at the character speci\214ed by)2.542 F -F2(of)2.543 E(fset)-.18 E F0 .043(and e)2.543 F .043(xtending to the) --.15 F .847(end of the v)144 628.8 R(alue.)-.25 E F2(length)5.846 E F0 -(and)3.346 E F2(of)3.346 E(fset)-.18 E F0 .846(are arithmetic e)3.346 F -.846(xpressions \(see)-.15 F/F3 9/Times-Bold@0 SF .846(ARITHMETIC EV) -3.346 F(ALU)-1.215 E -.855(AT)-.54 G(ION).855 E F0(belo)144 640.8 Q -(w\).)-.25 E(If)144 664.8 Q F2(of)3.028 E(fset)-.18 E F0 -.25(eva)3.029 -G .529(luates to a number less than zero, the v).25 F .529 -(alue is used as an of)-.25 F .529(fset in characters from the)-.25 F -.046(end of the v)144 676.8 R .046(alue of)-.25 F F2(par)2.546 E(ameter) --.15 E F0 5.046(.I)C(f)-5.046 E F2(length)2.546 E F0 -.25(eva)2.546 G -.046(luates to a number less than zero, it is interpreted as an).25 F -(of)144 688.8 Q .202(fset in characters from the end of the v)-.25 F -.202(alue of)-.25 F F2(par)2.702 E(ameter)-.15 E F0 .203 -(rather than a number of characters, and)2.702 F .558(the e)144 700.8 R -.558(xpansion is the characters between)-.15 F F2(of)3.058 E(fset)-.18 E -F0 .558(and that result.)3.058 F .557(Note that a ne)5.557 F -.05(ga) --.15 G(ti).05 E .857 -.15(ve o)-.25 H -.25(ff).15 G .557(set must be).25 -F(separated from the colon by at least one space to a)144 712.8 Q -.2 -(vo)-.2 G(id being confused with the).2 E F1(:-)2.5 E F0 -.15(ex)2.5 G -(pansion.).15 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(20)198.165 -E 0 Cg EP +(fer as described belo)-.25 F 4.522 -.65(w. I)-.25 H(f).65 E F4(length) +3.222 E F0 .722(is omitted, e)3.222 F .722(xpands to the)-.15 F .043 +(substring of the v)144 715.2 R .043(alue of)-.25 F F4(par)2.543 E +(ameter)-.15 E F0 .042(starting at the character speci\214ed by)2.543 F +F4(of)2.542 E(fset)-.18 E F0 .042(and e)2.542 F .042(xtending to the) +-.15 F .846(end of the v)144 727.2 R(alue.)-.25 E F4(length)5.846 E F0 +(and)3.346 E F4(of)3.346 E(fset)-.18 E F0 .846(are arithmetic e)3.346 F +.847(xpressions \(see)-.15 F F2 .847(ARITHMETIC EV)3.347 F(ALU)-1.215 E +-.855(AT)-.54 G(ION).855 E F0(GNU Bash 4.2)72 768 Q(2012 No)136.385 E +-.15(ve)-.15 G(mber 24).15 E(20)185.545 E 0 Cg EP %%Page: 21 21 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E(If)144 84 Q/F1 10/Times-Italic@0 SF(par)2.958 E(ameter)-.15 E F0 -(is)2.958 E/F2 10/Times-Bold@0 SF(@)2.958 E F0 2.958(,t)C .458 -(he result is)-2.958 F F1(length)2.959 E F0 .459 -(positional parameters be)2.959 F .459(ginning at)-.15 F F1(of)2.959 E -(fset)-.18 E F0 5.459(.A)C(ne)-2.5 E -.05(ga)-.15 G(ti).05 E -.15(ve) --.25 G F1(of)3.109 E(fset)-.18 E F0 .096(is tak)144 96 R .096(en relati) --.1 F .396 -.15(ve t)-.25 H 2.596(oo).15 G .096 -(ne greater than the greatest positional parameter)-2.596 F 2.596(,s)-.4 -G 2.596(oa)-2.596 G 2.596(no)-2.596 G -.25(ff)-2.596 G .096(set of -1 e) -.25 F -.25(va)-.25 G .095(luates to).25 F 1.321 -(the last positional parameter)144 108 R 6.322(.I)-.55 G 3.822(ti)-6.322 +-.35 E(belo)144 84 Q(w\).)-.25 E(If)144 108 Q/F1 10/Times-Italic@0 SF +(of)3.029 E(fset)-.18 E F0 -.25(eva)3.029 G .529 +(luates to a number less than zero, the v).25 F .529 +(alue is used as an of)-.25 F .529(fset in characters from the)-.25 F +.045(end of the v)144 120 R .045(alue of)-.25 F F1(par)2.546 E(ameter) +-.15 E F0 5.046(.I)C(f)-5.046 E F1(length)2.546 E F0 -.25(eva)2.546 G +.046(luates to a number less than zero, it is interpreted as an).25 F +(of)144 132 Q .203(fset in characters from the end of the v)-.25 F .202 +(alue of)-.25 F F1(par)2.702 E(ameter)-.15 E F0 .202 +(rather than a number of characters, and)2.702 F .557(the e)144 144 R +.557(xpansion is the characters between)-.15 F F1(of)3.057 E(fset)-.18 E +F0 .557(and that result.)3.057 F .558(Note that a ne)5.558 F -.05(ga) +-.15 G(ti).05 E .858 -.15(ve o)-.25 H -.25(ff).15 G .558(set must be).25 +F(separated from the colon by at least one space to a)144 156 Q -.2(vo) +-.2 G(id being confused with the).2 E/F2 10/Times-Bold@0 SF(:-)2.5 E F0 +-.15(ex)2.5 G(pansion.).15 E(If)144 180 Q F1(par)2.959 E(ameter)-.15 E +F0(is)2.959 E F2(@)2.959 E F0 2.959(,t)C .459(he result is)-2.959 F F1 +(length)2.959 E F0 .459(positional parameters be)2.959 F .458 +(ginning at)-.15 F F1(of)2.958 E(fset)-.18 E F0 5.458(.A)C(ne)-2.5 E +-.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G F1(of)3.108 E(fset)-.18 E F0 .095 +(is tak)144 192 R .095(en relati)-.1 F .396 -.15(ve t)-.25 H 2.596(oo) +.15 G .096(ne greater than the greatest positional parameter)-2.596 F +2.596(,s)-.4 G 2.596(oa)-2.596 G 2.596(no)-2.596 G -.25(ff)-2.596 G .096 +(set of -1 e).25 F -.25(va)-.25 G .096(luates to).25 F 1.322 +(the last positional parameter)144 204 R 6.322(.I)-.55 G 3.822(ti)-6.322 G 3.822(sa)-3.822 G 3.822(ne)-3.822 G 1.322(xpansion error if)-3.972 F F1(length)3.822 E F0 -.25(eva)3.822 G 1.322 -(luates to a number less than).25 F(zero.)144 120 Q(If)144 144 Q F1(par) -3.014 E(ameter)-.15 E F0 .514(is an inde)3.014 F -.15(xe)-.15 G 3.014 +(luates to a number less than).25 F(zero.)144 216 Q(If)144 240 Q F1(par) +3.013 E(ameter)-.15 E F0 .514(is an inde)3.013 F -.15(xe)-.15 G 3.014 (da).15 G .514(rray name subscripted by @ or *, the result is the)-3.014 -F F1(length)3.014 E F0 .513(members of)3.013 F 1.081(the array be)144 -156 R 1.081(ginning with ${)-.15 F F1(par)A(ameter)-.15 E F0([)A F1(of)A -(fset)-.18 E F0 3.581(]}. A)B(ne)3.581 E -.05(ga)-.15 G(ti).05 E -.15 -(ve)-.25 G F1(of)3.732 E(fset)-.18 E F0 1.082(is tak)3.582 F 1.082 -(en relati)-.1 F 1.382 -.15(ve t)-.25 H 3.582(oo).15 G 1.082(ne greater) --3.582 F 1.08(than the maximum inde)144 168 R 3.58(xo)-.15 G 3.58(ft) --3.58 G 1.08(he speci\214ed array)-3.58 F 6.079(.I)-.65 G 3.579(ti) --6.079 G 3.579(sa)-3.579 G 3.579(ne)-3.579 G 1.079(xpansion error if) --3.729 F F1(length)3.579 E F0 -.25(eva)3.579 G 1.079(luates to a).25 F -(number less than zero.)144 180 Q(Substring e)144 204 Q +F F1(length)3.014 E F0 .514(members of)3.014 F 1.082(the array be)144 +252 R 1.082(ginning with ${)-.15 F F1(par)A(ameter)-.15 E F0([)A F1(of)A +(fset)-.18 E F0 3.582(]}. A)B(ne)3.582 E -.05(ga)-.15 G(ti).05 E -.15 +(ve)-.25 G F1(of)3.732 E(fset)-.18 E F0 1.081(is tak)3.581 F 1.081 +(en relati)-.1 F 1.381 -.15(ve t)-.25 H 3.581(oo).15 G 1.081(ne greater) +-3.581 F 1.079(than the maximum inde)144 264 R 3.579(xo)-.15 G 3.579(ft) +-3.579 G 1.079(he speci\214ed array)-3.579 F 6.079(.I)-.65 G 3.579(ti) +-6.079 G 3.579(sa)-3.579 G 3.58(ne)-3.579 G 1.08(xpansion error if)-3.73 +F F1(length)3.58 E F0 -.25(eva)3.58 G 1.08(luates to a).25 F +(number less than zero.)144 276 Q(Substring e)144 300 Q (xpansion applied to an associati)-.15 E .3 -.15(ve a)-.25 H -(rray produces unde\214ned results.).15 E 1.93(Substring inde)144 228 R +(rray produces unde\214ned results.).15 E 1.931(Substring inde)144 324 R 1.931(xing is zero-based unless the positional parameters are used, in \ -which case the)-.15 F(inde)144 240 Q .307(xing starts at 1 by def)-.15 F -2.807(ault. If)-.1 F F1(of)2.807 E(fset)-.18 E F0 .307 -(is 0, and the positional parameters are used,)2.807 F F2($0)2.806 E F0 -.306(is pre\214x)2.806 F(ed)-.15 E(to the list.)144 252 Q(${)108 268.8 Q -F2(!)A F1(pr)A(e\214x)-.37 E F2(*)A F0(})A(${)108 280.8 Q F2(!)A F1(pr)A -(e\214x)-.37 E F2(@)A F0(})A F2 .084(Names matching pr)144 292.8 R -(e\214x)-.18 E F0 5.084(.E)C .084(xpands to the names of v)-5.084 F .084 -(ariables whose names be)-.25 F .085(gin with)-.15 F F1(pr)2.585 E -(e\214x)-.37 E F0 2.585(,s)C(epa-)-2.585 E .258 -(rated by the \214rst character of the)144 304.8 R/F3 9/Times-Bold@0 SF -(IFS)2.758 E F0 .257(special v)2.507 F 2.757(ariable. When)-.25 F F1(@) -2.757 E F0 .257(is used and the e)2.757 F .257(xpansion appears)-.15 F -(within double quotes, each v)144 316.8 Q(ariable name e)-.25 E -(xpands to a separate w)-.15 E(ord.)-.1 E(${)108 333.6 Q F2(!)A F1(name) -A F0([)A F1(@)A F0(]})A(${)108 345.6 Q F2(!)A F1(name)A F0([)A F1(*)A F0 -(]})A F2 2.035(List of array k)144 357.6 R(eys)-.1 E F0 7.036(.I)C(f) +which case the)-.15 F(inde)144 336 Q .306(xing starts at 1 by def)-.15 F +2.806(ault. If)-.1 F F1(of)2.807 E(fset)-.18 E F0 .307 +(is 0, and the positional parameters are used,)2.807 F F2($0)2.807 E F0 +.307(is pre\214x)2.807 F(ed)-.15 E(to the list.)144 348 Q(${)108 364.8 Q +F2(!)A F1(pr)A(e\214x)-.37 E F2(*)A F0(})A(${)108 376.8 Q F2(!)A F1(pr)A +(e\214x)-.37 E F2(@)A F0(})A F2 .085(Names matching pr)144 388.8 R +(e\214x)-.18 E F0 5.085(.E)C .084(xpands to the names of v)-5.085 F .084 +(ariables whose names be)-.25 F .084(gin with)-.15 F F1(pr)2.584 E +(e\214x)-.37 E F0 2.584(,s)C(epa-)-2.584 E .257 +(rated by the \214rst character of the)144 400.8 R/F3 9/Times-Bold@0 SF +(IFS)2.757 E F0 .257(special v)2.507 F 2.757(ariable. When)-.25 F F1(@) +2.758 E F0 .258(is used and the e)2.758 F .258(xpansion appears)-.15 F +(within double quotes, each v)144 412.8 Q(ariable name e)-.25 E +(xpands to a separate w)-.15 E(ord.)-.1 E(${)108 429.6 Q F2(!)A F1(name) +A F0([)A F1(@)A F0(]})A(${)108 441.6 Q F2(!)A F1(name)A F0([)A F1(*)A F0 +(]})A F2 2.036(List of array k)144 453.6 R(eys)-.1 E F0 7.036(.I)C(f) -7.036 E F1(name)4.536 E F0 2.036(is an array v)4.536 F 2.036 (ariable, e)-.25 F 2.036(xpands to the list of array indices \(k)-.15 F --.15(ey)-.1 G(s\)).15 E .596(assigned in)144 369.6 R F1(name)3.096 E F0 -5.596(.I)C(f)-5.596 E F1(name)3.096 E F0 .595(is not an array)3.096 F -3.095(,e)-.65 G .595(xpands to 0 if)-3.245 F F1(name)3.095 E F0 .595 -(is set and null otherwise.)3.095 F(When)5.595 E F1(@)144 381.6 Q F0 +-.15(ey)-.1 G(s\)).15 E .595(assigned in)144 465.6 R F1(name)3.095 E F0 +5.595(.I)C(f)-5.595 E F1(name)3.095 E F0 .595(is not an array)3.095 F +3.095(,e)-.65 G .595(xpands to 0 if)-3.245 F F1(name)3.095 E F0 .596 +(is set and null otherwise.)3.095 F(When)5.596 E F1(@)144 477.6 Q F0 (is used and the e)2.5 E(xpansion appears within double quotes, each k) -.15 E .3 -.15(ey ex)-.1 H(pands to a separate w).15 E(ord.)-.1 E(${)108 -398.4 Q F2(#)A F1(par)A(ameter)-.15 E F0(})A F2 -.1(Pa)144 410.4 S .47 -(rameter length).1 F F0 5.47(.T)C .471(he length in characters of the v) --5.47 F .471(alue of)-.25 F F1(par)2.971 E(ameter)-.15 E F0 .471 -(is substituted.)2.971 F(If)5.471 E F1(par)4.221 E(ame-)-.15 E(ter)144 -422.4 Q F0(is)4.439 E F2(*)3.709 E F0(or)3.709 E F2(@)3.709 E F0 3.708 -(,t)C 1.208(he v)-3.708 F 1.208 +494.4 Q F2(#)A F1(par)A(ameter)-.15 E F0(})A F2 -.1(Pa)144 506.4 S .471 +(rameter length).1 F F0 5.471(.T)C .471 +(he length in characters of the v)-5.471 F .471(alue of)-.25 F F1(par) +2.971 E(ameter)-.15 E F0 .47(is substituted.)2.97 F(If)5.47 E F1(par) +4.22 E(ame-)-.15 E(ter)144 518.4 Q F0(is)4.438 E F2(*)3.708 E F0(or) +3.708 E F2(@)3.708 E F0 3.708(,t)C 1.208(he v)-3.708 F 1.208 (alue substituted is the number of positional parameters.)-.25 F(If) -6.208 E F1(par)4.958 E(ameter)-.15 E F0 1.208(is an)4.438 F -(array name subscripted by)144 434.4 Q F2(*)2.5 E F0(or)2.5 E F2(@)2.5 E -F0 2.5(,t)C(he v)-2.5 E -(alue substituted is the number of elements in the array)-.25 E(.)-.65 E -(${)108 451.2 Q F1(par)A(ameter)-.15 E F2(#)A F1(wor)A(d)-.37 E F0(})A -(${)108 463.2 Q F1(par)A(ameter)-.15 E F2(##)A F1(wor)A(d)-.37 E F0(})A -F2(Remo)144 475.2 Q 1.396 -.1(ve m)-.1 H 1.196(atching pr).1 F 1.196 -(e\214x patter)-.18 F(n)-.15 E F0 6.196(.T)C(he)-6.196 E F1(wor)4.036 E -(d)-.37 E F0 1.196(is e)4.466 F 1.196 -(xpanded to produce a pattern just as in path-)-.15 F .152(name e)144 -487.2 R 2.652(xpansion. If)-.15 F .152(the pattern matches the be)2.652 -F .152(ginning of the v)-.15 F .152(alue of)-.25 F F1(par)2.652 E -(ameter)-.15 E F0 2.652(,t).73 G .151(hen the result of)-2.652 F 1.4 -(the e)144 499.2 R 1.4(xpansion is the e)-.15 F 1.4(xpanded v)-.15 F 1.4 -(alue of)-.25 F F1(par)5.15 E(ameter)-.15 E F0 1.4 -(with the shortest matching pattern \(the `)4.63 F(`)-.74 E F2(#)A F0 --.74('')C .281(case\) or the longest matching pattern \(the `)144 511.2 -R(`)-.74 E F2(##)A F0 1.761 -.74('' c)D .281(ase\) deleted.).74 F(If) -5.281 E F1(par)4.031 E(ameter)-.15 E F0(is)3.511 E F2(@)2.781 E F0(or) -2.781 E F2(*)2.781 E F0 2.781(,t)C .281(he pattern)-2.781 F(remo)144 -523.2 Q -.25(va)-.15 G 3.274(lo).25 G .774 +6.209 E F1(par)4.959 E(ameter)-.15 E F0 1.209(is an)4.439 F .349 +(array name subscripted by)144 530.4 R F2(*)2.849 E F0(or)2.849 E F2(@) +2.849 E F0 2.849(,t)C .349(he v)-2.849 F .349 +(alue substituted is the number of elements in the array)-.25 F 5.348 +(.I)-.65 G(f)-5.348 E F1(par)145.25 542.4 Q(ameter)-.15 E F0 .455 +(is an inde)3.685 F -.15(xe)-.15 G 2.955(da).15 G .456 +(rray name subscripted by a ne)-2.955 F -.05(ga)-.15 G(ti).05 E .756 +-.15(ve n)-.25 H(umber).15 E 2.956(,t)-.4 G .456 +(hat number is interpreted)-2.956 F .973(as relati)144 554.4 R 1.273 +-.15(ve t)-.25 H 3.473(oo).15 G .973(ne greater than the maximum inde) +-3.473 F 3.473(xo)-.15 G(f)-3.473 E F1(par)3.473 E(ameter)-.15 E F0 +3.472(,s)C 3.472(on)-3.472 G -2.25 -.15(eg a)-3.472 H(ti).15 E 1.272 +-.15(ve i)-.25 H .972(ndices count back).15 F(from the end of the array) +144 566.4 Q 2.5(,a)-.65 G(nd an inde)-2.5 E 2.5(xo)-.15 G 2.5<66ad>-2.5 +G 2.5(1r)-2.5 G(eferences the last element.)-2.5 E(${)108 583.2 Q F1 +(par)A(ameter)-.15 E F2(#)A F1(wor)A(d)-.37 E F0(})A(${)108 595.2 Q F1 +(par)A(ameter)-.15 E F2(##)A F1(wor)A(d)-.37 E F0(})A F2(Remo)144 607.2 +Q 1.396 -.1(ve m)-.1 H 1.196(atching pr).1 F 1.196(e\214x patter)-.18 F +(n)-.15 E F0 6.196(.T)C(he)-6.196 E F1(wor)4.036 E(d)-.37 E F0 1.196 +(is e)4.466 F 1.196(xpanded to produce a pattern just as in path-)-.15 F +.152(name e)144 619.2 R 2.652(xpansion. If)-.15 F .152 +(the pattern matches the be)2.652 F .152(ginning of the v)-.15 F .152 +(alue of)-.25 F F1(par)2.652 E(ameter)-.15 E F0 2.652(,t).73 G .151 +(hen the result of)-2.652 F 1.4(the e)144 631.2 R 1.4(xpansion is the e) +-.15 F 1.4(xpanded v)-.15 F 1.4(alue of)-.25 F F1(par)5.15 E(ameter)-.15 +E F0 1.4(with the shortest matching pattern \(the `)4.63 F(`)-.74 E F2 +(#)A F0 -.74('')C .281(case\) or the longest matching pattern \(the `) +144 643.2 R(`)-.74 E F2(##)A F0 1.761 -.74('' c)D .281(ase\) deleted.) +.74 F(If)5.281 E F1(par)4.031 E(ameter)-.15 E F0(is)3.511 E F2(@)2.781 E +F0(or)2.781 E F2(*)2.781 E F0 2.781(,t)C .281(he pattern)-2.781 F(remo) +144 655.2 Q -.25(va)-.15 G 3.274(lo).25 G .774 (peration is applied to each positional parameter in turn, and the e) --3.274 F .774(xpansion is the resul-)-.15 F .402(tant list.)144 535.2 R +-3.274 F .774(xpansion is the resul-)-.15 F .402(tant list.)144 667.2 R (If)5.402 E F1(par)4.152 E(ameter)-.15 E F0 .401(is an array v)3.632 F .401(ariable subscripted with)-.25 F F2(@)2.901 E F0(or)2.901 E F2(*) 2.901 E F0 2.901(,t)C .401(he pattern remo)-2.901 F -.25(va)-.15 G 2.901 (lo).25 G(peration)-2.901 E -(is applied to each member of the array in turn, and the e)144 547.2 Q -(xpansion is the resultant list.)-.15 E(${)108 564 Q F1(par)A(ameter) --.15 E F2(%)A F1(wor)A(d)-.37 E F0(})A(${)108 576 Q F1(par)A(ameter)-.15 -E F2(%%)A F1(wor)A(d)-.37 E F0(})A F2(Remo)144 588 Q .346 -.1(ve m)-.1 H -.146(atching suf\214x patter).1 F(n)-.15 E F0 5.146(.T)C(he)-5.146 E F1 -(wor)2.646 E(d)-.37 E F0 .147(is e)2.647 F .147 -(xpanded to produce a pattern just as in pathname)-.15 F -.15(ex)144 600 +(is applied to each member of the array in turn, and the e)144 679.2 Q +(xpansion is the resultant list.)-.15 E(${)108 696 Q F1(par)A(ameter) +-.15 E F2(%)A F1(wor)A(d)-.37 E F0(})A(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(21)185.545 E 0 Cg EP +%%Page: 22 22 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(${)108 84 Q/F1 10/Times-Italic@0 SF(par)A(ameter)-.15 E/F2 10 +/Times-Bold@0 SF(%%)A F1(wor)A(d)-.37 E F0(})A F2(Remo)144 96 Q .346 -.1 +(ve m)-.1 H .146(atching suf\214x patter).1 F(n)-.15 E F0 5.146(.T)C(he) +-5.146 E F1(wor)2.646 E(d)-.37 E F0 .147(is e)2.647 F .147 +(xpanded to produce a pattern just as in pathname)-.15 F -.15(ex)144 108 S 3.088(pansion. If).15 F .588 (the pattern matches a trailing portion of the e)3.088 F .588(xpanded v) -.15 F .588(alue of)-.25 F F1(par)3.088 E(ameter)-.15 E F0 3.088(,t).73 -G .588(hen the)-3.088 F .226(result of the e)144 612 R .226 +G .588(hen the)-3.088 F .226(result of the e)144 120 R .226 (xpansion is the e)-.15 F .226(xpanded v)-.15 F .226(alue of)-.25 F F1 (par)3.976 E(ameter)-.15 E F0 .226 -(with the shortest matching pattern \(the)3.456 F -.74(``)144 624 S F2 +(with the shortest matching pattern \(the)3.456 F -.74(``)144 132 S F2 (%).74 E F0 1.522 -.74('' c)D .042 (ase\) or the longest matching pattern \(the `).74 F(`)-.74 E F2(%%)A F0 1.522 -.74('' c)D .042(ase\) deleted.).74 F(If)5.042 E F1(par)3.792 E (ameter)-.15 E F0(is)3.272 E F2(@)2.541 E F0(or)2.541 E F2(*)2.541 E F0 -2.541(,t)C(he)-2.541 E .44(pattern remo)144 636 R -.25(va)-.15 G 2.94 +2.541(,t)C(he)-2.541 E .44(pattern remo)144 144 R -.25(va)-.15 G 2.94 (lo).25 G .441 (peration is applied to each positional parameter in turn, and the e) --2.94 F .441(xpansion is the)-.15 F .241(resultant list.)144 648 R(If) +-2.94 F .441(xpansion is the)-.15 F .241(resultant list.)144 156 R(If) 5.241 E F1(par)3.991 E(ameter)-.15 E F0 .241(is an array v)3.471 F .241 (ariable subscripted with)-.25 F F2(@)2.741 E F0(or)2.74 E F2(*)2.74 E F0 2.74(,t)C .24(he pattern remo)-2.74 F -.25(va)-.15 G 2.74(lo).25 G (per)-2.74 E(-)-.2 E -(ation is applied to each member of the array in turn, and the e)144 660 -Q(xpansion is the resultant list.)-.15 E(${)108 676.8 Q F1(par)A(ameter) --.15 E F2(/)A F1(pattern)A F2(/)A F1(string)A F0(})A F2 -.1(Pa)144 688.8 +(ation is applied to each member of the array in turn, and the e)144 168 +Q(xpansion is the resultant list.)-.15 E(${)108 184.8 Q F1(par)A(ameter) +-.15 E F2(/)A F1(pattern)A F2(/)A F1(string)A F0(})A F2 -.1(Pa)144 196.8 S(tter).1 E 3.606(ns)-.15 G(ubstitution)-3.606 E F0 6.106(.T)C(he)-6.106 E F1(pattern)3.606 E F0 1.106(is e)3.606 F 1.107 (xpanded to produce a pattern just as in pathname e)-.15 F(xpan-)-.15 E -(sion.)144 700.8 Q F1 -.8(Pa)6.034 G -.15(ra).8 G(meter).15 E F0 1.034 +(sion.)144 208.8 Q F1 -.8(Pa)6.034 G -.15(ra).8 G(meter).15 E F0 1.034 (is e)3.534 F 1.033(xpanded and the longest match of)-.15 F F1(pattern) 3.533 E F0(ag)3.533 E 1.033(ainst its v)-.05 F 1.033 -(alue is replaced with)-.25 F F1(string)144 712.8 Q F0 5.16(.I)C(f)-5.16 +(alue is replaced with)-.25 F F1(string)144 220.8 Q F0 5.16(.I)C(f)-5.16 E F1(pattern)2.66 E F0(be)2.66 E .16(gins with)-.15 F F2(/)2.66 E F0 2.66(,a)C .161(ll matches of)-2.66 F F1(pattern)2.661 E F0 .161 (are replaced with)2.661 F F1(string)2.661 E F0 5.161(.N)C .161 -(ormally only the)-5.161 F .807(\214rst match is replaced.)144 724.8 R +(ormally only the)-5.161 F .807(\214rst match is replaced.)144 232.8 R (If)5.807 E F1(pattern)3.307 E F0(be)3.307 E .807(gins with)-.15 F F2(#) 3.307 E F0 3.306(,i)C 3.306(tm)-3.306 G .806(ust match at the be)-3.306 -F .806(ginning of the e)-.15 F(xpanded)-.15 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(21)198.165 E 0 Cg EP -%%Page: 22 22 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E -.25(va)144 84 S .62(lue of).25 F/F1 10/Times-Italic@0 SF(par) -3.12 E(ameter)-.15 E F0 5.62(.I)C(f)-5.62 E F1(pattern)3.12 E F0(be)3.12 -E .62(gins with)-.15 F/F2 10/Times-Bold@0 SF(%)3.12 E F0 3.12(,i)C 3.121 -(tm)-3.12 G .621(ust match at the end of the e)-3.121 F .621(xpanded v) --.15 F .621(alue of)-.25 F F1(par)144 96 Q(ameter)-.15 E F0 6.254(.I)C -(f)-6.254 E F1(string)3.754 E F0 1.253(is null, matches of)3.753 F F1 -(pattern)3.753 E F0 1.253(are deleted and the)3.753 F F2(/)3.753 E F0 -(follo)3.753 E(wing)-.25 E F1(pattern)3.753 E F0 1.253(may be)3.753 F -2.678(omitted. If)144 108 R F1(par)3.928 E(ameter)-.15 E F0(is)3.408 E -F2(@)2.678 E F0(or)2.678 E F2(*)2.679 E F0 2.679(,t)C .179 +F .806(ginning of the e)-.15 F(xpanded)-.15 E -.25(va)144 244.8 S .62 +(lue of).25 F F1(par)3.12 E(ameter)-.15 E F0 5.62(.I)C(f)-5.62 E F1 +(pattern)3.12 E F0(be)3.12 E .62(gins with)-.15 F F2(%)3.12 E F0 3.12 +(,i)C 3.121(tm)-3.12 G .621(ust match at the end of the e)-3.121 F .621 +(xpanded v)-.15 F .621(alue of)-.25 F F1(par)144 256.8 Q(ameter)-.15 E +F0 6.254(.I)C(f)-6.254 E F1(string)3.754 E F0 1.253(is null, matches of) +3.753 F F1(pattern)3.753 E F0 1.253(are deleted and the)3.753 F F2(/) +3.753 E F0(follo)3.753 E(wing)-.25 E F1(pattern)3.753 E F0 1.253(may be) +3.753 F 2.678(omitted. If)144 268.8 R F1(par)3.928 E(ameter)-.15 E F0 +(is)3.408 E F2(@)2.678 E F0(or)2.678 E F2(*)2.679 E F0 2.679(,t)C .179 (he substitution operation is applied to each positional parameter) --2.679 F .619(in turn, and the e)144 120 R .619 +-2.679 F .619(in turn, and the e)144 280.8 R .619 (xpansion is the resultant list.)-.15 F(If)5.619 E F1(par)4.369 E (ameter)-.15 E F0 .618(is an array v)3.849 F .618 -(ariable subscripted with)-.25 F F2(@)144 132 Q F0(or)3.223 E F2(*)3.223 -E F0 3.223(,t)C .723(he substitution operation is applied to each membe\ -r of the array in turn, and the e)-3.223 F(xpan-)-.15 E -(sion is the resultant list.)144 144 Q(${)108 160.8 Q F1(par)A(ameter) --.15 E F2(^)A F1(pattern)A F0(})A(${)108 172.8 Q F1(par)A(ameter)-.15 E -F2(^^)A F1(pattern)A F0(})A(${)108 184.8 Q F1(par)A(ameter)-.15 E F2(,)A -F1(pattern)A F0(})A(${)108 196.8 Q F1(par)A(ameter)-.15 E F2(,,)A F1 -(pattern)A F0(})A F2 .438(Case modi\214cation)144 208.8 R F0 5.438(.T)C +(ariable subscripted with)-.25 F F2(@)144 292.8 Q F0(or)3.223 E F2(*) +3.223 E F0 3.223(,t)C .723(he substitution operation is applied to each\ + member of the array in turn, and the e)-3.223 F(xpan-)-.15 E +(sion is the resultant list.)144 304.8 Q(${)108 321.6 Q F1(par)A(ameter) +-.15 E F2(^)A F1(pattern)A F0(})A(${)108 333.6 Q F1(par)A(ameter)-.15 E +F2(^^)A F1(pattern)A F0(})A(${)108 345.6 Q F1(par)A(ameter)-.15 E F2(,)A +F1(pattern)A F0(})A(${)108 357.6 Q F1(par)A(ameter)-.15 E F2(,,)A F1 +(pattern)A F0(})A F2 .438(Case modi\214cation)144 369.6 R F0 5.438(.T)C .438(his e)-5.438 F .437 (xpansion modi\214es the case of alphabetic characters in)-.15 F F1(par) -2.937 E(ameter)-.15 E F0 5.437(.T)C(he)-5.437 E F1(pattern)144 220.8 Q +2.937 E(ameter)-.15 E F0 5.437(.T)C(he)-5.437 E F1(pattern)144 381.6 Q F0 1.406(is e)3.906 F 1.407 (xpanded to produce a pattern just as in pathname e)-.15 F 3.907 -(xpansion. Each)-.15 F 1.407(character in the)3.907 F -.15(ex)144 232.8 +(xpansion. Each)-.15 F 1.407(character in the)3.907 F -.15(ex)144 393.6 S 1.232(panded v).15 F 1.232(alue of)-.25 F F1(par)3.732 E(ameter)-.15 E F0 1.232(is tested ag)3.732 F(ainst)-.05 E F1(pattern)3.732 E F0 3.732 (,a)C 1.232(nd, if it matches the pattern, its case is)-3.732 F(con)144 -244.8 Q -.15(ve)-.4 G 2.924(rted. The).15 F .424 +405.6 Q -.15(ve)-.4 G 2.924(rted. The).15 F .424 (pattern should not attempt to match more than one character)2.924 F 5.424(.T)-.55 G(he)-5.424 E F2(^)2.924 E F0 .424(operator con-)2.924 F --.15(ve)144 256.8 S .61(rts lo).15 F .61(wercase letters matching)-.25 F +-.15(ve)144 417.6 S .61(rts lo).15 F .61(wercase letters matching)-.25 F F1(pattern)3.11 E F0 .61(to uppercase; the)3.11 F F2(,)3.11 E F0 .61 (operator con)3.11 F -.15(ve)-.4 G .61(rts matching uppercase).15 F -1.547(letters to lo)144 268.8 R 4.047(wercase. The)-.25 F F2(^^)4.047 E +1.547(letters to lo)144 429.6 R 4.047(wercase. The)-.25 F F2(^^)4.047 E F0(and)4.047 E F2(,,)4.047 E F0 -.15(ex)4.047 G 1.547(pansions con).15 F -.15(ve)-.4 G 1.547(rt each matched character in the e).15 F(xpanded) --.15 E -.25(va)144 280.8 S .634(lue; the).25 F F2(^)3.134 E F0(and)3.134 +-.15 E -.25(va)144 441.6 S .634(lue; the).25 F F2(^)3.134 E F0(and)3.134 E F2(,)3.134 E F0 -.15(ex)3.134 G .634(pansions match and con).15 F -.15 (ve)-.4 G .633(rt only the \214rst character in the e).15 F .633 -(xpanded v)-.15 F 3.133(alue. If)-.25 F F1(pattern)144 292.8 Q F0 .78 +(xpanded v)-.15 F 3.133(alue. If)-.25 F F1(pattern)144 453.6 Q F0 .78 (is omitted, it is treated lik)3.28 F 3.28(ea)-.1 G F2(?)A F0 3.28(,w)C .78(hich matches e)-3.28 F -.15(ve)-.25 G .78(ry character).15 F 5.78 (.I)-.55 G(f)-5.78 E F1(par)4.53 E(ameter)-.15 E F0(is)4.01 E F2(@)3.28 E F0(or)3.28 E F2(*)3.28 E F0(,)A .582(the case modi\214cation operatio\ -n is applied to each positional parameter in turn, and the e)144 304.8 R -(xpansion)-.15 E .468(is the resultant list.)144 316.8 R(If)5.468 E F1 +n is applied to each positional parameter in turn, and the e)144 465.6 R +(xpansion)-.15 E .468(is the resultant list.)144 477.6 R(If)5.468 E F1 (par)4.218 E(ameter)-.15 E F0 .468(is an array v)3.698 F .468 (ariable subscripted with)-.25 F F2(@)2.968 E F0(or)2.968 E F2(*)2.969 E F0 2.969(,t)C .469(he case modi\214ca-)-2.969 F .005(tion operation is \ -applied to each member of the array in turn, and the e)144 328.8 R .005 -(xpansion is the resultant list.)-.15 F F2(Command Substitution)87 345.6 -Q F1 1.697(Command substitution)108 357.6 R F0(allo)4.197 E 1.697 +applied to each member of the array in turn, and the e)144 489.6 R .005 +(xpansion is the resultant list.)-.15 F F2(Command Substitution)87 506.4 +Q F1 1.697(Command substitution)108 518.4 R F0(allo)4.197 E 1.697 (ws the output of a command to replace the command name.)-.25 F 1.698 -(There are tw)6.698 F(o)-.1 E(forms:)108 369.6 Q F2($\()144 386.4 Q F1 -(command)A F2(\))1.666 E F0(or)108 398.4 Q F2<92>144 410.4 Q F1(command) -A F2<92>A(Bash)108 427.2 Q F0 .02(performs the e)2.52 F .02 -(xpansion by e)-.15 F -.15(xe)-.15 G(cuting).15 E F1(command)2.519 E F0 -.019(and replacing the command substitution with the stan-)2.519 F .768 -(dard output of the command, with an)108 439.2 R 3.268(yt)-.15 G .768 +(There are tw)6.698 F(o)-.1 E(forms:)108 530.4 Q F2($\()144 547.2 Q F1 +(command)A F2(\))1.666 E F0(or)108 559.2 Q F2<92>144 571.2 Q F1(command) +A F2<92>A(Bash)108 588 Q F0 .02(performs the e)2.52 F .02(xpansion by e) +-.15 F -.15(xe)-.15 G(cuting).15 E F1(command)2.519 E F0 .019 +(and replacing the command substitution with the stan-)2.519 F .768 +(dard output of the command, with an)108 600 R 3.268(yt)-.15 G .768 (railing ne)-3.268 F .768(wlines deleted.)-.25 F .768(Embedded ne)5.768 -F .768(wlines are not deleted, b)-.25 F(ut)-.2 E(the)108 451.2 Q 3.219 -(ym)-.15 G .719(ay be remo)-3.219 F -.15(ve)-.15 G 3.219(dd).15 G .719 +F .768(wlines are not deleted, b)-.25 F(ut)-.2 E(the)108 612 Q 3.219(ym) +-.15 G .719(ay be remo)-3.219 F -.15(ve)-.15 G 3.219(dd).15 G .719 (uring w)-3.219 F .719(ord splitting.)-.1 F .719 (The command substitution)5.719 F F2($\(cat)3.219 E F1(\214le)3.219 E F2 -(\))A F0 .718(can be replaced by the)3.219 F(equi)108 463.2 Q -.25(va) --.25 G(lent b).25 E(ut f)-.2 E(aster)-.1 E F2($\(<)2.5 E F1(\214le)2.5 E -F2(\))A F0(.)A 1.724(When the old-style backquote form of substitution \ -is used, backslash retains its literal meaning e)108 480 R(xcept)-.15 E -.315(when follo)108 492 R .315(wed by)-.25 F F2($)2.815 E F0(,)A F2<92> -2.815 E F0 2.815(,o)C(r)-2.815 E F2(\\)2.815 E F0 5.315(.T)C .314(he \ -\214rst backquote not preceded by a backslash terminates the command su\ -b-)-5.315 F 3.886(stitution. When)108 504 R 1.386(using the $\()3.886 F -F1(command).833 E F0 3.886(\)f)1.666 G 1.387 +(\))A F0 .718(can be replaced by the)3.219 F(equi)108 624 Q -.25(va)-.25 +G(lent b).25 E(ut f)-.2 E(aster)-.1 E F2($\(<)2.5 E F1(\214le)2.5 E F2 +(\))A F0(.)A 1.724(When the old-style backquote form of substitution is\ + used, backslash retains its literal meaning e)108 640.8 R(xcept)-.15 E +.315(when follo)108 652.8 R .315(wed by)-.25 F F2($)2.815 E F0(,)A F2 +<92>2.815 E F0 2.815(,o)C(r)-2.815 E F2(\\)2.815 E F0 5.315(.T)C .314(h\ +e \214rst backquote not preceded by a backslash terminates the command \ +sub-)-5.315 F 3.886(stitution. When)108 664.8 R 1.386(using the $\() +3.886 F F1(command).833 E F0 3.886(\)f)1.666 G 1.387 (orm, all characters between the parentheses mak)-3.886 F 3.887(eu)-.1 G 3.887(pt)-3.887 G 1.387(he com-)-3.887 F -(mand; none are treated specially)108 516 Q(.)-.65 E .894 -(Command substitutions may be nested.)108 532.8 R 2.494 -.8(To n)5.894 H +(mand; none are treated specially)108 676.8 Q(.)-.65 E .894 +(Command substitutions may be nested.)108 693.6 R 2.494 -.8(To n)5.894 H .894(est when using the backquoted form, escape the inner back-).8 F -(quotes with backslashes.)108 544.8 Q .422 -(If the substitution appears within double quotes, w)108 561.6 R .422 +(quotes with backslashes.)108 705.6 Q .422 +(If the substitution appears within double quotes, w)108 722.4 R .422 (ord splitting and pathname e)-.1 F .423(xpansion are not performed)-.15 -F(on the results.)108 573.6 Q F2(Arithmetic Expansion)87 590.4 Q F0 -1.035(Arithmetic e)108 602.4 R 1.035(xpansion allo)-.15 F 1.035 -(ws the e)-.25 F -.25(va)-.25 G 1.034(luation of an arithmetic e).25 F -1.034(xpression and the substitution of the result.)-.15 F -(The format for arithmetic e)108 614.4 Q(xpansion is:)-.15 E F2($\(\() -144 631.2 Q F1 -.2(ex)C(pr).2 E(ession)-.37 E F2(\)\))A F0(The)108 648 Q -F1 -.2(ex)2.665 G(pr).2 E(ession)-.37 E F0 .165 -(is treated as if it were within double quotes, b)2.905 F .166 -(ut a double quote inside the parentheses is not)-.2 F 1.075 -(treated specially)108 660 R 6.075(.A)-.65 G 1.074(ll tok)-6.075 F 1.074 -(ens in the e)-.1 F 1.074(xpression under)-.15 F 1.074(go parameter e) --.18 F 1.074(xpansion, string e)-.15 F 1.074(xpansion, command)-.15 F -(substitution, and quote remo)108 672 Q -.25(va)-.15 G 2.5 -(l. Arithmetic).25 F -.15(ex)2.5 G(pansions may be nested.).15 E 1.378 -(The e)108 688.8 R -.25(va)-.25 G 1.378 -(luation is performed according to the rules listed belo).25 F 3.878(wu) --.25 G(nder)-3.878 E/F3 9/Times-Bold@0 SF 1.378(ARITHMETIC EV)3.878 F -(ALU)-1.215 E -.855(AT)-.54 G(ION).855 E/F4 9/Times-Roman@0 SF(.)A F0 -(If)5.879 E F1 -.2(ex)108 700.8 S(pr).2 E(ession)-.37 E F0(is in)2.74 E --.25(va)-.4 G(lid,).25 E F2(bash)2.5 E F0(prints a message indicating f) -2.5 E(ailure and no substitution occurs.)-.1 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(22)198.165 E 0 Cg EP +F(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(22)185.545 E 0 Cg EP %%Page: 23 23 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(Pr)87 84 Q(ocess Substitution)-.18 E/F2 10 -/Times-Italic@0 SF(Pr)108 96 Q .971(ocess substitution)-.45 F F0 .971 +-.35 E(on the results.)108 84 Q/F1 10/Times-Bold@0 SF +(Arithmetic Expansion)87 100.8 Q F0 1.035(Arithmetic e)108 112.8 R 1.035 +(xpansion allo)-.15 F 1.035(ws the e)-.25 F -.25(va)-.25 G 1.034 +(luation of an arithmetic e).25 F 1.034 +(xpression and the substitution of the result.)-.15 F +(The format for arithmetic e)108 124.8 Q(xpansion is:)-.15 E F1($\(\() +144 141.6 Q/F2 10/Times-Italic@0 SF -.2(ex)C(pr).2 E(ession)-.37 E F1 +(\)\))A F0(The)108 158.4 Q F2 -.2(ex)2.665 G(pr).2 E(ession)-.37 E F0 +.165(is treated as if it were within double quotes, b)2.905 F .166 +(ut a double quote inside the parentheses is not)-.2 F 1.075 +(treated specially)108 170.4 R 6.075(.A)-.65 G 1.074(ll tok)-6.075 F +1.074(ens in the e)-.1 F 1.074(xpression under)-.15 F 1.074 +(go parameter e)-.18 F 1.074(xpansion, string e)-.15 F 1.074 +(xpansion, command)-.15 F(substitution, and quote remo)108 182.4 Q -.25 +(va)-.15 G 2.5(l. Arithmetic).25 F -.15(ex)2.5 G +(pansions may be nested.).15 E 1.378(The e)108 199.2 R -.25(va)-.25 G +1.378(luation is performed according to the rules listed belo).25 F +3.878(wu)-.25 G(nder)-3.878 E/F3 9/Times-Bold@0 SF 1.378(ARITHMETIC EV) +3.878 F(ALU)-1.215 E -.855(AT)-.54 G(ION).855 E/F4 9/Times-Roman@0 SF(.) +A F0(If)5.879 E F2 -.2(ex)108 211.2 S(pr).2 E(ession)-.37 E F0(is in) +2.74 E -.25(va)-.4 G(lid,).25 E F1(bash)2.5 E F0 +(prints a message indicating f)2.5 E(ailure and no substitution occurs.) +-.1 E F1(Pr)87 228 Q(ocess Substitution)-.18 E F2(Pr)108 240 Q .971 +(ocess substitution)-.45 F F0 .971 (is supported on systems that support named pipes \()3.471 F F2(FIFOs)A F0 3.47(\)o)C 3.47(rt)-3.47 G(he)-3.47 E F1(/de)3.47 E(v/fd)-.15 E F0 -.97(method of)3.47 F .021(naming open \214les.)108 108 R .021(It tak) +.97(method of)3.47 F .021(naming open \214les.)108 252 R .021(It tak) 5.021 F .021(es the form of)-.1 F F1(<\()2.521 E F2(list)A F1(\)).833 E F0(or)2.521 E F1(>\()2.521 E F2(list)A F1(\)).833 E F0 5.021(.T)C .021 (he process)-5.021 F F2(list)2.521 E F0 .021 -(is run with its input or output con-)2.521 F .059(nected to a)108 120 R +(is run with its input or output con-)2.521 F .059(nected to a)108 264 R F2(FIFO)2.559 E F0 .058(or some \214le in)2.559 F F1(/de)2.558 E(v/fd) -.15 E F0 5.058(.T)C .058(he name of this \214le is passed as an ar) -5.058 F .058(gument to the current com-)-.18 F .13 -(mand as the result of the e)108 132 R 2.63(xpansion. If)-.15 F(the)2.63 +(mand as the result of the e)108 276 R 2.63(xpansion. If)-.15 F(the)2.63 E F1(>\()2.63 E F2(list)A F1(\)).833 E F0 .13 (form is used, writing to the \214le will pro)2.63 F .131 -(vide input for)-.15 F F2(list)2.631 E F0(.)A(If the)108 144 Q F1(<\() +(vide input for)-.15 F F2(list)2.631 E F0(.)A(If the)108 288 Q F1(<\() 2.5 E F2(list)A F1(\)).833 E F0 (form is used, the \214le passed as an ar)2.5 E (gument should be read to obtain the output of)-.18 E F2(list)2.5 E F0 -(.)A .897(When a)108 160.8 R -.25(va)-.2 G .896(ilable, process substit\ +(.)A .897(When a)108 304.8 R -.25(va)-.2 G .896(ilable, process substit\ ution is performed simultaneously with parameter and v).25 F .896 (ariable e)-.25 F(xpansion,)-.15 E -(command substitution, and arithmetic e)108 172.8 Q(xpansion.)-.15 E F1 --.75(Wo)87 189.6 S(rd Splitting).75 E F0 1.142 -(The shell scans the results of parameter e)108 201.6 R 1.143 +(command substitution, and arithmetic e)108 316.8 Q(xpansion.)-.15 E F1 +-.75(Wo)87 333.6 S(rd Splitting).75 E F0 1.142 +(The shell scans the results of parameter e)108 345.6 R 1.143 (xpansion, command substitution, and arithmetic e)-.15 F 1.143 -(xpansion that)-.15 F(did not occur within double quotes for)108 213.6 Q +(xpansion that)-.15 F(did not occur within double quotes for)108 357.6 Q F2(wor)2.5 E 2.5(ds)-.37 G(plitting)-2.5 E F0(.).22 E .063 -(The shell treats each character of)108 230.4 R/F3 9/Times-Bold@0 SF -(IFS)2.563 E F0 .063(as a delimiter)2.313 F 2.563(,a)-.4 G .063 +(The shell treats each character of)108 374.4 R F3(IFS)2.563 E F0 .063 +(as a delimiter)2.313 F 2.563(,a)-.4 G .063 (nd splits the results of the other e)-2.563 F .063(xpansions into w) --.15 F(ords)-.1 E 1.788(on these characters.)108 242.4 R(If)6.788 E F3 +-.15 F(ords)-.1 E 1.788(on these characters.)108 386.4 R(If)6.788 E F3 (IFS)4.288 E F0 1.788(is unset, or its v)4.038 F 1.789(alue is e)-.25 F (xactly)-.15 E F1()4.289 E F0 4.289(,t)C 1.789 -(he def)-4.289 F 1.789(ault, then)-.1 F .022(sequences of)108 254.4 R F1 +(he def)-4.289 F 1.789(ault, then)-.1 F .022(sequences of)108 398.4 R F1 ()2.522 E F0(,)A F1()2.522 E F0 2.521(,a)C(nd)-2.521 E F1 ()2.521 E F0 .021(at the be)2.521 F .021 (ginning and end of the results of the pre)-.15 F .021(vious e)-.25 F -(xpan-)-.15 E .585(sions are ignored, and an)108 266.4 R 3.086(ys)-.15 G +(xpan-)-.15 E .585(sions are ignored, and an)108 410.4 R 3.086(ys)-.15 G .586(equence of)-3.086 F F3(IFS)3.086 E F0 .586 (characters not at the be)2.836 F .586(ginning or end serv)-.15 F .586 -(es to delimit w)-.15 F(ords.)-.1 E(If)108 278.4 Q F3(IFS)3.617 E F0 +(es to delimit w)-.15 F(ords.)-.1 E(If)108 422.4 Q F3(IFS)3.617 E F0 1.117(has a v)3.367 F 1.117(alue other than the def)-.25 F 1.117 (ault, then sequences of the whitespace characters)-.1 F F1(space)3.617 E F0(and)3.617 E F1(tab)3.617 E F0(are)3.617 E .315(ignored at the be) -108 290.4 R .315(ginning and end of the w)-.15 F .315 +108 434.4 R .315(ginning and end of the w)-.15 F .315 (ord, as long as the whitespace character is in the v)-.1 F .315 -(alue of)-.25 F F3(IFS)2.815 E F0(\(an)2.566 E F3(IFS)108 302.4 Q F0 +(alue of)-.25 F F3(IFS)2.815 E F0(\(an)2.566 E F3(IFS)108 446.4 Q F0 1.054(whitespace character\).)3.304 F(An)6.054 E 3.554(yc)-.15 G 1.054 (haracter in)-3.554 F F3(IFS)3.554 E F0 1.053(that is not)3.303 F F3 (IFS)3.553 E F0 1.053(whitespace, along with an)3.303 F 3.553(ya)-.15 G (djacent)-3.553 E F3(IFS)3.553 E F0 .331 -(whitespace characters, delimits a \214eld.)108 314.4 R 2.831(As)5.331 G +(whitespace characters, delimits a \214eld.)108 458.4 R 2.831(As)5.331 G .332(equence of)-2.831 F F3(IFS)2.832 E F0 .332 (whitespace characters is also treated as a delim-)2.582 F(iter)108 -326.4 Q 5(.I)-.55 G 2.5(ft)-5 G(he v)-2.5 E(alue of)-.25 E F3(IFS)2.5 E +470.4 Q 5(.I)-.55 G 2.5(ft)-5 G(he v)-2.5 E(alue of)-.25 E F3(IFS)2.5 E F0(is null, no w)2.25 E(ord splitting occurs.)-.1 E 1.879 -(Explicit null ar)108 343.2 R 1.879(guments \()-.18 F F1 .833("").833 G +(Explicit null ar)108 487.2 R 1.879(guments \()-.18 F F1 .833("").833 G F0(or)3.545 E F1 .833<0808>5.211 G F0 4.378(\)a)C 1.878(re retained.) -4.378 F 1.878(Unquoted implicit null ar)6.878 F 1.878 -(guments, resulting from the)-.18 F -.15(ex)108 355.2 S .176 +(guments, resulting from the)-.18 F -.15(ex)108 499.2 S .176 (pansion of parameters that ha).15 F .476 -.15(ve n)-.2 H 2.676(ov).15 G .176(alues, are remo)-2.926 F -.15(ve)-.15 G 2.676(d. If).15 F 2.677(ap) 2.677 G .177(arameter with no v)-2.677 F .177(alue is e)-.25 F .177 -(xpanded within)-.15 F(double quotes, a null ar)108 367.2 Q -(gument results and is retained.)-.18 E(Note that if no e)108 384 Q -(xpansion occurs, no splitting is performed.)-.15 E F1 -.1(Pa)87 400.8 S -(thname Expansion).1 E F0 .371(After w)108 412.8 R .371 +(xpanded within)-.15 F(double quotes, a null ar)108 511.2 Q +(gument results and is retained.)-.18 E(Note that if no e)108 528 Q +(xpansion occurs, no splitting is performed.)-.15 E F1 -.1(Pa)87 544.8 S +(thname Expansion).1 E F0 .371(After w)108 556.8 R .371 (ord splitting, unless the)-.1 F F12.871 E F0 .371 (option has been set,)2.871 F F1(bash)2.871 E F0 .37(scans each w)2.87 F .37(ord for the characters)-.1 F F1(*)2.87 E F0(,)A F1(?)2.87 E F0 2.87 (,a)C(nd)-2.87 E F1([)2.87 E F0(.)A .677 -(If one of these characters appears, then the w)108 424.8 R .677 +(If one of these characters appears, then the w)108 568.8 R .677 (ord is re)-.1 F -.05(ga)-.15 G .677(rded as a).05 F F2(pattern)3.177 E F0 3.177(,a).24 G .678(nd replaced with an alphabeti-)-3.177 F .562 -(cally sorted list of \214lenames matching the pattern \(see)108 436.8 R +(cally sorted list of \214lenames matching the pattern \(see)108 580.8 R F3 -.09(Pa)3.062 G(tter).09 E 2.812(nM)-.135 G(atching)-2.812 E F0(belo) 2.812 E 3.062(w\). If)-.25 F .561(no matching \214lenames)3.061 F .008 -(are found, and the shell option)108 448.8 R F1(nullglob)2.508 E F0 .008 +(are found, and the shell option)108 592.8 R F1(nullglob)2.508 E F0 .008 (is not enabled, the w)2.508 F .009(ord is left unchanged.)-.1 F .009 (If the)5.009 F F1(nullglob)2.509 E F0 .009(option is)2.509 F .443 -(set, and no matches are found, the w)108 460.8 R .443(ord is remo)-.1 F +(set, and no matches are found, the w)108 604.8 R .443(ord is remo)-.1 F -.15(ve)-.15 G 2.943(d. If).15 F(the)2.942 E F1(failglob)2.942 E F0 .442 (shell option is set, and no matches are)2.942 F 1.38 -(found, an error message is printed and the command is not e)108 472.8 R +(found, an error message is printed and the command is not e)108 616.8 R -.15(xe)-.15 G 3.88(cuted. If).15 F 1.38(the shell option)3.88 F F1 (nocaseglob)3.88 E F0(is)3.88 E .104 -(enabled, the match is performed without re)108 484.8 R -.05(ga)-.15 G +(enabled, the match is performed without re)108 628.8 R -.05(ga)-.15 G .104(rd to the case of alphabetic characters.).05 F .103 -(When a pattern is used)5.103 F .377(for pathname e)108 496.8 R .377 +(When a pattern is used)5.103 F .377(for pathname e)108 640.8 R .377 (xpansion, the character)-.15 F F1 -.63(``)2.878 G -.55(.').63 G(')-.08 E F0 .378(at the start of a name or immediately follo)5.378 F .378 -(wing a slash must be)-.25 F .579(matched e)108 508.8 R(xplicitly)-.15 E +(wing a slash must be)-.25 F .579(matched e)108 652.8 R(xplicitly)-.15 E 3.079(,u)-.65 G .579(nless the shell option)-3.079 F F1(dotglob)3.079 E F0 .579(is set.)3.079 F .578 (When matching a pathname, the slash character)5.579 F 1.788(must al)108 -520.8 R -.1(wa)-.1 G 1.788(ys be matched e).1 F(xplicitly)-.15 E 6.788 +664.8 R -.1(wa)-.1 G 1.788(ys be matched e).1 F(xplicitly)-.15 E 6.788 (.I)-.65 G 4.288(no)-6.788 G 1.788(ther cases, the)-4.288 F F1 -.63(``) 4.288 G -.55(.').63 G(')-.08 E F0 1.788 (character is not treated specially)6.788 F 6.789(.S)-.65 G 1.789 -(ee the)-6.789 F .166(description of)108 532.8 R F1(shopt)2.666 E F0 +(ee the)-6.789 F .166(description of)108 676.8 R F1(shopt)2.666 E F0 (belo)2.666 E 2.666(wu)-.25 G(nder)-2.666 E F3 .166(SHELL B)2.666 F(UIL) -.09 E .165(TIN COMMANDS)-.828 F F0 .165(for a description of the)2.415 -F F1(nocaseglob)2.665 E F0(,)A F1(null-)2.665 E(glob)108 544.8 Q F0(,)A +F F1(nocaseglob)2.665 E F0(,)A F1(null-)2.665 E(glob)108 688.8 Q F0(,)A F1(failglob)2.5 E F0 2.5(,a)C(nd)-2.5 E F1(dotglob)2.5 E F0 -(shell options.)2.5 E(The)108 561.6 Q F3(GLOBIGNORE)2.785 E F0 .285 +(shell options.)2.5 E(The)108 705.6 Q F3(GLOBIGNORE)2.785 E F0 .285 (shell v)2.535 F .285 (ariable may be used to restrict the set of \214lenames matching a)-.25 F F2(pattern)2.786 E F0 5.286(.I).24 G(f)-5.286 E F3(GLO-)2.786 E -(BIGNORE)108 573.6 Q F0 2.316(is set, each matching \214lename that als\ +(BIGNORE)108 717.6 Q F0 2.316(is set, each matching \214lename that als\ o matches one of the patterns in)4.566 F F3(GLOBIGNORE)4.816 E F0(is) -4.565 E(remo)108 585.6 Q -.15(ve)-.15 G 2.659(df).15 G .159 +4.565 E(remo)108 729.6 Q -.15(ve)-.15 G 2.659(df).15 G .159 (rom the list of matches.)-2.659 F .16(The \214lenames)5.16 F F1 -.63 (``)2.66 G -.55(.').63 G(')-.08 E F0(and)5.16 E F1 -.63(``)2.66 G(..).63 E -.63('')-.55 G F0 .16(are al)5.79 F -.1(wa)-.1 G .16(ys ignored when) -.1 F F3(GLOBIGNORE)2.66 E F0(is)2.41 E .046(set and not null.)108 597.6 -R(Ho)5.046 E(we)-.25 E -.15(ve)-.25 G .846 -.4(r, s).15 H(etting).4 E F3 -(GLOBIGNORE)2.546 E F0 .046(to a non-null v)2.296 F .045 -(alue has the ef)-.25 F .045(fect of enabling the)-.25 F F1(dotglob) -2.545 E F0 .786(shell option, so all other \214lenames be)108 609.6 R -.787(ginning with a)-.15 F F1 -.63(``)3.287 G -.55(.').63 G(')-.08 E F0 -.787(will match.)5.787 F 2.387 -.8(To g)5.787 H .787(et the old beha).8 -F .787(vior of ignoring)-.2 F .642(\214lenames be)108 621.6 R .642 -(ginning with a)-.15 F F1 -.63(``)3.142 G -.55(.').63 G(')-.08 E F0 -3.142(,m)C(ak)-3.142 E(e)-.1 E F1 -.63(``)3.142 G(.*').63 E(')-.63 E F0 -.642(one of the patterns in)5.642 F F3(GLOBIGNORE)3.141 E/F4 9 -/Times-Roman@0 SF(.)A F0(The)5.141 E F1(dotglob)3.141 E F0 .641 -(option is)3.141 F(disabled when)108 633.6 Q F3(GLOBIGNORE)2.5 E F0 -(is unset.)2.25 E F1 -.1(Pa)108 650.4 S(tter).1 E 2.5(nM)-.15 G(atching) --2.5 E F0(An)108 667.2 Q 3.138(yc)-.15 G .638(haracter that appears in \ -a pattern, other than the special pattern characters described belo) --3.138 F 1.938 -.65(w, m)-.25 H(atches).65 E 3.62(itself. The)108 679.2 -R 1.12(NUL character may not occur in a pattern.)3.62 F 3.62(Ab)6.12 G -1.12(ackslash escapes the follo)-3.62 F 1.12(wing character; the)-.25 F -.576(escaping backslash is discarded when matching.)108 691.2 R .576 -(The special pattern characters must be quoted if the)5.576 F 3.076(ya) --.15 G(re)-3.076 E(to be matched literally)108 703.2 Q(.)-.65 E -(The special pattern characters ha)108 720 Q .3 -.15(ve t)-.2 H -(he follo).15 E(wing meanings:)-.25 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(23)198.165 E 0 Cg EP +.1 F F3(GLOBIGNORE)2.66 E F0(is)2.41 E(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(23)185.545 E 0 Cg EP %%Page: 24 24 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(*)144 84 Q F0 .377(Matches an)31 F 2.877 -(ys)-.15 G .376(tring, including the null string.)-2.877 F .376 -(When the)5.376 F F1(globstar)2.876 E F0 .376(shell option is enabled,) -2.876 F(and)180 96 Q F1(*)3.275 E F0 .775(is used in a pathname e)3.275 -F .775(xpansion conte)-.15 F .775(xt, tw)-.15 F 3.275(oa)-.1 G(djacent) --3.275 E F1(*)3.275 E F0 3.275(su)C .775(sed as a single pattern)-3.275 -F 1.058(will match all \214les and zero or more directories and subdire\ -ctories.)180 108 R 1.058(If follo)6.058 F 1.058(wed by a)-.25 F F1(/) -3.558 E F0(,)A(tw)180 120 Q 2.5(oa)-.1 G(djacent)-2.5 E F1(*)2.5 E F0 -2.5(sw)C(ill match only directories and subdirectories.)-2.5 E F1(?)144 -132 Q F0(Matches an)31 E 2.5(ys)-.15 G(ingle character)-2.5 E(.)-.55 E -F1([...])144 144 Q F0 .578(Matches an)21.84 F 3.078(yo)-.15 G .578 +-.35 E .046(set and not null.)108 84 R(Ho)5.046 E(we)-.25 E -.15(ve)-.25 +G .846 -.4(r, s).15 H(etting).4 E/F1 9/Times-Bold@0 SF(GLOBIGNORE)2.546 +E F0 .046(to a non-null v)2.296 F .045(alue has the ef)-.25 F .045 +(fect of enabling the)-.25 F/F2 10/Times-Bold@0 SF(dotglob)2.545 E F0 +.786(shell option, so all other \214lenames be)108 96 R .787 +(ginning with a)-.15 F F2 -.63(``)3.287 G -.55(.').63 G(')-.08 E F0 .787 +(will match.)5.787 F 2.387 -.8(To g)5.787 H .787(et the old beha).8 F +.787(vior of ignoring)-.2 F .642(\214lenames be)108 108 R .642 +(ginning with a)-.15 F F2 -.63(``)3.142 G -.55(.').63 G(')-.08 E F0 +3.142(,m)C(ak)-3.142 E(e)-.1 E F2 -.63(``)3.142 G(.*').63 E(')-.63 E F0 +.642(one of the patterns in)5.642 F F1(GLOBIGNORE)3.141 E/F3 9 +/Times-Roman@0 SF(.)A F0(The)5.141 E F2(dotglob)3.141 E F0 .641 +(option is)3.141 F(disabled when)108 120 Q F1(GLOBIGNORE)2.5 E F0 +(is unset.)2.25 E F2 -.1(Pa)108 136.8 S(tter).1 E 2.5(nM)-.15 G(atching) +-2.5 E F0(An)108 153.6 Q 3.138(yc)-.15 G .638(haracter that appears in \ +a pattern, other than the special pattern characters described belo) +-3.138 F 1.938 -.65(w, m)-.25 H(atches).65 E 3.62(itself. The)108 165.6 +R 1.12(NUL character may not occur in a pattern.)3.62 F 3.62(Ab)6.12 G +1.12(ackslash escapes the follo)-3.62 F 1.12(wing character; the)-.25 F +.576(escaping backslash is discarded when matching.)108 177.6 R .576 +(The special pattern characters must be quoted if the)5.576 F 3.076(ya) +-.15 G(re)-3.076 E(to be matched literally)108 189.6 Q(.)-.65 E +(The special pattern characters ha)108 206.4 Q .3 -.15(ve t)-.2 H +(he follo).15 E(wing meanings:)-.25 E F2(*)144 223.2 Q F0 .377 +(Matches an)31 F 2.877(ys)-.15 G .376(tring, including the null string.) +-2.877 F .376(When the)5.376 F F2(globstar)2.876 E F0 .376 +(shell option is enabled,)2.876 F(and)180 235.2 Q F2(*)3.275 E F0 .775 +(is used in a pathname e)3.275 F .775(xpansion conte)-.15 F .775(xt, tw) +-.15 F 3.275(oa)-.1 G(djacent)-3.275 E F2(*)3.275 E F0 3.275(su)C .775 +(sed as a single pattern)-3.275 F 1.058(will match all \214les and zero\ + or more directories and subdirectories.)180 247.2 R 1.058(If follo) +6.058 F 1.058(wed by a)-.25 F F2(/)3.558 E F0(,)A(tw)180 259.2 Q 2.5(oa) +-.1 G(djacent)-2.5 E F2(*)2.5 E F0 2.5(sw)C +(ill match only directories and subdirectories.)-2.5 E F2(?)144 271.2 Q +F0(Matches an)31 E 2.5(ys)-.15 G(ingle character)-2.5 E(.)-.55 E F2 +([...])144 283.2 Q F0 .578(Matches an)21.84 F 3.078(yo)-.15 G .578 (ne of the enclosed characters.)-3.078 F 3.079(Ap)5.579 G .579 -(air of characters separated by a h)-3.079 F(yphen)-.05 E .537 -(denotes a)180 156 R/F2 10/Times-Italic@0 SF -.15(ra)3.037 G(ng).15 E -3.037(ee)-.1 G(xpr)-3.237 E(ession)-.37 E F0 3.037(;a)C .837 -.15(ny c) --3.037 H .537(haracter that sorts between those tw).15 F 3.036(oc)-.1 G -.536(haracters, inclu-)-3.036 F(si)180 168 Q -.15(ve)-.25 G 3.712(,u).15 -G 1.212(sing the current locale')-3.712 F 3.712(sc)-.55 G 1.212 -(ollating sequence and character set, is matched.)-3.712 F 1.213(If the) -6.213 F 1.124(\214rst character follo)180 180 R 1.124(wing the)-.25 F F1 -([)3.624 E F0 1.124(is a)3.624 F F1(!)3.624 E F0 1.124(or a)6.124 F F1 -(^)3.623 E F0 1.123(then an)3.623 F 3.623(yc)-.15 G 1.123 -(haracter not enclosed is matched.)-3.623 F .894 -(The sorting order of characters in range e)180 192 R .895 +(air of characters separated by a h)-3.079 F(yphen)-.05 E .685 +(denotes a)180 295.2 R/F4 10/Times-Italic@0 SF -.15(ra)3.185 G(ng).15 E +3.184(ee)-.1 G(xpr)-3.384 E(ession)-.37 E F0 3.184(;a)C .984 -.15(ny c) +-3.184 H .684(haracter that f).15 F .684(alls between those tw)-.1 F +3.184(oc)-.1 G .684(haracters, inclu-)-3.184 F(si)180 307.2 Q -.15(ve) +-.25 G 3.712(,u).15 G 1.212(sing the current locale')-3.712 F 3.712(sc) +-.55 G 1.212(ollating sequence and character set, is matched.)-3.712 F +1.213(If the)6.213 F 1.124(\214rst character follo)180 319.2 R 1.124 +(wing the)-.25 F F2([)3.624 E F0 1.124(is a)3.624 F F2(!)3.624 E F0 +1.124(or a)6.124 F F2(^)3.623 E F0 1.123(then an)3.623 F 3.623(yc)-.15 G +1.123(haracter not enclosed is matched.)-3.623 F .894 +(The sorting order of characters in range e)180 331.2 R .895 (xpressions is determined by the current locale)-.15 F .376(and the v) -180 204 R .376(alues of the)-.25 F/F3 9/Times-Bold@0 SF(LC_COLLA)2.875 E -(TE)-.855 E F0(or)2.625 E F3(LC_ALL)2.875 E F0 .375(shell v)2.625 F .375 +180 343.2 R .376(alues of the)-.25 F F1(LC_COLLA)2.875 E(TE)-.855 E F0 +(or)2.625 E F1(LC_ALL)2.875 E F0 .375(shell v)2.625 F .375 (ariables, if set.)-.25 F 1.975 -.8(To o)5.375 H .375(btain the tra-).8 -F .067(ditional interpretation of range e)180 216 R .067 -(xpressions, where)-.15 F F1([a\255d])2.567 E F0 .068(is equi)2.568 F --.25(va)-.25 G .068(lent to).25 F F1([abcd])2.568 E F0 2.568(,s)C .068 -(et v)-2.568 F(alue)-.25 E .157(of the)180 228 R F1(LC_ALL)2.657 E F0 -.157(shell v)2.657 F .157(ariable to)-.25 F F1(C)2.657 E F0 2.657(,o)C -2.657(re)-2.657 G .157(nable the)-2.657 F F1(globasciiranges)2.657 E F0 -.156(shell option.)2.656 F(A)5.156 E F12.656 E F0(may)2.656 E .193(\ +F .067(ditional interpretation of range e)180 355.2 R .067 +(xpressions, where)-.15 F F2([a\255d])2.567 E F0 .068(is equi)2.568 F +-.25(va)-.25 G .068(lent to).25 F F2([abcd])2.568 E F0 2.568(,s)C .068 +(et v)-2.568 F(alue)-.25 E .157(of the)180 367.2 R F2(LC_ALL)2.657 E F0 +.157(shell v)2.657 F .157(ariable to)-.25 F F2(C)2.657 E F0 2.657(,o)C +2.657(re)-2.657 G .157(nable the)-2.657 F F2(globasciiranges)2.657 E F0 +.156(shell option.)2.656 F(A)5.156 E F22.656 E F0(may)2.656 E .193(\ be matched by including it as the \214rst or last character in the set.) -180 240 R(A)5.193 E F1(])2.693 E F0 .194(may be matched by)2.693 F -(including it as the \214rst character in the set.)180 252 Q -.4(Wi)180 -270 S(thin).4 E F1([)3.071 E F0(and)3.071 E F1(])3.071 E F0(,)A F2 -.15 -(ch)3.071 G(ar).15 E .571(acter classes)-.15 F F0 .571 -(can be speci\214ed using the syntax)3.071 F F1([:)3.07 E F2(class)A F1 -(:])A F0 3.07(,w)C(here)-3.07 E F2(class)3.07 E F0(is one of the follo) -180 282 Q(wing classes de\214ned in the POSIX standard:)-.25 E F1 8.173 -(alnum alpha ascii blank cntrl digit graph lo)180 294 R 8.173 -(wer print punct space)-.1 F 5(upper w)180 306 R 5(ord xdigit)-.1 F F0 -4.29(Ac)180 318 S 1.789(haracter class matches an)-4.29 F 4.289(yc)-.15 -G 1.789(haracter belonging to that class.)-4.289 F(The)6.789 E F1 -.1 -(wo)4.289 G(rd).1 E F0(character)4.289 E -(class matches letters, digits, and the character _.)180 330 Q -.4(Wi) -180 348 S(thin).4 E F1([)4.536 E F0(and)4.536 E F1(])4.536 E F0 4.536 -(,a)C(n)-4.536 E F2 2.036(equivalence class)4.536 F F0 2.037 -(can be speci\214ed using the syntax)4.536 F F1([=)4.537 E F2(c)A F1(=]) +180 379.2 R(A)5.193 E F2(])2.693 E F0 .194(may be matched by)2.693 F +(including it as the \214rst character in the set.)180 391.2 Q -.4(Wi) +180 409.2 S(thin).4 E F2([)3.071 E F0(and)3.071 E F2(])3.071 E F0(,)A F4 +-.15(ch)3.071 G(ar).15 E .571(acter classes)-.15 F F0 .571 +(can be speci\214ed using the syntax)3.071 F F2([:)3.07 E F4(class)A F2 +(:])A F0 3.07(,w)C(here)-3.07 E F4(class)3.07 E F0(is one of the follo) +180 421.2 Q(wing classes de\214ned in the POSIX standard:)-.25 E F2 +8.173(alnum alpha ascii blank cntrl digit graph lo)180 433.2 R 8.173 +(wer print punct space)-.1 F 5(upper w)180 445.2 R 5(ord xdigit)-.1 F F0 +4.29(Ac)180 457.2 S 1.789(haracter class matches an)-4.29 F 4.289(yc) +-.15 G 1.789(haracter belonging to that class.)-4.289 F(The)6.789 E F2 +-.1(wo)4.289 G(rd).1 E F0(character)4.289 E +(class matches letters, digits, and the character _.)180 469.2 Q -.4(Wi) +180 487.2 S(thin).4 E F2([)4.536 E F0(and)4.536 E F2(])4.536 E F0 4.536 +(,a)C(n)-4.536 E F4 2.036(equivalence class)4.536 F F0 2.037 +(can be speci\214ed using the syntax)4.536 F F2([=)4.537 E F4(c)A F2(=]) A F0 4.537(,w)C(hich)-4.537 E .125(matches all characters with the same\ - collation weight \(as de\214ned by the current locale\) as)180 360 R -(the character)180 372 Q F2(c)2.5 E F0(.)A -.4(Wi)180 390 S(thin).4 E F1 -([)2.5 E F0(and)2.5 E F1(])2.5 E F0 2.5(,t)C(he syntax)-2.5 E F1([.)2.5 -E F2(symbol)A F1(.])A F0(matches the collating symbol)2.5 E F2(symbol) -2.5 E F0(.)A .704(If the)108 406.8 R F1(extglob)3.204 E F0 .705 -(shell option is enabled using the)3.204 F F1(shopt)3.205 E F0 -.2(bu) + collation weight \(as de\214ned by the current locale\) as)180 499.2 R +(the character)180 511.2 Q F4(c)2.5 E F0(.)A -.4(Wi)180 529.2 S(thin).4 +E F2([)2.5 E F0(and)2.5 E F2(])2.5 E F0 2.5(,t)C(he syntax)-2.5 E F2([.) +2.5 E F4(symbol)A F2(.])A F0(matches the collating symbol)2.5 E F4 +(symbol)2.5 E F0(.)A .704(If the)108 546 R F2(extglob)3.204 E F0 .705 +(shell option is enabled using the)3.204 F F2(shopt)3.205 E F0 -.2(bu) 3.205 G .705(iltin, se).2 F -.15(ve)-.25 G .705(ral e).15 F .705 -(xtended pattern matching operators)-.15 F .256(are recognized.)108 -418.8 R .256(In the follo)5.256 F .256(wing description, a)-.25 F F2 +(xtended pattern matching operators)-.15 F .256(are recognized.)108 558 +R .256(In the follo)5.256 F .256(wing description, a)-.25 F F4 (pattern-list)2.755 E F0 .255 -(is a list of one or more patterns separated by a)2.755 F F1(|)2.755 E +(is a list of one or more patterns separated by a)2.755 F F2(|)2.755 E F0(.)A(Composite patterns may be formed using one or more of the follo) -108 430.8 Q(wing sub-patterns:)-.25 E F1(?\()144 454.8 Q F2 -(pattern-list).833 E F1(\)).833 E F0 -(Matches zero or one occurrence of the gi)180 466.8 Q -.15(ve)-.25 G 2.5 -(np).15 G(atterns)-2.5 E F1(*\()144 478.8 Q F2(pattern-list).833 E F1 -(\)).833 E F0(Matches zero or more occurrences of the gi)180 490.8 Q --.15(ve)-.25 G 2.5(np).15 G(atterns)-2.5 E F1(+\()144 502.8 Q F2 -(pattern-list).833 E F1(\)).833 E F0 -(Matches one or more occurrences of the gi)180 514.8 Q -.15(ve)-.25 G -2.5(np).15 G(atterns)-2.5 E F1(@\()144 526.8 Q F2(pattern-list).833 E F1 -(\)).833 E F0(Matches one of the gi)180 538.8 Q -.15(ve)-.25 G 2.5(np) -.15 G(atterns)-2.5 E F1(!\()144 550.8 Q F2(pattern-list).833 E F1(\)) -.833 E F0(Matches an)180 562.8 Q(ything e)-.15 E(xcept one of the gi) --.15 E -.15(ve)-.25 G 2.5(np).15 G(atterns)-2.5 E F1(Quote Remo)87 579.6 -Q -.1(va)-.1 G(l).1 E F0 1.112(After the preceding e)108 591.6 R 1.112 +108 570 Q(wing sub-patterns:)-.25 E F2(?\()144 594 Q F4(pattern-list) +.833 E F2(\)).833 E F0(Matches zero or one occurrence of the gi)180 606 +Q -.15(ve)-.25 G 2.5(np).15 G(atterns)-2.5 E F2(*\()144 618 Q F4 +(pattern-list).833 E F2(\)).833 E F0 +(Matches zero or more occurrences of the gi)180 630 Q -.15(ve)-.25 G 2.5 +(np).15 G(atterns)-2.5 E F2(+\()144 642 Q F4(pattern-list).833 E F2(\)) +.833 E F0(Matches one or more occurrences of the gi)180 654 Q -.15(ve) +-.25 G 2.5(np).15 G(atterns)-2.5 E F2(@\()144 666 Q F4(pattern-list).833 +E F2(\)).833 E F0(Matches one of the gi)180 678 Q -.15(ve)-.25 G 2.5(np) +.15 G(atterns)-2.5 E F2(!\()144 690 Q F4(pattern-list).833 E F2(\)).833 +E F0(Matches an)180 702 Q(ything e)-.15 E(xcept one of the gi)-.15 E +-.15(ve)-.25 G 2.5(np).15 G(atterns)-2.5 E(GNU Bash 4.2)72 768 Q +(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(24)185.545 E 0 Cg EP +%%Page: 25 25 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(Quote Remo)87 84 Q -.1(va)-.1 G(l).1 E F0 +1.112(After the preceding e)108 96 R 1.112 (xpansions, all unquoted occurrences of the characters)-.15 F F1(\\) 3.613 E F0(,)A F1<08>3.613 E F0 3.613(,a)C(nd)-3.613 E F1(")4.446 E F0 -1.113(that did not result)4.446 F(from one of the abo)108 603.6 Q .3 --.15(ve ex)-.15 H(pansions are remo).15 E -.15(ve)-.15 G(d.).15 E/F4 -10.95/Times-Bold@0 SF(REDIRECTION)72 620.4 Q F0 .545 -(Before a command is e)108 632.4 R -.15(xe)-.15 G .545 -(cuted, its input and output may be).15 F F2 -.37(re)3.045 G(dir).37 E -(ected)-.37 E F0 .545(using a special notation interpreted)3.815 F .405 -(by the shell.)108 644.4 R .405(Redirection allo)5.405 F .405(ws comman\ -ds' \214le handles to be duplicated, opened, closed, made to refer to) --.25 F(dif)108 656.4 Q 1.02(ferent \214les, and can change the \214les \ -the command reads from and writes to.)-.25 F 1.019 -(Redirection may also be)6.019 F .215 -(used to modify \214le handles in the current shell e)108 668.4 R -.15 +1.113(that did not result)4.446 F(from one of the abo)108 108 Q .3 -.15 +(ve ex)-.15 H(pansions are remo).15 E -.15(ve)-.15 G(d.).15 E/F2 10.95 +/Times-Bold@0 SF(REDIRECTION)72 124.8 Q F0 .545(Before a command is e) +108 136.8 R -.15(xe)-.15 G .545(cuted, its input and output may be).15 F +/F3 10/Times-Italic@0 SF -.37(re)3.045 G(dir).37 E(ected)-.37 E F0 .545 +(using a special notation interpreted)3.815 F .405(by the shell.)108 +148.8 R .405(Redirection allo)5.405 F .405(ws commands' \214le handles \ +to be duplicated, opened, closed, made to refer to)-.25 F(dif)108 160.8 +Q 1.02(ferent \214les, and can change the \214les the command reads fro\ +m and writes to.)-.25 F 1.019(Redirection may also be)6.019 F .215 +(used to modify \214le handles in the current shell e)108 172.8 R -.15 (xe)-.15 G .215(cution en).15 F 2.715(vironment. The)-.4 F(follo)2.715 E .215(wing redirection operators)-.25 F .876(may precede or appear an)108 -680.4 R .876(ywhere within a)-.15 F F2 .875(simple command)3.715 F F0 -.875(or may follo)4.145 F 3.375(wa)-.25 G F2(command)A F0 5.875(.R).77 G -.875(edirections are)-5.875 F(processed in the order the)108 692.4 Q 2.5 +184.8 R .876(ywhere within a)-.15 F F3 .875(simple command)3.715 F F0 +.875(or may follo)4.145 F 3.375(wa)-.25 G F3(command)A F0 5.875(.R).77 G +.875(edirections are)-5.875 F(processed in the order the)108 196.8 Q 2.5 (ya)-.15 G(ppear)-2.5 E 2.5(,f)-.4 G(rom left to right.)-2.5 E .771(Eac\ h redirection that may be preceded by a \214le descriptor number may in\ -stead be preceded by a w)108 709.2 R .772(ord of)-.1 F .293(the form {) -108 721.2 R F2(varname)A F0 2.793(}. In)B .293 +stead be preceded by a w)108 213.6 R .772(ord of)-.1 F .293(the form {) +108 225.6 R F3(varname)A F0 2.793(}. In)B .293 (this case, for each redirection operator e)2.793 F .293 -(xcept >&- and <&-, the shell will allocate)-.15 F(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(24)198.165 E 0 Cg EP -%%Page: 25 25 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E 3.179<618c>108 84 S .679 -(le descriptor greater than or equal to 10 and assign it to)-3.179 F/F1 -10/Times-Italic@0 SF(varname)3.179 E F0 5.679(.I)C 3.179(f>)-5.679 G -.679(&- or <&- is preceded by {)-3.179 F F1(var)A(-)-.2 E(name)108 96 Q -F0(}, the v)A(alue of)-.25 E F1(varname)2.5 E F0 +(xcept >&- and <&-, the shell will allocate)-.15 F 3.179<618c>108 237.6 +S .679(le descriptor greater than or equal to 10 and assign it to)-3.179 +F F3(varname)3.179 E F0 5.679(.I)C 3.179(f>)-5.679 G .679 +(&- or <&- is preceded by {)-3.179 F F3(var)A(-)-.2 E(name)108 249.6 Q +F0(}, the v)A(alue of)-.25 E F3(varname)2.5 E F0 (de\214nes the \214le descriptor to close.)2.5 E .284(In the follo)108 -112.8 R .283(wing descriptions, if the \214le descriptor number is omit\ +266.4 R .283(wing descriptions, if the \214le descriptor number is omit\ ted, and the \214rst character of the redirect-)-.25 F .512 -(ion operator is)108 124.8 R/F2 10/Times-Bold@0 SF(<)3.012 E F0 3.012 -(,t)C .512 +(ion operator is)108 278.4 R F1(<)3.012 E F0 3.012(,t)C .512 (he redirection refers to the standard input \(\214le descriptor 0\).) -3.012 F .512(If the \214rst character of the)5.512 F -(redirection operator is)108 136.8 Q F2(>)2.5 E F0 2.5(,t)C +(redirection operator is)108 290.4 Q F1(>)2.5 E F0 2.5(,t)C (he redirection refers to the standard output \(\214le descriptor 1\).) --2.5 E .825(The w)108 153.6 R .825(ord follo)-.1 F .824 +-2.5 E .825(The w)108 307.2 R .825(ord follo)-.1 F .824 (wing the redirection operator in the follo)-.25 F .824 (wing descriptions, unless otherwise noted, is sub-)-.25 F .462 -(jected to brace e)108 165.6 R .462(xpansion, tilde e)-.15 F .463 +(jected to brace e)108 319.2 R .462(xpansion, tilde e)-.15 F .463 (xpansion, parameter and v)-.15 F .463(ariable e)-.25 F .463 -(xpansion, command substitution, arith-)-.15 F .867(metic e)108 177.6 R +(xpansion, command substitution, arith-)-.15 F .867(metic e)108 331.2 R .867(xpansion, quote remo)-.15 F -.25(va)-.15 G .867(l, pathname e).25 F .867(xpansion, and w)-.15 F .867(ord splitting.)-.1 F .867(If it e)5.867 -F .866(xpands to more than one)-.15 F -.1(wo)108 189.6 S(rd,).1 E F2 +F .866(xpands to more than one)-.15 F -.1(wo)108 343.2 S(rd,).1 E F1 (bash)2.5 E F0(reports an error)2.5 E(.)-.55 E -(Note that the order of redirections is signi\214cant.)108 206.4 Q -.15 -(Fo)5 G 2.5(re).15 G(xample, the command)-2.65 E(ls)144 223.2 Q F2(>)2.5 -E F0(dirlist 2)2.5 E F2(>&)A F0(1)A -(directs both standard output and standard error to the \214le)108 240 Q -F1(dirlist)2.5 E F0 2.5(,w).68 G(hile the command)-2.5 E(ls 2)144 256.8 -Q F2(>&)A F0(1)A F2(>)2.5 E F0(dirlist)2.5 E .527 -(directs only the standard output to \214le)108 273.6 R F1(dirlist)3.027 +(Note that the order of redirections is signi\214cant.)108 360 Q -.15 +(Fo)5 G 2.5(re).15 G(xample, the command)-2.65 E(ls)144 376.8 Q F1(>)2.5 +E F0(dirlist 2)2.5 E F1(>&)A F0(1)A +(directs both standard output and standard error to the \214le)108 393.6 +Q F3(dirlist)2.5 E F0 2.5(,w).68 G(hile the command)-2.5 E(ls 2)144 +410.4 Q F1(>&)A F0(1)A F1(>)2.5 E F0(dirlist)2.5 E .527 +(directs only the standard output to \214le)108 427.2 R F3(dirlist)3.027 E F0 3.027(,b).68 G .527(ecause the standard error w)-3.027 F .527 (as duplicated from the standard)-.1 F -(output before the standard output w)108 285.6 Q(as redirected to)-.1 E -F1(dirlist)2.5 E F0(.).68 E F2(Bash)108 302.4 Q F0 .599(handles se)3.099 -F -.15(ve)-.25 G .599(ral \214lenames specially when the).15 F 3.099(ya) +(output before the standard output w)108 439.2 Q(as redirected to)-.1 E +F3(dirlist)2.5 E F0(.).68 E F1(Bash)108 456 Q F0 .599(handles se)3.099 F +-.15(ve)-.25 G .599(ral \214lenames specially when the).15 F 3.099(ya) -.15 G .598(re used in redirections, as described in the follo)-3.099 F -(wing)-.25 E(table:)108 314.4 Q F2(/de)144 331.2 Q(v/fd/)-.15 E F1(fd)A -F0(If)180 343.2 Q F1(fd)2.5 E F0(is a v)2.5 E(alid inte)-.25 E(ger)-.15 -E 2.5<2c8c>-.4 G(le descriptor)-2.5 E F1(fd)2.5 E F0(is duplicated.)2.5 -E F2(/de)144 355.2 Q(v/stdin)-.15 E F0(File descriptor 0 is duplicated.) -180 367.2 Q F2(/de)144 379.2 Q(v/stdout)-.15 E F0 -(File descriptor 1 is duplicated.)180 391.2 Q F2(/de)144 403.2 Q -(v/stderr)-.15 E F0(File descriptor 2 is duplicated.)180 415.2 Q F2(/de) -144 427.2 Q(v/tcp/)-.15 E F1(host)A F2(/)A F1(port)A F0(If)180 439.2 Q -F1(host)2.996 E F0 .496(is a v)2.996 F .496 -(alid hostname or Internet address, and)-.25 F F1(port)2.997 E F0 .497 +(wing)-.25 E(table:)108 468 Q F1(/de)144 484.8 Q(v/fd/)-.15 E F3(fd)A F0 +(If)180 496.8 Q F3(fd)2.5 E F0(is a v)2.5 E(alid inte)-.25 E(ger)-.15 E +2.5<2c8c>-.4 G(le descriptor)-2.5 E F3(fd)2.5 E F0(is duplicated.)2.5 E +F1(/de)144 508.8 Q(v/stdin)-.15 E F0(File descriptor 0 is duplicated.) +180 520.8 Q F1(/de)144 532.8 Q(v/stdout)-.15 E F0 +(File descriptor 1 is duplicated.)180 544.8 Q F1(/de)144 556.8 Q +(v/stderr)-.15 E F0(File descriptor 2 is duplicated.)180 568.8 Q F1(/de) +144 580.8 Q(v/tcp/)-.15 E F3(host)A F1(/)A F3(port)A F0(If)180 592.8 Q +F3(host)2.996 E F0 .496(is a v)2.996 F .496 +(alid hostname or Internet address, and)-.25 F F3(port)2.997 E F0 .497 (is an inte)2.997 F .497(ger port number or ser)-.15 F(-)-.2 E -(vice name,)180 451.2 Q F2(bash)2.5 E F0 -(attempts to open the corresponding TCP sock)2.5 E(et.)-.1 E F2(/de)144 -463.2 Q(v/udp/)-.15 E F1(host)A F2(/)A F1(port)A F0(If)180 475.2 Q F1 +(vice name,)180 604.8 Q F1(bash)2.5 E F0 +(attempts to open the corresponding TCP sock)2.5 E(et.)-.1 E F1(/de)144 +616.8 Q(v/udp/)-.15 E F3(host)A F1(/)A F3(port)A F0(If)180 628.8 Q F3 (host)2.997 E F0 .497(is a v)2.997 F .497 -(alid hostname or Internet address, and)-.25 F F1(port)2.996 E F0 .496 +(alid hostname or Internet address, and)-.25 F F3(port)2.996 E F0 .496 (is an inte)2.996 F .496(ger port number or ser)-.15 F(-)-.2 E -(vice name,)180 487.2 Q F2(bash)2.5 E F0 +(vice name,)180 640.8 Q F1(bash)2.5 E F0 (attempts to open the corresponding UDP sock)2.5 E(et.)-.1 E 2.5(Af)108 -504 S(ailure to open or create a \214le causes the redirection to f)-2.6 -E(ail.)-.1 E .946(Redirections using \214le descriptors greater than 9 \ -should be used with care, as the)108 520.8 R 3.447(ym)-.15 G .947 +657.6 S(ailure to open or create a \214le causes the redirection to f) +-2.6 E(ail.)-.1 E .946(Redirections using \214le descriptors greater th\ +an 9 should be used with care, as the)108 674.4 R 3.447(ym)-.15 G .947 (ay con\215ict with \214le)-3.447 F -(descriptors the shell uses internally)108 532.8 Q(.)-.65 E F2(Redir)87 -549.6 Q(ecting Input)-.18 E F0 .391 +(descriptors the shell uses internally)108 686.4 Q(.)-.65 E F1(Redir)87 +703.2 Q(ecting Input)-.18 E F0 .391 (Redirection of input causes the \214le whose name results from the e) -108 561.6 R .391(xpansion of)-.15 F F1(wor)3.231 E(d)-.37 E F0 .391 -(to be opened for read-)3.661 F(ing on \214le descriptor)108 573.6 Q F1 +108 715.2 R .391(xpansion of)-.15 F F3(wor)3.231 E(d)-.37 E F0 .391 +(to be opened for read-)3.661 F(ing on \214le descriptor)108 727.2 Q F3 (n)2.5 E F0 2.5(,o).24 G 2.5(rt)-2.5 G -(he standard input \(\214le descriptor 0\) if)-2.5 E F1(n)2.86 E F0 -(is not speci\214ed.)2.74 E -(The general format for redirecting input is:)108 590.4 Q([)144 607.2 Q -F1(n)A F0(])A F2(<)A F1(wor)A(d)-.37 E F2(Redir)87 624 Q(ecting Output) --.18 E F0 .174 +(he standard input \(\214le descriptor 0\) if)-2.5 E F3(n)2.86 E F0 +(is not speci\214ed.)2.74 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15 +(ve)-.15 G(mber 24).15 E(25)185.545 E 0 Cg EP +%%Page: 26 26 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(The general format for redirecting input is:)108 84 Q([)144 100.8 +Q/F1 10/Times-Italic@0 SF(n)A F0(])A/F2 10/Times-Bold@0 SF(<)A F1(wor)A +(d)-.37 E F2(Redir)87 117.6 Q(ecting Output)-.18 E F0 .174 (Redirection of output causes the \214le whose name results from the e) -108 636 R .175(xpansion of)-.15 F F1(wor)3.015 E(d)-.37 E F0 .175 -(to be opened for writ-)3.445 F .825(ing on \214le descriptor)108 648 R -F1(n)3.325 E F0 3.325(,o).24 G 3.325(rt)-3.325 G .824 +108 129.6 R .175(xpansion of)-.15 F F1(wor)3.015 E(d)-.37 E F0 .175 +(to be opened for writ-)3.445 F .825(ing on \214le descriptor)108 141.6 +R F1(n)3.325 E F0 3.325(,o).24 G 3.325(rt)-3.325 G .824 (he standard output \(\214le descriptor 1\) if)-3.325 F F1(n)3.684 E F0 .824(is not speci\214ed.)3.564 F .824(If the \214le does not)5.824 F --.15(ex)108 660 S(ist it is created; if it does e).15 E +-.15(ex)108 153.6 S(ist it is created; if it does e).15 E (xist it is truncated to zero size.)-.15 E -(The general format for redirecting output is:)108 676.8 Q([)144 693.6 Q +(The general format for redirecting output is:)108 170.4 Q([)144 187.2 Q F1(n)A F0(])A F2(>)A F1(wor)A(d)-.37 E F0 .154 -(If the redirection operator is)108 710.4 R F2(>)2.654 E F0 2.654(,a)C +(If the redirection operator is)108 204 R F2(>)2.654 E F0 2.654(,a)C .154(nd the)-2.654 F F2(noclob)2.654 E(ber)-.1 E F0 .154(option to the) 2.654 F F2(set)2.655 E F0 -.2(bu)2.655 G .155 -(iltin has been enabled, the redirection).2 F 1.76(will f)108 722.4 R -1.76(ail if the \214le whose name results from the e)-.1 F 1.759 -(xpansion of)-.15 F F1(wor)4.259 E(d)-.37 E F0 -.15(ex)4.259 G 1.759 -(ists and is a re).15 F 1.759(gular \214le.)-.15 F 1.759(If the)6.759 F -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(25)198.165 E 0 Cg EP -%%Page: 26 26 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E .594(redirection operator is)108 84 R/F1 10/Times-Bold@0 SF(>|) -3.094 E F0 3.094(,o)C 3.094(rt)-3.094 G .594(he redirection operator is) --3.094 F F1(>)3.094 E F0 .595(and the)3.094 F F1(noclob)3.095 E(ber)-.1 -E F0 .595(option to the)3.095 F F1(set)3.095 E F0 -.2(bu)3.095 G .595 -(iltin com-).2 F(mand is not enabled, the redirection is attempted e)108 -96 Q -.15(ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 G(he \214le named by)-2.5 E -/F2 10/Times-Italic@0 SF(wor)2.5 E(d)-.37 E F0 -.15(ex)2.5 G(ists.).15 E -F1 -.25(Ap)87 112.8 S(pending Redir).25 E(ected Output)-.18 E F0 .642 -(Redirection of output in this f)108 124.8 R .642 -(ashion causes the \214le whose name results from the e)-.1 F .641 -(xpansion of)-.15 F F2(wor)3.481 E(d)-.37 E F0 .641(to be)3.911 F .473 -(opened for appending on \214le descriptor)108 136.8 R F2(n)2.973 E F0 +(iltin has been enabled, the redirection).2 F .658(will f)108 216 R .658 +(ail if the \214le whose name results from the e)-.1 F .658(xpansion of) +-.15 F F1(wor)3.158 E(d)-.37 E F0 -.15(ex)3.158 G .657(ists and is a re) +.15 F .657(gular \214le.)-.15 F .657(If the redi-)5.657 F .408 +(rection operator is)108 228 R F2(>|)2.909 E F0 2.909(,o)C 2.909(rt) +-2.909 G .409(he redirection operator is)-2.909 F F2(>)2.909 E F0 .409 +(and the)2.909 F F2(noclob)2.909 E(ber)-.1 E F0 .409(option to the)2.909 +F F2(set)2.909 E F0 -.2(bu)2.909 G .409(iltin command).2 F +(is not enabled, the redirection is attempted e)108 240 Q -.15(ve)-.25 G +2.5(ni).15 G 2.5(ft)-2.5 G(he \214le named by)-2.5 E F1(wor)2.5 E(d)-.37 +E F0 -.15(ex)2.5 G(ists.).15 E F2 -.25(Ap)87 256.8 S(pending Redir).25 E +(ected Output)-.18 E F0 .642(Redirection of output in this f)108 268.8 R +.642(ashion causes the \214le whose name results from the e)-.1 F .641 +(xpansion of)-.15 F F1(wor)3.481 E(d)-.37 E F0 .641(to be)3.911 F .473 +(opened for appending on \214le descriptor)108 280.8 R F1(n)2.973 E F0 2.974(,o).24 G 2.974(rt)-2.974 G .474 -(he standard output \(\214le descriptor 1\) if)-2.974 F F2(n)3.334 E F0 +(he standard output \(\214le descriptor 1\) if)-2.974 F F1(n)3.334 E F0 .474(is not speci\214ed.)3.214 F(If)5.474 E(the \214le does not e)108 -148.8 Q(xist it is created.)-.15 E -(The general format for appending output is:)108 165.6 Q([)144 182.4 Q -F2(n)A F0(])A F1(>>)A F2(wor)A(d)-.37 E F1(Redir)87 204 Q +292.8 Q(xist it is created.)-.15 E +(The general format for appending output is:)108 309.6 Q([)144 326.4 Q +F1(n)A F0(])A F2(>>)A F1(wor)A(d)-.37 E F2(Redir)87 348 Q (ecting Standard Output and Standard Err)-.18 E(or)-.18 E F0 .249 -(This construct allo)108 216 R .249(ws both the standard output \(\214l\ +(This construct allo)108 360 R .249(ws both the standard output \(\214l\ e descriptor 1\) and the standard error output \(\214le descrip-)-.25 F -(tor 2\) to be redirected to the \214le whose name is the e)108 228 Q -(xpansion of)-.15 E F2(wor)2.5 E(d)-.37 E F0(.).77 E(There are tw)108 -244.8 Q 2.5(of)-.1 G -(ormats for redirecting standard output and standard error:)-2.5 E F1 -(&>)144 261.6 Q F2(wor)A(d)-.37 E F0(and)108 273.6 Q F1(>&)144 285.6 Q -F2(wor)A(d)-.37 E F0(Of the tw)108 302.4 Q 2.5(of)-.1 G +(tor 2\) to be redirected to the \214le whose name is the e)108 372 Q +(xpansion of)-.15 E F1(wor)2.5 E(d)-.37 E F0(.).77 E(There are tw)108 +388.8 Q 2.5(of)-.1 G +(ormats for redirecting standard output and standard error:)-2.5 E F2 +(&>)144 405.6 Q F1(wor)A(d)-.37 E F0(and)108 417.6 Q F2(>&)144 429.6 Q +F1(wor)A(d)-.37 E F0(Of the tw)108 446.4 Q 2.5(of)-.1 G (orms, the \214rst is preferred.)-2.5 E(This is semantically equi)5 E --.25(va)-.25 G(lent to).25 E F1(>)144 319.2 Q F2(wor)A(d)-.37 E F0(2)2.5 -E F1(>&)A F0(1)A .114(When using the second form,)108 336 R F2(wor)2.614 -E(d)-.37 E F0 .114(may not e)2.614 F .114(xpand to a number or)-.15 F F1 +-.25(va)-.25 G(lent to).25 E F2(>)144 463.2 Q F1(wor)A(d)-.37 E F0(2)2.5 +E F2(>&)A F0(1)A .114(When using the second form,)108 480 R F1(wor)2.614 +E(d)-.37 E F0 .114(may not e)2.614 F .114(xpand to a number or)-.15 F F2 2.614 E F0 5.114(.I)C 2.614(fi)-5.114 G 2.615(td)-2.614 G .115 -(oes, other redirection operators)-2.615 F(apply \(see)108 348 Q F1 +(oes, other redirection operators)-2.615 F(apply \(see)108 492 Q F2 (Duplicating File Descriptors)2.5 E F0(belo)2.5 E -(w\) for compatibility reasons.)-.25 E F1 -.25(Ap)87 364.8 S +(w\) for compatibility reasons.)-.25 E F2 -.25(Ap)87 508.8 S (pending Standard Output and Standard Err).25 E(or)-.18 E F0 .249 -(This construct allo)108 376.8 R .249(ws both the standard output \(\ +(This construct allo)108 520.8 R .249(ws both the standard output \(\ \214le descriptor 1\) and the standard error output \(\214le descrip-) -.25 F(tor 2\) to be appended to the \214le whose name is the e)108 -388.8 Q(xpansion of)-.15 E F2(wor)2.5 E(d)-.37 E F0(.).77 E +532.8 Q(xpansion of)-.15 E F1(wor)2.5 E(d)-.37 E F0(.).77 E (The format for appending standard output and standard error is:)108 -405.6 Q F1(&>>)144 422.4 Q F2(wor)A(d)-.37 E F0 -(This is semantically equi)108 439.2 Q -.25(va)-.25 G(lent to).25 E F1 -(>>)144 456 Q F2(wor)A(d)-.37 E F0(2)2.5 E F1(>&)A F0(1)A(\(see)108 -472.8 Q F1(Duplicating File Descriptors)2.5 E F0(belo)2.5 E(w\).)-.25 E -F1(Her)87 489.6 Q 2.5(eD)-.18 G(ocuments)-2.5 E F0 .33(This type of red\ +549.6 Q F2(&>>)144 566.4 Q F1(wor)A(d)-.37 E F0 +(This is semantically equi)108 583.2 Q -.25(va)-.25 G(lent to).25 E F2 +(>>)144 600 Q F1(wor)A(d)-.37 E F0(2)2.5 E F2(>&)A F0(1)A(\(see)108 +616.8 Q F2(Duplicating File Descriptors)2.5 E F0(belo)2.5 E(w\).)-.25 E +F2(Her)87 633.6 Q 2.5(eD)-.18 G(ocuments)-2.5 E F0 .33(This type of red\ irection instructs the shell to read input from the current source unti\ -l a line containing only)108 501.6 R F2(delimiter)108.35 513.6 Q F0 .615 +l a line containing only)108 645.6 R F1(delimiter)108.35 657.6 Q F0 .615 (\(with no trailing blanks\) is seen.)3.845 F .615 (All of the lines read up to that point are then used as the stan-)5.615 -F(dard input for a command.)108 525.6 Q -(The format of here-documents is:)108 542.4 Q F1(<<)144 559.2 Q F0([)A -F1A F0(])A F2(wor)A(d)-.37 E(her)164 571.2 Q(e-document)-.37 E -(delimiter)144 583.2 Q F0 .301(No parameter and v)108 600 R .302 -(ariable e)-.25 F .302(xpansion, command substitution, arithmetic e)-.15 -F .302(xpansion, or pathname e)-.15 F(xpansion)-.15 E .226 -(is performed on)108 612 R F2(wor)2.726 E(d)-.37 E F0 5.226(.I).77 G -2.726(fa)-5.226 G .526 -.15(ny c)-2.726 H .226(haracters in).15 F F2 -(wor)3.066 E(d)-.37 E F0 .226(are quoted, the)3.496 F F2(delimiter)3.076 +F(dard input for a command.)108 669.6 Q +(The format of here-documents is:)108 686.4 Q F2(<<)144 703.2 Q F0([)A +F2A F0(])A F1(wor)A(d)-.37 E(her)164 715.2 Q(e-document)-.37 E +(delimiter)144 727.2 Q F0(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15 +(ve)-.15 G(mber 24).15 E(26)185.545 E 0 Cg EP +%%Page: 27 27 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E .301(No parameter and v)108 84 R .302(ariable e)-.25 F .302 +(xpansion, command substitution, arithmetic e)-.15 F .302 +(xpansion, or pathname e)-.15 F(xpansion)-.15 E .226(is performed on)108 +96 R/F1 10/Times-Italic@0 SF(wor)2.726 E(d)-.37 E F0 5.226(.I).77 G +2.726(fa)-5.226 G .526 -.15(ny c)-2.726 H .226(haracters in).15 F F1 +(wor)3.066 E(d)-.37 E F0 .226(are quoted, the)3.496 F F1(delimiter)3.076 E F0 .225(is the result of quote remo)3.456 F -.25(va)-.15 G 2.725(lo) -.25 G(n)-2.725 E F2(wor)108 624 Q(d)-.37 E F0 2.714(,a).77 G .214 +.25 G(n)-2.725 E F1(wor)108 108 Q(d)-.37 E F0 2.714(,a).77 G .214 (nd the lines in the here-document are not e)-2.714 F 2.714(xpanded. If) --.15 F F2(wor)2.715 E(d)-.37 E F0 .215 +-.15 F F1(wor)2.715 E(d)-.37 E F0 .215 (is unquoted, all lines of the here-docu-)2.715 F .499 -(ment are subjected to parameter e)108 636 R .499 +(ment are subjected to parameter e)108 120 R .499 (xpansion, command substitution, and arithmetic e)-.15 F .499 -(xpansion, the character)-.15 F(sequence)108 648 Q F1(\\)2.5 E -F0(is ignored, and)2.5 E F1(\\)2.5 E F0 -(must be used to quote the characters)2.5 E F1(\\)2.5 E F0(,)A F1($)2.5 -E F0 2.5(,a)C(nd)-2.5 E F1<92>2.5 E F0(.)A .601 -(If the redirection operator is)108 664.8 R F1(<<\255)3.101 E F0 3.101 +(xpansion, the character)-.15 F(sequence)108 132 Q/F2 10/Times-Bold@0 SF +(\\)2.5 E F0(is ignored, and)2.5 E F2(\\)2.5 E F0 +(must be used to quote the characters)2.5 E F2(\\)2.5 E F0(,)A F2($)2.5 +E F0 2.5(,a)C(nd)-2.5 E F2<92>2.5 E F0(.)A .601 +(If the redirection operator is)108 148.8 R F2(<<\255)3.101 E F0 3.101 (,t)C .601(hen all leading tab characters are stripped from input lines\ - and the line)-3.101 F(containing)108 676.8 Q F2(delimiter)2.5 E F0 5 + and the line)-3.101 F(containing)108 160.8 Q F1(delimiter)2.5 E F0 5 (.T).73 G(his allo)-5 E (ws here-documents within shell scripts to be indented in a natural f) --.25 E(ashion.)-.1 E F1(Her)87 693.6 Q 2.5(eS)-.18 G(trings)-2.5 E F0 -2.5(Av)108 705.6 S(ariant of here documents, the format is:)-2.75 E F1 -(<<<)144 722.4 Q F2(wor)A(d)-.37 E F0(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(26)198.165 E 0 Cg EP -%%Page: 27 27 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E(The)108 84 Q/F1 10/Times-Italic@0 SF(wor)2.894 E(d)-.37 E F0 -(under)2.894 E .394(goes brace e)-.18 F .393(xpansion, tilde e)-.15 F -.393(xpansion, parameter and v)-.15 F .393(ariable e)-.25 F .393 -(xpansion, command substi-)-.15 F 2.147(tution, arithmetic e)108 96 R +-.25 E(ashion.)-.1 E F2(Her)87 177.6 Q 2.5(eS)-.18 G(trings)-2.5 E F0 +2.5(Av)108 189.6 S(ariant of here documents, the format is:)-2.75 E F2 +(<<<)144 206.4 Q F1(wor)A(d)-.37 E F0(The)108 223.2 Q F1(wor)2.894 E(d) +-.37 E F0(under)2.894 E .394(goes brace e)-.18 F .393(xpansion, tilde e) +-.15 F .393(xpansion, parameter and v)-.15 F .393(ariable e)-.25 F .393 +(xpansion, command substi-)-.15 F 2.147(tution, arithmetic e)108 235.2 R 2.147(xpansion, and quote remo)-.15 F -.25(va)-.15 G 4.648(l. P).25 F 2.148(athname e)-.15 F 2.148(xpansion and w)-.15 F 2.148 -(ord splitting are not per)-.1 F(-)-.2 E 2.5(formed. The)108 108 R(resu\ -lt is supplied as a single string to the command on its standard input.) -2.5 E/F2 10/Times-Bold@0 SF(Duplicating File Descriptors)87 124.8 Q F0 -(The redirection operator)108 136.8 Q([)144 153.6 Q F1(n)A F0(])A F2(<&) -A F1(wor)A(d)-.37 E F0 .127 -(is used to duplicate input \214le descriptors.)108 170.4 R(If)5.127 E +(ord splitting are not per)-.1 F(-)-.2 E 2.5(formed. The)108 247.2 R(re\ +sult is supplied as a single string to the command on its standard inpu\ +t.)2.5 E F2(Duplicating File Descriptors)87 264 Q F0 +(The redirection operator)108 276 Q([)144 292.8 Q F1(n)A F0(])A F2(<&)A +F1(wor)A(d)-.37 E F0 .127 +(is used to duplicate input \214le descriptors.)108 309.6 R(If)5.127 E F1(wor)2.967 E(d)-.37 E F0 -.15(ex)3.397 G .126 (pands to one or more digits, the \214le descriptor denoted).15 F(by)108 -182.4 Q F1(n)3.317 E F0 .457(is made to be a cop)3.197 F 2.957(yo)-.1 G +321.6 Q F1(n)3.317 E F0 .457(is made to be a cop)3.197 F 2.957(yo)-.1 G 2.957(ft)-2.957 G .457(hat \214le descriptor)-2.957 F 5.457(.I)-.55 G 2.957(ft)-5.457 G .457(he digits in)-2.957 F F1(wor)3.298 E(d)-.37 E F0 .458(do not specify a \214le descriptor open)3.728 F .15 -(for input, a redirection error occurs.)108 194.4 R(If)5.15 E F1(wor) +(for input, a redirection error occurs.)108 333.6 R(If)5.15 E F1(wor) 2.99 E(d)-.37 E F0 -.25(eva)3.42 G .15(luates to).25 F F22.65 E F0 2.649<2c8c>C .149(le descriptor)-2.649 F F1(n)3.009 E F0 .149 (is closed.)2.889 F(If)5.149 E F1(n)3.009 E F0 .149(is not speci\214ed,) -2.889 F(the standard input \(\214le descriptor 0\) is used.)108 206.4 Q -(The operator)108 223.2 Q([)144 240 Q F1(n)A F0(])A F2(>&)A F1(wor)A(d) --.37 E F0 .443 -(is used similarly to duplicate output \214le descriptors.)108 256.8 R -(If)5.443 E F1(n)3.304 E F0 .444 +2.889 F(the standard input \(\214le descriptor 0\) is used.)108 345.6 Q +(The operator)108 362.4 Q([)144 379.2 Q F1(n)A F0(])A F2(>&)A F1(wor)A +(d)-.37 E F0 .443 +(is used similarly to duplicate output \214le descriptors.)108 396 R(If) +5.443 E F1(n)3.304 E F0 .444 (is not speci\214ed, the standard output \(\214le descrip-)3.184 F 1.358 -(tor 1\) is used.)108 268.8 R 1.358(If the digits in)6.358 F F1(wor) -4.198 E(d)-.37 E F0 1.357(do not specify a \214le descriptor open for o\ -utput, a redirection error)4.628 F 2.753(occurs. If)108 280.8 R F1(wor) -3.093 E(d)-.37 E F0 -.25(eva)3.523 G .253(luates to).25 F F22.754 E -F0 2.754<2c8c>C .254(le descriptor)-2.754 F F1(n)3.114 E F0 .254 +(tor 1\) is used.)108 408 R 1.358(If the digits in)6.358 F F1(wor)4.198 +E(d)-.37 E F0 1.357(do not specify a \214le descriptor open for output,\ + a redirection error)4.628 F 2.753(occurs. If)108 420 R F1(wor)3.093 E +(d)-.37 E F0 -.25(eva)3.523 G .253(luates to).25 F F22.754 E F0 +2.754<2c8c>C .254(le descriptor)-2.754 F F1(n)3.114 E F0 .254 (is closed.)2.994 F .254(As a special case, if)5.254 F F1(n)2.754 E F0 .254(is omitted, and)2.754 F F1(wor)2.754 E(d)-.37 E F0(does)2.754 E -.966(not e)108 292.8 R .966(xpand to one or more digits or)-.15 F F2 +.966(not e)108 432 R .966(xpand to one or more digits or)-.15 F F2 3.466 E F0 3.466(,t)C .965 (he standard output and standard error are redirected as described) --3.466 F(pre)108 304.8 Q(viously)-.25 E(.)-.65 E F2(Mo)87 321.6 Q -(ving File Descriptors)-.1 E F0(The redirection operator)108 333.6 Q([) -144 350.4 Q F1(n)A F0(])A F2(<&)A F1(digit)A F2A F0(mo)108 367.2 Q +-3.466 F(pre)108 444 Q(viously)-.25 E(.)-.65 E F2(Mo)87 460.8 Q +(ving File Descriptors)-.1 E F0(The redirection operator)108 472.8 Q([) +144 489.6 Q F1(n)A F0(])A F2(<&)A F1(digit)A F2A F0(mo)108 506.4 Q -.15(ve)-.15 G 3.035(st).15 G .535(he \214le descriptor)-3.035 F F1 (digit)3.035 E F0 .535(to \214le descriptor)3.035 F F1(n)3.035 E F0 3.035(,o).24 G 3.035(rt)-3.035 G .536 (he standard input \(\214le descriptor 0\) if)-3.035 F F1(n)3.036 E F0 -.536(is not speci-)3.036 F(\214ed.)108 379.2 Q F1(digit)5 E F0 +.536(is not speci-)3.036 F(\214ed.)108 518.4 Q F1(digit)5 E F0 (is closed after being duplicated to)2.5 E F1(n)2.5 E F0(.)A(Similarly) -108 396 Q 2.5(,t)-.65 G(he redirection operator)-2.5 E([)144 412.8 Q F1 -(n)A F0(])A F2(>&)A F1(digit)A F2A F0(mo)108 429.6 Q -.15(ve)-.15 G +108 535.2 Q 2.5(,t)-.65 G(he redirection operator)-2.5 E([)144 552 Q F1 +(n)A F0(])A F2(>&)A F1(digit)A F2A F0(mo)108 568.8 Q -.15(ve)-.15 G 2.786(st).15 G .286(he \214le descriptor)-2.786 F F1(digit)2.786 E F0 .286(to \214le descriptor)2.786 F F1(n)2.786 E F0 2.786(,o).24 G 2.786 (rt)-2.786 G .285(he standard output \(\214le descriptor 1\) if)-2.786 F -F1(n)2.785 E F0 .285(is not speci-)2.785 F(\214ed.)108 441.6 Q F2 -(Opening File Descriptors f)87 458.4 Q(or Reading and Writing)-.25 E F0 -(The redirection operator)108 470.4 Q([)144 487.2 Q F1(n)A F0(])A F2(<>) +F1(n)2.785 E F0 .285(is not speci-)2.785 F(\214ed.)108 580.8 Q F2 +(Opening File Descriptors f)87 597.6 Q(or Reading and Writing)-.25 E F0 +(The redirection operator)108 609.6 Q([)144 626.4 Q F1(n)A F0(])A F2(<>) A F1(wor)A(d)-.37 E F0 1.349(causes the \214le whose name is the e)108 -504 R 1.349(xpansion of)-.15 F F1(wor)4.189 E(d)-.37 E F0 1.349 +643.2 R 1.349(xpansion of)-.15 F F1(wor)4.189 E(d)-.37 E F0 1.349 (to be opened for both reading and writing on \214le)4.619 F(descriptor) -108 516 Q F1(n)2.5 E F0 2.5(,o).24 G 2.5(ro)-2.5 G 2.5<6e8c>-2.5 G +108 655.2 Q F1(n)2.5 E F0 2.5(,o).24 G 2.5(ro)-2.5 G 2.5<6e8c>-2.5 G (le descriptor 0 if)-2.5 E F1(n)2.86 E F0(is not speci\214ed.)2.74 E (If the \214le does not e)5 E(xist, it is created.)-.15 E/F3 10.95 -/Times-Bold@0 SF(ALIASES)72 532.8 Q F1(Aliases)108 544.8 Q F0(allo)3.174 -E 3.174(was)-.25 G .674(tring to be substituted for a w)-3.174 F .674 +/Times-Bold@0 SF(ALIASES)72 672 Q F1(Aliases)108 684 Q F0(allo)3.174 E +3.174(was)-.25 G .674(tring to be substituted for a w)-3.174 F .674 (ord when it is used as the \214rst w)-.1 F .673 (ord of a simple command.)-.1 F .394(The shell maintains a list of alia\ -ses that may be set and unset with the)108 556.8 R F2(alias)2.894 E F0 +ses that may be set and unset with the)108 696 R F2(alias)2.894 E F0 (and)2.894 E F2(unalias)2.894 E F0 -.2(bu)2.894 G .394(iltin commands).2 -F(\(see)108 568.8 Q/F4 9/Times-Bold@0 SF 1.98(SHELL B)4.48 F(UIL)-.09 E +F(\(see)108 708 Q/F4 9/Times-Bold@0 SF 1.98(SHELL B)4.48 F(UIL)-.09 E 1.98(TIN COMMANDS)-.828 F F0(belo)4.23 E 4.48(w\). The)-.25 F 1.98 (\214rst w)4.48 F 1.979(ord of each simple command, if unquoted, is)-.1 -F(check)108 580.8 Q .472(ed to see if it has an alias.)-.1 F .472 +F(check)108 720 Q .472(ed to see if it has an alias.)-.1 F .472 (If so, that w)5.472 F .473(ord is replaced by the te)-.1 F .473 (xt of the alias.)-.15 F .473(The characters)5.473 F F2(/)2.973 E F0(,)A -F2($)2.973 E F0(,)A F2<92>2.973 E F0(,)A(and)108 592.8 Q F2(=)3.612 E F0 -1.112(and an)3.612 F 3.612(yo)-.15 G 3.612(ft)-3.612 G 1.112(he shell) --3.612 F F1(metac)3.612 E(har)-.15 E(acter)-.15 E(s)-.1 E F0 1.112 -(or quoting characters listed abo)3.612 F 1.411 -.15(ve m)-.15 H 1.111 -(ay not appear in an alias).15 F 3.619(name. The)108 604.8 R 1.119 +F2($)2.973 E F0(,)A F2<92>2.973 E F0(,)A(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(27)185.545 E 0 Cg EP +%%Page: 28 28 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(and)108 84 Q/F1 10/Times-Bold@0 SF(=)3.612 E F0 1.112(and an) +3.612 F 3.612(yo)-.15 G 3.612(ft)-3.612 G 1.112(he shell)-3.612 F/F2 10 +/Times-Italic@0 SF(metac)3.612 E(har)-.15 E(acter)-.15 E(s)-.1 E F0 +1.112(or quoting characters listed abo)3.612 F 1.411 -.15(ve m)-.15 H +1.111(ay not appear in an alias).15 F 3.619(name. The)108 96 R 1.119 (replacement te)3.619 F 1.119(xt may contain an)-.15 F 3.619(yv)-.15 G 1.119(alid shell input, including shell metacharacters.)-3.869 F 1.12 -(The \214rst)6.12 F -.1(wo)108 616.8 S .514(rd of the replacement te).1 -F .514(xt is tested for aliases, b)-.15 F .514(ut a w)-.2 F .513 +(The \214rst)6.12 F -.1(wo)108 108 S .514(rd of the replacement te).1 F +.514(xt is tested for aliases, b)-.15 F .514(ut a w)-.2 F .513 (ord that is identical to an alias being e)-.1 F .513(xpanded is)-.15 F -.295(not e)108 628.8 R .295(xpanded a second time.)-.15 F .296 -(This means that one may alias)5.295 F F2(ls)2.796 E F0(to)2.796 E F2 -.296(ls \255F)2.796 F F0 2.796(,f)C .296(or instance, and)-2.796 F F2 -(bash)2.796 E F0 .296(does not try)2.796 F .543(to recursi)108 640.8 R +.295(not e)108 120 R .295(xpanded a second time.)-.15 F .296 +(This means that one may alias)5.295 F F1(ls)2.796 E F0(to)2.796 E F1 +.296(ls \255F)2.796 F F0 2.796(,f)C .296(or instance, and)-2.796 F F1 +(bash)2.796 E F0 .296(does not try)2.796 F .543(to recursi)108 132 R -.15(ve)-.25 G .543(ly e).15 F .543(xpand the replacement te)-.15 F 3.043(xt. If)-.15 F .543(the last character of the alias v)3.043 F .542 -(alue is a)-.25 F F1(blank)3.042 E F0 3.042(,t).67 G .542(hen the ne) --3.042 F(xt)-.15 E(command w)108 652.8 Q(ord follo)-.1 E +(alue is a)-.25 F F2(blank)3.042 E F0 3.042(,t).67 G .542(hen the ne) +-3.042 F(xt)-.15 E(command w)108 144 Q(ord follo)-.1 E (wing the alias is also check)-.25 E(ed for alias e)-.1 E(xpansion.)-.15 -E(Aliases are created and listed with the)108 669.6 Q F2(alias)2.5 E F0 -(command, and remo)2.5 E -.15(ve)-.15 G 2.5(dw).15 G(ith the)-2.5 E F2 +E(Aliases are created and listed with the)108 160.8 Q F1(alias)2.5 E F0 +(command, and remo)2.5 E -.15(ve)-.15 G 2.5(dw).15 G(ith the)-2.5 E F1 (unalias)2.5 E F0(command.)2.5 E .284 -(There is no mechanism for using ar)108 686.4 R .284 +(There is no mechanism for using ar)108 177.6 R .284 (guments in the replacement te)-.18 F 2.784(xt. If)-.15 F(ar)2.784 E .284(guments are needed, a shell func-)-.18 F(tion should be used \(see) -108 698.4 Q F4(FUNCTIONS)2.5 E F0(belo)2.25 E(w\).)-.25 E 1.22 -(Aliases are not e)108 715.2 R 1.22 +108 189.6 Q/F3 9/Times-Bold@0 SF(FUNCTIONS)2.5 E F0(belo)2.25 E(w\).) +-.25 E 1.22(Aliases are not e)108 206.4 R 1.22 (xpanded when the shell is not interacti)-.15 F -.15(ve)-.25 G 3.72(,u) -.15 G 1.22(nless the)-3.72 F F2(expand_aliases)3.72 E F0 1.22 -(shell option is set)3.72 F(using)108 727.2 Q F2(shopt)2.5 E F0 -(\(see the description of)2.5 E F2(shopt)2.5 E F0(under)2.5 E F4 +.15 G 1.22(nless the)-3.72 F F1(expand_aliases)3.72 E F0 1.22 +(shell option is set)3.72 F(using)108 218.4 Q F1(shopt)2.5 E F0 +(\(see the description of)2.5 E F1(shopt)2.5 E F0(under)2.5 E F3 (SHELL B)2.5 E(UIL)-.09 E(TIN COMMANDS)-.828 E F0(belo)2.25 E(w\).)-.25 -E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(27)198.165 E 0 Cg EP -%%Page: 28 28 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E .435 +E .435 (The rules concerning the de\214nition and use of aliases are some)108 -84 R .436(what confusing.)-.25 F/F1 10/Times-Bold@0 SF(Bash)5.436 E F0 -(al)2.936 E -.1(wa)-.1 G .436(ys reads at least).1 F .338 -(one complete line of input before e)108 96 R -.15(xe)-.15 G .338 +235.2 R .436(what confusing.)-.25 F F1(Bash)5.436 E F0(al)2.936 E -.1 +(wa)-.1 G .436(ys reads at least).1 F .338 +(one complete line of input before e)108 247.2 R -.15(xe)-.15 G .338 (cuting an).15 F 2.838(yo)-.15 G 2.838(ft)-2.838 G .338 (he commands on that line.)-2.838 F .337(Aliases are e)5.337 F .337 -(xpanded when)-.15 F 3.403(ac)108 108 S .904 +(xpanded when)-.15 F 3.403(ac)108 259.2 S .904 (ommand is read, not when it is e)-3.403 F -.15(xe)-.15 G 3.404 (cuted. Therefore,).15 F .904 (an alias de\214nition appearing on the same line as)3.404 F 1.162 -(another command does not tak)108 120 R 3.662(ee)-.1 G -.25(ff)-3.662 G -1.162(ect until the ne).25 F 1.162(xt line of input is read.)-.15 F +(another command does not tak)108 271.2 R 3.662(ee)-.1 G -.25(ff)-3.662 +G 1.162(ect until the ne).25 F 1.162(xt line of input is read.)-.15 F 1.161(The commands follo)6.161 F 1.161(wing the)-.25 F .277 -(alias de\214nition on that line are not af)108 132 R .277 +(alias de\214nition on that line are not af)108 283.2 R .277 (fected by the ne)-.25 F 2.777(wa)-.25 G 2.777(lias. This)-2.777 F(beha) 2.777 E .277(vior is also an issue when functions)-.2 F .699(are e)108 -144 R -.15(xe)-.15 G 3.199(cuted. Aliases).15 F .699(are e)3.199 F .699 -(xpanded when a function de\214nition is read, not when the function is\ - e)-.15 F -.15(xe)-.15 G(cuted,).15 E .494 -(because a function de\214nition is itself a compound command.)108 156 R -.495(As a consequence, aliases de\214ned in a func-)5.494 F .085 -(tion are not a)108 168 R -.25(va)-.2 G .084 +295.2 R -.15(xe)-.15 G 3.199(cuted. Aliases).15 F .699(are e)3.199 F +.699(xpanded when a function de\214nition is read, not when the functio\ +n is e)-.15 F -.15(xe)-.15 G(cuted,).15 E .494 +(because a function de\214nition is itself a compound command.)108 307.2 +R .495(As a consequence, aliases de\214ned in a func-)5.494 F .085 +(tion are not a)108 319.2 R -.25(va)-.2 G .084 (ilable until after that function is e).25 F -.15(xe)-.15 G 2.584 (cuted. T).15 F 2.584(ob)-.8 G 2.584(es)-2.584 G .084(afe, al)-2.584 F -.1(wa)-.1 G .084(ys put alias de\214nitions on a sepa-).1 F -(rate line, and do not use)108 180 Q F1(alias)2.5 E F0 -(in compound commands.)2.5 E -.15(Fo)108 196.8 S 2.5(ra).15 G(lmost e) --2.5 E -.15(ve)-.25 G -(ry purpose, aliases are superseded by shell functions.).15 E/F2 10.95 -/Times-Bold@0 SF(FUNCTIONS)72 213.6 Q F0 3.467(As)108 225.6 S .967 -(hell function, de\214ned as described abo)-3.467 F 1.267 -.15(ve u)-.15 -H(nder).15 E/F3 9/Times-Bold@0 SF .967(SHELL GRAMMAR)3.467 F/F4 9 +(rate line, and do not use)108 331.2 Q F1(alias)2.5 E F0 +(in compound commands.)2.5 E -.15(Fo)108 348 S 2.5(ra).15 G(lmost e)-2.5 +E -.15(ve)-.25 G(ry purpose, aliases are superseded by shell functions.) +.15 E/F4 10.95/Times-Bold@0 SF(FUNCTIONS)72 364.8 Q F0 3.467(As)108 +376.8 S .967(hell function, de\214ned as described abo)-3.467 F 1.267 +-.15(ve u)-.15 H(nder).15 E F3 .967(SHELL GRAMMAR)3.467 F/F5 9 /Times-Roman@0 SF(,)A F0 .968(stores a series of commands for)3.217 F -1.002(later e)108 237.6 R -.15(xe)-.15 G 3.502(cution. When).15 F 1.002 +1.002(later e)108 388.8 R -.15(xe)-.15 G 3.502(cution. When).15 F 1.002 (the name of a shell function is used as a simple command name, the lis\ t of com-)3.502 F .315(mands associated with that function name is e)108 -249.6 R -.15(xe)-.15 G 2.816(cuted. Functions).15 F .316(are e)2.816 F +400.8 R -.15(xe)-.15 G 2.816(cuted. Functions).15 F .316(are e)2.816 F -.15(xe)-.15 G .316(cuted in the conte).15 F .316(xt of the current)-.15 -F .036(shell; no ne)108 261.6 R 2.536(wp)-.25 G .036 +F .036(shell; no ne)108 412.8 R 2.536(wp)-.25 G .036 (rocess is created to interpret them \(contrast this with the e)-2.536 F -.15(xe)-.15 G .036(cution of a shell script\).).15 F .035(When a)5.035 -F .639(function is e)108 273.6 R -.15(xe)-.15 G .639(cuted, the ar).15 F +F .639(function is e)108 424.8 R -.15(xe)-.15 G .639(cuted, the ar).15 F .639 (guments to the function become the positional parameters during its e) --.18 F -.15(xe)-.15 G(cution.).15 E .533(The special parameter)108 285.6 +-.18 F -.15(xe)-.15 G(cution.).15 E .533(The special parameter)108 436.8 R F1(#)3.033 E F0 .532(is updated to re\215ect the change.)3.033 F .532 (Special parameter)5.532 F F1(0)3.032 E F0 .532(is unchanged.)3.032 F -.532(The \214rst ele-)5.532 F(ment of the)108 297.6 Q F3(FUNCN)2.5 E +.532(The \214rst ele-)5.532 F(ment of the)108 448.8 Q F3(FUNCN)2.5 E (AME)-.18 E F0 -.25(va)2.25 G (riable is set to the name of the function while the function is e).25 E -.15(xe)-.15 G(cuting.).15 E 1.25(All other aspects of the shell e)108 -314.4 R -.15(xe)-.15 G 1.25(cution en).15 F 1.25 +465.6 R -.15(xe)-.15 G 1.25(cution en).15 F 1.25 (vironment are identical between a function and its caller with)-.4 F -1.049(these e)108 326.4 R 3.548(xceptions: the)-.15 F F3(DEB)3.548 E(UG) +1.049(these e)108 477.6 R 3.548(xceptions: the)-.15 F F3(DEB)3.548 E(UG) -.09 E F0(and)3.298 E F1(RETURN)3.548 E F0 1.048 (traps \(see the description of the)3.548 F F1(trap)3.548 E F0 -.2(bu) -3.548 G 1.048(iltin under).2 F F3(SHELL)3.548 E -.09(BU)108 338.4 S(IL) +3.548 G 1.048(iltin under).2 F F3(SHELL)3.548 E -.09(BU)108 489.6 S(IL) .09 E .478(TIN COMMANDS)-.828 F F0(belo)2.728 E .479 (w\) are not inherited unless the function has been gi)-.25 F -.15(ve) -.25 G 2.979(nt).15 G(he)-2.979 E F1(trace)2.979 E F0(attrib)2.979 E -.479(ute \(see)-.2 F .421(the description of the)108 350.4 R F3(declar) +.479(ute \(see)-.2 F .421(the description of the)108 501.6 R F3(declar) 2.92 E(e)-.162 E F0 -.2(bu)2.67 G .42(iltin belo).2 F .42(w\) or the) -.25 F F1 .42(\255o functrace)2.92 F F0 .42 (shell option has been enabled with the)2.92 F F1(set)2.92 E F0 -.2(bu) -108 362.4 S .071(iltin \(in which case all functions inherit the).2 F F1 +108 513.6 S .071(iltin \(in which case all functions inherit the).2 F F1 (DEB)2.572 E(UG)-.1 E F0(and)2.572 E F1(RETURN)2.572 E F0 .072 (traps\), and the)2.572 F F3(ERR)2.572 E F0 .072(trap is not inher)2.322 -F(-)-.2 E(ited unless the)108 374.4 Q F1(\255o errtrace)2.5 E F0 -(shell option has been enabled.)2.5 E -1.11(Va)108 391.2 S .656 +F(-)-.2 E(ited unless the)108 525.6 Q F1(\255o errtrace)2.5 E F0 +(shell option has been enabled.)2.5 E -1.11(Va)108 542.4 S .656 (riables local to the function may be declared with the)1.11 F F1(local) 3.155 E F0 -.2(bu)3.155 G .655(iltin command.).2 F(Ordinarily)5.655 E -3.155(,v)-.65 G .655(ariables and)-3.405 F(their v)108 403.2 Q +3.155(,v)-.65 G .655(ariables and)-3.405 F(their v)108 554.4 Q (alues are shared between the function and its caller)-.25 E(.)-.55 E -(The)108 420 Q F1(FUNCNEST)3.528 E F0 -.25(va)3.528 G 1.028 +(The)108 571.2 Q F1(FUNCNEST)3.528 E F0 -.25(va)3.528 G 1.028 (riable, if set to a numeric v).25 F 1.028 (alue greater than 0, de\214nes a maximum function nesting)-.25 F(le)108 -432 Q -.15(ve)-.25 G 2.5(l. Function).15 F(in)2.5 E -.2(vo)-.4 G +583.2 Q -.15(ve)-.25 G 2.5(l. Function).15 F(in)2.5 E -.2(vo)-.4 G (cations that e).2 E(xceed the limit cause the entire command to abort.) --.15 E .044(If the b)108 448.8 R .043(uiltin command)-.2 F F1 -.18(re) +-.15 E .044(If the b)108 600 R .043(uiltin command)-.2 F F1 -.18(re) 2.543 G(tur).18 E(n)-.15 E F0 .043(is e)2.543 F -.15(xe)-.15 G .043 (cuted in a function, the function completes and e).15 F -.15(xe)-.15 G -.043(cution resumes with).15 F 1.011(the ne)108 460.8 R 1.011 +.043(cution resumes with).15 F 1.011(the ne)108 612 R 1.011 (xt command after the function call.)-.15 F(An)6.011 E 3.511(yc)-.15 G 1.011(ommand associated with the)-3.511 F F1(RETURN)3.512 E F0 1.012 -(trap is e)3.512 F -.15(xe)-.15 G(cuted).15 E .214(before e)108 472.8 R +(trap is e)3.512 F -.15(xe)-.15 G(cuted).15 E .214(before e)108 624 R -.15(xe)-.15 G .214(cution resumes.).15 F .213 (When a function completes, the v)5.214 F .213 (alues of the positional parameters and the spe-)-.25 F(cial parameter) -108 484.8 Q F1(#)2.5 E F0(are restored to the v)2.5 E(alues the)-.25 E -2.5(yh)-.15 G(ad prior to the function')-2.5 E 2.5(se)-.55 G -.15(xe) --2.65 G(cution.).15 E 1.358 -(Function names and de\214nitions may be listed with the)108 501.6 R F1 +108 636 Q F1(#)2.5 E F0(are restored to the v)2.5 E(alues the)-.25 E 2.5 +(yh)-.15 G(ad prior to the function')-2.5 E 2.5(se)-.55 G -.15(xe)-2.65 +G(cution.).15 E 1.358 +(Function names and de\214nitions may be listed with the)108 652.8 R F1 3.858 E F0 1.358(option to the)3.858 F F1(declar)3.858 E(e)-.18 E F0(or)3.859 E F1(typeset)3.859 E F0 -.2(bu)3.859 G 1.359(iltin com-).2 F -3.39(mands. The)108 513.6 R F13.39 E F0 .89(option to)3.39 F F1 +3.39(mands. The)108 664.8 R F13.39 E F0 .89(option to)3.39 F F1 (declar)3.39 E(e)-.18 E F0(or)3.39 E F1(typeset)3.39 E F0 .89 (will list the function names only \(and optionally the source)3.39 F -.326(\214le and line number)108 525.6 R 2.826(,i)-.4 G 2.826(ft)-2.826 G +.326(\214le and line number)108 676.8 R 2.826(,i)-.4 G 2.826(ft)-2.826 G (he)-2.826 E F1(extdeb)2.826 E(ug)-.2 E F0 .326 (shell option is enabled\).)2.826 F .327(Functions may be e)5.327 F .327 -(xported so that subshells)-.15 F 1.298(automatically ha)108 537.6 R +(xported so that subshells)-.15 F 1.298(automatically ha)108 688.8 R 1.598 -.15(ve t)-.2 H 1.298(hem de\214ned with the).15 F F13.798 E F0 1.298(option to the)3.798 F F1(export)3.797 E F0 -.2(bu)3.797 G 3.797 (iltin. A).2 F 1.297(function de\214nition may be)3.797 F .16 -(deleted using the)108 549.6 R F12.66 E F0 .16(option to the)2.66 +(deleted using the)108 700.8 R F12.66 E F0 .16(option to the)2.66 F F1(unset)2.66 E F0 -.2(bu)2.66 G 2.661(iltin. Note).2 F .161 (that shell functions and v)2.661 F .161(ariables with the same name) -.25 F 1.325(may result in multiple identically-named entries in the en) -108 561.6 R 1.325(vironment passed to the shell')-.4 F 3.825(sc)-.55 G -3.825(hildren. Care)-3.825 F(should be tak)108 573.6 Q -(en in cases where this may cause a problem.)-.1 E .371 -(Functions may be recursi)108 590.4 R -.15(ve)-.25 G 5.371(.T).15 G(he) --5.371 E F1(FUNCNEST)2.871 E F0 -.25(va)2.871 G .371 -(riable may be used to limit the depth of the function call).25 F 1.141 -(stack and restrict the number of function in)108 602.4 R -.2(vo)-.4 G -3.641(cations. By).2 F(def)3.641 E 1.141 -(ault, no limit is imposed on the number of)-.1 F(recursi)108 614.4 Q .3 --.15(ve c)-.25 H(alls.).15 E F2(ARITHMETIC EV)72 631.2 Q(ALU)-1.478 E --1.04(AT)-.657 G(ION)1.04 E F0 2.297(The shell allo)108 643.2 R 2.297 -(ws arithmetic e)-.25 F 2.297(xpressions to be e)-.15 F -.25(va)-.25 G -2.297(luated, under certain circumstances \(see the).25 F F1(let)4.798 E -F0(and)4.798 E F1(declar)108 655.2 Q(e)-.18 E F0 -.2(bu)2.706 G .206 +108 712.8 R 1.325(vironment passed to the shell')-.4 F 3.825(sc)-.55 G +3.825(hildren. Care)-3.825 F(should be tak)108 724.8 Q +(en in cases where this may cause a problem.)-.1 E(GNU Bash 4.2)72 768 Q +(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(28)185.545 E 0 Cg EP +%%Page: 29 29 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E .371(Functions may be recursi)108 84 R -.15(ve)-.25 G 5.371(.T) +.15 G(he)-5.371 E/F1 10/Times-Bold@0 SF(FUNCNEST)2.871 E F0 -.25(va) +2.871 G .371(riable may be used to limit the depth of the function call) +.25 F 1.141(stack and restrict the number of function in)108 96 R -.2 +(vo)-.4 G 3.641(cations. By).2 F(def)3.641 E 1.141 +(ault, no limit is imposed on the number of)-.1 F(recursi)108 108 Q .3 +-.15(ve c)-.25 H(alls.).15 E/F2 10.95/Times-Bold@0 SF(ARITHMETIC EV)72 +124.8 Q(ALU)-1.478 E -1.04(AT)-.657 G(ION)1.04 E F0 2.297 +(The shell allo)108 136.8 R 2.297(ws arithmetic e)-.25 F 2.297 +(xpressions to be e)-.15 F -.25(va)-.25 G 2.297 +(luated, under certain circumstances \(see the).25 F F1(let)4.798 E F0 +(and)4.798 E F1(declar)108 148.8 Q(e)-.18 E F0 -.2(bu)2.706 G .206 (iltin commands and).2 F F1 .206(Arithmetic Expansion)2.706 F F0 2.705 (\). Ev)B .205(aluation is done in \214x)-.25 F .205(ed-width inte)-.15 -F .205(gers with no)-.15 F .428(check for o)108 667.2 R -.15(ve)-.15 G +F .205(gers with no)-.15 F .428(check for o)108 160.8 R -.15(ve)-.15 G (r\215o).15 E 1.728 -.65(w, t)-.25 H .428(hough di).65 F .428 (vision by 0 is trapped and \215agged as an error)-.25 F 5.429(.T)-.55 G .429(he operators and their prece-)-5.429 F 1.92(dence, associati)108 -679.2 R(vity)-.25 E 4.42(,a)-.65 G 1.92(nd v)-4.42 F 1.92 +172.8 R(vity)-.25 E 4.42(,a)-.65 G 1.92(nd v)-4.42 F 1.92 (alues are the same as in the C language.)-.25 F 1.919(The follo)6.919 F -1.919(wing list of operators is)-.25 F(grouped into le)108 691.2 Q -.15 +1.919(wing list of operators is)-.25 F(grouped into le)108 184.8 Q -.15 (ve)-.25 G(ls of equal-precedence operators.).15 E(The le)5 E -.15(ve) --.25 G(ls are listed in order of decreasing precedence.).15 E -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(28)198.165 E 0 Cg EP -%%Page: 29 29 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Italic@0 SF(id)108 84 Q/F2 10/Times-Bold@0 SF(++)A F1 -(id)2.5 E F2A F0 -.25(va)144 96 S -(riable post-increment and post-decrement).25 E F2(++)108 108 Q F1(id)A -F22.5 E F1(id)A F0 -.25(va)144 120 S -(riable pre-increment and pre-decrement).25 E F2 2.5108 132 S F0 -(unary minus and plus)19.6 E F2 2.5(!~)108 144 S F0 -(logical and bitwise ne)24.34 E -.05(ga)-.15 G(tion).05 E F2(**)108 156 -Q F0 -.15(ex)26 G(ponentiation).15 E F2 2.5(*/%)108 168 S F0 -(multiplication, di)10.72 E(vision, remainder)-.25 E F2 2.5<2bad>108 180 -S F0(addition, subtraction)19.6 E F2(<< >>)108 192 Q F0 -(left and right bitwise shifts)10.7 E F2(<= >= < >)108 204 Q F0 -(comparison)144 216 Q F2(== !=)108 228 Q F0(equality and inequality) -13.07 E F2(&)108 240 Q F0(bitwise AND)27.67 E F2(^)108 252 Q F0 -(bitwise e)32.67 E(xclusi)-.15 E .3 -.15(ve O)-.25 H(R).15 E F2(|)108 -264 Q F0(bitwise OR)33.8 E F2(&&)108 276 Q F0(logical AND)19.34 E F2(||) -108 288 Q F0(logical OR)31.6 E F1 -.2(ex)108 300 S(pr).2 E F2(?)A F1 -.2 -(ex)C(pr).2 E F2(:)A F1 -.2(ex)C(pr).2 E F0(conditional operator)144 312 -Q F2 2.5(=*)108 324 S 2.5(=/)-2.5 G 2.5(=%)-2.5 G 2.5(=+)-2.5 G 2.5 -<3dad>-2.5 G 2.5(=<)-2.5 G(<= >>= &= ^= |=)-2.5 E F0(assignment)144 336 -Q F1 -.2(ex)108 348 S(pr1).2 E F2(,)2.5 E F1 -.2(ex)2.5 G(pr2).2 E F0 -(comma)144 360 Q .68(Shell v)108 376.8 R .68(ariables are allo)-.25 F -.68(wed as operands; parameter e)-.25 F .68 +-.25 G(ls are listed in order of decreasing precedence.).15 E/F3 10 +/Times-Italic@0 SF(id)108 201.6 Q F1(++)A F3(id)2.5 E F1A F0 -.25 +(va)144 213.6 S(riable post-increment and post-decrement).25 E F1(++)108 +225.6 Q F3(id)A F12.5 E F3(id)A F0 -.25(va)144 237.6 S +(riable pre-increment and pre-decrement).25 E F1 2.5108 249.6 S F0 +(unary minus and plus)19.6 E F1 2.5(!~)108 261.6 S F0 +(logical and bitwise ne)24.34 E -.05(ga)-.15 G(tion).05 E F1(**)108 +273.6 Q F0 -.15(ex)26 G(ponentiation).15 E F1 2.5(*/%)108 285.6 S F0 +(multiplication, di)10.72 E(vision, remainder)-.25 E F1 2.5<2bad>108 +297.6 S F0(addition, subtraction)19.6 E F1(<< >>)108 309.6 Q F0 +(left and right bitwise shifts)10.7 E F1(<= >= < >)108 321.6 Q F0 +(comparison)144 333.6 Q F1(== !=)108 345.6 Q F0(equality and inequality) +13.07 E F1(&)108 357.6 Q F0(bitwise AND)27.67 E F1(^)108 369.6 Q F0 +(bitwise e)32.67 E(xclusi)-.15 E .3 -.15(ve O)-.25 H(R).15 E F1(|)108 +381.6 Q F0(bitwise OR)33.8 E F1(&&)108 393.6 Q F0(logical AND)19.34 E F1 +(||)108 405.6 Q F0(logical OR)31.6 E F3 -.2(ex)108 417.6 S(pr).2 E F1(?) +A F3 -.2(ex)C(pr).2 E F1(:)A F3 -.2(ex)C(pr).2 E F0 +(conditional operator)144 429.6 Q F1 2.5(=*)108 441.6 S 2.5(=/)-2.5 G +2.5(=%)-2.5 G 2.5(=+)-2.5 G 2.5<3dad>-2.5 G 2.5(=<)-2.5 G +(<= >>= &= ^= |=)-2.5 E F0(assignment)144 453.6 Q F3 -.2(ex)108 465.6 S +(pr1).2 E F1(,)2.5 E F3 -.2(ex)2.5 G(pr2).2 E F0(comma)144 477.6 Q .68 +(Shell v)108 494.4 R .68(ariables are allo)-.25 F .68 +(wed as operands; parameter e)-.25 F .68 (xpansion is performed before the e)-.15 F .68(xpression is e)-.15 F --.25(va)-.25 G(lu-).25 E 3.508(ated. W)108 388.8 R 1.008(ithin an e)-.4 +-.25(va)-.25 G(lu-).25 E 3.508(ated. W)108 506.4 R 1.008(ithin an e)-.4 F 1.008(xpression, shell v)-.15 F 1.007 (ariables may also be referenced by name without using the parameter) --.25 F -.15(ex)108 400.8 S 1.04(pansion syntax.).15 F 3.54(As)6.04 G +-.25 F -.15(ex)108 518.4 S 1.04(pansion syntax.).15 F 3.54(As)6.04 G 1.04(hell v)-3.54 F 1.04(ariable that is null or unset e)-.25 F -.25(va) -.25 G 1.041(luates to 0 when referenced by name without).25 F 1.467 -(using the parameter e)108 412.8 R 1.467(xpansion syntax.)-.15 F 1.467 +(using the parameter e)108 530.4 R 1.467(xpansion syntax.)-.15 F 1.467 (The v)6.467 F 1.467(alue of a v)-.25 F 1.467(ariable is e)-.25 F -.25 (va)-.25 G 1.466(luated as an arithmetic e).25 F(xpression)-.15 E 1.389 -(when it is referenced, or when a v)108 424.8 R 1.389 +(when it is referenced, or when a v)108 542.4 R 1.389 (ariable which has been gi)-.25 F -.15(ve)-.25 G 3.89(nt).15 G(he)-3.89 -E F1(inte)3.89 E -.1(ge)-.4 G(r).1 E F0(attrib)3.89 E 1.39(ute using)-.2 -F F2(declar)3.89 E 3.89(e-)-.18 G(i)-3.89 E F0(is)3.89 E .333 -(assigned a v)108 436.8 R 2.832(alue. A)-.25 F .332(null v)2.832 F .332 +E F3(inte)3.89 E -.1(ge)-.4 G(r).1 E F0(attrib)3.89 E 1.39(ute using)-.2 +F F1(declar)3.89 E 3.89(e-)-.18 G(i)-3.89 E F0(is)3.89 E .333 +(assigned a v)108 554.4 R 2.832(alue. A)-.25 F .332(null v)2.832 F .332 (alue e)-.25 F -.25(va)-.25 G .332(luates to 0.).25 F 2.832(As)5.332 G .332(hell v)-2.832 F .332(ariable need not ha)-.25 F .632 -.15(ve i)-.2 -H(ts).15 E F1(inte)2.832 E -.1(ge)-.4 G(r).1 E F0(attrib)2.832 E .332 -(ute turned on)-.2 F(to be used in an e)108 448.8 Q(xpression.)-.15 E +H(ts).15 E F3(inte)2.832 E -.1(ge)-.4 G(r).1 E F0(attrib)2.832 E .332 +(ute turned on)-.2 F(to be used in an e)108 566.4 Q(xpression.)-.15 E 1.406(Constants with a leading 0 are interpreted as octal numbers.)108 -465.6 R 3.906(Al)6.406 G 1.407(eading 0x or 0X denotes he)-3.906 F -(xadecimal.)-.15 E .113(Otherwise, numbers tak)108 477.6 R 2.613(et)-.1 -G .113(he form [)-2.613 F F1(base#)A F0 .112(]n, where the optional)B F1 +583.2 R 3.906(Al)6.406 G 1.407(eading 0x or 0X denotes he)-3.906 F +(xadecimal.)-.15 E .113(Otherwise, numbers tak)108 595.2 R 2.613(et)-.1 +G .113(he form [)-2.613 F F3(base#)A F0 .112(]n, where the optional)B F3 (base)2.612 E F0 .112(is a decimal number between 2 and 64)2.612 F .533 -(representing the arithmetic base, and)108 489.6 R F1(n)3.033 E F0 .533 -(is a number in that base.)3.033 F(If)5.534 E F1(base#)3.034 E F0 .534 -(is omitted, then base 10 is used.)3.034 F .16(When specifying)108 501.6 -R F1(n)2.66 E F0 2.66(,t)C .16 +(representing the arithmetic base, and)108 607.2 R F3(n)3.033 E F0 .533 +(is a number in that base.)3.033 F(If)5.534 E F3(base#)3.034 E F0 .534 +(is omitted, then base 10 is used.)3.034 F .16(When specifying)108 619.2 +R F3(n)2.66 E F0 2.66(,t)C .16 (he digits greater< than 9 are represented by the lo)-2.66 F .16 (wercase letters, the uppercase letters,)-.25 F .942 -(@, and _, in that order)108 513.6 R 5.942(.I)-.55 G(f)-5.942 E F1(base) +(@, and _, in that order)108 631.2 R 5.942(.I)-.55 G(f)-5.942 E F3(base) 3.442 E F0 .942(is less than or equal to 36, lo)3.442 F .943 (wercase and uppercase letters may be used)-.25 F -(interchangeably to represent numbers between 10 and 35.)108 525.6 Q -.235(Operators are e)108 542.4 R -.25(va)-.25 G .235 +(interchangeably to represent numbers between 10 and 35.)108 643.2 Q +.235(Operators are e)108 660 R -.25(va)-.25 G .235 (luated in order of precedence.).25 F(Sub-e)5.234 E .234 (xpressions in parentheses are e)-.15 F -.25(va)-.25 G .234 -(luated \214rst and may).25 F -.15(ove)108 554.4 S -(rride the precedence rules abo).15 E -.15(ve)-.15 G(.).15 E/F3 10.95 -/Times-Bold@0 SF(CONDITION)72 571.2 Q(AL EXPRESSIONS)-.219 E F0 .255 -(Conditional e)108 583.2 R .255(xpressions are used by the)-.15 F F2([[) -2.755 E F0 .255(compound command and the)2.755 F F2(test)2.755 E F0(and) -2.755 E F2([)2.756 E F0 -.2(bu)2.756 G .256(iltin commands to test).2 F -.77(\214le attrib)108 595.2 R .77 +(luated \214rst and may).25 F -.15(ove)108 672 S +(rride the precedence rules abo).15 E -.15(ve)-.15 G(.).15 E F2 +(CONDITION)72 688.8 Q(AL EXPRESSIONS)-.219 E F0 .255(Conditional e)108 +700.8 R .255(xpressions are used by the)-.15 F F1([[)2.755 E F0 .255 +(compound command and the)2.755 F F1(test)2.755 E F0(and)2.755 E F1([) +2.756 E F0 -.2(bu)2.756 G .256(iltin commands to test).2 F .77 +(\214le attrib)108 712.8 R .77 (utes and perform string and arithmetic comparisons.)-.2 F .77 (Expressions are formed from the follo)5.77 F(wing)-.25 E 1.04 -(unary or binary primaries.)108 607.2 R 1.04(If an)6.04 F(y)-.15 E F1 +(unary or binary primaries.)108 724.8 R 1.04(If an)6.04 F(y)-.15 E F3 (\214le)3.54 E F0(ar)3.54 E 1.041 -(gument to one of the primaries is of the form)-.18 F F1(/de)3.541 E -(v/fd/n)-.15 E F0 3.541(,t)C 1.041(hen \214le)-3.541 F(descriptor)108 -619.2 Q F1(n)3.789 E F0 1.289(is check)3.789 F 3.789(ed. If)-.1 F(the) -3.789 E F1(\214le)3.789 E F0(ar)3.789 E 1.289 -(gument to one of the primaries is one of)-.18 F F1(/de)3.789 E(v/stdin) --.15 E F0(,)A F1(/de)3.788 E(v/stdout)-.15 E F0 3.788(,o)C(r)-3.788 E F1 -(/de)108 631.2 Q(v/stderr)-.15 E F0 2.5<2c8c>C -(le descriptor 0, 1, or 2, respecti)-2.5 E -.15(ve)-.25 G(ly).15 E 2.5 -(,i)-.65 G 2.5(sc)-2.5 G(heck)-2.5 E(ed.)-.1 E .721 -(Unless otherwise speci\214ed, primaries that operate on \214les follo) -108 648 R 3.221(ws)-.25 G .722(ymbolic links and operate on the tar) --3.221 F(get)-.18 E(of the link, rather than the link itself.)108 660 Q -1.096(When used with)108 678 R F2([[)3.596 E F0 3.596(,t)C(he)-3.596 E -F2(<)3.596 E F0(and)3.595 E F2(>)3.595 E F0 1.095(operators sort le) -3.595 F 1.095(xicographically using the current locale.)-.15 F(The)6.095 -E F2(test)3.595 E F0(com-)3.595 E(mand sorts using ASCII ordering.)108 -690 Q F2108 714 Q F1(\214le)2.5 E F0 -.35(Tr)10.58 G(ue if).35 E -F1(\214le)2.5 E F0 -.15(ex)2.5 G(ists.).15 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(29)198.165 E 0 Cg EP +(gument to one of the primaries is of the form)-.18 F F3(/de)3.541 E +(v/fd/n)-.15 E F0 3.541(,t)C 1.041(hen \214le)-3.541 F(GNU Bash 4.2)72 +768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(29)185.545 E 0 Cg +EP %%Page: 30 30 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF108 84 Q/F2 10/Times-Italic@0 SF -(\214le)2.5 E F0 -.35(Tr)10.02 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex) -2.5 G(ists and is a block special \214le.).15 E F1108 96 Q F2 -(\214le)2.5 E F0 -.35(Tr)11.14 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex) -2.5 G(ists and is a character special \214le.).15 E F1108 108 Q F2 -(\214le)2.5 E F0 -.35(Tr)10.02 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex) -2.5 G(ists and is a directory).15 E(.)-.65 E F1108 120 Q F2 -(\214le)2.5 E F0 -.35(Tr)11.14 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex) -2.5 G(ists.).15 E F1108 132 Q F2(\214le)2.5 E F0 -.35(Tr)12.25 G -(ue if).35 E F2(\214le)2.5 E F0 -.15(ex)2.5 G(ists and is a re).15 E -(gular \214le.)-.15 E F1108 144 Q F2(\214le)2.5 E F0 -.35(Tr)10.58 -G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex)2.5 G -(ists and is set-group-id.).15 E F1108 156 Q F2(\214le)2.5 E F0 --.35(Tr)10.02 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex)2.5 G -(ists and is a symbolic link.).15 E F1108 168 Q F2(\214le)2.5 E F0 --.35(Tr)10.02 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex)2.5 G +-.35 E(descriptor)108 84 Q/F1 10/Times-Italic@0 SF(n)3.789 E F0 1.289 +(is check)3.789 F 3.789(ed. If)-.1 F(the)3.789 E F1(\214le)3.789 E F0 +(ar)3.789 E 1.289(gument to one of the primaries is one of)-.18 F F1 +(/de)3.789 E(v/stdin)-.15 E F0(,)A F1(/de)3.788 E(v/stdout)-.15 E F0 +3.788(,o)C(r)-3.788 E F1(/de)108 96 Q(v/stderr)-.15 E F0 2.5<2c8c>C +(le descriptor 0, 1, or 2, respecti)-2.5 E -.15(ve)-.25 G(ly).15 E 2.5 +(,i)-.65 G 2.5(sc)-2.5 G(heck)-2.5 E(ed.)-.1 E .721 +(Unless otherwise speci\214ed, primaries that operate on \214les follo) +108 112.8 R 3.221(ws)-.25 G .722(ymbolic links and operate on the tar) +-3.221 F(get)-.18 E(of the link, rather than the link itself.)108 124.8 +Q 1.096(When used with)108 142.8 R/F2 10/Times-Bold@0 SF([[)3.596 E F0 +3.596(,t)C(he)-3.596 E F2(<)3.596 E F0(and)3.595 E F2(>)3.595 E F0 1.095 +(operators sort le)3.595 F 1.095 +(xicographically using the current locale.)-.15 F(The)6.095 E F2(test) +3.595 E F0(com-)3.595 E(mand sorts using ASCII ordering.)108 154.8 Q F2 +108 178.8 Q F1(\214le)2.5 E F0 -.35(Tr)10.58 G(ue if).35 E F1 +(\214le)2.5 E F0 -.15(ex)2.5 G(ists.).15 E F2108 190.8 Q F1 +(\214le)2.5 E F0 -.35(Tr)10.02 G(ue if).35 E F1(\214le)2.5 E F0 -.15(ex) +2.5 G(ists and is a block special \214le.).15 E F2108 202.8 Q F1 +(\214le)2.5 E F0 -.35(Tr)11.14 G(ue if).35 E F1(\214le)2.5 E F0 -.15(ex) +2.5 G(ists and is a character special \214le.).15 E F2108 214.8 Q +F1(\214le)2.5 E F0 -.35(Tr)10.02 G(ue if).35 E F1(\214le)2.5 E F0 -.15 +(ex)2.5 G(ists and is a directory).15 E(.)-.65 E F2108 226.8 Q F1 +(\214le)2.5 E F0 -.35(Tr)11.14 G(ue if).35 E F1(\214le)2.5 E F0 -.15(ex) +2.5 G(ists.).15 E F2108 238.8 Q F1(\214le)2.5 E F0 -.35(Tr)12.25 G +(ue if).35 E F1(\214le)2.5 E F0 -.15(ex)2.5 G(ists and is a re).15 E +(gular \214le.)-.15 E F2108 250.8 Q F1(\214le)2.5 E F0 -.35(Tr) +10.58 G(ue if).35 E F1(\214le)2.5 E F0 -.15(ex)2.5 G +(ists and is set-group-id.).15 E F2108 262.8 Q F1(\214le)2.5 E F0 +-.35(Tr)10.02 G(ue if).35 E F1(\214le)2.5 E F0 -.15(ex)2.5 G +(ists and is a symbolic link.).15 E F2108 274.8 Q F1(\214le)2.5 E +F0 -.35(Tr)10.02 G(ue if).35 E F1(\214le)2.5 E F0 -.15(ex)2.5 G (ists and its `).15 E(`stick)-.74 E(y')-.15 E 2.5('b)-.74 G(it is set.) --2.5 E F1108 180 Q F2(\214le)2.5 E F0 -.35(Tr)10.02 G(ue if).35 E -F2(\214le)2.5 E F0 -.15(ex)2.5 G(ists and is a named pipe \(FIFO\).).15 -E F1108 192 Q F2(\214le)2.5 E F0 -.35(Tr)11.14 G(ue if).35 E F2 -(\214le)2.5 E F0 -.15(ex)2.5 G(ists and is readable.).15 E F1108 -204 Q F2(\214le)2.5 E F0 -.35(Tr)11.69 G(ue if).35 E F2(\214le)2.5 E F0 --.15(ex)2.5 G(ists and has a size greater than zero.).15 E F1108 -216 Q F2(fd)2.5 E F0 -.35(Tr)16.69 G(ue if \214le descriptor).35 E F2 -(fd)4.47 E F0(is open and refers to a terminal.)3.27 E F1108 228 Q -F2(\214le)2.5 E F0 -.35(Tr)10.02 G(ue if).35 E F2(\214le)2.5 E F0 -.15 -(ex)2.5 G(ists and its set-user).15 E(-id bit is set.)-.2 E F1108 -240 Q F2(\214le)2.5 E F0 -.35(Tr)8.36 G(ue if).35 E F2(\214le)2.5 E F0 --.15(ex)2.5 G(ists and is writable.).15 E F1108 252 Q F2(\214le) -2.5 E F0 -.35(Tr)10.58 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex)2.5 G -(ists and is e).15 E -.15(xe)-.15 G(cutable.).15 E F1108 264 Q F2 -(\214le)2.5 E F0 -.35(Tr)7.8 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex) -2.5 G(ists and is o).15 E(wned by the ef)-.25 E(fecti)-.25 E .3 -.15 -(ve g)-.25 H(roup id.).15 E F1108 276 Q F2(\214le)2.5 E F0 -.35 -(Tr)8.91 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex)2.5 G -(ists and is a symbolic link.).15 E F1108 288 Q F2(\214le)2.5 E F0 --.35(Tr)8.36 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex)2.5 G -(ists and has been modi\214ed since it w).15 E(as last read.)-.1 E F1 -108 300 Q F2(\214le)2.5 E F0 -.35(Tr)7.8 G(ue if).35 E F2(\214le) -2.5 E F0 -.15(ex)2.5 G(ists and is o).15 E(wned by the ef)-.25 E(fecti) --.25 E .3 -.15(ve u)-.25 H(ser id.).15 E F1108 312 Q F2(\214le)2.5 -E F0 -.35(Tr)10.02 G(ue if).35 E F2(\214le)2.5 E F0 -.15(ex)2.5 G -(ists and is a sock).15 E(et.)-.1 E F2(\214le1)108 324 Q F1(\255ef)2.5 E -F2(\214le2)2.5 E F0 -.35(Tr)144 336 S(ue if).35 E F2(\214le1)2.5 E F0 -(and)2.5 E F2(\214le2)2.5 E F0(refer to the same de)2.5 E -(vice and inode numbers.)-.25 E F2(\214le1)108 348 Q F02.5 E F1(nt)A -F2(\214le2)2.5 E F0 -.35(Tr)144 360 S .038(ue if).35 F F2(\214le1)2.538 -E F0 .039(is ne)2.539 F .039 -(wer \(according to modi\214cation date\) than)-.25 F F2(\214le2)2.539 E -F0 2.539(,o)C 2.539(ri)-2.539 G(f)-2.539 E F2(\214le1)2.539 E F0 -.15 -(ex)2.539 G .039(ists and).15 F F2(\214le2)2.539 E F0 .039(does not.) -2.539 F F2(\214le1)108 372 Q F02.5 E F1(ot)A F2(\214le2)2.5 E F0 --.35(Tr)144 384 S(ue if).35 E F2(\214le1)2.5 E F0(is older than)2.5 E F2 -(\214le2)2.5 E F0 2.5(,o)C 2.5(ri)-2.5 G(f)-2.5 E F2(\214le2)2.5 E F0 --.15(ex)2.5 G(ists and).15 E F2(\214le1)2.5 E F0(does not.)2.5 E F1 -108 396 Q F2(optname)2.5 E F0 -.35(Tr)144 408 S .263 -(ue if the shell option).35 F F2(optname)2.992 E F0 .262(is enabled.) +-2.5 E F2108 286.8 Q F1(\214le)2.5 E F0 -.35(Tr)10.02 G(ue if).35 +E F1(\214le)2.5 E F0 -.15(ex)2.5 G(ists and is a named pipe \(FIFO\).) +.15 E F2108 298.8 Q F1(\214le)2.5 E F0 -.35(Tr)11.14 G(ue if).35 E +F1(\214le)2.5 E F0 -.15(ex)2.5 G(ists and is readable.).15 E F2108 +310.8 Q F1(\214le)2.5 E F0 -.35(Tr)11.69 G(ue if).35 E F1(\214le)2.5 E +F0 -.15(ex)2.5 G(ists and has a size greater than zero.).15 E F2 +108 322.8 Q F1(fd)2.5 E F0 -.35(Tr)16.69 G(ue if \214le descriptor).35 E +F1(fd)4.47 E F0(is open and refers to a terminal.)3.27 E F2108 +334.8 Q F1(\214le)2.5 E F0 -.35(Tr)10.02 G(ue if).35 E F1(\214le)2.5 E +F0 -.15(ex)2.5 G(ists and its set-user).15 E(-id bit is set.)-.2 E F2 +108 346.8 Q F1(\214le)2.5 E F0 -.35(Tr)8.36 G(ue if).35 E F1 +(\214le)2.5 E F0 -.15(ex)2.5 G(ists and is writable.).15 E F2108 +358.8 Q F1(\214le)2.5 E F0 -.35(Tr)10.58 G(ue if).35 E F1(\214le)2.5 E +F0 -.15(ex)2.5 G(ists and is e).15 E -.15(xe)-.15 G(cutable.).15 E F2 +108 370.8 Q F1(\214le)2.5 E F0 -.35(Tr)7.8 G(ue if).35 E F1 +(\214le)2.5 E F0 -.15(ex)2.5 G(ists and is o).15 E(wned by the ef)-.25 E +(fecti)-.25 E .3 -.15(ve g)-.25 H(roup id.).15 E F2108 382.8 Q F1 +(\214le)2.5 E F0 -.35(Tr)8.91 G(ue if).35 E F1(\214le)2.5 E F0 -.15(ex) +2.5 G(ists and is a symbolic link.).15 E F2108 394.8 Q F1(\214le) +2.5 E F0 -.35(Tr)8.36 G(ue if).35 E F1(\214le)2.5 E F0 -.15(ex)2.5 G +(ists and has been modi\214ed since it w).15 E(as last read.)-.1 E F2 +108 406.8 Q F1(\214le)2.5 E F0 -.35(Tr)7.8 G(ue if).35 E F1 +(\214le)2.5 E F0 -.15(ex)2.5 G(ists and is o).15 E(wned by the ef)-.25 E +(fecti)-.25 E .3 -.15(ve u)-.25 H(ser id.).15 E F2108 418.8 Q F1 +(\214le)2.5 E F0 -.35(Tr)10.02 G(ue if).35 E F1(\214le)2.5 E F0 -.15(ex) +2.5 G(ists and is a sock).15 E(et.)-.1 E F1(\214le1)108 430.8 Q F2 +(\255ef)2.5 E F1(\214le2)2.5 E F0 -.35(Tr)144 442.8 S(ue if).35 E F1 +(\214le1)2.5 E F0(and)2.5 E F1(\214le2)2.5 E F0(refer to the same de)2.5 +E(vice and inode numbers.)-.25 E F1(\214le1)108 454.8 Q F02.5 E F2 +(nt)A F1(\214le2)2.5 E F0 -.35(Tr)144 466.8 S .038(ue if).35 F F1 +(\214le1)2.538 E F0 .039(is ne)2.539 F .039 +(wer \(according to modi\214cation date\) than)-.25 F F1(\214le2)2.539 E +F0 2.539(,o)C 2.539(ri)-2.539 G(f)-2.539 E F1(\214le1)2.539 E F0 -.15 +(ex)2.539 G .039(ists and).15 F F1(\214le2)2.539 E F0 .039(does not.) +2.539 F F1(\214le1)108 478.8 Q F02.5 E F2(ot)A F1(\214le2)2.5 E F0 +-.35(Tr)144 490.8 S(ue if).35 E F1(\214le1)2.5 E F0(is older than)2.5 E +F1(\214le2)2.5 E F0 2.5(,o)C 2.5(ri)-2.5 G(f)-2.5 E F1(\214le2)2.5 E F0 +-.15(ex)2.5 G(ists and).15 E F1(\214le1)2.5 E F0(does not.)2.5 E F2 +108 502.8 Q F1(optname)2.5 E F0 -.35(Tr)144 514.8 S .263 +(ue if the shell option).35 F F1(optname)2.992 E F0 .262(is enabled.) 2.942 F .262(See the list of options under the description of the)5.262 -F F12.762 E F0(option to the)144 420 Q F1(set)2.5 E F0 -.2(bu)2.5 -G(iltin belo).2 E -.65(w.)-.25 G F1108 432 Q F2(varname)2.5 E F0 --.35(Tr)144 444 S(ue if the shell v).35 E(ariable)-.25 E F2(varname)2.79 -E F0(is set \(has been assigned a v)2.68 E(alue\).)-.25 E F1108 -456 Q F2(string)2.5 E F0 -.35(Tr)144 468 S(ue if the length of).35 E F2 -(string)2.5 E F0(is zero.)2.5 E F2(string)108 480 Q F1108 492 Q F2 -(string)2.5 E F0 -.35(Tr)144 504 S(ue if the length of).35 E F2(string) -2.84 E F0(is non-zero.)2.72 E F2(string1)108 520.8 Q F1(==)2.5 E F2 -(string2)2.5 E(string1)108 532.8 Q F1(=)2.5 E F2(string2)2.5 E F0 -.35 -(Tr)144 544.8 S(ue if the strings are equal.).35 E F1(=)5 E F0 -(should be used with the)2.5 E F1(test)2.5 E F0 -(command for POSIX conformance.)2.5 E F2(string1)108 561.6 Q F1(!=)2.5 E -F2(string2)2.5 E F0 -.35(Tr)144 573.6 S -(ue if the strings are not equal.).35 E F2(string1)108 590.4 Q F1(<)2.5 -E F2(string2)2.5 E F0 -.35(Tr)144 602.4 S(ue if).35 E F2(string1)2.5 E -F0(sorts before)2.5 E F2(string2)2.5 E F0(le)2.5 E(xicographically)-.15 -E(.)-.65 E F2(string1)108 619.2 Q F1(>)2.5 E F2(string2)2.5 E F0 -.35 -(Tr)144 631.2 S(ue if).35 E F2(string1)2.5 E F0(sorts after)2.5 E F2 -(string2)2.5 E F0(le)2.5 E(xicographically)-.15 E(.)-.65 E F2(ar)108.33 -648 Q(g1)-.37 E F1(OP)2.5 E F2(ar)2.5 E(g2)-.37 E/F3 9/Times-Bold@0 SF -(OP)144 660 Q F0 .385(is one of)2.634 F F1(\255eq)2.885 E F0(,)A F1 -(\255ne)2.885 E F0(,)A F1(\255lt)2.885 E F0(,)A F1(\255le)2.885 E F0(,)A -F1(\255gt)2.885 E F0 2.885(,o)C(r)-2.885 E F1(\255ge)2.885 E F0 5.385 -(.T)C .385(hese arithmetic binary operators return true if)-5.385 F F2 -(ar)2.885 E(g1)-.37 E F0 .845(is equal to, not equal to, less than, les\ -s than or equal to, greater than, or greater than or equal to)144 672 R -F2(ar)144 684 Q(g2)-.37 E F0 2.5(,r)C(especti)-2.5 E -.15(ve)-.25 G(ly) -.15 E(.)-.65 E F2(Ar)6.01 E(g1)-.37 E F0(and)2.5 E F2(ar)2.83 E(g2)-.37 -E F0(may be positi)2.52 E .3 -.15(ve o)-.25 H 2.5(rn).15 G -2.25 -.15 -(eg a)-2.5 H(ti).15 E .3 -.15(ve i)-.25 H(nte).15 E(gers.)-.15 E/F4 -10.95/Times-Bold@0 SF(SIMPLE COMMAND EXP)72 700.8 Q(ANSION)-.81 E F0 -.613(When a simple command is e)108 712.8 R -.15(xe)-.15 G .614 -(cuted, the shell performs the follo).15 F .614(wing e)-.25 F .614 -(xpansions, assignments, and redi-)-.15 F(rections, from left to right.) -108 724.8 Q(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(30)198.165 E 0 -Cg EP +F F22.762 E F0(option to the)144 526.8 Q F2(set)2.5 E F0 -.2(bu) +2.5 G(iltin belo).2 E -.65(w.)-.25 G F2108 538.8 Q F1(varname)2.5 +E F0 -.35(Tr)144 550.8 S(ue if the shell v).35 E(ariable)-.25 E F1 +(varname)2.79 E F0(is set \(has been assigned a v)2.68 E(alue\).)-.25 E +F2108 562.8 Q F1(varname)2.5 E F0 -.35(Tr)144 574.8 S +(ue if the shell v).35 E(ariable)-.25 E F1(varname)2.79 E F0 +(is set and is a name reference.)2.68 E F2108 586.8 Q F1(string) +2.5 E F0 -.35(Tr)144 598.8 S(ue if the length of).35 E F1(string)2.5 E +F0(is zero.)2.5 E F1(string)108 610.8 Q F2108 622.8 Q F1(string) +2.5 E F0 -.35(Tr)144 634.8 S(ue if the length of).35 E F1(string)2.84 E +F0(is non-zero.)2.72 E F1(string1)108 651.6 Q F2(==)2.5 E F1(string2)2.5 +E(string1)108 663.6 Q F2(=)2.5 E F1(string2)2.5 E F0 -.35(Tr)144 675.6 S +.861(ue if the strings are equal.).35 F F2(=)5.861 E F0 .861 +(should be used with the)3.361 F F2(test)3.361 E F0 .862 +(command for POSIX conformance.)3.362 F .447(When used with the)144 +687.6 R F2([[)2.946 E F0 .446 +(command, this performs pattern matching as described abo)2.946 F .746 +-.15(ve \()-.15 H F2(Compound).15 E(Commands)144 699.6 Q F0(\).)A +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(30)185.545 E 0 Cg EP %%Page: 31 31 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E 26(1. The)108 84 R -.1(wo)4.349 G 1.849 +-.35 E/F1 10/Times-Italic@0 SF(string1)108 84 Q/F2 10/Times-Bold@0 SF +(!=)2.5 E F1(string2)2.5 E F0 -.35(Tr)144 96 S +(ue if the strings are not equal.).35 E F1(string1)108 112.8 Q F2(<)2.5 +E F1(string2)2.5 E F0 -.35(Tr)144 124.8 S(ue if).35 E F1(string1)2.5 E +F0(sorts before)2.5 E F1(string2)2.5 E F0(le)2.5 E(xicographically)-.15 +E(.)-.65 E F1(string1)108 141.6 Q F2(>)2.5 E F1(string2)2.5 E F0 -.35 +(Tr)144 153.6 S(ue if).35 E F1(string1)2.5 E F0(sorts after)2.5 E F1 +(string2)2.5 E F0(le)2.5 E(xicographically)-.15 E(.)-.65 E F1(ar)108.33 +170.4 Q(g1)-.37 E F2(OP)2.5 E F1(ar)2.5 E(g2)-.37 E/F3 9/Times-Bold@0 SF +(OP)144 182.4 Q F0 .385(is one of)2.634 F F2(\255eq)2.885 E F0(,)A F2 +(\255ne)2.885 E F0(,)A F2(\255lt)2.885 E F0(,)A F2(\255le)2.885 E F0(,)A +F2(\255gt)2.885 E F0 2.885(,o)C(r)-2.885 E F2(\255ge)2.885 E F0 5.385 +(.T)C .385(hese arithmetic binary operators return true if)-5.385 F F1 +(ar)2.885 E(g1)-.37 E F0 .845(is equal to, not equal to, less than, les\ +s than or equal to, greater than, or greater than or equal to)144 194.4 +R F1(ar)144 206.4 Q(g2)-.37 E F0 2.5(,r)C(especti)-2.5 E -.15(ve)-.25 G +(ly).15 E(.)-.65 E F1(Ar)6.01 E(g1)-.37 E F0(and)2.5 E F1(ar)2.83 E(g2) +-.37 E F0(may be positi)2.52 E .3 -.15(ve o)-.25 H 2.5(rn).15 G -2.25 +-.15(eg a)-2.5 H(ti).15 E .3 -.15(ve i)-.25 H(nte).15 E(gers.)-.15 E/F4 +10.95/Times-Bold@0 SF(SIMPLE COMMAND EXP)72 223.2 Q(ANSION)-.81 E F0 +.613(When a simple command is e)108 235.2 R -.15(xe)-.15 G .614 +(cuted, the shell performs the follo).15 F .614(wing e)-.25 F .614 +(xpansions, assignments, and redi-)-.15 F(rections, from left to right.) +108 247.2 Q 26(1. The)108 264 R -.1(wo)4.349 G 1.849 (rds that the parser has mark).1 F 1.848(ed as v)-.1 F 1.848 (ariable assignments \(those preceding the command)-.25 F -(name\) and redirections are sa)144 96 Q -.15(ve)-.2 G 2.5(df).15 G -(or later processing.)-2.5 E 26(2. The)108 112.8 R -.1(wo)3.663 G 1.163 +(name\) and redirections are sa)144 276 Q -.15(ve)-.2 G 2.5(df).15 G +(or later processing.)-2.5 E 26(2. The)108 292.8 R -.1(wo)3.663 G 1.163 (rds that are not v).1 F 1.164 (ariable assignments or redirections are e)-.25 F 3.664(xpanded. If)-.15 F(an)3.664 E 3.664(yw)-.15 G 1.164(ords remain)-3.764 F .776(after e)144 -124.8 R .776(xpansion, the \214rst w)-.15 F .776(ord is tak)-.1 F .775 +304.8 R .776(xpansion, the \214rst w)-.15 F .776(ord is tak)-.1 F .775 (en to be the name of the command and the remaining w)-.1 F(ords)-.1 E -(are the ar)144 136.8 Q(guments.)-.18 E 26(3. Redirections)108 153.6 R -(are performed as described abo)2.5 E .3 -.15(ve u)-.15 H(nder).15 E/F1 -9/Times-Bold@0 SF(REDIRECTION)2.5 E/F2 9/Times-Roman@0 SF(.)A F0 26 -(4. The)108 170.4 R(te)3.216 E .717(xt after the)-.15 F/F3 10 -/Times-Bold@0 SF(=)3.217 E F0 .717(in each v)3.217 F .717 -(ariable assignment under)-.25 F .717(goes tilde e)-.18 F .717 -(xpansion, parameter e)-.15 F(xpansion,)-.15 E .34 -(command substitution, arithmetic e)144 182.4 R .339 +(are the ar)144 316.8 Q(guments.)-.18 E 26(3. Redirections)108 333.6 R +(are performed as described abo)2.5 E .3 -.15(ve u)-.15 H(nder).15 E F3 +(REDIRECTION)2.5 E/F5 9/Times-Roman@0 SF(.)A F0 26(4. The)108 350.4 R +(te)3.216 E .717(xt after the)-.15 F F2(=)3.217 E F0 .717(in each v) +3.217 F .717(ariable assignment under)-.25 F .717(goes tilde e)-.18 F +.717(xpansion, parameter e)-.15 F(xpansion,)-.15 E .34 +(command substitution, arithmetic e)144 362.4 R .339 (xpansion, and quote remo)-.15 F -.25(va)-.15 G 2.839(lb).25 G .339 -(efore being assigned to the v)-2.839 F(ari-)-.25 E(able.)144 194.4 Q -.332(If no command name results, the v)108 211.2 R .332 +(efore being assigned to the v)-2.839 F(ari-)-.25 E(able.)144 374.4 Q +.332(If no command name results, the v)108 391.2 R .332 (ariable assignments af)-.25 F .332(fect the current shell en)-.25 F -2.833(vironment. Otherwise,)-.4 F(the)2.833 E -.25(va)108 223.2 S .757 +2.833(vironment. Otherwise,)-.4 F(the)2.833 E -.25(va)108 403.2 S .757 (riables are added to the en).25 F .757(vironment of the e)-.4 F -.15 (xe)-.15 G .757(cuted command and do not af).15 F .757 -(fect the current shell en)-.25 F(vi-)-.4 E 3.176(ronment. If)108 235.2 +(fect the current shell en)-.25 F(vi-)-.4 E 3.176(ronment. If)108 415.2 R(an)3.176 E 3.176(yo)-.15 G 3.176(ft)-3.176 G .677 (he assignments attempts to assign a v)-3.176 F .677 (alue to a readonly v)-.25 F .677(ariable, an error occurs, and)-.25 F -(the command e)108 247.2 Q(xits with a non-zero status.)-.15 E .15 -(If no command name results, redirections are performed, b)108 264 R +(the command e)108 427.2 Q(xits with a non-zero status.)-.15 E .15 +(If no command name results, redirections are performed, b)108 444 R .149(ut do not af)-.2 F .149(fect the current shell en)-.25 F 2.649 -(vironment. A)-.4 F(redirection error causes the command to e)108 276 Q +(vironment. A)-.4 F(redirection error causes the command to e)108 456 Q (xit with a non-zero status.)-.15 E 1.064 -(If there is a command name left after e)108 292.8 R 1.064(xpansion, e) +(If there is a command name left after e)108 472.8 R 1.064(xpansion, e) -.15 F -.15(xe)-.15 G 1.064(cution proceeds as described belo).15 F 4.864 -.65(w. O)-.25 H 1.064(therwise, the).65 F .069(command e)108 -304.8 R 2.569(xits. If)-.15 F .069(one of the e)2.569 F .069 +484.8 R 2.569(xits. If)-.15 F .069(one of the e)2.569 F .069 (xpansions contained a command substitution, the e)-.15 F .068 -(xit status of the command)-.15 F .466(is the e)108 316.8 R .466 +(xit status of the command)-.15 F .466(is the e)108 496.8 R .466 (xit status of the last command substitution performed.)-.15 F .467 -(If there were no command substitutions, the)5.466 F(command e)108 328.8 -Q(xits with a status of zero.)-.15 E/F4 10.95/Times-Bold@0 SF -(COMMAND EXECUTION)72 345.6 Q F0 .547 -(After a command has been split into w)108 357.6 R .546 +(If there were no command substitutions, the)5.466 F(command e)108 508.8 +Q(xits with a status of zero.)-.15 E F4(COMMAND EXECUTION)72 525.6 Q F0 +.547(After a command has been split into w)108 537.6 R .546 (ords, if it results in a simple command and an optional list of ar)-.1 -F(gu-)-.18 E(ments, the follo)108 369.6 Q(wing actions are tak)-.25 E +F(gu-)-.18 E(ments, the follo)108 549.6 Q(wing actions are tak)-.25 E (en.)-.1 E .379(If the command name contains no slashes, the shell atte\ -mpts to locate it.)108 386.4 R .379(If there e)5.379 F .379 +mpts to locate it.)108 566.4 R .379(If there e)5.379 F .379 (xists a shell function by)-.15 F .246(that name, that function is in) -108 398.4 R -.2(vo)-.4 G -.1(ke).2 G 2.746(da).1 G 2.746(sd)-2.746 G -.246(escribed abo)-2.746 F .546 -.15(ve i)-.15 H(n).15 E F1(FUNCTIONS) -2.746 E F2(.)A F0 .246(If the name does not match a func-)4.746 F -(tion, the shell searches for it in the list of shell b)108 410.4 Q 2.5 +108 578.4 R -.2(vo)-.4 G -.1(ke).2 G 2.746(da).1 G 2.746(sd)-2.746 G +.246(escribed abo)-2.746 F .546 -.15(ve i)-.15 H(n).15 E F3(FUNCTIONS) +2.746 E F5(.)A F0 .246(If the name does not match a func-)4.746 F +(tion, the shell searches for it in the list of shell b)108 590.4 Q 2.5 (uiltins. If)-.2 F 2.5(am)2.5 G(atch is found, that b)-2.5 E (uiltin is in)-.2 E -.2(vo)-.4 G -.1(ke).2 G(d.).1 E .309 -(If the name is neither a shell function nor a b)108 427.2 R .31 -(uiltin, and contains no slashes,)-.2 F F3(bash)2.81 E F0 .31 -(searches each element of)2.81 F(the)108 439.2 Q F1 -.666(PA)3.163 G(TH) +(If the name is neither a shell function nor a b)108 607.2 R .31 +(uiltin, and contains no slashes,)-.2 F F2(bash)2.81 E F0 .31 +(searches each element of)2.81 F(the)108 619.2 Q F3 -.666(PA)3.163 G(TH) -.189 E F0 .662(for a directory containing an e)2.913 F -.15(xe)-.15 G -.662(cutable \214le by that name.).15 F F3(Bash)5.662 E F0 .662 +.662(cutable \214le by that name.).15 F F2(Bash)5.662 E F0 .662 (uses a hash table to remember)3.162 F 1.914(the full pathnames of e)108 -451.2 R -.15(xe)-.15 G 1.915(cutable \214les \(see).15 F F3(hash)4.415 E -F0(under)4.415 E F1 1.915(SHELL B)4.415 F(UIL)-.09 E 1.915(TIN COMMANDS) +631.2 R -.15(xe)-.15 G 1.915(cutable \214les \(see).15 F F2(hash)4.415 E +F0(under)4.415 E F3 1.915(SHELL B)4.415 F(UIL)-.09 E 1.915(TIN COMMANDS) -.828 F F0(belo)4.165 E 4.415(w\). A)-.25 F(full)4.415 E .72 -(search of the directories in)108 463.2 R F1 -.666(PA)3.22 G(TH)-.189 E +(search of the directories in)108 643.2 R F3 -.666(PA)3.22 G(TH)-.189 E F0 .719 (is performed only if the command is not found in the hash table.)2.97 F .719(If the)5.719 F .956(search is unsuccessful, the shell searches for\ - a de\214ned shell function named)108 475.2 R F3(command_not_f)3.456 E -(ound_han-)-.25 E(dle)108 487.2 Q F0 5.278(.I)C 2.778(ft)-5.278 G .278 + a de\214ned shell function named)108 655.2 R F2(command_not_f)3.456 E +(ound_han-)-.25 E(dle)108 667.2 Q F0 5.278(.I)C 2.778(ft)-5.278 G .278 (hat function e)-2.778 F .278(xists, it is in)-.15 F -.2(vo)-.4 G -.1 (ke).2 G 2.778(dw).1 G .277 (ith the original command and the original command')-2.778 F 2.777(sa) --.55 G -.18(rg)-2.777 G(uments).18 E .775(as its ar)108 499.2 R .775 +-.55 G -.18(rg)-2.777 G(uments).18 E .775(as its ar)108 679.2 R .775 (guments, and the function')-.18 F 3.275(se)-.55 G .775 (xit status becomes the e)-3.425 F .775(xit status of the shell.)-.15 F .776(If that function is not)5.776 F -(de\214ned, the shell prints an error message and returns an e)108 511.2 +(de\214ned, the shell prints an error message and returns an e)108 691.2 Q(xit status of 127.)-.15 E 1.089(If the search is successful, or if th\ -e command name contains one or more slashes, the shell e)108 528 R -.15 -(xe)-.15 G 1.089(cutes the).15 F .197(named program in a separate e)108 -540 R -.15(xe)-.15 G .197(cution en).15 F 2.698(vironment. Ar)-.4 F .198 -(gument 0 is set to the name gi)-.18 F -.15(ve)-.25 G .198 -(n, and the remain-).15 F(ing ar)108 552 Q -(guments to the command are set to the ar)-.18 E(guments gi)-.18 E -.15 -(ve)-.25 G(n, if an).15 E -.65(y.)-.15 G 1.809(If this e)108 568.8 R --.15(xe)-.15 G 1.809(cution f).15 F 1.809 +e command name contains one or more slashes, the shell e)108 708 R -.15 +(xe)-.15 G 1.089(cutes the).15 F 2.31(named program in a separate e)108 +720 R -.15(xe)-.15 G 2.31(cution en).15 F 4.81(vironment. Ar)-.4 F 2.31 +(gument 0 is set to the name gi)-.18 F -.15(ve)-.25 G 2.31(n, and the) +.15 F(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 +E(31)185.545 E 0 Cg EP +%%Page: 32 32 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(remaining ar)108 84 Q(guments to the command are set to the ar) +-.18 E(guments gi)-.18 E -.15(ve)-.25 G(n, if an).15 E -.65(y.)-.15 G +1.809(If this e)108 100.8 R -.15(xe)-.15 G 1.809(cution f).15 F 1.809 (ails because the \214le is not in e)-.1 F -.15(xe)-.15 G 1.809 (cutable format, and the \214le is not a directory).15 F 4.309(,i)-.65 G -4.309(ti)-4.309 G(s)-4.309 E .677(assumed to be a)108 580.8 R/F5 10 +4.309(ti)-4.309 G(s)-4.309 E .677(assumed to be a)108 112.8 R/F1 10 /Times-Italic@0 SF .678(shell script)3.177 F F0 3.178(,a\214)C .678 (le containing shell commands.)-3.178 F 3.178(As)5.678 G .678 (ubshell is spa)-3.178 F .678(wned to e)-.15 F -.15(xe)-.15 G .678 (cute it.).15 F(This)5.678 E .33 -(subshell reinitializes itself, so that the ef)108 592.8 R .33 +(subshell reinitializes itself, so that the ef)108 124.8 R .33 (fect is as if a ne)-.25 F 2.829(ws)-.25 G .329(hell had been in)-2.829 F -.2(vo)-.4 G -.1(ke).2 G 2.829(dt).1 G 2.829(oh)-2.829 G .329 -(andle the script, with)-2.829 F 1.219(the e)108 604.8 R 1.219 +(andle the script, with)-2.829 F 1.219(the e)108 136.8 R 1.219 (xception that the locations of commands remembered by the parent \(see) --.15 F F3(hash)3.719 E F0(belo)3.719 E 3.719(wu)-.25 G(nder)-3.719 E F1 -(SHELL)3.719 E -.09(BU)108 616.8 S(IL).09 E(TIN COMMANDS)-.828 E F2(\))A -F0(are retained by the child.)2.25 E .348(If the program is a \214le be) -108 633.6 R .348(ginning with)-.15 F F3(#!)2.848 E F0 2.848(,t)C .347(h\ +-.15 F/F2 10/Times-Bold@0 SF(hash)3.719 E F0(belo)3.719 E 3.719(wu)-.25 +G(nder)-3.719 E/F3 9/Times-Bold@0 SF(SHELL)3.719 E -.09(BU)108 148.8 S +(IL).09 E(TIN COMMANDS)-.828 E/F4 9/Times-Roman@0 SF(\))A F0 +(are retained by the child.)2.25 E .348(If the program is a \214le be) +108 165.6 R .348(ginning with)-.15 F F2(#!)2.848 E F0 2.848(,t)C .347(h\ e remainder of the \214rst line speci\214es an interpreter for the pro-) --2.848 F 3.178(gram. The)108 645.6 R .678(shell e)3.178 F -.15(xe)-.15 G +-2.848 F 3.178(gram. The)108 177.6 R .678(shell e)3.178 F -.15(xe)-.15 G .678(cutes the speci\214ed interpreter on operating systems that do not\ handle this e).15 F -.15(xe)-.15 G(cutable).15 E 1.193(format themselv) -108 657.6 R 3.693(es. The)-.15 F(ar)3.693 E 1.193 +108 189.6 R 3.693(es. The)-.15 F(ar)3.693 E 1.193 (guments to the interpreter consist of a single optional ar)-.18 F 1.192 (gument follo)-.18 F 1.192(wing the)-.25 F 1.13 -(interpreter name on the \214rst line of the program, follo)108 669.6 R +(interpreter name on the \214rst line of the program, follo)108 201.6 R 1.131(wed by the name of the program, follo)-.25 F 1.131(wed by the)-.25 -F(command ar)108 681.6 Q(guments, if an)-.18 E -.65(y.)-.15 G F4 -(COMMAND EXECUTION ENVIR)72 698.4 Q(ONMENT)-.329 E F0(The shell has an) -108 710.4 Q F5 -.2(ex)2.5 G(ecution en).2 E(vir)-.4 E(onment)-.45 E F0 -2.5(,w)C(hich consists of the follo)-2.5 E(wing:)-.25 E(GNU Bash 4.2)72 -768 Q(2012 July 14)149.005 E(31)198.165 E 0 Cg EP -%%Page: 32 32 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E 32.5<836f>108 84 S 1.406 -(pen \214les inherited by the shell at in)-32.5 F -.2(vo)-.4 G 1.405 -(cation, as modi\214ed by redirections supplied to the).2 F/F1 10 -/Times-Bold@0 SF(exec)3.905 E F0 -.2(bu)144 96 S(iltin).2 E 32.5<8374> -108 112.8 S(he current w)-32.5 E(orking directory as set by)-.1 E F1(cd) -2.5 E F0(,)A F1(pushd)2.5 E F0 2.5(,o)C(r)-2.5 E F1(popd)2.5 E F0 2.5 -(,o)C 2.5(ri)-2.5 G(nherited by the shell at in)-2.5 E -.2(vo)-.4 G -(cation).2 E 32.5<8374>108 129.6 S -(he \214le creation mode mask as set by)-32.5 E F1(umask)2.5 E F0 -(or inherited from the shell')2.5 E 2.5(sp)-.55 G(arent)-2.5 E 32.5 -<8363>108 146.4 S(urrent traps set by)-32.5 E F1(trap)2.5 E F0 32.5 -<8373>108 163.2 S .256(hell parameters that are set by v)-32.5 F .256 -(ariable assignment or with)-.25 F F1(set)2.756 E F0 .257 +F(command ar)108 213.6 Q(guments, if an)-.18 E -.65(y.)-.15 G/F5 10.95 +/Times-Bold@0 SF(COMMAND EXECUTION ENVIR)72 230.4 Q(ONMENT)-.329 E F0 +(The shell has an)108 242.4 Q F1 -.2(ex)2.5 G(ecution en).2 E(vir)-.4 E +(onment)-.45 E F0 2.5(,w)C(hich consists of the follo)-2.5 E(wing:)-.25 +E 32.5<836f>108 259.2 S 1.406(pen \214les inherited by the shell at in) +-32.5 F -.2(vo)-.4 G 1.405 +(cation, as modi\214ed by redirections supplied to the).2 F F2(exec) +3.905 E F0 -.2(bu)144 271.2 S(iltin).2 E 32.5<8374>108 288 S +(he current w)-32.5 E(orking directory as set by)-.1 E F2(cd)2.5 E F0(,) +A F2(pushd)2.5 E F0 2.5(,o)C(r)-2.5 E F2(popd)2.5 E F0 2.5(,o)C 2.5(ri) +-2.5 G(nherited by the shell at in)-2.5 E -.2(vo)-.4 G(cation).2 E 32.5 +<8374>108 304.8 S(he \214le creation mode mask as set by)-32.5 E F2 +(umask)2.5 E F0(or inherited from the shell')2.5 E 2.5(sp)-.55 G(arent) +-2.5 E 32.5<8363>108 321.6 S(urrent traps set by)-32.5 E F2(trap)2.5 E +F0 32.5<8373>108 338.4 S .256(hell parameters that are set by v)-32.5 F +.256(ariable assignment or with)-.25 F F2(set)2.756 E F0 .257 (or inherited from the shell')2.756 F 2.757(sp)-.55 G(arent)-2.757 E -(in the en)144 175.2 Q(vironment)-.4 E 32.5<8373>108 192 S +(in the en)144 350.4 Q(vironment)-.4 E 32.5<8373>108 367.2 S (hell functions de\214ned during e)-32.5 E -.15(xe)-.15 G (cution or inherited from the shell').15 E 2.5(sp)-.55 G -(arent in the en)-2.5 E(vironment)-.4 E 32.5<836f>108 208.8 S +(arent in the en)-2.5 E(vironment)-.4 E 32.5<836f>108 384 S (ptions enabled at in)-32.5 E -.2(vo)-.4 G(cation \(either by def).2 E -(ault or with command-line ar)-.1 E(guments\) or by)-.18 E F1(set)2.5 E -F0 32.5<836f>108 225.6 S(ptions enabled by)-32.5 E F1(shopt)2.5 E F0 -32.5<8373>108 242.4 S(hell aliases de\214ned with)-32.5 E F1(alias)2.5 E -F0 32.5<8376>108 259.2 S +(ault or with command-line ar)-.1 E(guments\) or by)-.18 E F2(set)2.5 E +F0 32.5<836f>108 400.8 S(ptions enabled by)-32.5 E F2(shopt)2.5 E F0 +32.5<8373>108 417.6 S(hell aliases de\214ned with)-32.5 E F2(alias)2.5 E +F0 32.5<8376>108 434.4 S (arious process IDs, including those of background jobs, the v)-32.75 E -(alue of)-.25 E F1($$)2.5 E F0 2.5(,a)C(nd the v)-2.5 E(alue of)-.25 E -/F2 9/Times-Bold@0 SF(PPID)2.5 E F0 .427 -(When a simple command other than a b)108 276 R .426 -(uiltin or shell function is to be e)-.2 F -.15(xe)-.15 G .426 +(alue of)-.25 E F2($$)2.5 E F0 2.5(,a)C(nd the v)-2.5 E(alue of)-.25 E +F3(PPID)2.5 E F0 .427(When a simple command other than a b)108 451.2 R +.426(uiltin or shell function is to be e)-.2 F -.15(xe)-.15 G .426 (cuted, it is in).15 F -.2(vo)-.4 G -.1(ke).2 G 2.926(di).1 G 2.926(nas) --2.926 G(eparate)-2.926 E -.15(exe)108 288 S .133(cution en).15 F .133 +-2.926 G(eparate)-2.926 E -.15(exe)108 463.2 S .133(cution en).15 F .133 (vironment that consists of the follo)-.4 F 2.634(wing. Unless)-.25 F .134(otherwise noted, the v)2.634 F .134(alues are inherited from)-.25 F -(the shell.)108 300 Q 32.5<8374>108 316.8 S 1.056(he shell')-32.5 F +(the shell.)108 475.2 Q 32.5<8374>108 492 S 1.056(he shell')-32.5 F 3.556(so)-.55 G 1.056(pen \214les, plus an)-3.556 F 3.556(ym)-.15 G 1.056 (odi\214cations and additions speci\214ed by redirections to the com-) --3.556 F(mand)144 328.8 Q 32.5<8374>108 345.6 S(he current w)-32.5 E -(orking directory)-.1 E 32.5<8374>108 362.4 S -(he \214le creation mode mask)-32.5 E 32.5<8373>108 379.2 S .856(hell v) +-3.556 F(mand)144 504 Q 32.5<8374>108 520.8 S(he current w)-32.5 E +(orking directory)-.1 E 32.5<8374>108 537.6 S +(he \214le creation mode mask)-32.5 E 32.5<8373>108 554.4 S .856(hell v) -32.5 F .857(ariables and functions mark)-.25 F .857(ed for e)-.1 F .857 (xport, along with v)-.15 F .857(ariables e)-.25 F .857 -(xported for the command,)-.15 F(passed in the en)144 391.2 Q(vironment) --.4 E 32.5<8374>108 408 S .307 +(xported for the command,)-.15 F(passed in the en)144 566.4 Q(vironment) +-.4 E 32.5<8374>108 583.2 S .307 (raps caught by the shell are reset to the v)-32.5 F .306 (alues inherited from the shell')-.25 F 2.806(sp)-.55 G .306 -(arent, and traps ignored)-2.806 F(by the shell are ignored)144 420 Q -2.5(Ac)108 436.8 S(ommand in)-2.5 E -.2(vo)-.4 G -.1(ke).2 G 2.5(di).1 G +(arent, and traps ignored)-2.806 F(by the shell are ignored)144 595.2 Q +2.5(Ac)108 612 S(ommand in)-2.5 E -.2(vo)-.4 G -.1(ke).2 G 2.5(di).1 G 2.5(nt)-2.5 G(his separate en)-2.5 E(vironment cannot af)-.4 E (fect the shell')-.25 E 2.5(se)-.55 G -.15(xe)-2.65 G(cution en).15 E (vironment.)-.4 E .577(Command substitution, commands grouped with pare\ -ntheses, and asynchronous commands are in)108 453.6 R -.2(vo)-.4 G -.1 -(ke).2 G 3.078(di).1 G(n)-3.078 E 2.745(as)108 465.6 S .245(ubshell en) +ntheses, and asynchronous commands are in)108 628.8 R -.2(vo)-.4 G -.1 +(ke).2 G 3.078(di).1 G(n)-3.078 E 2.745(as)108 640.8 S .245(ubshell en) -2.745 F .245(vironment that is a duplicate of the shell en)-.4 F .244 (vironment, e)-.4 F .244(xcept that traps caught by the shell are)-.15 F -.358(reset to the v)108 477.6 R .358 +.358(reset to the v)108 652.8 R .358 (alues that the shell inherited from its parent at in)-.25 F -.2(vo)-.4 G 2.858(cation. Builtin).2 F .359(commands that are in)2.859 F -.2(vo) --.4 G -.1(ke).2 G(d).1 E .857(as part of a pipeline are also e)108 489.6 +-.4 G -.1(ke).2 G(d).1 E .857(as part of a pipeline are also e)108 664.8 R -.15(xe)-.15 G .856(cuted in a subshell en).15 F 3.356 (vironment. Changes)-.4 F .856(made to the subshell en)3.356 F(viron-) --.4 E(ment cannot af)108 501.6 Q(fect the shell')-.25 E 2.5(se)-.55 G +-.4 E(ment cannot af)108 676.8 Q(fect the shell')-.25 E 2.5(se)-.55 G -.15(xe)-2.65 G(cution en).15 E(vironment.)-.4 E 1.376(Subshells spa)108 -518.4 R 1.376(wned to e)-.15 F -.15(xe)-.15 G 1.377 +693.6 R 1.376(wned to e)-.15 F -.15(xe)-.15 G 1.377 (cute command substitutions inherit the v).15 F 1.377(alue of the)-.25 F -F13.877 E F0 1.377(option from the parent)3.877 F 2.5(shell. When) -108 530.4 R(not in)2.5 E/F3 10/Times-Italic@0 SF(posix)2.5 E F0(mode,) -2.5 E F1(bash)2.5 E F0(clears the)2.5 E F12.5 E F0 -(option in such subshells.)2.5 E .405(If a command is follo)108 547.2 R -.405(wed by a)-.25 F F1(&)2.905 E F0 .404(and job control is not acti) -2.905 F -.15(ve)-.25 G 2.904(,t).15 G .404(he def)-2.904 F .404 -(ault standard input for the command)-.1 F .197(is the empty \214le)108 -559.2 R F3(/de)2.697 E(v/null)-.15 E F0 5.197(.O)C .197 -(therwise, the in)-5.197 F -.2(vo)-.4 G -.1(ke).2 G 2.697(dc).1 G .198 +F23.877 E F0 1.377(option from the parent)3.877 F 2.5(shell. When) +108 705.6 R(not in)2.5 E F1(posix)2.5 E F0(mode,)2.5 E F2(bash)2.5 E F0 +(clears the)2.5 E F22.5 E F0(option in such subshells.)2.5 E .405 +(If a command is follo)108 722.4 R .405(wed by a)-.25 F F2(&)2.905 E F0 +.404(and job control is not acti)2.905 F -.15(ve)-.25 G 2.904(,t).15 G +.404(he def)-2.904 F .404(ault standard input for the command)-.1 F +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(32)185.545 E 0 Cg EP +%%Page: 33 33 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E .197(is the empty \214le)108 84 R/F1 10/Times-Italic@0 SF(/de) +2.697 E(v/null)-.15 E F0 5.197(.O)C .197(therwise, the in)-5.197 F -.2 +(vo)-.4 G -.1(ke).2 G 2.697(dc).1 G .198 (ommand inherits the \214le descriptors of the calling shell)-2.697 F -(as modi\214ed by redirections.)108 571.2 Q/F4 10.95/Times-Bold@0 SF -(ENVIR)72 588 Q(ONMENT)-.329 E F0 2.354(When a program is in)108 600 R --.2(vo)-.4 G -.1(ke).2 G 4.853(di).1 G 4.853(ti)-4.853 G 4.853(sg)-4.853 -G -2.15 -.25(iv e)-4.853 H 4.853(na).25 G 4.853(na)-4.853 G 2.353 -(rray of strings called the)-4.853 F F3(en)4.853 E(vir)-.4 E(onment)-.45 -E F0 7.353(.T).68 G 2.353(his is a list of)-7.353 F F3(name)108 612 Q F0 -A F3(value)A F0(pairs, of the form)2.5 E F3(name)2.5 E F0(=)A F3 -(value)A F0(.).18 E 1.485(The shell pro)108 628.8 R 1.485(vides se)-.15 +(as modi\214ed by redirections.)108 96 Q/F2 10.95/Times-Bold@0 SF(ENVIR) +72 112.8 Q(ONMENT)-.329 E F0 2.354(When a program is in)108 124.8 R -.2 +(vo)-.4 G -.1(ke).2 G 4.853(di).1 G 4.853(ti)-4.853 G 4.853(sg)-4.853 G +-2.15 -.25(iv e)-4.853 H 4.853(na).25 G 4.853(na)-4.853 G 2.353 +(rray of strings called the)-4.853 F F1(en)4.853 E(vir)-.4 E(onment)-.45 +E F0 7.353(.T).68 G 2.353(his is a list of)-7.353 F F1(name)108 136.8 Q +F0A F1(value)A F0(pairs, of the form)2.5 E F1(name)2.5 E F0(=)A F1 +(value)A F0(.).18 E 1.485(The shell pro)108 153.6 R 1.485(vides se)-.15 F -.15(ve)-.25 G 1.485(ral w).15 F 1.485(ays to manipulate the en)-.1 F 3.985(vironment. On)-.4 F(in)3.985 E -.2(vo)-.4 G 1.486 -(cation, the shell scans its o).2 F(wn)-.25 E(en)108 640.8 Q .144(viron\ +(cation, the shell scans its o).2 F(wn)-.25 E(en)108 165.6 Q .144(viron\ ment and creates a parameter for each name found, automatically marking\ - it for)-.4 F F3 -.2(ex)2.643 G(port).2 E F0 .143(to child pro-)3.323 F -2.703(cesses. Ex)108 652.8 R .203(ecuted commands inherit the en)-.15 F -2.703(vironment. The)-.4 F F1(export)2.703 E F0(and)2.703 E F1(declar) -2.703 E 2.703<65ad>-.18 G(x)-2.703 E F0 .203(commands allo)2.703 F 2.704 -(wp)-.25 G(aram-)-2.704 E 1.153 -(eters and functions to be added to and deleted from the en)108 664.8 R + it for)-.4 F F1 -.2(ex)2.643 G(port).2 E F0 .143(to child pro-)3.323 F +2.703(cesses. Ex)108 177.6 R .203(ecuted commands inherit the en)-.15 F +2.703(vironment. The)-.4 F/F3 10/Times-Bold@0 SF(export)2.703 E F0(and) +2.703 E F3(declar)2.703 E 2.703<65ad>-.18 G(x)-2.703 E F0 .203 +(commands allo)2.703 F 2.704(wp)-.25 G(aram-)-2.704 E 1.153 +(eters and functions to be added to and deleted from the en)108 189.6 R 3.653(vironment. If)-.4 F 1.153(the v)3.653 F 1.153 -(alue of a parameter in the)-.25 F(en)108 676.8 Q .64 +(alue of a parameter in the)-.25 F(en)108 201.6 Q .64 (vironment is modi\214ed, the ne)-.4 F 3.14(wv)-.25 G .64 (alue becomes part of the en)-3.39 F .64(vironment, replacing the old.) --.4 F .64(The en)5.64 F(viron-)-.4 E .58(ment inherited by an)108 688.8 +-.4 F .64(The en)5.64 F(viron-)-.4 E .58(ment inherited by an)108 213.6 R 3.08(ye)-.15 G -.15(xe)-3.23 G .58 (cuted command consists of the shell').15 F 3.08(si)-.55 G .58 (nitial en)-3.08 F .58(vironment, whose v)-.4 F .58(alues may be)-.25 F -.3(modi\214ed in the shell, less an)108 700.8 R 2.8(yp)-.15 G .3 +.3(modi\214ed in the shell, less an)108 225.6 R 2.8(yp)-.15 G .3 (airs remo)-2.8 F -.15(ve)-.15 G 2.8(db).15 G 2.801(yt)-2.8 G(he)-2.801 -E F1(unset)2.801 E F0 .301(command, plus an)2.801 F 2.801(ya)-.15 G .301 -(dditions via the)-2.801 F F1(export)2.801 E F0(and)2.801 E F1(declar) -108 712.8 Q 2.5<65ad>-.18 G(x)-2.5 E F0(commands.)2.5 E .563(The en)108 -729.6 R .563(vironment for an)-.4 F(y)-.15 E F3 .563(simple command) +E F3(unset)2.801 E F0 .301(command, plus an)2.801 F 2.801(ya)-.15 G .301 +(dditions via the)-2.801 F F3(export)2.801 E F0(and)2.801 E F3(declar) +108 237.6 Q 2.5<65ad>-.18 G(x)-2.5 E F0(commands.)2.5 E .563(The en)108 +254.4 R .563(vironment for an)-.4 F(y)-.15 E F1 .563(simple command) 3.403 F F0 .562 (or function may be augmented temporarily by pre\214xing it with)3.833 F -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(32)198.165 E 0 Cg EP -%%Page: 33 33 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E .202(parameter assignments, as described abo)108 84 R .502 -.15 -(ve i)-.15 H(n).15 E/F1 9/Times-Bold@0 SF -.666(PA)2.702 G(RAMETERS).666 -E/F2 9/Times-Roman@0 SF(.)A F0 .202(These assignment statements af)4.702 -F .203(fect only the)-.25 F(en)108 96 Q(vironment seen by that command.) --.4 E .81(If the)108 112.8 R/F3 10/Times-Bold@0 SF3.31 E F0 .81 -(option is set \(see the)3.31 F F3(set)3.31 E F0 -.2(bu)3.31 G .81 -(iltin command belo).2 F .81(w\), then)-.25 F/F4 10/Times-Italic@0 SF -(all)3.64 E F0 .81(parameter assignments are placed in)3.82 F(the en)108 -124.8 Q +.202(parameter assignments, as described abo)108 266.4 R .502 -.15(ve i) +-.15 H(n).15 E/F4 9/Times-Bold@0 SF -.666(PA)2.702 G(RAMETERS).666 E/F5 +9/Times-Roman@0 SF(.)A F0 .202(These assignment statements af)4.702 F +.203(fect only the)-.25 F(en)108 278.4 Q +(vironment seen by that command.)-.4 E .81(If the)108 295.2 R F3 +3.31 E F0 .81(option is set \(see the)3.31 F F3(set)3.31 E F0 -.2(bu) +3.31 G .81(iltin command belo).2 F .81(w\), then)-.25 F F1(all)3.64 E F0 +.81(parameter assignments are placed in)3.82 F(the en)108 307.2 Q (vironment for a command, not just those that precede the command name.) --.4 E(When)108 141.6 Q F3(bash)3.585 E F0(in)3.585 E -.2(vo)-.4 G -.1 -(ke).2 G 3.585(sa).1 G 3.585(ne)-3.585 G 1.085(xternal command, the v) --3.735 F(ariable)-.25 E F3(_)3.585 E F0 1.086 +-.4 E(When)108 324 Q F3(bash)3.585 E F0(in)3.585 E -.2(vo)-.4 G -.1(ke) +.2 G 3.585(sa).1 G 3.585(ne)-3.585 G 1.085(xternal command, the v)-3.735 +F(ariable)-.25 E F3(_)3.585 E F0 1.086 (is set to the full \214lename of the command and)3.586 F -(passed to that command in its en)108 153.6 Q(vironment.)-.4 E/F5 10.95 -/Times-Bold@0 SF(EXIT ST)72 170.4 Q -1.04(AT)-.986 G(US)1.04 E F0 .151 -(The e)108 182.4 R .151(xit status of an e)-.15 F -.15(xe)-.15 G .151 -(cuted command is the v).15 F .15(alue returned by the)-.25 F F4 -(waitpid)2.65 E F0 .15(system call or equi)2.65 F -.25(va)-.25 G .15 -(lent func-).25 F 2.847(tion. Exit)108 194.4 R .347(statuses f)2.847 F -.347(all between 0 and 255, though, as e)-.1 F .347(xplained belo)-.15 F +(passed to that command in its en)108 336 Q(vironment.)-.4 E F2(EXIT ST) +72 352.8 Q -1.04(AT)-.986 G(US)1.04 E F0 .151(The e)108 364.8 R .151 +(xit status of an e)-.15 F -.15(xe)-.15 G .151(cuted command is the v) +.15 F .15(alue returned by the)-.25 F F1(waitpid)2.65 E F0 .15 +(system call or equi)2.65 F -.25(va)-.25 G .15(lent func-).25 F 2.847 +(tion. Exit)108 376.8 R .347(statuses f)2.847 F .347 +(all between 0 and 255, though, as e)-.1 F .347(xplained belo)-.15 F 1.647 -.65(w, t)-.25 H .347(he shell may use v).65 F .348(alues abo)-.25 -F .648 -.15(ve 1)-.15 H(25).15 E(specially)108 206.4 Q 5.674(.E)-.65 G +F .648 -.15(ve 1)-.15 H(25).15 E(specially)108 388.8 Q 5.674(.E)-.65 G .674(xit statuses from shell b)-5.674 F .673 (uiltins and compound commands are also limited to this range. Under)-.2 -F(certain circumstances, the shell will use special v)108 218.4 Q +F(certain circumstances, the shell will use special v)108 400.8 Q (alues to indicate speci\214c f)-.25 E(ailure modes.)-.1 E -.15(Fo)108 -235.2 S 3.372(rt).15 G .872(he shell')-3.372 F 3.372(sp)-.55 G .873 +417.6 S 3.372(rt).15 G .872(he shell')-3.372 F 3.372(sp)-.55 G .873 (urposes, a command which e)-3.372 F .873(xits with a zero e)-.15 F .873 (xit status has succeeded.)-.15 F .873(An e)5.873 F .873(xit status of) --.15 F .049(zero indicates success.)108 247.2 R 2.549(An)5.049 G .049 +-.15 F .049(zero indicates success.)108 429.6 R 2.549(An)5.049 G .049 (on-zero e)-2.549 F .049(xit status indicates f)-.15 F 2.549 (ailure. When)-.1 F 2.549(ac)2.549 G .048(ommand terminates on a f) --2.549 F .048(atal sig-)-.1 F(nal)108 259.2 Q F4(N)2.5 E F0(,)A F3(bash) -2.5 E F0(uses the v)2.5 E(alue of 128+)-.25 E F4(N)A F0(as the e)2.5 E +-2.549 F .048(atal sig-)-.1 F(nal)108 441.6 Q F1(N)2.5 E F0(,)A F3(bash) +2.5 E F0(uses the v)2.5 E(alue of 128+)-.25 E F1(N)A F0(as the e)2.5 E (xit status.)-.15 E .404 -(If a command is not found, the child process created to e)108 276 R +(If a command is not found, the child process created to e)108 458.4 R -.15(xe)-.15 G .404(cute it returns a status of 127.).15 F .405 -(If a command is)5.405 F(found b)108 288 Q(ut is not e)-.2 E -.15(xe) --.15 G(cutable, the return status is 126.).15 E(If a command f)108 304.8 +(If a command is)5.405 F(found b)108 470.4 Q(ut is not e)-.2 E -.15(xe) +-.15 G(cutable, the return status is 126.).15 E(If a command f)108 487.2 Q(ails because of an error during e)-.1 E (xpansion or redirection, the e)-.15 E(xit status is greater than zero.) --.15 E .081(Shell b)108 321.6 R .081 -(uiltin commands return a status of 0 \()-.2 F F4(true)A F0 2.581(\)i)C -2.581(fs)-2.581 G .08(uccessful, and non-zero \()-2.581 F F4(false)A F0 +-.15 E .081(Shell b)108 504 R .081 +(uiltin commands return a status of 0 \()-.2 F F1(true)A F0 2.581(\)i)C +2.581(fs)-2.581 G .08(uccessful, and non-zero \()-2.581 F F1(false)A F0 2.58(\)i)C 2.58(fa)-2.58 G 2.58(ne)-2.58 G .08(rror occurs while)-2.58 F -(the)108 333.6 Q 2.5(ye)-.15 G -.15(xe)-2.65 G 2.5(cute. All).15 F -.2 -(bu)2.5 G(iltins return an e).2 E -(xit status of 2 to indicate incorrect usage.)-.15 E F3(Bash)108 350.4 Q +(the)108 516 Q 2.5(ye)-.15 G -.15(xe)-2.65 G 2.5(cute. All).15 F -.2(bu) +2.5 G(iltins return an e).2 E +(xit status of 2 to indicate incorrect usage.)-.15 E F3(Bash)108 532.8 Q F0 .201(itself returns the e)2.701 F .202 (xit status of the last command e)-.15 F -.15(xe)-.15 G .202 -(cuted, unless a syntax error occurs, in which case).15 F(it e)108 362.4 +(cuted, unless a syntax error occurs, in which case).15 F(it e)108 544.8 Q(xits with a non-zero v)-.15 E 2.5(alue. See)-.25 F(also the)2.5 E F3 -(exit)2.5 E F0 -.2(bu)2.5 G(iltin command belo).2 E -.65(w.)-.25 G F5 -(SIGN)72 379.2 Q(ALS)-.219 E F0(When)108 391.2 Q F3(bash)3.183 E F0 .683 +(exit)2.5 E F0 -.2(bu)2.5 G(iltin command belo).2 E -.65(w.)-.25 G F2 +(SIGN)72 561.6 Q(ALS)-.219 E F0(When)108 573.6 Q F3(bash)3.183 E F0 .683 (is interacti)3.183 F -.15(ve)-.25 G 3.183(,i).15 G 3.183(nt)-3.183 G .683(he absence of an)-3.183 F 3.183(yt)-.15 G .683(raps, it ignores) --3.183 F F1(SIGTERM)3.183 E F0 .682(\(so that)2.933 F F3 .682(kill 0) -3.182 F F0 .682(does not kill an)3.182 F(interacti)108 403.2 Q .757 -.15 -(ve s)-.25 H .457(hell\), and).15 F F1(SIGINT)2.957 E F0 .458 +-3.183 F F4(SIGTERM)3.183 E F0 .682(\(so that)2.933 F F3 .682(kill 0) +3.182 F F0 .682(does not kill an)3.182 F(interacti)108 585.6 Q .757 -.15 +(ve s)-.25 H .457(hell\), and).15 F F4(SIGINT)2.957 E F0 .458 (is caught and handled \(so that the)2.707 F F3(wait)2.958 E F0 -.2(bu) 2.958 G .458(iltin is interruptible\).).2 F .458(In all cases,)5.458 F -F3(bash)108 415.2 Q F0(ignores)2.5 E F1(SIGQ)2.5 E(UIT)-.09 E F2(.)A F0 +F3(bash)108 597.6 Q F0(ignores)2.5 E F4(SIGQ)2.5 E(UIT)-.09 E F5(.)A F0 (If job control is in ef)4.5 E(fect,)-.25 E F3(bash)2.5 E F0(ignores)2.5 -E F1(SIGTTIN)2.5 E F2(,)A F1(SIGTT)2.25 E(OU)-.162 E F2(,)A F0(and)2.25 -E F1(SIGTSTP)2.5 E F2(.)A F0(Non-b)108 432 Q 1.065 +E F4(SIGTTIN)2.5 E F5(,)A F4(SIGTT)2.25 E(OU)-.162 E F5(,)A F0(and)2.25 +E F4(SIGTSTP)2.5 E F5(.)A F0(Non-b)108 614.4 Q 1.065 (uiltin commands run by)-.2 F F3(bash)3.565 E F0(ha)3.565 E 1.365 -.15 (ve s)-.2 H 1.065(ignal handlers set to the v).15 F 1.064 -(alues inherited by the shell from its)-.25 F 3.247(parent. When)108 444 -R .747(job control is not in ef)3.247 F .747 -(fect, asynchronous commands ignore)-.25 F F1(SIGINT)3.248 E F0(and) -2.998 E F1(SIGQ)3.248 E(UIT)-.09 E F0 .748(in addi-)2.998 F .653 -(tion to these inherited handlers.)108 456 R .653 +(alues inherited by the shell from its)-.25 F 3.247(parent. When)108 +626.4 R .747(job control is not in ef)3.247 F .747 +(fect, asynchronous commands ignore)-.25 F F4(SIGINT)3.248 E F0(and) +2.998 E F4(SIGQ)3.248 E(UIT)-.09 E F0 .748(in addi-)2.998 F .653 +(tion to these inherited handlers.)108 638.4 R .653 (Commands run as a result of command substitution ignore the k)5.653 F --.15(ey)-.1 G(board-).15 E(generated job control signals)108 468 Q F1 -(SIGTTIN)2.5 E F2(,)A F1(SIGTT)2.25 E(OU)-.162 E F2(,)A F0(and)2.25 E F1 -(SIGTSTP)2.5 E F2(.)A F0 2.045(The shell e)108 484.8 R 2.045 -(xits by def)-.15 F 2.045(ault upon receipt of a)-.1 F F1(SIGHUP)4.545 E -F2(.)A F0 2.045(Before e)6.545 F 2.045(xiting, an interacti)-.15 F 2.346 --.15(ve s)-.25 H 2.046(hell resends the).15 F F1(SIGHUP)108 496.8 Q F0 +-.15(ey)-.1 G(board-).15 E(generated job control signals)108 650.4 Q F4 +(SIGTTIN)2.5 E F5(,)A F4(SIGTT)2.25 E(OU)-.162 E F5(,)A F0(and)2.25 E F4 +(SIGTSTP)2.5 E F5(.)A F0 2.045(The shell e)108 667.2 R 2.045 +(xits by def)-.15 F 2.045(ault upon receipt of a)-.1 F F4(SIGHUP)4.545 E +F5(.)A F0 2.045(Before e)6.545 F 2.045(xiting, an interacti)-.15 F 2.346 +-.15(ve s)-.25 H 2.046(hell resends the).15 F F4(SIGHUP)108 679.2 Q F0 1.005(to all jobs, running or stopped.)3.255 F 1.004 -(Stopped jobs are sent)6.005 F F1(SIGCONT)3.504 E F0 1.004 +(Stopped jobs are sent)6.005 F F4(SIGCONT)3.504 E F0 1.004 (to ensure that the)3.254 F 3.504(yr)-.15 G(ecei)-3.504 E 1.304 -.15 -(ve t)-.25 H(he).15 E F1(SIGHUP)108 508.8 Q F2(.)A F0 2.529 -.8(To p) +(ve t)-.25 H(he).15 E F4(SIGHUP)108 691.2 Q F5(.)A F0 2.529 -.8(To p) 5.429 H(re).8 E -.15(ve)-.25 G .93(nt the shell from sending the signal\ to a particular job, it should be remo).15 F -.15(ve)-.15 G 3.43(df).15 -G .93(rom the)-3.43 F 1.357(jobs table with the)108 520.8 R F3(diso) -3.857 E(wn)-.1 E F0 -.2(bu)3.857 G 1.357(iltin \(see).2 F F1 1.356 +G .93(rom the)-3.43 F 1.357(jobs table with the)108 703.2 R F3(diso) +3.857 E(wn)-.1 E F0 -.2(bu)3.857 G 1.357(iltin \(see).2 F F4 1.356 (SHELL B)3.856 F(UIL)-.09 E 1.356(TIN COMMANDS)-.828 F F0(belo)3.606 E -1.356(w\) or mark)-.25 F 1.356(ed to not recei)-.1 F -.15(ve)-.25 G F1 -(SIGHUP)108 532.8 Q F0(using)2.25 E F3(diso)2.5 E(wn \255h)-.1 E F0(.)A -.166(If the)108 549.6 R F3(huponexit)2.666 E F0 .166 -(shell option has been set with)2.666 F F3(shopt)2.666 E F0(,)A F3(bash) -2.666 E F0 .166(sends a)2.666 F F1(SIGHUP)2.666 E F0 .166 -(to all jobs when an interacti)2.416 F -.15(ve)-.25 G(login shell e)108 -561.6 Q(xits.)-.15 E(If)108 578.4 Q F3(bash)3.047 E F0 .547(is w)3.047 F -.546(aiting for a command to complete and recei)-.1 F -.15(ve)-.25 G -3.046(sas).15 G .546(ignal for which a trap has been set, the trap) --3.046 F .662(will not be e)108 590.4 R -.15(xe)-.15 G .662 -(cuted until the command completes.).15 F(When)5.663 E F3(bash)3.163 E +1.356(w\) or mark)-.25 F 1.356(ed to not recei)-.1 F -.15(ve)-.25 G F4 +(SIGHUP)108 715.2 Q F0(using)2.25 E F3(diso)2.5 E(wn \255h)-.1 E F0(.)A +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(33)185.545 E 0 Cg EP +%%Page: 34 34 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E .166(If the)108 84 R/F1 10/Times-Bold@0 SF(huponexit)2.666 E F0 +.166(shell option has been set with)2.666 F F1(shopt)2.666 E F0(,)A F1 +(bash)2.666 E F0 .166(sends a)2.666 F/F2 9/Times-Bold@0 SF(SIGHUP)2.666 +E F0 .166(to all jobs when an interacti)2.416 F -.15(ve)-.25 G +(login shell e)108 96 Q(xits.)-.15 E(If)108 112.8 Q F1(bash)3.047 E F0 +.547(is w)3.047 F .546(aiting for a command to complete and recei)-.1 F +-.15(ve)-.25 G 3.046(sas).15 G .546 +(ignal for which a trap has been set, the trap)-3.046 F .662 +(will not be e)108 124.8 R -.15(xe)-.15 G .662 +(cuted until the command completes.).15 F(When)5.663 E F1(bash)3.163 E F0 .663(is w)3.163 F .663(aiting for an asynchronous command)-.1 F .99 -(via the)108 602.4 R F3(wait)3.49 E F0 -.2(bu)3.49 G .99(iltin, the rec\ -eption of a signal for which a trap has been set will cause the).2 F F3 +(via the)108 136.8 R F1(wait)3.49 E F0 -.2(bu)3.49 G .99(iltin, the rec\ +eption of a signal for which a trap has been set will cause the).2 F F1 (wait)3.49 E F0 -.2(bu)3.49 G .99(iltin to).2 F -(return immediately with an e)108 614.4 Q +(return immediately with an e)108 148.8 Q (xit status greater than 128, immediately after which the trap is e)-.15 -E -.15(xe)-.15 G(cuted.).15 E F5(JOB CONTR)72 631.2 Q(OL)-.329 E F4 -.25 -(Jo)108 643.2 S 4.567(bc).25 G(ontr)-4.567 E(ol)-.45 E F0 2.067 -(refers to the ability to selecti)5.077 F -.15(ve)-.25 G 2.067 -(ly stop \().15 F F4(suspend)A F0 4.567(\)t)C 2.068(he e)-4.567 F -.15 -(xe)-.15 G 2.068(cution of processes and continue).15 F(\()108 655.2 Q -F4 -.37(re)C(sume).37 E F0 3.202(\)t)C .702(heir e)-3.202 F -.15(xe)-.15 -G .702(cution at a later point.).15 F 3.202(Au)5.702 G .702 +E -.15(xe)-.15 G(cuted.).15 E/F3 10.95/Times-Bold@0 SF(JOB CONTR)72 +165.6 Q(OL)-.329 E/F4 10/Times-Italic@0 SF -.25(Jo)108 177.6 S 4.567(bc) +.25 G(ontr)-4.567 E(ol)-.45 E F0 2.067(refers to the ability to selecti) +5.077 F -.15(ve)-.25 G 2.067(ly stop \().15 F F4(suspend)A F0 4.567(\)t) +C 2.068(he e)-4.567 F -.15(xe)-.15 G 2.068 +(cution of processes and continue).15 F(\()108 189.6 Q F4 -.37(re)C +(sume).37 E F0 3.202(\)t)C .702(heir e)-3.202 F -.15(xe)-.15 G .702 +(cution at a later point.).15 F 3.202(Au)5.702 G .702 (ser typically emplo)-3.202 F .702(ys this f)-.1 F .702 (acility via an interacti)-.1 F 1.001 -.15(ve i)-.25 H(nterf).15 E(ace) --.1 E(supplied jointly by the operating system k)108 667.2 Q(ernel')-.1 +-.1 E(supplied jointly by the operating system k)108 201.6 Q(ernel')-.1 E 2.5(st)-.55 G(erminal dri)-2.5 E -.15(ve)-.25 G 2.5(ra).15 G(nd)-2.5 E -F3(bash)2.5 E F0(.)A .784(The shell associates a)108 684 R F4(job)5.024 -E F0 .784(with each pipeline.)3.514 F .784(It k)5.784 F .785 +F1(bash)2.5 E F0(.)A .784(The shell associates a)108 218.4 R F4(job) +5.024 E F0 .784(with each pipeline.)3.514 F .784(It k)5.784 F .785 (eeps a table of currently e)-.1 F -.15(xe)-.15 G .785 -(cuting jobs, which may be).15 F .341(listed with the)108 696 R F3(jobs) -2.841 E F0 2.841(command. When)2.841 F F3(bash)2.841 E F0 .341 +(cuting jobs, which may be).15 F .341(listed with the)108 230.4 R F1 +(jobs)2.841 E F0 2.841(command. When)2.841 F F1(bash)2.841 E F0 .341 (starts a job asynchronously \(in the)2.841 F F4(bac)2.84 E(kgr)-.2 E -(ound)-.45 E F0 .34(\), it prints a line).77 F(that looks lik)108 708 Q -(e:)-.1 E([1] 25647)144 724.8 Q(GNU Bash 4.2)72 768 Q(2012 July 14) -149.005 E(33)198.165 E 0 Cg EP -%%Page: 34 34 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E .241(indicating that this job is job number 1 and that the proce\ -ss ID of the last process in the pipeline associated)108 84 R .733 -(with this job is 25647.)108 96 R .732 +(ound)-.45 E F0 .34(\), it prints a line).77 F(that looks lik)108 242.4 +Q(e:)-.1 E([1] 25647)144 259.2 Q .241(indicating that this job is job n\ +umber 1 and that the process ID of the last process in the pipeline ass\ +ociated)108 276 R .733(with this job is 25647.)108 288 R .732 (All of the processes in a single pipeline are members of the same job) -5.733 F(.)-.4 E/F1 10/Times-Bold@0 SF(Bash)5.732 E F0(uses)3.232 E(the) -108 108 Q/F2 10/Times-Italic@0 SF(job)4.24 E F0 -(abstraction as the basis for job control.)2.73 E 3.062 -.8(To f)108 -124.8 T 1.462(acilitate the implementation of the user interf).7 F 1.463 -(ace to job control, the operating system maintains the)-.1 F .871 -(notion of a)108 136.8 R F2(curr)3.371 E .871(ent terminal pr)-.37 F +5.733 F(.)-.4 E F1(Bash)5.732 E F0(uses)3.232 E(the)108 300 Q F4(job) +4.24 E F0(abstraction as the basis for job control.)2.73 E 3.062 -.8 +(To f)108 316.8 T 1.462(acilitate the implementation of the user interf) +.7 F 1.463(ace to job control, the operating system maintains the)-.1 F +.871(notion of a)108 328.8 R F4(curr)3.371 E .871(ent terminal pr)-.37 F .871(ocess gr)-.45 F .871(oup ID)-.45 F F0 5.871(.M)C .87 (embers of this process group \(processes whose process)-5.871 F .023 (group ID is equal to the current terminal process group ID\) recei)108 -148.8 R .323 -.15(ve k)-.25 H -.15(ey).05 G .023 -(board-generated signals such as).15 F/F3 9/Times-Bold@0 SF(SIG-)2.523 E -(INT)108 160.8 Q/F4 9/Times-Roman@0 SF(.)A F0 1.347 -(These processes are said to be in the)5.847 F F2(for)3.846 E -.4(eg) --.37 G -.45(ro).4 G(und).45 E F0(.).77 E F2(Bac)6.926 E(kgr)-.2 E(ound) +340.8 R .323 -.15(ve k)-.25 H -.15(ey).05 G .023 +(board-generated signals such as).15 F F2(SIG-)2.523 E(INT)108 352.8 Q +/F5 9/Times-Roman@0 SF(.)A F0 1.347 +(These processes are said to be in the)5.847 F F4(for)3.846 E -.4(eg) +-.37 G -.45(ro).4 G(und).45 E F0(.).77 E F4(Bac)6.926 E(kgr)-.2 E(ound) -.45 E F0 1.346(processes are those whose process)4.616 F .145 -(group ID dif)108 172.8 R .145(fers from the terminal')-.25 F .146 +(group ID dif)108 364.8 R .145(fers from the terminal')-.25 F .146 (s; such processes are immune to k)-.55 F -.15(ey)-.1 G .146 (board-generated signals.).15 F .146(Only fore-)5.146 F .16 -(ground processes are allo)108 184.8 R .16(wed to read from or)-.25 F -2.66(,i)-.4 G 2.66(ft)-2.66 G .16(he user so speci\214es with)-2.66 F/F5 +(ground processes are allo)108 376.8 R .16(wed to read from or)-.25 F +2.66(,i)-.4 G 2.66(ft)-2.66 G .16(he user so speci\214es with)-2.66 F/F6 10/Courier@0 SF .16(stty tostop)2.66 F F0 2.66(,w)C .16(rite to the ter) --2.66 F(-)-.2 E 3.051(minal. Background)108 196.8 R .551 -(processes which attempt to read from \(write to when)3.051 F F5 .551 +-2.66 F(-)-.2 E 3.051(minal. Background)108 388.8 R .551 +(processes which attempt to read from \(write to when)3.051 F F6 .551 (stty tostop)3.051 F F0 .552(is in ef)3.052 F .552(fect\) the)-.25 F -.718(terminal are sent a)108 208.8 R F3 .718(SIGTTIN \(SIGTT)3.218 F +.718(terminal are sent a)108 400.8 R F2 .718(SIGTTIN \(SIGTT)3.218 F (OU\))-.162 E F0 .718(signal by the k)2.968 F(ernel')-.1 E 3.217(st)-.55 G .717(erminal dri)-3.217 F -.15(ve)-.25 G 1.517 -.4(r, w).15 H .717 -(hich, unless caught, sus-).4 F(pends the process.)108 220.8 Q 1.087 -(If the operating system on which)108 237.6 R F1(bash)3.587 E F0 1.088 +(hich, unless caught, sus-).4 F(pends the process.)108 412.8 Q 1.087 +(If the operating system on which)108 429.6 R F1(bash)3.587 E F0 1.088 (is running supports job control,)3.588 F F1(bash)3.588 E F0 1.088 -(contains f)3.588 F 1.088(acilities to use it.)-.1 F -.8(Ty)108 249.6 S -.302(ping the).8 F F2(suspend)3.142 E F0 .302(character \(typically) +(contains f)3.588 F 1.088(acilities to use it.)-.1 F -.8(Ty)108 441.6 S +.302(ping the).8 F F4(suspend)3.142 E F0 .302(character \(typically) 3.572 F F1(^Z)2.801 E F0 2.801(,C)C .301 (ontrol-Z\) while a process is running causes that process to be)-2.801 -F 2.142(stopped and returns control to)108 261.6 R F1(bash)4.642 E F0 -7.142(.T)C 2.142(yping the)-7.942 F F2 2.142(delayed suspend)4.992 F F0 +F 2.142(stopped and returns control to)108 453.6 R F1(bash)4.642 E F0 +7.142(.T)C 2.142(yping the)-7.942 F F4 2.142(delayed suspend)4.992 F F0 2.143(character \(typically)5.413 F F1(^Y)4.643 E F0 4.643(,C)C (ontrol-Y\))-4.643 E .021(causes the process to be stopped when it atte\ mpts to read input from the terminal, and control to be returned)108 -273.6 R(to)108 285.6 Q F1(bash)3.392 E F0 5.892(.T)C .892 +465.6 R(to)108 477.6 Q F1(bash)3.392 E F0 5.892(.T)C .892 (he user may then manipulate the state of this job, using the)-5.892 F F1(bg)3.392 E F0 .892(command to continue it in the)3.392 F .895 -(background, the)108 297.6 R F1(fg)3.395 E F0 .895 +(background, the)108 489.6 R F1(fg)3.395 E F0 .895 (command to continue it in the fore)3.395 F .895(ground, or the)-.15 F F1(kill)3.395 E F0 .894(command to kill it.)3.395 F(A)5.894 E F1(^Z) -3.394 E F0(tak)3.394 E(es)-.1 E(ef)108 309.6 Q .948(fect immediately) +3.394 E F0(tak)3.394 E(es)-.1 E(ef)108 501.6 Q .948(fect immediately) -.25 F 3.448(,a)-.65 G .948(nd has the additional side ef)-3.448 F .948 (fect of causing pending output and typeahead to be dis-)-.25 F(carded.) -108 321.6 Q .777(There are a number of w)108 338.4 R .777 +108 513.6 Q .777(There are a number of w)108 530.4 R .777 (ays to refer to a job in the shell.)-.1 F .777(The character)5.777 F F1 -(%)3.277 E F0 .777(introduces a job speci\214cation)3.277 F(\()108 350.4 -Q F2(jobspec)A F0 3.457(\). Job)B(number)3.457 E F2(n)3.817 E F0 .957 +(%)3.277 E F0 .777(introduces a job speci\214cation)3.277 F(\()108 542.4 +Q F4(jobspec)A F0 3.457(\). Job)B(number)3.457 E F4(n)3.817 E F0 .957 (may be referred to as)3.697 F F1(%n)3.457 E F0 5.957(.A)C .957 (job may also be referred to using a pre\214x of the)-2.5 F .59(name us\ ed to start it, or using a substring that appears in its command line.) -108 362.4 R -.15(Fo)5.59 G 3.09(re).15 G(xample,)-3.24 E F1(%ce)3.09 E -F0 .59(refers to a)3.09 F(stopped)108 374.4 Q F1(ce)3.463 E F0(job)3.463 +108 554.4 R -.15(Fo)5.59 G 3.09(re).15 G(xample,)-3.24 E F1(%ce)3.09 E +F0 .59(refers to a)3.09 F(stopped)108 566.4 Q F1(ce)3.463 E F0(job)3.463 E 5.963(.I)-.4 G 3.463(fap)-5.963 G .963 (re\214x matches more than one job,)-3.463 F F1(bash)3.463 E F0 .963 (reports an error)3.463 F 5.963(.U)-.55 G(sing)-5.963 E F1(%?ce)3.463 E F0 3.464(,o)C 3.464(nt)-3.464 G .964(he other)-3.464 F .087 -(hand, refers to an)108 386.4 R 2.587(yj)-.15 G .087 +(hand, refers to an)108 578.4 R 2.587(yj)-.15 G .087 (ob containing the string)-2.587 F F1(ce)2.587 E F0 .087 (in its command line.)2.587 F .087 -(If the substring matches more than one)5.087 F(job,)108 398.4 Q F1 +(If the substring matches more than one)5.087 F(job,)108 590.4 Q F1 (bash)2.518 E F0 .018(reports an error)2.518 F 5.018(.T)-.55 G .018 (he symbols)-5.018 F F1(%%)2.518 E F0(and)2.518 E F1(%+)2.518 E F0 .018 (refer to the shell')2.518 F 2.518(sn)-.55 G .018(otion of the)-2.518 F -F2(curr)2.518 E .018(ent job)-.37 F F0 2.518(,w).23 G .018(hich is) --2.518 F .495(the last job stopped while it w)108 410.4 R .495 +F4(curr)2.518 E .018(ent job)-.37 F F0 2.518(,w).23 G .018(hich is) +-2.518 F .495(the last job stopped while it w)108 602.4 R .495 (as in the fore)-.1 F .495(ground or started in the background.)-.15 F -(The)5.494 E F2(pr)4.244 E -.15(ev)-.37 G .494(ious job).15 F F0 .494 -(may be)3.224 F .787(referenced using)108 422.4 R F1<25ad>3.287 E F0 +(The)5.494 E F4(pr)4.244 E -.15(ev)-.37 G .494(ious job).15 F F0 .494 +(may be)3.224 F .787(referenced using)108 614.4 R F1<25ad>3.287 E F0 5.787(.I)C 3.287(ft)-5.787 G .787(here is only a single job,)-3.287 F F1 (%+)3.287 E F0(and)3.287 E F1<25ad>3.287 E F0 .788 (can both be used to refer to that job)3.287 F 5.788(.I)-.4 G(n)-5.788 E -.257(output pertaining to jobs \(e.g., the output of the)108 434.4 R F1 +.257(output pertaining to jobs \(e.g., the output of the)108 626.4 R F1 (jobs)2.756 E F0 .256(command\), the current job is al)2.756 F -.1(wa) -.1 G .256(ys \215agged with a).1 F F1(+)2.756 E F0(,)A .41(and the pre) -108 446.4 R .41(vious job with a)-.25 F F12.91 E F0 5.41(.A)C .411 +108 638.4 R .41(vious job with a)-.25 F F12.91 E F0 5.41(.A)C .411 (single % \(with no accompan)-2.5 F .411 (ying job speci\214cation\) also refers to the cur)-.15 F(-)-.2 E -(rent job)108 458.4 Q(.)-.4 E .444 -(Simply naming a job can be used to bring it into the fore)108 475.2 R +(rent job)108 650.4 Q(.)-.4 E .444 +(Simply naming a job can be used to bring it into the fore)108 667.2 R (ground:)-.15 E F1(%1)2.943 E F0 .443(is a synon)2.943 F .443(ym for) -.15 F F1 -.63(``)2.943 G .443(fg %1').63 F(')-.63 E F0 2.943(,b)C (ringing)-2.943 E 1.472(job 1 from the background into the fore)108 -487.2 R 3.972(ground. Similarly)-.15 F(,)-.65 E F1 -.63(``)3.973 G 1.473 +679.2 R 3.972(ground. Similarly)-.15 F(,)-.65 E F1 -.63(``)3.973 G 1.473 (%1 &').63 F(')-.63 E F0 1.473(resumes job 1 in the background,)3.973 F -(equi)108 499.2 Q -.25(va)-.25 G(lent to).25 E F1 -.63(``)2.5 G(bg %1') -.63 E(')-.63 E F0(.)A .131(The shell learns immediately whene)108 516 R +(equi)108 691.2 Q -.25(va)-.25 G(lent to).25 E F1 -.63(``)2.5 G(bg %1') +.63 E(')-.63 E F0(.)A .131(The shell learns immediately whene)108 708 R -.15(ve)-.25 G 2.631(raj).15 G .131(ob changes state.)-2.631 F(Normally) 5.131 E(,)-.65 E F1(bash)2.631 E F0 -.1(wa)2.63 G .13 (its until it is about to print a).1 F .157 -(prompt before reporting changes in a job')108 528 R 2.657(ss)-.55 G +(prompt before reporting changes in a job')108 720 R 2.657(ss)-.55 G .157(tatus so as to not interrupt an)-2.657 F 2.658(yo)-.15 G .158 (ther output.)-2.658 F .158(If the)5.158 F F12.658 E F0 .158 -(option to)2.658 F(the)108 540 Q F1(set)3.952 E F0 -.2(bu)3.952 G 1.452 -(iltin command is enabled,).2 F F1(bash)3.952 E F0 1.451 +(option to)2.658 F(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 +G(mber 24).15 E(34)185.545 E 0 Cg EP +%%Page: 35 35 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(the)108 84 Q/F1 10/Times-Bold@0 SF(set)3.952 E F0 -.2(bu)3.952 G +1.452(iltin command is enabled,).2 F F1(bash)3.952 E F0 1.451 (reports such changes immediately)3.952 F 6.451(.A)-.65 G 1.751 -.15 -(ny t)-6.451 H 1.451(rap on).15 F F3(SIGCHLD)3.951 E F0(is)3.701 E -.15 -(exe)108 552 S(cuted for each child that e).15 E(xits.)-.15 E .032 -(If an attempt to e)108 568.8 R(xit)-.15 E F1(bash)2.532 E F0 .032 -(is made while jobs are stopped \(or)2.532 F 2.533(,i)-.4 G 2.533(ft) --2.533 G(he)-2.533 E F1(checkjobs)2.533 E F0 .033 -(shell option has been enabled)2.533 F 2.02(using the)108 580.8 R F1 +(ny t)-6.451 H 1.451(rap on).15 F/F2 9/Times-Bold@0 SF(SIGCHLD)3.951 E +F0(is)3.701 E -.15(exe)108 96 S(cuted for each child that e).15 E(xits.) +-.15 E .032(If an attempt to e)108 112.8 R(xit)-.15 E F1(bash)2.532 E F0 +.032(is made while jobs are stopped \(or)2.532 F 2.533(,i)-.4 G 2.533 +(ft)-2.533 G(he)-2.533 E F1(checkjobs)2.533 E F0 .033 +(shell option has been enabled)2.533 F 2.02(using the)108 124.8 R F1 (shopt)4.52 E F0 -.2(bu)4.52 G 2.02 (iltin, running\), the shell prints a w).2 F 2.019 (arning message, and, if the)-.1 F F1(checkjobs)4.519 E F0 2.019 (option is)4.519 F .458(enabled, lists the jobs and their statuses.)108 -592.8 R(The)5.458 E F1(jobs)2.958 E F0 .459 +136.8 R(The)5.458 E F1(jobs)2.958 E F0 .459 (command may then be used to inspect their status.)2.958 F .459(If a) -5.459 F .604(second attempt to e)108 604.8 R .604 +5.459 F .604(second attempt to e)108 148.8 R .604 (xit is made without an interv)-.15 F .604 (ening command, the shell does not print another w)-.15 F(arning,)-.1 E -(and an)108 616.8 Q 2.5(ys)-.15 G(topped jobs are terminated.)-2.5 E/F6 -10.95/Times-Bold@0 SF(PR)72 633.6 Q(OMPTING)-.329 E F0 .644(When e)108 -645.6 R -.15(xe)-.15 G .644(cuting interacti).15 F -.15(ve)-.25 G(ly).15 +(and an)108 160.8 Q 2.5(ys)-.15 G(topped jobs are terminated.)-2.5 E/F3 +10.95/Times-Bold@0 SF(PR)72 177.6 Q(OMPTING)-.329 E F0 .644(When e)108 +189.6 R -.15(xe)-.15 G .644(cuting interacti).15 F -.15(ve)-.25 G(ly).15 E(,)-.65 E F1(bash)3.144 E F0 .645(displays the primary prompt)3.145 F -F3(PS1)3.145 E F0 .645(when it is ready to read a command,)2.895 F 1.826 -(and the secondary prompt)108 657.6 R F3(PS2)4.326 E F0 1.825 +F2(PS1)3.145 E F0 .645(when it is ready to read a command,)2.895 F 1.826 +(and the secondary prompt)108 201.6 R F2(PS2)4.326 E F0 1.825 (when it needs more input to complete a command.)4.076 F F1(Bash)6.825 E F0(allo)4.325 E 1.825(ws these)-.25 F 1.499(prompt strings to be custom\ ized by inserting a number of backslash-escaped special characters that\ - are)108 669.6 R(decoded as follo)108 681.6 Q(ws:)-.25 E F1(\\a)144 -693.6 Q F0(an ASCII bell character \(07\))28.22 E F1(\\d)144 705.6 Q F0 + are)108 213.6 R(decoded as follo)108 225.6 Q(ws:)-.25 E F1(\\a)144 +237.6 Q F0(an ASCII bell character \(07\))28.22 E F1(\\d)144 249.6 Q F0 (the date in "W)27.66 E(eekday Month Date" format \(e.g., "T)-.8 E -(ue May 26"\))-.45 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(34) -198.165 E 0 Cg EP -%%Page: 35 35 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(\\D{)144 84 Q/F2 10/Times-Italic@0 SF -(format)A F1(})A F0(the)180 96 Q F2(format)3.927 E F0 1.427 -(is passed to)3.927 F F2(strftime)3.927 E F0 1.427 +(ue May 26"\))-.45 E F1(\\D{)144 261.6 Q/F4 10/Times-Italic@0 SF(format) +A F1(})A F0(the)180 273.6 Q F4(format)3.927 E F0 1.427(is passed to) +3.927 F F4(strftime)3.927 E F0 1.427 (\(3\) and the result is inserted into the prompt string; an)B(empty)180 -108 Q F2(format)2.5 E F0 +285.6 Q F4(format)2.5 E F0 (results in a locale-speci\214c time representation.)2.5 E -(The braces are required)5 E F1(\\e)144 120 Q F0 -(an ASCII escape character \(033\))28.78 E F1(\\h)144 132 Q F0 -(the hostname up to the \214rst `.)27.66 E(')-.7 E F1(\\H)144 144 Q F0 -(the hostname)25.44 E F1(\\j)144 156 Q F0 +(The braces are required)5 E F1(\\e)144 297.6 Q F0 +(an ASCII escape character \(033\))28.78 E F1(\\h)144 309.6 Q F0 +(the hostname up to the \214rst `.)27.66 E(')-.7 E F1(\\H)144 321.6 Q F0 +(the hostname)25.44 E F1(\\j)144 333.6 Q F0 (the number of jobs currently managed by the shell)29.89 E F1(\\l)144 -168 Q F0(the basename of the shell')30.44 E 2.5(st)-.55 G(erminal de) --2.5 E(vice name)-.25 E F1(\\n)144 180 Q F0(ne)27.66 E(wline)-.25 E F1 -(\\r)144 192 Q F0(carriage return)28.78 E F1(\\s)144 204 Q F0 +345.6 Q F0(the basename of the shell')30.44 E 2.5(st)-.55 G(erminal de) +-2.5 E(vice name)-.25 E F1(\\n)144 357.6 Q F0(ne)27.66 E(wline)-.25 E F1 +(\\r)144 369.6 Q F0(carriage return)28.78 E F1(\\s)144 381.6 Q F0 (the name of the shell, the basename of)29.33 E F1($0)2.5 E F0 (\(the portion follo)2.5 E(wing the \214nal slash\))-.25 E F1(\\t)144 -216 Q F0(the current time in 24-hour HH:MM:SS format)29.89 E F1(\\T)144 -228 Q F0(the current time in 12-hour HH:MM:SS format)26.55 E F1(\\@)144 -240 Q F0(the current time in 12-hour am/pm format)23.92 E F1(\\A)144 252 -Q F0(the current time in 24-hour HH:MM format)26 E F1(\\u)144 264 Q F0 -(the username of the current user)27.66 E F1(\\v)144 276 Q F0(the v) -28.22 E(ersion of)-.15 E F1(bash)2.5 E F0(\(e.g., 2.00\))2.5 E F1(\\V) -144 288 Q F0(the release of)26 E F1(bash)2.5 E F0 2.5(,v)C -(ersion + patch le)-2.65 E -.15(ve)-.25 G 2.5(l\().15 G(e.g., 2.00.0\)) --2.5 E F1(\\w)144 300 Q F0 .115(the current w)26 F .115 -(orking directory)-.1 F 2.615(,w)-.65 G(ith)-2.615 E/F3 9/Times-Bold@0 -SF($HOME)2.615 E F0(abbre)2.365 E .116(viated with a tilde \(uses the v) --.25 F .116(alue of the)-.25 F F3(PR)180 312 Q(OMPT_DIR)-.27 E(TRIM)-.36 -E F0 -.25(va)2.25 G(riable\)).25 E F1(\\W)144 324 Q F0 +393.6 Q F0(the current time in 24-hour HH:MM:SS format)29.89 E F1(\\T) +144 405.6 Q F0(the current time in 12-hour HH:MM:SS format)26.55 E F1 +(\\@)144 417.6 Q F0(the current time in 12-hour am/pm format)23.92 E F1 +(\\A)144 429.6 Q F0(the current time in 24-hour HH:MM format)26 E F1 +(\\u)144 441.6 Q F0(the username of the current user)27.66 E F1(\\v)144 +453.6 Q F0(the v)28.22 E(ersion of)-.15 E F1(bash)2.5 E F0 +(\(e.g., 2.00\))2.5 E F1(\\V)144 465.6 Q F0(the release of)26 E F1(bash) +2.5 E F0 2.5(,v)C(ersion + patch le)-2.65 E -.15(ve)-.25 G 2.5(l\().15 G +(e.g., 2.00.0\))-2.5 E F1(\\w)144 477.6 Q F0 .115(the current w)26 F +.115(orking directory)-.1 F 2.615(,w)-.65 G(ith)-2.615 E F2($HOME)2.615 +E F0(abbre)2.365 E .116(viated with a tilde \(uses the v)-.25 F .116 +(alue of the)-.25 F F2(PR)180 489.6 Q(OMPT_DIR)-.27 E(TRIM)-.36 E F0 +-.25(va)2.25 G(riable\)).25 E F1(\\W)144 501.6 Q F0 (the basename of the current w)23.22 E(orking directory)-.1 E 2.5(,w) --.65 G(ith)-2.5 E F3($HOME)2.5 E F0(abbre)2.25 E(viated with a tilde) --.25 E F1(\\!)144 336 Q F0(the history number of this command)29.89 E F1 -(\\#)144 348 Q F0(the command number of this command)28.22 E F1(\\$)144 -360 Q F0(if the ef)28.22 E(fecti)-.25 E .3 -.15(ve U)-.25 H(ID is 0, a) -.15 E F1(#)2.5 E F0 2.5(,o)C(therwise a)-2.5 E F1($)2.5 E(\\)144 372 Q -F2(nnn)A F0(the character corresponding to the octal number)18.22 E F2 -(nnn)2.5 E F1(\\\\)144 384 Q F0 2.5(ab)30.44 G(ackslash)-2.5 E F1(\\[) -144 396 Q F0(be)29.89 E 1.257(gin a sequence of non-printing characters\ -, which could be used to embed a terminal)-.15 F -(control sequence into the prompt)180 408 Q F1(\\])144 420 Q F0 +-.65 G(ith)-2.5 E F2($HOME)2.5 E F0(abbre)2.25 E(viated with a tilde) +-.25 E F1(\\!)144 513.6 Q F0(the history number of this command)29.89 E +F1(\\#)144 525.6 Q F0(the command number of this command)28.22 E F1(\\$) +144 537.6 Q F0(if the ef)28.22 E(fecti)-.25 E .3 -.15(ve U)-.25 H +(ID is 0, a).15 E F1(#)2.5 E F0 2.5(,o)C(therwise a)-2.5 E F1($)2.5 E +(\\)144 549.6 Q F4(nnn)A F0 +(the character corresponding to the octal number)18.22 E F4(nnn)2.5 E F1 +(\\\\)144 561.6 Q F0 2.5(ab)30.44 G(ackslash)-2.5 E F1(\\[)144 573.6 Q +F0(be)29.89 E 1.257(gin a sequence of non-printing characters, which co\ +uld be used to embed a terminal)-.15 F(control sequence into the prompt) +180 585.6 Q F1(\\])144 597.6 Q F0 (end a sequence of non-printing characters)29.89 E .119 -(The command number and the history number are usually dif)108 436.8 R +(The command number and the history number are usually dif)108 614.4 R .12(ferent: the history number of a command is its)-.25 F 1.585(positio\ n in the history list, which may include commands restored from the his\ -tory \214le \(see)108 448.8 R F3(HIST)4.084 E(OR)-.162 E(Y)-.315 E F0 -(belo)108 460.8 Q .541(w\), while the command number is the position in\ +tory \214le \(see)108 626.4 R F2(HIST)4.084 E(OR)-.162 E(Y)-.315 E F0 +(belo)108 638.4 Q .541(w\), while the command number is the position in\ the sequence of commands e)-.25 F -.15(xe)-.15 G .541 -(cuted during the cur).15 F(-)-.2 E .546(rent shell session.)108 472.8 R +(cuted during the cur).15 F(-)-.2 E .546(rent shell session.)108 650.4 R .546(After the string is decoded, it is e)5.546 F .546 (xpanded via parameter e)-.15 F .546(xpansion, command substitu-)-.15 F -.351(tion, arithmetic e)108 484.8 R .352(xpansion, and quote remo)-.15 F +.351(tion, arithmetic e)108 662.4 R .352(xpansion, and quote remo)-.15 F -.25(va)-.15 G .352(l, subject to the v).25 F .352(alue of the)-.25 F F1 (pr)2.852 E(omptv)-.18 E(ars)-.1 E F0 .352(shell option \(see the)2.852 -F(description of the)108 496.8 Q F1(shopt)2.5 E F0(command under)2.5 E -F3(SHELL B)2.5 E(UIL)-.09 E(TIN COMMANDS)-.828 E F0(belo)2.25 E(w\).) --.25 E/F4 10.95/Times-Bold@0 SF(READLINE)72 513.6 Q F0 .151 +F(description of the)108 674.4 Q F1(shopt)2.5 E F0(command under)2.5 E +F2(SHELL B)2.5 E(UIL)-.09 E(TIN COMMANDS)-.828 E F0(belo)2.25 E(w\).) +-.25 E F3(READLINE)72 691.2 Q F0 .151 (This is the library that handles reading input when using an interacti) -108 525.6 R .45 -.15(ve s)-.25 H .15(hell, unless the).15 F F1 -(\255\255noediting)2.65 E F0(option)2.65 E 1.208(is gi)108 537.6 R -.15 +108 703.2 R .45 -.15(ve s)-.25 H .15(hell, unless the).15 F F1 +(\255\255noediting)2.65 E F0(option)2.65 E 1.208(is gi)108 715.2 R -.15 (ve)-.25 G 3.708(na).15 G 3.708(ts)-3.708 G 1.208(hell in)-3.708 F -.2 (vo)-.4 G 3.708(cation. Line).2 F 1.208 (editing is also used when using the)3.708 F F13.709 E F0 1.209 (option to the)3.709 F F1 -.18(re)3.709 G(ad).18 E F0 -.2(bu)3.709 G -3.709(iltin. By).2 F(def)108 549.6 Q .851 +3.709(iltin. By).2 F(def)108 727.2 Q .851 (ault, the line editing commands are similar to those of Emacs.)-.1 F 3.351(Av)5.851 G .851(i-style line editing interf)-3.351 F .851 -(ace is also)-.1 F -.2(av)108 561.6 S 3.35(ailable. Line)-.05 F .85 +(ace is also)-.1 F(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 +G(mber 24).15 E(35)185.545 E 0 Cg EP +%%Page: 36 36 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E -.2(av)108 84 S 3.35(ailable. Line)-.05 F .85 (editing can be enabled at an)3.35 F 3.35(yt)-.15 G .85(ime using the) --3.35 F F1 .85(\255o emacs)3.35 F F0(or)3.35 E F1 .85(\255o vi)3.35 F F0 -.85(options to the)3.35 F F1(set)3.35 E F0 -.2(bu)3.35 G(iltin).2 E -(\(see)108 573.6 Q F3 .763(SHELL B)3.263 F(UIL)-.09 E .763(TIN COMMANDS) --.828 F F0(belo)3.013 E 3.263(w\). T)-.25 F 3.263(ot)-.8 G .763(urn of) --3.263 F 3.263(fl)-.25 G .763 +-3.35 F/F1 10/Times-Bold@0 SF .85(\255o emacs)3.35 F F0(or)3.35 E F1 .85 +(\255o vi)3.35 F F0 .85(options to the)3.35 F F1(set)3.35 E F0 -.2(bu) +3.35 G(iltin).2 E(\(see)108 96 Q/F2 9/Times-Bold@0 SF .763(SHELL B)3.263 +F(UIL)-.09 E .763(TIN COMMANDS)-.828 F F0(belo)3.013 E 3.263(w\). T)-.25 +F 3.263(ot)-.8 G .763(urn of)-3.263 F 3.263(fl)-.25 G .763 (ine editing after the shell is running, use the)-3.263 F F1(+o)3.262 E -(emacs)108 585.6 Q F0(or)2.5 E F1(+o vi)2.5 E F0(options to the)2.5 E F1 -(set)2.5 E F0 -.2(bu)2.5 G(iltin.).2 E F1(Readline Notation)87 602.4 Q +(emacs)108 108 Q F0(or)2.5 E F1(+o vi)2.5 E F0(options to the)2.5 E F1 +(set)2.5 E F0 -.2(bu)2.5 G(iltin.).2 E F1(Readline Notation)87 124.8 Q F0 .463(In this section, the Emacs-style notation is used to denote k) -108 614.4 R -.15(ey)-.1 G(strok).15 E 2.963(es. Control)-.1 F -.1(ke) -2.963 G .463(ys are denoted by C\255)-.05 F F2 -.1(ke)C(y)-.2 E F0(,)A -1.153(e.g., C\255n means Control\255N.)108 626.4 R(Similarly)6.153 E(,) --.65 E F2(meta)4.033 E F0 -.1(ke)3.913 G 1.153(ys are denoted by M\255) --.05 F F2 -.1(ke)C(y)-.2 E F0 3.652(,s)C 3.652(oM)-3.652 G 1.152 -(\255x means Meta\255X.)-3.652 F(\(On)6.152 E -.1(ke)108 638.4 S .83 -(yboards without a)-.05 F F2(meta)3.71 E F0 -.1(ke)3.59 G 2.13 -.65 -(y, M)-.05 H.65 E F2(x)A F0 .83(means ESC)3.33 F F2(x)3.33 E F0 3.33 -(,i)C .831(.e., press the Escape k)-3.33 F 1.131 -.15(ey t)-.1 H .831 -(hen the).15 F F2(x)4.101 E F0 -.1(ke)3.861 G 4.631 -.65(y. T)-.05 H -.831(his mak).65 F(es)-.1 E .6(ESC the)108 650.4 R F2 .6(meta pr)3.1 F -(e\214x)-.37 E F0 5.6(.T)C .6(he combination M\255C\255)-5.6 F F2(x)A F0 -.599(means ESC\255Control\255)3.099 F F2(x)A F0 3.099(,o)C 3.099(rp) +108 136.8 R -.15(ey)-.1 G(strok).15 E 2.963(es. Control)-.1 F -.1(ke) +2.963 G .463(ys are denoted by C\255)-.05 F/F3 10/Times-Italic@0 SF -.1 +(ke)C(y)-.2 E F0(,)A 1.153(e.g., C\255n means Control\255N.)108 148.8 R +(Similarly)6.153 E(,)-.65 E F3(meta)4.033 E F0 -.1(ke)3.913 G 1.153 +(ys are denoted by M\255)-.05 F F3 -.1(ke)C(y)-.2 E F0 3.652(,s)C 3.652 +(oM)-3.652 G 1.152(\255x means Meta\255X.)-3.652 F(\(On)6.152 E -.1(ke) +108 160.8 S .83(yboards without a)-.05 F F3(meta)3.71 E F0 -.1(ke)3.59 G +2.13 -.65(y, M)-.05 H.65 E F3(x)A F0 .83(means ESC)3.33 F F3(x)3.33 +E F0 3.33(,i)C .831(.e., press the Escape k)-3.33 F 1.131 -.15(ey t)-.1 +H .831(hen the).15 F F3(x)4.101 E F0 -.1(ke)3.861 G 4.631 -.65(y. T)-.05 +H .831(his mak).65 F(es)-.1 E .6(ESC the)108 172.8 R F3 .6(meta pr)3.1 F +(e\214x)-.37 E F0 5.6(.T)C .6(he combination M\255C\255)-5.6 F F3(x)A F0 +.599(means ESC\255Control\255)3.099 F F3(x)A F0 3.099(,o)C 3.099(rp) -3.099 G .599(ress the Escape k)-3.099 F .899 -.15(ey t)-.1 H .599 -(hen hold).15 F(the Control k)108 662.4 Q .3 -.15(ey w)-.1 H -(hile pressing the).15 E F2(x)3.27 E F0 -.1(ke)3.03 G -.65(y.)-.05 G(\)) -.65 E .619(Readline commands may be gi)108 679.2 R -.15(ve)-.25 G 3.119 -(nn).15 G(umeric)-3.119 E F2(ar)3.119 E(guments)-.37 E F0 3.119(,w).27 G +(hen hold).15 F(the Control k)108 184.8 Q .3 -.15(ey w)-.1 H +(hile pressing the).15 E F3(x)3.27 E F0 -.1(ke)3.03 G -.65(y.)-.05 G(\)) +.65 E .619(Readline commands may be gi)108 201.6 R -.15(ve)-.25 G 3.119 +(nn).15 G(umeric)-3.119 E F3(ar)3.119 E(guments)-.37 E F0 3.119(,w).27 G .619(hich normally act as a repeat count.)-3.119 F(Sometimes,)5.62 E(ho) -108 691.2 Q(we)-.25 E -.15(ve)-.25 G 1.419 -.4(r, i).15 H 3.119(ti).4 G +108 213.6 Q(we)-.25 E -.15(ve)-.25 G 1.419 -.4(r, i).15 H 3.119(ti).4 G 3.119(st)-3.119 G .619(he sign of the ar)-3.119 F .619 (gument that is signi\214cant.)-.18 F -.15(Pa)5.619 G .619(ssing a ne) .15 F -.05(ga)-.15 G(ti).05 E .919 -.15(ve a)-.25 H -.18(rg).15 G .619 -(ument to a command that).18 F 1.018(acts in the forw)108 703.2 R 1.018 +(ument to a command that).18 F 1.018(acts in the forw)108 225.6 R 1.018 (ard direction \(e.g.,)-.1 F F1(kill\255line)3.518 E F0 3.518(\)c)C 1.018(auses that command to act in a backw)-3.518 F 1.019 -(ard direction.)-.1 F(Com-)6.019 E(mands whose beha)108 715.2 Q +(ard direction.)-.1 F(Com-)6.019 E(mands whose beha)108 237.6 Q (vior with ar)-.2 E(guments de)-.18 E(viates from this are noted belo) --.25 E -.65(w.)-.25 G(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(35) -198.165 E 0 Cg EP -%%Page: 36 36 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E .812(When a command is described as)108 84 R/F1 10/Times-Italic@0 -SF(killing)3.311 E F0(te)3.311 E .811(xt, the te)-.15 F .811 +-.25 E -.65(w.)-.25 G .812(When a command is described as)108 254.4 R F3 +(killing)3.311 E F0(te)3.311 E .811(xt, the te)-.15 F .811 (xt deleted is sa)-.15 F -.15(ve)-.2 G 3.311(df).15 G .811 -(or possible future retrie)-3.311 F -.25(va)-.25 G 3.311(l\().25 G F1 -(yank-)-3.311 E(ing)108 96 Q F0 2.529(\). The)B .029(killed te)2.529 F -.029(xt is sa)-.15 F -.15(ve)-.2 G 2.529(di).15 G 2.529(na)-2.529 G F1 +(or possible future retrie)-3.311 F -.25(va)-.25 G 3.311(l\().25 G F3 +(yank-)-3.311 E(ing)108 266.4 Q F0 2.529(\). The)B .029(killed te)2.529 +F .029(xt is sa)-.15 F -.15(ve)-.2 G 2.529(di).15 G 2.529(na)-2.529 G F3 .029(kill ring)B F0 5.029(.C)C(onsecuti)-5.029 E .329 -.15(ve k)-.25 H .029(ills cause the te).15 F .029(xt to be accumulated into one unit,) --.15 F .567(which can be yank)108 108 R .567(ed all at once.)-.1 F .567 -(Commands which do not kill te)5.567 F .567 +-.15 F .567(which can be yank)108 278.4 R .567(ed all at once.)-.1 F +.567(Commands which do not kill te)5.567 F .567 (xt separate the chunks of te)-.15 F .567(xt on the kill)-.15 F(ring.) -108 120 Q/F2 10/Times-Bold@0 SF(Readline Initialization)87 136.8 Q F0 -.091(Readline is customized by putting commands in an initialization \ -\214le \(the)108 148.8 R F1(inputr)2.591 E(c)-.37 E F0 2.591 -(\214le\). The)2.591 F .092(name of this \214le)2.591 F .197(is tak)108 -160.8 R .196(en from the v)-.1 F .196(alue of the)-.25 F/F3 9 -/Times-Bold@0 SF(INPUTRC)2.696 E F0 -.25(va)2.446 G 2.696(riable. If).25 -F .196(that v)2.696 F .196(ariable is unset, the def)-.25 F .196 -(ault is)-.1 F F1(~/.inputr)2.696 E(c)-.37 E F0 5.196(.W).31 G .196 -(hen a)-5.196 F 1.034(program which uses the readline library starts up\ -, the initialization \214le is read, and the k)108 172.8 R 1.335 -.15 -(ey b)-.1 H 1.035(indings and).15 F -.25(va)108 184.8 S 1.15 -(riables are set.).25 F 1.15(There are only a fe)6.15 F 3.649(wb)-.25 G -1.149(asic constructs allo)-3.649 F 1.149 +108 290.4 Q F1(Readline Initialization)87 307.2 Q F0 .091(Readline is c\ +ustomized by putting commands in an initialization \214le \(the)108 +319.2 R F3(inputr)2.591 E(c)-.37 E F0 2.591(\214le\). The)2.591 F .092 +(name of this \214le)2.591 F .197(is tak)108 331.2 R .196(en from the v) +-.1 F .196(alue of the)-.25 F F2(INPUTRC)2.696 E F0 -.25(va)2.446 G +2.696(riable. If).25 F .196(that v)2.696 F .196 +(ariable is unset, the def)-.25 F .196(ault is)-.1 F F3(~/.inputr)2.696 +E(c)-.37 E F0 5.196(.W).31 G .196(hen a)-5.196 F 1.034(program which us\ +es the readline library starts up, the initialization \214le is read, a\ +nd the k)108 343.2 R 1.335 -.15(ey b)-.1 H 1.035(indings and).15 F -.25 +(va)108 355.2 S 1.15(riables are set.).25 F 1.15(There are only a fe) +6.15 F 3.649(wb)-.25 G 1.149(asic constructs allo)-3.649 F 1.149 (wed in the readline initialization \214le.)-.25 F(Blank)6.149 E .736 -(lines are ignored.)108 196.8 R .737(Lines be)5.737 F .737 -(ginning with a)-.15 F F2(#)3.237 E F0 .737(are comments.)3.237 F .737 -(Lines be)5.737 F .737(ginning with a)-.15 F F2($)3.237 E F0 .737 -(indicate conditional)3.237 F 2.5(constructs. Other)108 208.8 R +(lines are ignored.)108 367.2 R .737(Lines be)5.737 F .737 +(ginning with a)-.15 F F1(#)3.237 E F0 .737(are comments.)3.237 F .737 +(Lines be)5.737 F .737(ginning with a)-.15 F F1($)3.237 E F0 .737 +(indicate conditional)3.237 F 2.5(constructs. Other)108 379.2 R (lines denote k)2.5 E .3 -.15(ey b)-.1 H(indings and v).15 E -(ariable settings.)-.25 E .987(The def)108 225.6 R .987(ault k)-.1 F --.15(ey)-.1 G .987(-bindings may be changed with an).15 F F1(inputr) -3.497 E(c)-.37 E F0 3.487(\214le. Other)3.797 F .987 -(programs that use this library may)3.487 F(add their o)108 237.6 Q -(wn commands and bindings.)-.25 E -.15(Fo)108 254.4 S 2.5(re).15 G -(xample, placing)-2.65 E(M\255Control\255u: uni)144 271.2 Q -.15(ve)-.25 -G(rsal\255ar).15 E(gument)-.18 E(or)108 283.2 Q(C\255Meta\255u: uni)144 -295.2 Q -.15(ve)-.25 G(rsal\255ar).15 E(gument)-.18 E(into the)108 307.2 -Q F1(inputr)2.51 E(c)-.37 E F0 -.1(wo)2.81 G(uld mak).1 E 2.5(eM)-.1 G -(\255C\255u e)-2.5 E -.15(xe)-.15 G(cute the readline command).15 E F1 +(ariable settings.)-.25 E .987(The def)108 396 R .987(ault k)-.1 F -.15 +(ey)-.1 G .987(-bindings may be changed with an).15 F F3(inputr)3.497 E +(c)-.37 E F0 3.487(\214le. Other)3.797 F .987 +(programs that use this library may)3.487 F(add their o)108 408 Q +(wn commands and bindings.)-.25 E -.15(Fo)108 424.8 S 2.5(re).15 G +(xample, placing)-2.65 E(M\255Control\255u: uni)144 441.6 Q -.15(ve)-.25 +G(rsal\255ar).15 E(gument)-.18 E(or)108 453.6 Q(C\255Meta\255u: uni)144 +465.6 Q -.15(ve)-.25 G(rsal\255ar).15 E(gument)-.18 E(into the)108 477.6 +Q F3(inputr)2.51 E(c)-.37 E F0 -.1(wo)2.81 G(uld mak).1 E 2.5(eM)-.1 G +(\255C\255u e)-2.5 E -.15(xe)-.15 G(cute the readline command).15 E F3 (univer)2.5 E(sal\255ar)-.1 E(gument)-.37 E F0(.).68 E 1.26(The follo) -108 324 R 1.261(wing symbolic character names are recognized:)-.25 F F1 --.4(RU)3.761 G(BOUT).4 E F0(,)1.27 E F1(DEL)3.761 E F0(,).53 E F1(ESC) -3.761 E F0(,).72 E F1(LFD)3.761 E F0(,).28 E F1(NEWLINE)3.761 E F0(,).73 -E F1(RET)3.761 E F0(,)1.27 E F1(RETURN)108 336 Q F0(,)1.1 E F1(SPC)2.5 E -F0(,).72 E F1(SP)2.5 E -.3(AC)-.9 G(E).3 E F0 2.5(,a).73 G(nd)-2.5 E F1 --.5(TA)2.5 G(B).5 E F0(.).27 E .209 -(In addition to command names, readline allo)108 352.8 R .209(ws k)-.25 +108 494.4 R 1.261(wing symbolic character names are recognized:)-.25 F +F3 -.4(RU)3.761 G(BOUT).4 E F0(,)1.27 E F3(DEL)3.761 E F0(,).53 E F3 +(ESC)3.761 E F0(,).72 E F3(LFD)3.761 E F0(,).28 E F3(NEWLINE)3.761 E F0 +(,).73 E F3(RET)3.761 E F0(,)1.27 E F3(RETURN)108 506.4 Q F0(,)1.1 E F3 +(SPC)2.5 E F0(,).72 E F3(SP)2.5 E -.3(AC)-.9 G(E).3 E F0 2.5(,a).73 G +(nd)-2.5 E F3 -.5(TA)2.5 G(B).5 E F0(.).27 E .209 +(In addition to command names, readline allo)108 523.2 R .209(ws k)-.25 F -.15(ey)-.1 G 2.709(st).15 G 2.709(ob)-2.709 G 2.709(eb)-2.709 G .209 (ound to a string that is inserted when the k)-2.709 F .509 -.15(ey i) --.1 H(s).15 E(pressed \(a)108 364.8 Q F1(macr)2.5 E(o)-.45 E F0(\).)A F2 -(Readline K)87 381.6 Q(ey Bindings)-.25 E F0 .366 -(The syntax for controlling k)108 393.6 R .666 -.15(ey b)-.1 H .366 -(indings in the).15 F F1(inputr)2.876 E(c)-.37 E F0 .366 +-.1 H(s).15 E(pressed \(a)108 535.2 Q F3(macr)2.5 E(o)-.45 E F0(\).)A F1 +(Readline K)87 552 Q(ey Bindings)-.25 E F0 .366 +(The syntax for controlling k)108 564 R .666 -.15(ey b)-.1 H .366 +(indings in the).15 F F3(inputr)2.876 E(c)-.37 E F0 .366 (\214le is simple.)3.176 F .366(All that is required is the name of the) -5.366 F .383(command or the te)108 405.6 R .383(xt of a macro and a k) --.15 F .683 -.15(ey s)-.1 H .383 +5.366 F .383(command or the te)108 576 R .383(xt of a macro and a k)-.15 +F .683 -.15(ey s)-.1 H .383 (equence to which it should be bound. The name may be speci-).15 F .853 -(\214ed in one of tw)108 417.6 R 3.353(ow)-.1 G .853 -(ays: as a symbolic k)-3.453 F 1.153 -.15(ey n)-.1 H .853 -(ame, possibly with).15 F F1(Meta\255)3.353 E F0(or)3.353 E F1(Contr) -3.353 E(ol\255)-.45 E F0(pre\214x)3.353 E .853(es, or as a k)-.15 F -.15 -(ey)-.1 G(sequence.)108 429.6 Q 1.542(When using the form)108 446.4 R F2 --.1(ke)4.042 G(yname).1 E F0(:)A F1(function\255name).833 E F0(or)4.042 -E F1(macr)4.042 E(o)-.45 E F0(,)A F1 -.1(ke)4.042 G(yname)-.2 E F0 1.542 -(is the name of a k)4.222 F 1.841 -.15(ey s)-.1 H 1.541(pelled out in) -.15 F 2.5(English. F)108 458.4 R(or e)-.15 E(xample:)-.15 E -(Control-u: uni)144 482.4 Q -.15(ve)-.25 G(rsal\255ar).15 E(gument)-.18 -E(Meta-Rubout: backw)144 494.4 Q(ard-kill-w)-.1 E(ord)-.1 E -(Control-o: "> output")144 506.4 Q .698(In the abo)108 523.2 R .998 -.15 -(ve ex)-.15 H(ample,).15 E F1(C\255u)3.038 E F0 .698 -(is bound to the function)3.448 F F2(uni)3.198 E -.1(ve)-.1 G -(rsal\255ar).1 E(gument)-.1 E F0(,)A F1(M\255DEL)3.878 E F0 .698 -(is bound to the func-)3.728 F(tion)108 535.2 Q F2 -(backward\255kill\255w)2.759 E(ord)-.1 E F0 2.759(,a)C(nd)-2.759 E F1 +(\214ed in one of tw)108 588 R 3.353(ow)-.1 G .853(ays: as a symbolic k) +-3.453 F 1.153 -.15(ey n)-.1 H .853(ame, possibly with).15 F F3 +(Meta\255)3.353 E F0(or)3.353 E F3(Contr)3.353 E(ol\255)-.45 E F0 +(pre\214x)3.353 E .853(es, or as a k)-.15 F -.15(ey)-.1 G(sequence.)108 +600 Q 1.542(When using the form)108 616.8 R F1 -.1(ke)4.042 G(yname).1 E +F0(:)A F3(function\255name).833 E F0(or)4.042 E F3(macr)4.042 E(o)-.45 E +F0(,)A F3 -.1(ke)4.042 G(yname)-.2 E F0 1.542(is the name of a k)4.222 F +1.841 -.15(ey s)-.1 H 1.541(pelled out in).15 F 2.5(English. F)108 628.8 +R(or e)-.15 E(xample:)-.15 E(Control-u: uni)144 652.8 Q -.15(ve)-.25 G +(rsal\255ar).15 E(gument)-.18 E(Meta-Rubout: backw)144 664.8 Q +(ard-kill-w)-.1 E(ord)-.1 E(Control-o: "> output")144 676.8 Q .698 +(In the abo)108 693.6 R .998 -.15(ve ex)-.15 H(ample,).15 E F3(C\255u) +3.038 E F0 .698(is bound to the function)3.448 F F1(uni)3.198 E -.1(ve) +-.1 G(rsal\255ar).1 E(gument)-.1 E F0(,)A F3(M\255DEL)3.878 E F0 .698 +(is bound to the func-)3.728 F(tion)108 705.6 Q F1 +(backward\255kill\255w)2.759 E(ord)-.1 E F0 2.759(,a)C(nd)-2.759 E F3 (C\255o)2.599 E F0 .258(is bound to run the macro e)2.939 F .258 (xpressed on the right hand side \(that is, to)-.15 F(insert the te)108 -547.2 Q(xt)-.15 E/F4 10/Courier@0 SF 6(>o)2.5 G(utput)-6 E F0 -(into the line\).)2.5 E .055(In the second form,)108 564 R F2("k)2.555 E -(eyseq")-.1 E F0(:)A F1(function\255name).833 E F0(or)2.555 E F1(macr) -2.555 E(o)-.45 E F0(,)A F2 -.1(ke)2.555 G(yseq).1 E F0(dif)2.556 E .056 -(fers from)-.25 F F2 -.1(ke)2.556 G(yname).1 E F0(abo)2.556 E .356 -.15 -(ve i)-.15 H 2.556(nt).15 G .056(hat strings)-2.556 F 1.284 -(denoting an entire k)108 576 R 1.584 -.15(ey s)-.1 H 1.284(equence may\ - be speci\214ed by placing the sequence within double quotes.).15 F -(Some)6.284 E .385(GNU Emacs style k)108 588 R .685 -.15(ey e)-.1 H .385 -(scapes can be used, as in the follo).15 F .385(wing e)-.25 F .386 -(xample, b)-.15 F .386(ut the symbolic character names)-.2 F -(are not recognized.)108 600 Q("\\C\255u": uni)144 624 Q -.15(ve)-.25 G -(rsal\255ar).15 E(gument)-.18 E -("\\C\255x\\C\255r": re\255read\255init\255\214le)144 636 Q -("\\e[11~": "Function K)144 648 Q .3 -.15(ey 1)-.25 H(").15 E .315 -(In this e)108 664.8 R(xample,)-.15 E F1(C\255u)2.655 E F0 .315(is ag) -3.065 F .315(ain bound to the function)-.05 F F2(uni)2.815 E -.1(ve)-.1 -G(rsal\255ar).1 E(gument)-.1 E F0(.)A F1 .315(C\255x C\255r)5.155 F F0 -.314(is bound to the func-)3.544 F(tion)108 676.8 Q F2 -.18(re)2.5 G -.18 E(ead\255init\255\214le)-.18 E F0 2.5(,a)C(nd)-2.5 E F1 -(ESC [ 1 1 ~)3.01 E F0(is bound to insert the te)3.94 E(xt)-.15 E F4 -(Function Key 1)2.5 E F0(.)A -(The full set of GNU Emacs style escape sequences is)108 693.6 Q F2 -<5c43ad>144 705.6 Q F0(control pre\214x)20.3 E F2<5c4dad>144 717.6 Q F0 -(meta pre\214x)18.08 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(36) -198.165 E 0 Cg EP +717.6 Q(xt)-.15 E/F4 10/Courier@0 SF 6(>o)2.5 G(utput)-6 E F0 +(into the line\).)2.5 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve) +-.15 G(mber 24).15 E(36)185.545 E 0 Cg EP %%Page: 37 37 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(\\e)144 84 Q F0(an escape character)28.78 E -F1(\\\\)144 96 Q F0(backslash)30.44 E F1(\\")144 108 Q F0(literal ") -27.67 E F1<5c08>144 120 Q F0(literal \010)30.44 E(In addition to the GN\ -U Emacs style escape sequences, a second set of backslash escapes is a) -108 136.8 Q -.25(va)-.2 G(ilable:).25 E F1(\\a)144 148.8 Q F0 -(alert \(bell\))28.22 E F1(\\b)144 160.8 Q F0(backspace)27.66 E F1(\\d) -144 172.8 Q F0(delete)27.66 E F1(\\f)144 184.8 Q F0(form feed)29.89 E F1 -(\\n)144 196.8 Q F0(ne)27.66 E(wline)-.25 E F1(\\r)144 208.8 Q F0 -(carriage return)28.78 E F1(\\t)144 220.8 Q F0(horizontal tab)29.89 E F1 -(\\v)144 232.8 Q F0 -.15(ve)28.22 G(rtical tab).15 E F1(\\)144 244.8 Q -/F2 10/Times-Italic@0 SF(nnn)A F0(the eight-bit character whose v)18.22 -E(alue is the octal v)-.25 E(alue)-.25 E F2(nnn)2.5 E F0 -(\(one to three digits\))2.5 E F1(\\x)144 256.8 Q F2(HH)A F0 -(the eight-bit character whose v)13.78 E(alue is the he)-.25 E -(xadecimal v)-.15 E(alue)-.25 E F2(HH)2.5 E F0(\(one or tw)2.5 E 2.5(oh) --.1 G .3 -.15(ex d)-2.5 H(igits\)).15 E 1.141(When entering the te)108 -273.6 R 1.141(xt of a macro, single or double quotes must be used to in\ -dicate a macro de\214nition.)-.15 F .09(Unquoted te)108 285.6 R .09 -(xt is assumed to be a function name.)-.15 F .089(In the macro body) -5.089 F 2.589(,t)-.65 G .089(he backslash escapes described abo)-2.589 F --.15(ve)-.15 G(are e)108 297.6 Q 2.5(xpanded. Backslash)-.15 F -(will quote an)2.5 E 2.5(yo)-.15 G(ther character in the macro te)-2.5 E -(xt, including " and \010.)-.15 E F1(Bash)108 314.4 Q F0(allo)2.929 E -.429(ws the current readline k)-.25 F .729 -.15(ey b)-.1 H .429 +-.35 E .055(In the second form,)108 84 R/F1 10/Times-Bold@0 SF("k)2.555 +E(eyseq")-.1 E F0(:)A/F2 10/Times-Italic@0 SF(function\255name).833 E F0 +(or)2.555 E F2(macr)2.555 E(o)-.45 E F0(,)A F1 -.1(ke)2.555 G(yseq).1 E +F0(dif)2.556 E .056(fers from)-.25 F F1 -.1(ke)2.556 G(yname).1 E F0 +(abo)2.556 E .356 -.15(ve i)-.15 H 2.556(nt).15 G .056(hat strings) +-2.556 F 1.284(denoting an entire k)108 96 R 1.584 -.15(ey s)-.1 H 1.284 +(equence may be speci\214ed by placing the sequence within double quote\ +s.).15 F(Some)6.284 E .385(GNU Emacs style k)108 108 R .685 -.15(ey e) +-.1 H .385(scapes can be used, as in the follo).15 F .385(wing e)-.25 F +.386(xample, b)-.15 F .386(ut the symbolic character names)-.2 F +(are not recognized.)108 120 Q("\\C\255u": uni)144 144 Q -.15(ve)-.25 G +(rsal\255ar).15 E(gument)-.18 E +("\\C\255x\\C\255r": re\255read\255init\255\214le)144 156 Q +("\\e[11~": "Function K)144 168 Q .3 -.15(ey 1)-.25 H(").15 E .315 +(In this e)108 184.8 R(xample,)-.15 E F2(C\255u)2.655 E F0 .315(is ag) +3.065 F .315(ain bound to the function)-.05 F F1(uni)2.815 E -.1(ve)-.1 +G(rsal\255ar).1 E(gument)-.1 E F0(.)A F2 .315(C\255x C\255r)5.155 F F0 +.314(is bound to the func-)3.544 F(tion)108 196.8 Q F1 -.18(re)2.5 G +.18 E(ead\255init\255\214le)-.18 E F0 2.5(,a)C(nd)-2.5 E F2 +(ESC [ 1 1 ~)3.01 E F0(is bound to insert the te)3.94 E(xt)-.15 E/F3 10 +/Courier@0 SF(Function Key 1)2.5 E F0(.)A +(The full set of GNU Emacs style escape sequences is)108 213.6 Q F1 +<5c43ad>144 225.6 Q F0(control pre\214x)20.3 E F1<5c4dad>144 237.6 Q F0 +(meta pre\214x)18.08 E F1(\\e)144 249.6 Q F0(an escape character)28.78 E +F1(\\\\)144 261.6 Q F0(backslash)30.44 E F1(\\")144 273.6 Q F0 +(literal ")27.67 E F1<5c08>144 285.6 Q F0(literal \010)30.44 E(In addit\ +ion to the GNU Emacs style escape sequences, a second set of backslash \ +escapes is a)108 302.4 Q -.25(va)-.2 G(ilable:).25 E F1(\\a)144 314.4 Q +F0(alert \(bell\))28.22 E F1(\\b)144 326.4 Q F0(backspace)27.66 E F1 +(\\d)144 338.4 Q F0(delete)27.66 E F1(\\f)144 350.4 Q F0(form feed)29.89 +E F1(\\n)144 362.4 Q F0(ne)27.66 E(wline)-.25 E F1(\\r)144 374.4 Q F0 +(carriage return)28.78 E F1(\\t)144 386.4 Q F0(horizontal tab)29.89 E F1 +(\\v)144 398.4 Q F0 -.15(ve)28.22 G(rtical tab).15 E F1(\\)144 410.4 Q +F2(nnn)A F0(the eight-bit character whose v)18.22 E(alue is the octal v) +-.25 E(alue)-.25 E F2(nnn)2.5 E F0(\(one to three digits\))2.5 E F1(\\x) +144 422.4 Q F2(HH)A F0(the eight-bit character whose v)13.78 E +(alue is the he)-.25 E(xadecimal v)-.15 E(alue)-.25 E F2(HH)2.5 E F0 +(\(one or tw)2.5 E 2.5(oh)-.1 G .3 -.15(ex d)-2.5 H(igits\)).15 E 1.141 +(When entering the te)108 439.2 R 1.141(xt of a macro, single or double\ + quotes must be used to indicate a macro de\214nition.)-.15 F .09 +(Unquoted te)108 451.2 R .09(xt is assumed to be a function name.)-.15 F +.089(In the macro body)5.089 F 2.589(,t)-.65 G .089 +(he backslash escapes described abo)-2.589 F -.15(ve)-.15 G(are e)108 +463.2 Q 2.5(xpanded. Backslash)-.15 F(will quote an)2.5 E 2.5(yo)-.15 G +(ther character in the macro te)-2.5 E(xt, including " and \010.)-.15 E +F1(Bash)108 480 Q F0(allo)2.929 E .429(ws the current readline k)-.25 F +.729 -.15(ey b)-.1 H .429 (indings to be displayed or modi\214ed with the).15 F F1(bind)2.93 E F0 -.2(bu)2.93 G .43(iltin command.).2 F .046 -(The editing mode may be switched during interacti)108 326.4 R .346 -.15 +(The editing mode may be switched during interacti)108 492 R .346 -.15 (ve u)-.25 H .046(se by using the).15 F F12.545 E F0 .045 (option to the)2.545 F F1(set)2.545 E F0 -.2(bu)2.545 G .045 -(iltin command).2 F(\(see)108 338.4 Q/F3 9/Times-Bold@0 SF(SHELL B)2.5 E +(iltin command).2 F(\(see)108 504 Q/F4 9/Times-Bold@0 SF(SHELL B)2.5 E (UIL)-.09 E(TIN COMMANDS)-.828 E F0(belo)2.25 E(w\).)-.25 E F1 -(Readline V)87 355.2 Q(ariables)-.92 E F0 .043(Readline has v)108 367.2 +(Readline V)87 520.8 Q(ariables)-.92 E F0 .043(Readline has v)108 532.8 R .043(ariables that can be used to further customize its beha)-.25 F (vior)-.2 E 5.043(.A)-.55 G -.25(va)-2.5 G .043 -(riable may be set in the).25 F F2(inpu-)2.554 E(tr)108 379.2 Q(c)-.37 E -F0(\214le with a statement of the form)2.81 E F1(set)144 396 Q F2 +(riable may be set in the).25 F F2(inpu-)2.554 E(tr)108 544.8 Q(c)-.37 E +F0(\214le with a statement of the form)2.81 E F1(set)144 561.6 Q F2 (variable\255name value)2.5 E F0 .79(Except where noted, readline v)108 -412.8 R .79(ariables can tak)-.25 F 3.29(et)-.1 G .79(he v)-3.29 F +578.4 R .79(ariables can tak)-.25 F 3.29(et)-.1 G .79(he v)-3.29 F (alues)-.25 E F1(On)3.29 E F0(or)3.29 E F1(Off)3.29 E F0 .79 (\(without re)3.29 F -.05(ga)-.15 G .79(rd to case\).).05 F(Unrecog-) -5.79 E .448(nized v)108 424.8 R .448(ariable names are ignored.)-.25 F +5.79 E .448(nized v)108 590.4 R .448(ariable names are ignored.)-.25 F .448(When a v)5.448 F .448(ariable v)-.25 F .448 (alue is read, empty or null v)-.25 F .449(alues, "on" \(case-insensi-) --.25 F(ti)108 436.8 Q -.15(ve)-.25 G .468(\), and "1" are equi).15 F +-.25 F(ti)108 602.4 Q -.15(ve)-.25 G .468(\), and "1" are equi).15 F -.25(va)-.25 G .468(lent to).25 F F1(On)2.968 E F0 5.468(.A)C .468 (ll other v)-5.468 F .468(alues are equi)-.25 F -.25(va)-.25 G .468 (lent to).25 F F1(Off)2.968 E F0 5.468(.T)C .467(he v)-5.468 F .467 -(ariables and their def)-.25 F(ault)-.1 E -.25(va)108 448.8 S(lues are:) -.25 E F1(bell\255style \(audible\))108 465.6 Q F0 .01 -(Controls what happens when readline w)144 477.6 R .011 +(ariables and their def)-.25 F(ault)-.1 E -.25(va)108 614.4 S(lues are:) +.25 E F1(bell\255style \(audible\))108 631.2 Q F0 .01 +(Controls what happens when readline w)144 643.2 R .011 (ants to ring the terminal bell.)-.1 F .011(If set to)5.011 F F1(none) 2.511 E F0 2.511(,r)C .011(eadline ne)-2.511 F -.15(ve)-.25 G(r).15 E -.94(rings the bell.)144 489.6 R .94(If set to)5.94 F F1(visible)3.44 E +.94(rings the bell.)144 655.2 R .94(If set to)5.94 F F1(visible)3.44 E F0 3.44(,r)C .94(eadline uses a visible bell if one is a)-3.44 F -.25 (va)-.2 G 3.44(ilable. If).25 F .94(set to)3.44 F F1(audible)3.44 E F0 -(,)A(readline attempts to ring the terminal')144 501.6 Q 2.5(sb)-.55 G -(ell.)-2.5 E F1(bind\255tty\255special\255chars \(On\))108 513.6 Q F0 -.055(If set to)144 525.6 R F1(On)2.555 E F0 2.555(,r)C .056(eadline att\ +(,)A(readline attempts to ring the terminal')144 667.2 Q 2.5(sb)-.55 G +(ell.)-2.5 E F1(bind\255tty\255special\255chars \(On\))108 679.2 Q F0 +.055(If set to)144 691.2 R F1(On)2.555 E F0 2.555(,r)C .056(eadline att\ empts to bind the control characters treated specially by the k)-2.555 F -(ernel')-.1 E 2.556(st)-.55 G(ermi-)-2.556 E(nal dri)144 537.6 Q -.15 +(ernel')-.1 E 2.556(st)-.55 G(ermi-)-2.556 E(nal dri)144 703.2 Q -.15 (ve)-.25 G 2.5(rt).15 G 2.5(ot)-2.5 G(heir readline equi)-2.5 E -.25(va) --.25 G(lents.).25 E F1(color)108 549.6 Q(ed\255stats \(Off\))-.18 E F0 -1.58(If set to)144 561.6 R F1(On)4.08 E F0 4.08(,r)C 1.579 +-.25 G(lents.).25 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 +G(mber 24).15 E(37)185.545 E 0 Cg EP +%%Page: 38 38 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(color)108 84 Q(ed\255stats \(Off\))-.18 E +F0 1.58(If set to)144 96 R F1(On)4.08 E F0 4.08(,r)C 1.579 (eadline displays possible completions using dif)-4.08 F 1.579 -(ferent colors to indicate their \214le)-.25 F 2.5(type. The)144 573.6 R +(ferent colors to indicate their \214le)-.25 F 2.5(type. The)144 108 R (color de\214nitions are tak)2.5 E(en from the v)-.1 E(alue of the)-.25 E F1(LS_COLORS)2.5 E F0(en)2.5 E(vironment v)-.4 E(ariable.)-.25 E F1 -(comment\255begin \(`)108 585.6 Q(`#')-.63 E('\))-.63 E F0 .884 -(The string that is inserted when the readline)144 597.6 R F1 +(comment\255begin \(`)108 120 Q(`#')-.63 E('\))-.63 E F0 .884 +(The string that is inserted when the readline)144 132 R F1 (insert\255comment)3.385 E F0 .885(command is e)3.385 F -.15(xe)-.15 G -3.385(cuted. This).15 F(com-)3.385 E(mand is bound to)144 609.6 Q F1 +3.385(cuted. This).15 F(com-)3.385 E(mand is bound to)144 144 Q F1 (M\255#)2.5 E F0(in emacs mode and to)2.5 E F1(#)2.5 E F0 -(in vi command mode.)2.5 E F1(completion\255ignor)108 621.6 Q -(e\255case \(Off\))-.18 E F0(If set to)144 633.6 Q F1(On)2.5 E F0 2.5 -(,r)C(eadline performs \214lename matching and completion in a case\255\ -insensiti)-2.5 E .3 -.15(ve f)-.25 H(ashion.).05 E F1(completion\255pr) -108 645.6 Q(e\214x\255display\255length \(0\))-.18 E F0 .829(The length\ - in characters of the common pre\214x of a list of possible completions\ - that is displayed)144 657.6 R 1.274(without modi\214cation.)144 669.6 R -1.274(When set to a v)6.274 F 1.274 -(alue greater than zero, common pre\214x)-.25 F 1.275 -(es longer than this)-.15 F -.25(va)144 681.6 S(lue are replaced with a\ -n ellipsis when displaying possible completions.).25 E F1 -(completion\255query\255items \(100\))108 693.6 Q F0 .53 -(This determines when the user is queried about vie)144 705.6 R .529 +(in vi command mode.)2.5 E F1(completion\255ignor)108 156 Q +(e\255case \(Off\))-.18 E F0(If set to)144 168 Q F1(On)2.5 E F0 2.5(,r)C +(eadline performs \214lename matching and completion in a case\255insen\ +siti)-2.5 E .3 -.15(ve f)-.25 H(ashion.).05 E F1(completion\255pr)108 +180 Q(e\214x\255display\255length \(0\))-.18 E F0 .829(The length in ch\ +aracters of the common pre\214x of a list of possible completions that \ +is displayed)144 192 R 1.274(without modi\214cation.)144 204 R 1.274 +(When set to a v)6.274 F 1.274(alue greater than zero, common pre\214x) +-.25 F 1.275(es longer than this)-.15 F -.25(va)144 216 S(lue are repla\ +ced with an ellipsis when displaying possible completions.).25 E F1 +(completion\255query\255items \(100\))108 228 Q F0 .53 +(This determines when the user is queried about vie)144 240 R .529 (wing the number of possible completions gen-)-.25 F .56(erated by the) -144 717.6 R F1(possible\255completions)3.06 E F0 3.06(command. It)3.06 F +144 252 R F1(possible\255completions)3.06 E F0 3.06(command. It)3.06 F .561(may be set to an)3.061 F 3.061(yi)-.15 G(nte)-3.061 E .561(ger v) --.15 F .561(alue greater than or)-.25 F .783(equal to zero.)144 729.6 R +-.15 F .561(alue greater than or)-.25 F .783(equal to zero.)144 264 R .783(If the number of possible completions is greater than or equal to \ -the v)5.783 F .782(alue of this)-.25 F(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(37)198.165 E 0 Cg EP -%%Page: 38 38 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E -.25(va)144 84 S .237(riable, the user is ask).25 F .237 -(ed whether or not he wishes to vie)-.1 F 2.737(wt)-.25 G .237 -(hem; otherwise the)-2.737 F 2.737(ya)-.15 G .237(re simply listed) --2.737 F(on the terminal.)144 96 Q/F1 10/Times-Bold@0 SF(con)108 108 Q --.1(ve)-.4 G(rt\255meta \(On\)).1 E F0 .613(If set to)144 120 R F1(On) +the v)5.783 F .782(alue of this)-.25 F -.25(va)144 276 S .237 +(riable, the user is ask).25 F .237(ed whether or not he wishes to vie) +-.1 F 2.737(wt)-.25 G .237(hem; otherwise the)-2.737 F 2.737(ya)-.15 G +.237(re simply listed)-2.737 F(on the terminal.)144 288 Q F1(con)108 300 +Q -.1(ve)-.4 G(rt\255meta \(On\)).1 E F0 .613(If set to)144 312 R F1(On) 3.113 E F0 3.113(,r)C .613(eadline will con)-3.113 F -.15(ve)-.4 G .613 (rt characters with the eighth bit set to an ASCII k).15 F .912 -.15 (ey s)-.1 H .612(equence by).15 F .541 (stripping the eighth bit and pre\214xing an escape character \(in ef) -144 132 R .541(fect, using escape as the)-.25 F/F2 10/Times-Italic@0 SF -.542(meta pr)3.042 F(e-)-.37 E<8c78>144 144 Q F0(\).)A F1 -(disable\255completion \(Off\))108 156 Q F0 .038(If set to)144 168 R F1 +144 324 R .541(fect, using escape as the)-.25 F/F2 10/Times-Italic@0 SF +.542(meta pr)3.042 F(e-)-.37 E<8c78>144 336 Q F0(\).)A F1 +(disable\255completion \(Off\))108 348 Q F0 .038(If set to)144 360 R F1 (On)2.538 E F0 2.538(,r)C .038(eadline will inhibit w)-2.538 F .038 (ord completion.)-.1 F .038 (Completion characters will be inserted into the)5.038 F(line as if the) -144 180 Q 2.5(yh)-.15 G(ad been mapped to)-2.5 E F1(self-insert)2.5 E F0 -(.)A F1(editing\255mode \(emacs\))108 192 Q F0 .141 -(Controls whether readline be)144 204 R .141(gins with a set of k)-.15 F +144 372 Q 2.5(yh)-.15 G(ad been mapped to)-2.5 E F1(self-insert)2.5 E F0 +(.)A F1(editing\255mode \(emacs\))108 384 Q F0 .141 +(Controls whether readline be)144 396 R .141(gins with a set of k)-.15 F .441 -.15(ey b)-.1 H .141(indings similar to).15 F F2(Emacs)2.642 E F0 (or)2.642 E F2(vi)2.642 E F0(.)A F1(editing\255mode)5.142 E F0 -(can be set to either)144 216 Q F1(emacs)2.5 E F0(or)2.5 E F1(vi)2.5 E -F0(.)A F1(echo\255contr)108 228 Q(ol\255characters \(On\))-.18 E F0 -1.211(When set to)144 240 R F1(On)3.711 E F0 3.711(,o)C 3.711(no)-3.711 +(can be set to either)144 408 Q F1(emacs)2.5 E F0(or)2.5 E F1(vi)2.5 E +F0(.)A F1(echo\255contr)108 420 Q(ol\255characters \(On\))-.18 E F0 +1.211(When set to)144 432 R F1(On)3.711 E F0 3.711(,o)C 3.711(no)-3.711 G 1.211(perating systems that indicate the)-3.711 F 3.711(ys)-.15 G 1.21 (upport it, readline echoes a character)-3.711 F -(corresponding to a signal generated from the k)144 252 Q -.15(ey)-.1 G -(board.).15 E F1(enable\255k)108 264 Q(eypad \(Off\))-.1 E F0 .892 -(When set to)144 276 R F1(On)3.393 E F0 3.393(,r)C .893 +(corresponding to a signal generated from the k)144 444 Q -.15(ey)-.1 G +(board.).15 E F1(enable\255k)108 456 Q(eypad \(Off\))-.1 E F0 .892 +(When set to)144 468 R F1(On)3.393 E F0 3.393(,r)C .893 (eadline will try to enable the application k)-3.393 F -.15(ey)-.1 G .893(pad when it is called.).15 F .893(Some sys-)5.893 F -(tems need this to enable the arro)144 288 Q 2.5(wk)-.25 G -.15(ey)-2.6 -G(s.).15 E F1(enable\255meta\255k)108 300 Q(ey \(On\))-.1 E F0 .64 -(When set to)144 312 R F1(On)3.14 E F0 3.14(,r)C .64 +(tems need this to enable the arro)144 480 Q 2.5(wk)-.25 G -.15(ey)-2.6 +G(s.).15 E F1(enable\255meta\255k)108 492 Q(ey \(On\))-.1 E F0 .64 +(When set to)144 504 R F1(On)3.14 E F0 3.14(,r)C .64 (eadline will try to enable an)-3.14 F 3.14(ym)-.15 G .64 (eta modi\214er k)-3.14 F .94 -.15(ey t)-.1 H .64 -(he terminal claims to support).15 F(when it is called.)144 324 Q +(he terminal claims to support).15 F(when it is called.)144 516 Q (On man)5 E 2.5(yt)-.15 G(erminals, the meta k)-2.5 E .3 -.15(ey i)-.1 H 2.5(su).15 G(sed to send eight-bit characters.)-2.5 E F1 -(expand\255tilde \(Off\))108 336 Q F0(If set to)144 348 Q F1(On)2.5 E F0 +(expand\255tilde \(Off\))108 528 Q F0(If set to)144 540 Q F1(On)2.5 E F0 2.5(,t)C(ilde e)-2.5 E(xpansion is performed when readline attempts w) --.15 E(ord completion.)-.1 E F1(history\255pr)108 360 Q(eser)-.18 E -.1 -(ve)-.1 G(\255point \(Off\)).1 E F0 1.338(If set to)144 372 R F1(On) +-.15 E(ord completion.)-.1 E F1(history\255pr)108 552 Q(eser)-.18 E -.1 +(ve)-.1 G(\255point \(Off\)).1 E F0 1.338(If set to)144 564 R F1(On) 3.838 E F0 3.838(,t)C 1.338(he history code attempts to place point at \ -the same location on each history line)-3.838 F(retrie)144 384 Q -.15 +the same location on each history line)-3.838 F(retrie)144 576 Q -.15 (ve)-.25 G 2.5(dw).15 G(ith)-2.5 E F1(pr)2.5 E -.15(ev)-.18 G (ious-history).15 E F0(or)2.5 E F1(next-history)2.5 E F0(.)A F1 -(history\255size \(0\))108 396 Q F0 .463 -(Set the maximum number of history entries sa)144 408 R -.15(ve)-.2 G -2.963(di).15 G 2.963(nt)-2.963 G .463(he history list.)-2.963 F .462 -(If set to zero, the number of)5.463 F -(entries in the history list is not limited.)144 420 Q F1 -(horizontal\255scr)108 432 Q(oll\255mode \(Off\))-.18 E F0 .448 -(When set to)144 444 R F1(On)2.948 E F0 2.948(,m)C(ak)-2.948 E .448 -(es readline use a single line for display)-.1 F 2.948(,s)-.65 G .449 +(history\255size \(0\))108 588 Q F0 .949 +(Set the maximum number of history entries sa)144 600 R -.15(ve)-.2 G +3.448(di).15 G 3.448(nt)-3.448 G .948(he history list.)-3.448 F .948 +(If set to zero, an)5.948 F 3.448(ye)-.15 G(xisting)-3.598 E .482 +(history entries are deleted and no ne)144 612 R 2.982(we)-.25 G .483 +(ntries are sa)-2.982 F -.15(ve)-.2 G 2.983(d. If).15 F .483(set to a v) +2.983 F .483(alue less than zero, the num-)-.25 F +(ber of history entries is not limited.)144 624 Q(By def)5 E +(ault, the number of history entries is not limited.)-.1 E F1 +(horizontal\255scr)108 636 Q(oll\255mode \(Off\))-.18 E F0 .449 +(When set to)144 648 R F1(On)2.949 E F0 2.949(,m)C(ak)-2.949 E .448 +(es readline use a single line for display)-.1 F 2.948(,s)-.65 G .448 (crolling the input horizontally on a)-2.948 F 1.194(single screen line\ when it becomes longer than the screen width rather than wrapping to a\ - ne)144 456 R(w)-.25 E(line.)144 468 Q F1(input\255meta \(Off\))108 480 -Q F0 .227(If set to)144 492 R F1(On)2.727 E F0 2.727(,r)C .228(eadline \ + ne)144 660 R(w)-.25 E(line.)144 672 Q F1(input\255meta \(Off\))108 684 +Q F0 .228(If set to)144 696 R F1(On)2.728 E F0 2.728(,r)C .227(eadline \ will enable eight-bit input \(that is, it will not strip the high bit f\ -rom the char)-2.727 F(-)-.2 E .957(acters it reads\), re)144 504 R -.05 +rom the char)-2.728 F(-)-.2 E .956(acters it reads\), re)144 708 R -.05 (ga)-.15 G .956(rdless of what the terminal claims it can support.).05 F -.956(The name)5.956 F F1(meta\255\215ag)3.456 E F0 .956(is a)3.456 F -(synon)144 516 Q(ym for this v)-.15 E(ariable.)-.25 E F1(isear)108 528 Q -(ch\255terminators \(`)-.18 E(`C\255[C\255J')-.63 E('\))-.63 E F0 .439(\ -The string of characters that should terminate an incremental search wi\ -thout subsequently e)144 540 R -.15(xe)-.15 G(cut-).15 E .935 -(ing the character as a command.)144 552 R .935(If this v)5.935 F .935 -(ariable has not been gi)-.25 F -.15(ve)-.25 G 3.434(nav).15 G .934 -(alue, the characters)-3.684 F F2(ESC)3.434 E F0(and)144 564 Q F2 -(C\255J)2.5 E F0(will terminate an incremental search.)2.5 E F1 -.1(ke) -108 576 S(ymap \(emacs\)).1 E F0 2.02(Set the current readline k)144 588 -R -.15(ey)-.1 G 4.521(map. The).15 F 2.021(set of v)4.521 F 2.021 -(alid k)-.25 F -.15(ey)-.1 G 2.021(map names is).15 F F2 2.021 -(emacs, emacs\255standar)4.521 F(d,)-.37 E .069 -(emacs\255meta, emacs\255ctlx, vi, vi\255command)144 600 R F0 2.568(,a)C +.957(The name)5.956 F F1(meta\255\215ag)3.457 E F0 .957(is a)3.457 F +(synon)144 720 Q(ym for this v)-.15 E(ariable.)-.25 E(GNU Bash 4.2)72 +768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(38)185.545 E 0 Cg +EP +%%Page: 39 39 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(isear)108 84 Q(ch\255terminators \(`)-.18 E +(`C\255[C\255J')-.63 E('\))-.63 E F0 .439(The string of characters that\ + should terminate an incremental search without subsequently e)144 96 R +-.15(xe)-.15 G(cut-).15 E .934(ing the character as a command.)144 108 R +.935(If this v)5.935 F .935(ariable has not been gi)-.25 F -.15(ve)-.25 +G 3.435(nav).15 G .935(alue, the characters)-3.685 F/F2 10 +/Times-Italic@0 SF(ESC)3.435 E F0(and)144 120 Q F2(C\255J)2.5 E F0 +(will terminate an incremental search.)2.5 E F1 -.1(ke)108 132 S +(ymap \(emacs\)).1 E F0 2.021(Set the current readline k)144 144 R -.15 +(ey)-.1 G 4.521(map. The).15 F 2.021(set of v)4.521 F 2.021(alid k)-.25 +F -.15(ey)-.1 G 2.021(map names is).15 F F2 2.02 +(emacs, emacs\255standar)4.52 F(d,)-.37 E .068 +(emacs\255meta, emacs\255ctlx, vi, vi\255command)144 156 R F0 2.568(,a)C (nd)-2.568 E F2(vi\255insert)2.568 E F0(.).68 E F2(vi)5.068 E F0 .068 (is equi)2.568 F -.25(va)-.25 G .068(lent to).25 F F2(vi\255command) -2.568 E F0(;)A F2(emacs)2.568 E F0 1.543(is equi)144 612 R -.25(va)-.25 -G 1.543(lent to).25 F F2(emacs\255standar)4.044 E(d)-.37 E F0 6.544(.T)C +2.569 E F0(;)A F2(emacs)2.569 E F0 1.544(is equi)144 168 R -.25(va)-.25 +G 1.544(lent to).25 F F2(emacs\255standar)4.044 E(d)-.37 E F0 6.544(.T)C 1.544(he def)-6.544 F 1.544(ault v)-.1 F 1.544(alue is)-.25 F F2(emacs) 4.044 E F0 4.044(;t).27 G 1.544(he v)-4.044 F 1.544(alue of)-.25 F F1 -(editing\255mode)4.044 E F0(also)4.044 E(af)144 624 Q(fects the def)-.25 -E(ault k)-.1 E -.15(ey)-.1 G(map.).15 E F1 -.1(ke)108 636 S -(yseq\255timeout \(500\)).1 E F0 .368(Speci\214es the duration)144 648 R +(editing\255mode)4.043 E F0(also)4.043 E(af)144 180 Q(fects the def)-.25 +E(ault k)-.1 E -.15(ey)-.1 G(map.).15 E F1 -.1(ke)108 192 S +(yseq\255timeout \(500\)).1 E F0 .367(Speci\214es the duration)144 204 R F2 -.37(re)2.867 G(adline).37 E F0 .367(will w)2.867 F .367 -(ait for a character when reading an ambiguous k)-.1 F .667 -.15(ey s) --.1 H(equence).15 E 1.356(\(one that can form a complete k)144 660 R +(ait for a character when reading an ambiguous k)-.1 F .668 -.15(ey s) +-.1 H(equence).15 E 1.356(\(one that can form a complete k)144 216 R 1.656 -.15(ey s)-.1 H 1.356(equence using the input read so f).15 F(ar) --.1 E 3.856(,o)-.4 G 3.856(rc)-3.856 G 1.356(an tak)-3.856 F 3.856(ea) --.1 G(dditional)-3.856 E .32(input to complete a longer k)144 672 R .62 +-.1 E 3.856(,o)-.4 G 3.856(rc)-3.856 G 1.355(an tak)-3.856 F 3.855(ea) +-.1 G(dditional)-3.855 E .32(input to complete a longer k)144 228 R .62 -.15(ey s)-.1 H 2.82(equence\). If).15 F .32(no input is recei)2.82 F -.15(ve)-.25 G 2.82(dw).15 G .32(ithin the timeout,)-2.82 F F2 -.37(re) -2.82 G(adline).37 E F0(will)2.82 E .906(use the shorter b)144 684 R .907 +2.82 G(adline).37 E F0(will)2.82 E .907(use the shorter b)144 240 R .907 (ut complete k)-.2 F 1.207 -.15(ey s)-.1 H 3.407(equence. The).15 F -.25 -(va)3.407 G .907(lue is speci\214ed in milliseconds, so a v).25 F .907 -(alue of)-.25 F .05(1000 means that)144 696 R F2 -.37(re)2.55 G(adline) +(va)3.407 G .907(lue is speci\214ed in milliseconds, so a v).25 F .906 +(alue of)-.25 F .05(1000 means that)144 252 R F2 -.37(re)2.55 G(adline) .37 E F0 .05(will w)2.55 F .05(ait one second for additional input.)-.1 F .05(If this v)5.05 F .05(ariable is set to a v)-.25 F(alue)-.25 E .051 -(less than or equal to zero, or to a non-numeric v)144 708 R(alue,)-.25 +(less than or equal to zero, or to a non-numeric v)144 264 R(alue,)-.25 E F2 -.37(re)2.551 G(adline).37 E F0 .051(will w)2.551 F .051 -(ait until another k)-.1 F .352 -.15(ey i)-.1 H 2.552(sp).15 G(ressed) --2.552 E(to decide which k)144 720 Q .3 -.15(ey s)-.1 H -(equence to complete.).15 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E -(38)198.165 E 0 Cg EP -%%Page: 39 39 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(mark\255dir)108 84 Q(ectories \(On\))-.18 E -F0(If set to)144 96 Q F1(On)2.5 E F0 2.5(,c)C +(ait until another k)-.1 F .351 -.15(ey i)-.1 H 2.551(sp).15 G(ressed) +-2.551 E(to decide which k)144 276 Q .3 -.15(ey s)-.1 H +(equence to complete.).15 E F1(mark\255dir)108 288 Q(ectories \(On\)) +-.18 E F0(If set to)144 300 Q F1(On)2.5 E F0 2.5(,c)C (ompleted directory names ha)-2.5 E .3 -.15(ve a s)-.2 H(lash appended.) -.15 E F1(mark\255modi\214ed\255lines \(Off\))108 108 Q F0(If set to)144 -120 Q F1(On)2.5 E F0 2.5(,h)C(istory lines that ha)-2.5 E .3 -.15(ve b) +.15 E F1(mark\255modi\214ed\255lines \(Off\))108 312 Q F0(If set to)144 +324 Q F1(On)2.5 E F0 2.5(,h)C(istory lines that ha)-2.5 E .3 -.15(ve b) -.2 H(een modi\214ed are displayed with a preceding asterisk \().15 E F1 -(*)A F0(\).)A F1(mark\255symlink)108 132 Q(ed\255dir)-.1 E -(ectories \(Off\))-.18 E F0 .175(If set to)144 144 R F1(On)2.675 E F0 +(*)A F0(\).)A F1(mark\255symlink)108 336 Q(ed\255dir)-.1 E +(ectories \(Off\))-.18 E F0 .175(If set to)144 348 R F1(On)2.675 E F0 2.675(,c)C .175 (ompleted names which are symbolic links to directories ha)-2.675 F .475 --.15(ve a s)-.2 H .175(lash appended \(sub-).15 F(ject to the v)144 156 +-.15(ve a s)-.2 H .175(lash appended \(sub-).15 F(ject to the v)144 360 Q(alue of)-.25 E F1(mark\255dir)2.5 E(ectories)-.18 E F0(\).)A F1 -(match\255hidden\255\214les \(On\))108 168 Q F0 .192(This v)144 180 R -.192(ariable, when set to)-.25 F F1(On)2.692 E F0 2.692(,c)C .192 -(auses readline to match \214les whose names be)-2.692 F .193 -(gin with a `.)-.15 F 2.693('\()-.7 G(hidden)-2.693 E .457 -(\214les\) when performing \214lename completion.)144 192 R .456 +(match\255hidden\255\214les \(On\))108 372 Q F0 .193(This v)144 384 R +.193(ariable, when set to)-.25 F F1(On)2.693 E F0 2.693(,c)C .192 +(auses readline to match \214les whose names be)-2.693 F .192 +(gin with a `.)-.15 F 2.692('\()-.7 G(hidden)-2.692 E .456 +(\214les\) when performing \214lename completion.)144 396 R .456 (If set to)5.456 F F1(Off)2.956 E F0 2.956(,t)C .456(he leading `.) --2.956 F 2.956('m)-.7 G .456(ust be supplied by the)-2.956 F -(user in the \214lename to be completed.)144 204 Q F1 -(menu\255complete\255display\255pr)108 216 Q(e\214x \(Off\))-.18 E F0 -1.585(If set to)144 228 R F1(On)4.085 E F0 4.085(,m)C 1.585(enu complet\ +-2.956 F 2.956('m)-.7 G .457(ust be supplied by the)-2.956 F +(user in the \214lename to be completed.)144 408 Q F1 +(menu\255complete\255display\255pr)108 420 Q(e\214x \(Off\))-.18 E F0 +1.586(If set to)144 432 R F1(On)4.086 E F0 4.086(,m)C 1.585(enu complet\ ion displays the common pre\214x of the list of possible completions) --4.085 F(\(which may be empty\) before c)144 240 Q -(ycling through the list.)-.15 E F1(output\255meta \(Off\))108 252 Q F0 -.507(If set to)144 264 R F1(On)3.007 E F0 3.007(,r)C .507(eadline will \ +-4.086 F(\(which may be empty\) before c)144 444 Q +(ycling through the list.)-.15 E F1(output\255meta \(Off\))108 456 Q F0 +.506(If set to)144 468 R F1(On)3.006 E F0 3.006(,r)C .507(eadline will \ display characters with the eighth bit set directly rather than as a me\ -ta-)-3.007 F(pre\214x)144 276 Q(ed escape sequence.)-.15 E F1 -(page\255completions \(On\))108 288 Q F0 .808(If set to)144 300 R F1(On) -3.308 E F0 3.308(,r)C .808(eadline uses an internal)-3.308 F/F2 10 -/Times-Italic@0 SF(mor)3.308 E(e)-.37 E F0(-lik)A 3.308(ep)-.1 G .808 +ta-)-3.006 F(pre\214x)144 480 Q(ed escape sequence.)-.15 E F1 +(page\255completions \(On\))108 492 Q F0 .809(If set to)144 504 R F1(On) +3.308 E F0 3.308(,r)C .808(eadline uses an internal)-3.308 F F2(mor) +3.308 E(e)-.37 E F0(-lik)A 3.308(ep)-.1 G .808 (ager to display a screenful of possible comple-)-3.308 F -(tions at a time.)144 312 Q F1 -(print\255completions\255horizontally \(Off\))108 324 Q F0 1.319 -(If set to)144 336 R F1(On)3.819 E F0 3.819(,r)C 1.318(eadline will dis\ -play completions with matches sorted horizontally in alphabetical)-3.819 -F(order)144 348 Q 2.5(,r)-.4 G(ather than do)-2.5 E(wn the screen.)-.25 -E F1 -2.29 -.18(re v)108 360 T(ert\255all\255at\255newline \(Off\)).08 E -F0 .698(If set to)144 372 R F1(On)3.198 E F0 3.198(,r)C .699 +(tions at a time.)144 516 Q F1 +(print\255completions\255horizontally \(Off\))108 528 Q F0 1.318 +(If set to)144 540 R F1(On)3.818 E F0 3.818(,r)C 1.319(eadline will dis\ +play completions with matches sorted horizontally in alphabetical)-3.818 +F(order)144 552 Q 2.5(,r)-.4 G(ather than do)-2.5 E(wn the screen.)-.25 +E F1 -2.29 -.18(re v)108 564 T(ert\255all\255at\255newline \(Off\)).08 E +F0 .699(If set to)144 576 R F1(On)3.199 E F0 3.199(,r)C .699 (eadline will undo all changes to history lines before returning when) --3.198 F F1(accept\255line)3.199 E F0(is)3.199 E -.15(exe)144 384 S +-3.199 F F1(accept\255line)3.198 E F0(is)3.198 E -.15(exe)144 588 S 2.686(cuted. By).15 F(def)2.686 E .186 (ault, history lines may be modi\214ed and retain indi)-.1 F .186 -(vidual undo lists across calls to)-.25 F F1 -.18(re)144 396 S(adline) -.18 E F0(.)A F1(sho)108 408 Q(w\255all\255if\255ambiguous \(Off\))-.1 E -F0 .303(This alters the def)144 420 R .303(ault beha)-.1 F .304 +(vidual undo lists across calls to)-.25 F F1 -.18(re)144 600 S(adline) +.18 E F0(.)A F1(sho)108 612 Q(w\255all\255if\255ambiguous \(Off\))-.1 E +F0 .304(This alters the def)144 624 R .304(ault beha)-.1 F .304 (vior of the completion functions.)-.2 F .304(If set to)5.304 F F1(On) -2.804 E F0 2.804(,w)C .304(ords which ha)-2.904 F .604 -.15(ve m)-.2 H +2.804 E F0 2.803(,w)C .303(ords which ha)-2.903 F .603 -.15(ve m)-.2 H (ore).15 E 1.264(than one possible completion cause the matches to be l\ -isted immediately instead of ringing the)144 432 R(bell.)144 444 Q F1 -(sho)108 456 Q(w\255all\255if\255unmodi\214ed \(Off\))-.1 E F0 5.345 -(This alters the def)144 468 R 5.345(ault beha)-.1 F 5.345 -(vior of the completion functions in a f)-.2 F 5.346(ashion similar to) --.1 F F1(sho)144 480 Q(w\255all\255if\255ambiguous)-.1 E F0 6.691(.I)C -4.191(fs)-6.691 G 1.691(et to)-4.191 F F1(On)4.191 E F0 4.191(,w)C 1.691 +isted immediately instead of ringing the)144 636 R(bell.)144 648 Q F1 +(sho)108 660 Q(w\255all\255if\255unmodi\214ed \(Off\))-.1 E F0 5.346 +(This alters the def)144 672 R 5.346(ault beha)-.1 F 5.345 +(vior of the completion functions in a f)-.2 F 5.345(ashion similar to) +-.1 F F1(sho)144 684 Q(w\255all\255if\255ambiguous)-.1 E F0 6.69(.I)C +4.19(fs)-6.69 G 1.691(et to)-4.19 F F1(On)4.191 E F0 4.191(,w)C 1.691 (ords which ha)-4.291 F 1.991 -.15(ve m)-.2 H 1.691 -(ore than one possible completion).15 F 1.039(without an)144 492 R 3.539 +(ore than one possible completion).15 F 1.04(without an)144 696 R 3.54 (yp)-.15 G 1.039 -(ossible partial completion \(the possible completions don')-3.539 F -3.539(ts)-.18 G 1.04(hare a common pre\214x\))-3.539 F(cause the matche\ -s to be listed immediately instead of ringing the bell.)144 504 Q F1 -(skip\255completed\255text \(Off\))108 516 Q F0 .095(If set to)144 528 R +(ossible partial completion \(the possible completions don')-3.54 F +3.539(ts)-.18 G 1.039(hare a common pre\214x\))-3.539 F(cause the match\ +es to be listed immediately instead of ringing the bell.)144 708 Q +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(39)185.545 E 0 Cg EP +%%Page: 40 40 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(sho)108 84 Q(w\255mode\255in\255pr)-.1 E +(ompt \(Off\))-.18 E F0 1.018(If set to)144 96 R F1(On)3.518 E F0 3.518 +(,a)C 1.018(dd a character to the be)-3.518 F 1.018 +(ginning of the prompt indicating the editing mode: emacs)-.15 F +(\(@\), vi command \(:\) or vi insertion \(+\).)144 108 Q F1 +(skip\255completed\255text \(Off\))108 120 Q F0 .095(If set to)144 132 R F1(On)2.595 E F0 2.595(,t)C .095(his alters the def)-2.595 F .095 (ault completion beha)-.1 F .094 -(vior when inserting a single match into the line.)-.2 F(It')144 540 Q +(vior when inserting a single match into the line.)-.2 F(It')144 144 Q 2.545(so)-.55 G .045(nly acti)-2.545 F .345 -.15(ve w)-.25 H .046 (hen performing completion in the middle of a w).15 F 2.546(ord. If)-.1 F .046(enabled, readline does not)2.546 F 1.394(insert characters from \ -the completion that match characters after point in the w)144 552 R -1.394(ord being com-)-.1 F(pleted, so portions of the w)144 564 Q +the completion that match characters after point in the w)144 156 R +1.394(ord being com-)-.1 F(pleted, so portions of the w)144 168 Q (ord follo)-.1 E(wing the cursor are not duplicated.)-.25 E F1 -(visible\255stats \(Off\))108 576 Q F0 .846(If set to)144 588 R F1(On) +(visible\255stats \(Off\))108 180 Q F0 .846(If set to)144 192 R F1(On) 3.346 E F0 3.346(,ac)C .846(haracter denoting a \214le')-3.346 F 3.346 -(st)-.55 G .846(ype as reported by)-3.346 F F2(stat)3.346 E F0 .846 -(\(2\) is appended to the \214lename)B -(when listing possible completions.)144 600 Q F1 -(Readline Conditional Constructs)87 616.8 Q F0 .05 -(Readline implements a f)108 628.8 R .05(acility similar in spirit to t\ +(st)-.55 G .846(ype as reported by)-3.346 F/F2 10/Times-Italic@0 SF +(stat)3.346 E F0 .846(\(2\) is appended to the \214lename)B +(when listing possible completions.)144 204 Q F1 +(Readline Conditional Constructs)87 220.8 Q F0 .05 +(Readline implements a f)108 232.8 R .05(acility similar in spirit to t\ he conditional compilation features of the C preprocessor)-.1 F .096 -(which allo)108 640.8 R .096(ws k)-.25 F .396 -.15(ey b)-.1 H .096 +(which allo)108 244.8 R .096(ws k)-.25 F .396 -.15(ey b)-.1 H .096 (indings and v).15 F .096 (ariable settings to be performed as the result of tests.)-.25 F .097 -(There are four parser)5.096 F(directi)108 652.8 Q -.15(ve)-.25 G 2.5 -(su).15 G(sed.)-2.5 E F1($if)108 669.6 Q F0(The)24.89 E F1($if)2.963 E +(There are four parser)5.096 F(directi)108 256.8 Q -.15(ve)-.25 G 2.5 +(su).15 G(sed.)-2.5 E F1($if)108 273.6 Q F0(The)24.89 E F1($if)2.963 E F0 .463(construct allo)2.963 F .462(ws bindings to be made based on the\ editing mode, the terminal being used,)-.25 F .477 -(or the application using readline.)144 681.6 R .477(The te)5.477 F .477 +(or the application using readline.)144 285.6 R .477(The te)5.477 F .477 (xt of the test e)-.15 F .477 (xtends to the end of the line; no characters)-.15 F -(are required to isolate it.)144 693.6 Q F1(mode)144 710.4 Q F0(The) +(are required to isolate it.)144 297.6 Q F1(mode)144 314.4 Q F0(The) 12.67 E F1(mode=)3.712 E F0 1.212(form of the)3.712 F F1($if)3.711 E F0 (directi)3.711 E 1.511 -.15(ve i)-.25 H 3.711(su).15 G 1.211 (sed to test whether readline is in emacs or vi)-3.711 F 3.065 -(mode. This)180 722.4 R .565(may be used in conjunction with the)3.065 F +(mode. This)180 326.4 R .565(may be used in conjunction with the)3.065 F F1 .565(set k)3.065 F(eymap)-.1 E F0 .565(command, for instance, to) -3.065 F(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(39)198.165 E 0 Cg -EP -%%Page: 40 40 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E .735(set bindings in the)180 84 R/F1 10/Times-Italic@0 SF -(emacs\255standar)3.235 E(d)-.37 E F0(and)3.235 E F1(emacs\255ctlx)3.235 -E F0 -.1(ke)3.235 G .735(ymaps only if readline is starting)-.05 F -(out in emacs mode.)180 96 Q/F2 10/Times-Bold@0 SF(term)144 112.8 Q F0 -(The)15.46 E F2(term=)3.196 E F0 .696 +3.065 F .735(set bindings in the)180 338.4 R F2(emacs\255standar)3.235 E +(d)-.37 E F0(and)3.235 E F2(emacs\255ctlx)3.235 E F0 -.1(ke)3.235 G .735 +(ymaps only if readline is starting)-.05 F(out in emacs mode.)180 350.4 +Q F1(term)144 367.2 Q F0(The)15.46 E F1(term=)3.196 E F0 .696 (form may be used to include terminal-speci\214c k)3.196 F .996 -.15 -(ey b)-.1 H .697(indings, perhaps to bind).15 F .654(the k)180 124.8 R +(ey b)-.1 H .697(indings, perhaps to bind).15 F .654(the k)180 379.2 R .954 -.15(ey s)-.1 H .654(equences output by the terminal').15 F 3.154 (sf)-.55 G .654(unction k)-3.154 F -.15(ey)-.1 G 3.154(s. The).15 F -.1 -(wo)3.154 G .654(rd on the right side of).1 F(the)180 136.8 Q F2(=)3.231 +(wo)3.154 G .654(rd on the right side of).1 F(the)180 391.2 Q F1(=)3.231 E F0 .731(is tested ag)3.231 F .732(ainst the both full name of the ter\ minal and the portion of the terminal)-.05 F(name before the \214rst)180 -148.8 Q F22.5 E F0 5(.T)C(his allo)-5 E(ws)-.25 E F1(sun)2.84 E F0 -(to match both)2.74 E F1(sun)2.84 E F0(and)2.74 E F1(sun\255cmd)2.5 E F0 -2.5(,f).77 G(or instance.)-2.5 E F2(application)144 165.6 Q F0(The)180 -177.6 Q F2(application)3.003 E F0 .503 +403.2 Q F12.5 E F0 5(.T)C(his allo)-5 E(ws)-.25 E F2(sun)2.84 E F0 +(to match both)2.74 E F2(sun)2.84 E F0(and)2.74 E F2(sun\255cmd)2.5 E F0 +2.5(,f).77 G(or instance.)-2.5 E F1(application)144 420 Q F0(The)180 432 +Q F1(application)3.003 E F0 .503 (construct is used to include application-speci\214c settings.)3.003 F .503(Each program)5.503 F .114(using the readline library sets the)180 -189.6 R F1 .114(application name)2.614 F F0 2.614(,a)C .114 +444 R F2 .114(application name)2.614 F F0 2.614(,a)C .114 (nd an initialization \214le can test for a)-2.614 F .501(particular v) -180 201.6 R 3.001(alue. This)-.25 F .501(could be used to bind k)3.001 F +180 456 R 3.001(alue. This)-.25 F .501(could be used to bind k)3.001 F .801 -.15(ey s)-.1 H .5(equences to functions useful for a spe-).15 F -.396(ci\214c program.)180 213.6 R -.15(Fo)5.396 G 2.896(ri).15 G .396 +.396(ci\214c program.)180 468 R -.15(Fo)5.396 G 2.896(ri).15 G .396 (nstance, the follo)-2.896 F .396(wing command adds a k)-.25 F .696 -.15 -(ey s)-.1 H .397(equence that quotes the).15 F(current or pre)180 225.6 -Q(vious w)-.25 E(ord in)-.1 E F2(bash)2.5 E F0(:)A F2($if)180 249.6 Q F0 -(Bash)2.5 E 2.5(#Q)180 261.6 S(uote the current or pre)-2.5 E(vious w) --.25 E(ord)-.1 E("\\C\255xq": "\\eb\\"\\ef\\"")180 273.6 Q F2($endif)180 -285.6 Q($endif)108 302.4 Q F0(This command, as seen in the pre)9.33 E -(vious e)-.25 E(xample, terminates an)-.15 E F2($if)2.5 E F0(command.) -2.5 E F2($else)108 319.2 Q F0(Commands in this branch of the)15.45 E F2 -($if)2.5 E F0(directi)2.5 E .3 -.15(ve a)-.25 H(re e).15 E -.15(xe)-.15 -G(cuted if the test f).15 E(ails.)-.1 E F2($include)108 336 Q F0 .357 -(This directi)144 348 R .657 -.15(ve t)-.25 H(ak).15 E .357 +(ey s)-.1 H .397(equence that quotes the).15 F(current or pre)180 480 Q +(vious w)-.25 E(ord in)-.1 E F1(bash)2.5 E F0(:)A F1($if)180 504 Q F0 +(Bash)2.5 E 2.5(#Q)180 516 S(uote the current or pre)-2.5 E(vious w)-.25 +E(ord)-.1 E("\\C\255xq": "\\eb\\"\\ef\\"")180 528 Q F1($endif)180 540 Q +($endif)108 556.8 Q F0(This command, as seen in the pre)9.33 E(vious e) +-.25 E(xample, terminates an)-.15 E F1($if)2.5 E F0(command.)2.5 E F1 +($else)108 573.6 Q F0(Commands in this branch of the)15.45 E F1($if)2.5 +E F0(directi)2.5 E .3 -.15(ve a)-.25 H(re e).15 E -.15(xe)-.15 G +(cuted if the test f).15 E(ails.)-.1 E F1($include)108 590.4 Q F0 .357 +(This directi)144 602.4 R .657 -.15(ve t)-.25 H(ak).15 E .357 (es a single \214lename as an ar)-.1 F .356 (gument and reads commands and bindings from that)-.18 F 2.5(\214le. F) -144 360 R(or e)-.15 E(xample, the follo)-.15 E(wing directi)-.25 E .3 --.15(ve w)-.25 H(ould read).05 E F1(/etc/inputr)2.5 E(c)-.37 E F0(:)A F2 -($include)144 384 Q F1(/etc/inputr)5.833 E(c)-.37 E F2(Sear)87 400.8 Q -(ching)-.18 E F0 .834(Readline pro)108 412.8 R .834 +144 614.4 R(or e)-.15 E(xample, the follo)-.15 E(wing directi)-.25 E .3 +-.15(ve w)-.25 H(ould read).05 E F2(/etc/inputr)2.5 E(c)-.37 E F0(:)A F1 +($include)144 638.4 Q F2(/etc/inputr)5.833 E(c)-.37 E F1(Sear)87 655.2 Q +(ching)-.18 E F0 .834(Readline pro)108 667.2 R .834 (vides commands for searching through the command history \(see)-.15 F /F3 9/Times-Bold@0 SF(HIST)3.335 E(OR)-.162 E(Y)-.315 E F0(belo)3.085 E -.835(w\) for lines)-.25 F(containing a speci\214ed string.)108 424.8 Q -(There are tw)5 E 2.5(os)-.1 G(earch modes:)-2.5 E F1(incr)2.51 E -(emental)-.37 E F0(and)3.01 E F1(non-incr)2.5 E(emental)-.37 E F0(.).51 -E .698(Incremental searches be)108 441.6 R .698 +.835(w\) for lines)-.25 F(containing a speci\214ed string.)108 679.2 Q +(There are tw)5 E 2.5(os)-.1 G(earch modes:)-2.5 E F2(incr)2.51 E +(emental)-.37 E F0(and)3.01 E F2(non-incr)2.5 E(emental)-.37 E F0(.).51 +E .698(Incremental searches be)108 696 R .698 (gin before the user has \214nished typing the search string.)-.15 F .697(As each character of the)5.697 F .112 -(search string is typed, readline displays the ne)108 453.6 R .112 +(search string is typed, readline displays the ne)108 708 R .112 (xt entry from the history matching the string typed so f)-.15 F(ar)-.1 -E 5.113(.A)-.55 G(n)-5.113 E .542 -(incremental search requires only as man)108 465.6 R 3.042(yc)-.15 G -.542(haracters as needed to \214nd the desired history entry)-3.042 F -5.541(.T)-.65 G .541(he char)-5.541 F(-)-.2 E .224 -(acters present in the v)108 477.6 R .224(alue of the)-.25 F F2(isear) -2.724 E(ch-terminators)-.18 E F0 -.25(va)2.724 G .224 -(riable are used to terminate an incremental search.).25 F .66 -(If that v)108 489.6 R .66(ariable has not been assigned a v)-.25 F .66 -(alue the Escape and Control-J characters will terminate an incre-)-.25 -F .096(mental search.)108 501.6 R .096(Control-G will abort an incremen\ -tal search and restore the original line.)5.096 F .097 -(When the search is)5.097 F(terminated, the history entry containing th\ -e search string becomes the current line.)108 513.6 Q 2.939 -.8(To \214) -108 530.4 T 1.339(nd other matching entries in the history list, type C\ -ontrol-S or Control-R as appropriate.).8 F 1.338(This will)6.338 F .674 -(search backw)108 542.4 R .674(ard or forw)-.1 F .674 -(ard in the history for the ne)-.1 F .675 +E 5.113(.A)-.55 G(n)-5.113 E 2.101 +(incremental search requires only as man)108 720 R 4.601(yc)-.15 G 2.101 +(haracters as needed to \214nd the desired history entry)-4.601 F 7.1 +(.T)-.65 G(he)-7.1 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve) +-.15 G(mber 24).15 E(40)185.545 E 0 Cg EP +%%Page: 41 41 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E 1.192(characters present in the v)108 84 R 1.192(alue of the)-.25 +F/F1 10/Times-Bold@0 SF(isear)3.692 E(ch-terminators)-.18 E F0 -.25(va) +3.692 G 1.192(riable are used to terminate an incremental).25 F 2.736 +(search. If)108 96 R .236(that v)2.736 F .235 +(ariable has not been assigned a v)-.25 F .235 +(alue the Escape and Control-J characters will terminate an)-.25 F 1.34 +(incremental search.)108 108 R 1.34(Control-G will abort an incremental\ + search and restore the original line.)6.34 F 1.34(When the)6.34 F(sear\ +ch is terminated, the history entry containing the search string become\ +s the current line.)108 120 Q 2.939 -.8(To \214)108 136.8 T 1.339(nd ot\ +her matching entries in the history list, type Control-S or Control-R a\ +s appropriate.).8 F 1.338(This will)6.338 F .674(search backw)108 148.8 +R .674(ard or forw)-.1 F .674(ard in the history for the ne)-.1 F .675 (xt entry matching the search string typed so f)-.15 F(ar)-.1 E 5.675 -(.A)-.55 G -.15(ny)-5.675 G .175(other k)108 554.4 R .475 -.15(ey s)-.1 +(.A)-.55 G -.15(ny)-5.675 G .175(other k)108 160.8 R .475 -.15(ey s)-.1 H .174 (equence bound to a readline command will terminate the search and e).15 F -.15(xe)-.15 G .174(cute that command.).15 F -.15(Fo)5.174 G(r).15 E -.54(instance, a)108 566.4 R F1(ne)3.04 E(wline)-.15 E F0 .541 -(will terminate the search and accept the line, thereby e)3.04 F -.15 -(xe)-.15 G .541(cuting the command from the).15 F(history list.)108 -578.4 Q .653(Readline remembers the last incremental search string.)108 -595.2 R .653(If tw)5.653 F 3.153(oC)-.1 G .653 +.54(instance, a)108 172.8 R/F2 10/Times-Italic@0 SF(ne)3.04 E(wline)-.15 +E F0 .541(will terminate the search and accept the line, thereby e)3.04 +F -.15(xe)-.15 G .541(cuting the command from the).15 F(history list.) +108 184.8 Q .653(Readline remembers the last incremental search string.) +108 201.6 R .653(If tw)5.653 F 3.153(oC)-.1 G .653 (ontrol-Rs are typed without an)-3.153 F 3.152(yi)-.15 G(nterv)-3.152 E -(en-)-.15 E(ing characters de\214ning a ne)108 607.2 Q 2.5(ws)-.25 G +(en-)-.15 E(ing characters de\214ning a ne)108 213.6 Q 2.5(ws)-.25 G (earch string, an)-2.5 E 2.5(yr)-.15 G(emembered search string is used.) -2.5 E .567(Non-incremental searches read the entire search string befo\ -re starting to search for matching history lines.)108 624 R(The search \ -string may be typed by the user or be part of the contents of the curre\ -nt line.)108 636 Q F2(Readline Command Names)87 652.8 Q F0 1.392 -(The follo)108 664.8 R 1.391 +re starting to search for matching history lines.)108 230.4 R(The searc\ +h string may be typed by the user or be part of the contents of the cur\ +rent line.)108 242.4 Q F1(Readline Command Names)87 259.2 Q F0 1.392 +(The follo)108 271.2 R 1.391 (wing is a list of the names of the commands and the def)-.25 F 1.391 (ault k)-.1 F 1.691 -.15(ey s)-.1 H 1.391(equences to which the).15 F -3.891(ya)-.15 G(re)-3.891 E 2.621(bound. Command)108 676.8 R .121 +3.891(ya)-.15 G(re)-3.891 E 2.621(bound. Command)108 283.2 R .121 (names without an accompan)2.621 F .121(ying k)-.15 F .421 -.15(ey s)-.1 H .122(equence are unbound by def).15 F 2.622(ault. In)-.1 F .122 -(the follo)2.622 F(wing)-.25 E(descriptions,)108 688.8 Q F1(point)3.411 -E F0 .911(refers to the current cursor position, and)3.411 F F1(mark) +(the follo)2.622 F(wing)-.25 E(descriptions,)108 295.2 Q F2(point)3.411 +E F0 .911(refers to the current cursor position, and)3.411 F F2(mark) 3.411 E F0 .91(refers to a cursor position sa)3.411 F -.15(ve)-.2 G 3.41 -(db).15 G 3.41(yt)-3.41 G(he)-3.41 E F2(set\255mark)108 700.8 Q F0 2.5 +(db).15 G 3.41(yt)-3.41 G(he)-3.41 E F1(set\255mark)108 307.2 Q F0 2.5 (command. The)2.5 F(te)2.5 E -(xt between the point and mark is referred to as the)-.15 E F1 -.37(re) -2.5 G(gion)-.03 E F0(.)A(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E -(40)198.165 E 0 Cg EP -%%Page: 41 41 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(Commands f)87 84 Q(or Mo)-.25 E(ving)-.1 E -(beginning\255of\255line \(C\255a\))108 96 Q F0(Mo)144 108 Q .3 -.15 +(xt between the point and mark is referred to as the)-.15 E F2 -.37(re) +2.5 G(gion)-.03 E F0(.)A F1(Commands f)87 324 Q(or Mo)-.25 E(ving)-.1 E +(beginning\255of\255line \(C\255a\))108 336 Q F0(Mo)144 348 Q .3 -.15 (ve t)-.15 H 2.5(ot).15 G(he start of the current line.)-2.5 E F1 -(end\255of\255line \(C\255e\))108 120 Q F0(Mo)144 132 Q .3 -.15(ve t) --.15 H 2.5(ot).15 G(he end of the line.)-2.5 E F1 -.25(fo)108 144 S -(rward\255char \(C\255f\)).25 E F0(Mo)144 156 Q .3 -.15(ve f)-.15 H(orw) +(end\255of\255line \(C\255e\))108 360 Q F0(Mo)144 372 Q .3 -.15(ve t) +-.15 H 2.5(ot).15 G(he end of the line.)-2.5 E F1 -.25(fo)108 384 S +(rward\255char \(C\255f\)).25 E F0(Mo)144 396 Q .3 -.15(ve f)-.15 H(orw) .15 E(ard a character)-.1 E(.)-.55 E F1(backward\255char \(C\255b\))108 -168 Q F0(Mo)144 180 Q .3 -.15(ve b)-.15 H(ack a character).15 E(.)-.55 E -F1 -.25(fo)108 192 S(rward\255w).25 E(ord \(M\255f\))-.1 E F0(Mo)144 204 +408 Q F0(Mo)144 420 Q .3 -.15(ve b)-.15 H(ack a character).15 E(.)-.55 E +F1 -.25(fo)108 432 S(rward\255w).25 E(ord \(M\255f\))-.1 E F0(Mo)144 444 Q .822 -.15(ve f)-.15 H(orw).15 E .522(ard to the end of the ne)-.1 F .523(xt w)-.15 F 3.023(ord. W)-.1 F .523 (ords are composed of alphanumeric characters \(let-)-.8 F -(ters and digits\).)144 216 Q F1(backward\255w)108 228 Q(ord \(M\255b\)) --.1 E F0(Mo)144 240 Q 1.71 -.15(ve b)-.15 H 1.41 +(ters and digits\).)144 456 Q F1(backward\255w)108 468 Q(ord \(M\255b\)) +-.1 E F0(Mo)144 480 Q 1.71 -.15(ve b)-.15 H 1.41 (ack to the start of the current or pre).15 F 1.41(vious w)-.25 F 3.91 (ord. W)-.1 F 1.41(ords are composed of alphanumeric)-.8 F -(characters \(letters and digits\).)144 252 Q F1(shell\255f)108 264 Q -(orward\255w)-.25 E(ord)-.1 E F0(Mo)144 276 Q .784 -.15(ve f)-.15 H(orw) +(characters \(letters and digits\).)144 492 Q F1(shell\255f)108 504 Q +(orward\255w)-.25 E(ord)-.1 E F0(Mo)144 516 Q .784 -.15(ve f)-.15 H(orw) .15 E .484(ard to the end of the ne)-.1 F .484(xt w)-.15 F 2.984(ord. W) -.1 F .484(ords are delimited by non-quoted shell metacharac-)-.8 F -(ters.)144 288 Q F1(shell\255backward\255w)108 300 Q(ord)-.1 E F0(Mo)144 -312 Q .909 -.15(ve b)-.15 H .609(ack to the start of the current or pre) +(ters.)144 528 Q F1(shell\255backward\255w)108 540 Q(ord)-.1 E F0(Mo)144 +552 Q .909 -.15(ve b)-.15 H .609(ack to the start of the current or pre) .15 F .609(vious w)-.25 F 3.109(ord. W)-.1 F .608 -(ords are delimited by non-quoted shell)-.8 F(metacharacters.)144 324 Q -F1(clear\255scr)108 336 Q(een \(C\255l\))-.18 E F0 .993 -(Clear the screen lea)144 348 R .993 +(ords are delimited by non-quoted shell)-.8 F(metacharacters.)144 564 Q +F1(clear\255scr)108 576 Q(een \(C\255l\))-.18 E F0 .993 +(Clear the screen lea)144 588 R .993 (ving the current line at the top of the screen.)-.2 F -.4(Wi)5.993 G .993(th an ar).4 F .993(gument, refresh the)-.18 F -(current line without clearing the screen.)144 360 Q F1 -.18(re)108 372 +(current line without clearing the screen.)144 600 Q F1 -.18(re)108 612 S(draw\255curr).18 E(ent\255line)-.18 E F0(Refresh the current line.)144 -384 Q F1(Commands f)87 400.8 Q(or Manipulating the History)-.25 E -(accept\255line \(Newline, Retur)108 412.8 Q(n\))-.15 E F0 .159 -(Accept the line re)144 424.8 R -.05(ga)-.15 G .159 +624 Q F1(Commands f)87 640.8 Q(or Manipulating the History)-.25 E +(accept\255line \(Newline, Retur)108 652.8 Q(n\))-.15 E F0 .159 +(Accept the line re)144 664.8 R -.05(ga)-.15 G .159 (rdless of where the cursor is.).05 F .158(If this line is non-empty) 5.158 F 2.658(,a)-.65 G .158(dd it to the history list)-2.658 F .699 -(according to the state of the)144 436.8 R/F2 9/Times-Bold@0 SF +(according to the state of the)144 676.8 R/F3 9/Times-Bold@0 SF (HISTCONTR)3.199 E(OL)-.27 E F0 -.25(va)2.949 G 3.199(riable. If).25 F .699(the line is a modi\214ed history line, then)3.199 F -(restore the history line to its original state.)144 448.8 Q F1(pr)108 -460.8 Q -.15(ev)-.18 G(ious\255history \(C\255p\)).15 E F0 -(Fetch the pre)144 472.8 Q(vious command from the history list, mo)-.25 -E(ving back in the list.)-.15 E F1(next\255history \(C\255n\))108 484.8 -Q F0(Fetch the ne)144 496.8 Q(xt command from the history list, mo)-.15 -E(ving forw)-.15 E(ard in the list.)-.1 E F1 -(beginning\255of\255history \(M\255<\))108 508.8 Q F0(Mo)144 520.8 Q .3 --.15(ve t)-.15 H 2.5(ot).15 G(he \214rst line in the history)-2.5 E(.) --.65 E F1(end\255of\255history \(M\255>\))108 532.8 Q F0(Mo)144 544.8 Q -.3 -.15(ve t)-.15 H 2.5(ot).15 G(he end of the input history)-2.5 E 2.5 -(,i)-.65 G(.e., the line currently being entered.)-2.5 E F1 -2.29 -.18 -(re v)108 556.8 T(erse\255sear).08 E(ch\255history \(C\255r\))-.18 E F0 -1.471(Search backw)144 568.8 R 1.471 -(ard starting at the current line and mo)-.1 F 1.47 -(ving `up' through the history as necessary)-.15 F(.)-.65 E -(This is an incremental search.)144 580.8 Q F1 -.25(fo)108 592.8 S -(rward\255sear).25 E(ch\255history \(C\255s\))-.18 E F0 1.131 -(Search forw)144 604.8 R 1.131(ard starting at the current line and mo) --.1 F 1.132(ving `do)-.15 F 1.132(wn' through the history as necessary) --.25 F(.)-.65 E(This is an incremental search.)144 616.8 Q F1 -(non\255incr)108 628.8 Q(emental\255r)-.18 E -2.3 -.15(ev e)-.18 H -(rse\255sear).15 E(ch\255history \(M\255p\))-.18 E F0 .165(Search backw) -144 640.8 R .164(ard through the history starting at the current line u\ -sing a non-incremental search for)-.1 F 2.5(as)144 652.8 S -(tring supplied by the user)-2.5 E(.)-.55 E F1(non\255incr)108 664.8 Q -(emental\255f)-.18 E(orward\255sear)-.25 E(ch\255history \(M\255n\))-.18 -E F0 1.353(Search forw)144 676.8 R 1.354(ard through the history using \ -a non-incremental search for a string supplied by the)-.1 F(user)144 -688.8 Q(.)-.55 E F1(history\255sear)108 700.8 Q(ch\255f)-.18 E(orward) --.25 E F0 .249(Search forw)144 712.8 R .249(ard through the history for\ - the string of characters between the start of the current line)-.1 F -(and the point.)144 724.8 Q(This is a non-incremental search.)5 E -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(41)198.165 E 0 Cg EP +(restore the history line to its original state.)144 688.8 Q F1(pr)108 +700.8 Q -.15(ev)-.18 G(ious\255history \(C\255p\)).15 E F0 +(Fetch the pre)144 712.8 Q(vious command from the history list, mo)-.25 +E(ving back in the list.)-.15 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E +-.15(ve)-.15 G(mber 24).15 E(41)185.545 E 0 Cg EP %%Page: 42 42 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(history\255sear)108 84 Q(ch\255backward) --.18 E F0 .95(Search backw)144 96 R .951(ard through the history for th\ -e string of characters between the start of the current)-.1 F -(line and the point.)144 108 Q(This is a non-incremental search.)5 E F1 -(yank\255nth\255ar)108 120 Q 2.5(g\()-.1 G<4dad43ad7929>-2.5 E F0 .622 -(Insert the \214rst ar)144 132 R .622(gument to the pre)-.18 F .622 +-.35 E/F1 10/Times-Bold@0 SF(next\255history \(C\255n\))108 84 Q F0 +(Fetch the ne)144 96 Q(xt command from the history list, mo)-.15 E +(ving forw)-.15 E(ard in the list.)-.1 E F1 +(beginning\255of\255history \(M\255<\))108 108 Q F0(Mo)144 120 Q .3 -.15 +(ve t)-.15 H 2.5(ot).15 G(he \214rst line in the history)-2.5 E(.)-.65 E +F1(end\255of\255history \(M\255>\))108 132 Q F0(Mo)144 144 Q .3 -.15 +(ve t)-.15 H 2.5(ot).15 G(he end of the input history)-2.5 E 2.5(,i)-.65 +G(.e., the line currently being entered.)-2.5 E F1 -2.29 -.18(re v)108 +156 T(erse\255sear).08 E(ch\255history \(C\255r\))-.18 E F0 1.471 +(Search backw)144 168 R 1.471(ard starting at the current line and mo) +-.1 F 1.47(ving `up' through the history as necessary)-.15 F(.)-.65 E +(This is an incremental search.)144 180 Q F1 -.25(fo)108 192 S +(rward\255sear).25 E(ch\255history \(C\255s\))-.18 E F0 1.131 +(Search forw)144 204 R 1.131(ard starting at the current line and mo)-.1 +F 1.132(ving `do)-.15 F 1.132(wn' through the history as necessary)-.25 +F(.)-.65 E(This is an incremental search.)144 216 Q F1(non\255incr)108 +228 Q(emental\255r)-.18 E -2.3 -.15(ev e)-.18 H(rse\255sear).15 E +(ch\255history \(M\255p\))-.18 E F0 .165(Search backw)144 240 R .164(ar\ +d through the history starting at the current line using a non-incremen\ +tal search for)-.1 F 2.5(as)144 252 S(tring supplied by the user)-2.5 E +(.)-.55 E F1(non\255incr)108 264 Q(emental\255f)-.18 E(orward\255sear) +-.25 E(ch\255history \(M\255n\))-.18 E F0 1.353(Search forw)144 276 R +1.354(ard through the history using a non-incremental search for a stri\ +ng supplied by the)-.1 F(user)144 288 Q(.)-.55 E F1(history\255sear)108 +300 Q(ch\255f)-.18 E(orward)-.25 E F0 .249(Search forw)144 312 R .249(a\ +rd through the history for the string of characters between the start o\ +f the current line)-.1 F(and the point.)144 324 Q +(This is a non-incremental search.)5 E F1(history\255sear)108 336 Q +(ch\255backward)-.18 E F0 .95(Search backw)144 348 R .951(ard through t\ +he history for the string of characters between the start of the curren\ +t)-.1 F(line and the point.)144 360 Q(This is a non-incremental search.) +5 E F1(yank\255nth\255ar)108 372 Q 2.5(g\()-.1 G<4dad43ad7929>-2.5 E F0 +.622(Insert the \214rst ar)144 384 R .622(gument to the pre)-.18 F .622 (vious command \(usually the second w)-.25 F .622(ord on the pre)-.1 F -.622(vious line\))-.25 F .794(at point.)144 144 R -.4(Wi)5.794 G .794 +.622(vious line\))-.25 F .794(at point.)144 396 R -.4(Wi)5.794 G .794 (th an ar).4 F(gument)-.18 E/F2 10/Times-Italic@0 SF(n)3.294 E F0 3.294 (,i).24 G .794(nsert the)-3.294 F F2(n)3.294 E F0 .794(th w)B .794 (ord from the pre)-.1 F .794(vious command \(the w)-.25 F .795 -(ords in the)-.1 F(pre)144 156 Q .292(vious command be)-.25 F .292 +(ords in the)-.1 F(pre)144 408 Q .292(vious command be)-.25 F .292 (gin with w)-.15 F .291(ord 0\).)-.1 F 2.791(An)5.291 G -2.25 -.15(eg a) -2.791 H(ti).15 E .591 -.15(ve a)-.25 H -.18(rg).15 G .291 (ument inserts the).18 F F2(n)2.791 E F0 .291(th w)B .291 -(ord from the end of)-.1 F .281(the pre)144 168 R .281(vious command.) +(ord from the end of)-.1 F .281(the pre)144 420 R .281(vious command.) -.25 F .281(Once the ar)5.281 F(gument)-.18 E F2(n)2.781 E F0 .281 (is computed, the ar)2.781 F .281(gument is e)-.18 F .282 -(xtracted as if the "!)-.15 F F2(n)A F0(")A(history e)144 180 Q -(xpansion had been speci\214ed.)-.15 E F1(yank\255last\255ar)108 192 Q +(xtracted as if the "!)-.15 F F2(n)A F0(")A(history e)144 432 Q +(xpansion had been speci\214ed.)-.15 E F1(yank\255last\255ar)108 444 Q 2.5(g\()-.1 G -1.667(M\255. ,)-2.5 F -1.667(M\255_ \))2.5 F F0 1.308 -(Insert the last ar)144 204 R 1.308(gument to the pre)-.18 F 1.307 +(Insert the last ar)144 456 R 1.308(gument to the pre)-.18 F 1.307 (vious command \(the last w)-.25 F 1.307(ord of the pre)-.1 F 1.307 -(vious history entry\).)-.25 F -.4(Wi)144 216 S .203(th a numeric ar).4 +(vious history entry\).)-.25 F -.4(Wi)144 468 S .203(th a numeric ar).4 F .203(gument, beha)-.18 F .504 -.15(ve ex)-.2 H .204(actly lik).15 F(e) -.1 E F1(yank\255nth\255ar)2.704 E(g)-.1 E F0 5.204(.S)C(uccessi)-5.204 E .504 -.15(ve c)-.25 H .204(alls to).15 F F1(yank\255last\255ar)2.704 E -(g)-.1 E F0(mo)144 228 Q .807 -.15(ve b)-.15 H .507 +(g)-.1 E F0(mo)144 480 Q .807 -.15(ve b)-.15 H .507 (ack through the history list, inserting the last w).15 F .507 (ord \(or the w)-.1 F .507(ord speci\214ed by the ar)-.1 F(gument)-.18 E -1.396(to the \214rst call\) of each line in turn.)144 240 R(An)6.396 E +1.396(to the \214rst call\) of each line in turn.)144 492 R(An)6.396 E 3.896(yn)-.15 G 1.396(umeric ar)-3.896 F 1.397 (gument supplied to these successi)-.18 F 1.697 -.15(ve c)-.25 H(alls) -.15 E .492(determines the direction to mo)144 252 R .792 -.15(ve t)-.15 +.15 E .492(determines the direction to mo)144 504 R .792 -.15(ve t)-.15 H .492(hrough the history).15 F 5.491(.A)-.65 G(ne)-2.5 E -.05(ga)-.15 G (ti).05 E .791 -.15(ve a)-.25 H -.18(rg).15 G .491 (ument switches the direction).18 F .494 -(through the history \(back or forw)144 264 R 2.994(ard\). The)-.1 F +(through the history \(back or forw)144 516 R 2.994(ard\). The)-.1 F .494(history e)2.994 F .494(xpansion f)-.15 F .494 -(acilities are used to e)-.1 F .494(xtract the last)-.15 F(ar)144 276 Q +(acilities are used to e)-.1 F .494(xtract the last)-.15 F(ar)144 528 Q (gument, as if the "!$" history e)-.18 E(xpansion had been speci\214ed.) --.15 E F1(shell\255expand\255line \(M\255C\255e\))108 288 Q F0 .623 -(Expand the line as the shell does.)144 300 R .622 +-.15 E F1(shell\255expand\255line \(M\255C\255e\))108 540 Q F0 .623 +(Expand the line as the shell does.)144 552 R .622 (This performs alias and history e)5.622 F .622 -(xpansion as well as all of the)-.15 F(shell w)144 312 Q(ord e)-.1 E 2.5 +(xpansion as well as all of the)-.15 F(shell w)144 564 Q(ord e)-.1 E 2.5 (xpansions. See)-.15 F/F3 9/Times-Bold@0 SF(HIST)2.5 E(OR)-.162 E 2.25 (YE)-.315 G(XP)-2.25 E(ANSION)-.666 E F0(belo)2.25 E 2.5(wf)-.25 G (or a description of history e)-2.5 E(xpansion.)-.15 E F1 -(history\255expand\255line \(M\255^\))108 324 Q F0 .938 -(Perform history e)144 336 R .939(xpansion on the current line.)-.15 F +(history\255expand\255line \(M\255^\))108 576 Q F0 .938 +(Perform history e)144 588 R .939(xpansion on the current line.)-.15 F (See)5.939 E F3(HIST)3.439 E(OR)-.162 E 3.189(YE)-.315 G(XP)-3.189 E (ANSION)-.666 E F0(belo)3.189 E 3.439(wf)-.25 G .939(or a descrip-) --3.439 F(tion of history e)144 348 Q(xpansion.)-.15 E F1(magic\255space) -108 360 Q F0 1.627(Perform history e)144 372 R 1.627 +-3.439 F(tion of history e)144 600 Q(xpansion.)-.15 E F1(magic\255space) +108 612 Q F0 1.627(Perform history e)144 624 R 1.627 (xpansion on the current line and insert a space.)-.15 F(See)6.626 E F3 (HIST)4.126 E(OR)-.162 E 3.876(YE)-.315 G(XP)-3.876 E(ANSION)-.666 E F0 -(belo)144 384 Q 2.5(wf)-.25 G(or a description of history e)-2.5 E -(xpansion.)-.15 E F1(alias\255expand\255line)108 396 Q F0 .394 -(Perform alias e)144 408 R .394(xpansion on the current line.)-.15 F +(belo)144 636 Q 2.5(wf)-.25 G(or a description of history e)-2.5 E +(xpansion.)-.15 E F1(alias\255expand\255line)108 648 Q F0 .394 +(Perform alias e)144 660 R .394(xpansion on the current line.)-.15 F (See)5.395 E F3(ALIASES)2.895 E F0(abo)2.645 E .695 -.15(ve f)-.15 H -.395(or a description of alias e).15 F(xpan-)-.15 E(sion.)144 420 Q F1 -(history\255and\255alias\255expand\255line)108 432 Q F0 -(Perform history and alias e)144 444 Q(xpansion on the current line.) --.15 E F1(insert\255last\255ar)108 456 Q(gument \(M\255.)-.1 E 2.5(,M) -.833 G -1.667(\255_ \))-2.5 F F0 2.5(As)144 468 S(ynon)-2.5 E(ym for) --.15 E F1(yank\255last\255ar)2.5 E(g)-.1 E F0(.)A F1 -(operate\255and\255get\255next \(C\255o\))108 480 Q F0 .948 -(Accept the current line for e)144 492 R -.15(xe)-.15 G .948 +.395(or a description of alias e).15 F(xpan-)-.15 E(sion.)144 672 Q F1 +(history\255and\255alias\255expand\255line)108 684 Q F0 +(Perform history and alias e)144 696 Q(xpansion on the current line.) +-.15 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24) +.15 E(42)185.545 E 0 Cg EP +%%Page: 43 43 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(insert\255last\255ar)108 84 Q +(gument \(M\255.)-.1 E 2.5(,M).833 G -1.667(\255_ \))-2.5 F F0 2.5(As) +144 96 S(ynon)-2.5 E(ym for)-.15 E F1(yank\255last\255ar)2.5 E(g)-.1 E +F0(.)A F1(operate\255and\255get\255next \(C\255o\))108 108 Q F0 .948 +(Accept the current line for e)144 120 R -.15(xe)-.15 G .948 (cution and fetch the ne).15 F .948(xt line relati)-.15 F 1.247 -.15 (ve t)-.25 H 3.447(ot).15 G .947(he current line from the)-3.447 F -(history for editing.)144 504 Q(An)5 E 2.5(ya)-.15 G -.18(rg)-2.5 G +(history for editing.)144 132 Q(An)5 E 2.5(ya)-.15 G -.18(rg)-2.5 G (ument is ignored.).18 E F1 -(edit\255and\255execute\255command \(C\255xC\255e\))108 516 Q F0(In)144 -528 Q -.2(vo)-.4 G 1.226 -.1(ke a).2 H 3.526(ne).1 G 1.026 +(edit\255and\255execute\255command \(C\255xC\255e\))108 144 Q F0(In)144 +156 Q -.2(vo)-.4 G 1.226 -.1(ke a).2 H 3.526(ne).1 G 1.026 (ditor on the current command line, and e)-3.526 F -.15(xe)-.15 G 1.026 (cute the result as shell commands.).15 F F1(Bash)6.026 E F0 -(attempts to in)144 540 Q -.2(vo)-.4 G -.1(ke).2 G F3($VISU)2.6 E(AL) --.54 E/F4 9/Times-Roman@0 SF(,)A F3($EDIT)2.25 E(OR)-.162 E F4(,)A F0 -(and)2.25 E F2(emacs)2.5 E F0(as the editor)2.5 E 2.5(,i)-.4 G 2.5(nt) --2.5 G(hat order)-2.5 E(.)-.55 E F1(Commands f)87 556.8 Q(or Changing T) --.25 E(ext)-.92 E(delete\255char \(C\255d\))108 568.8 Q F0 .358 -(Delete the character at point.)144 580.8 R .358(If point is at the be) +(attempts to in)144 168 Q -.2(vo)-.4 G -.1(ke).2 G/F2 9/Times-Bold@0 SF +($VISU)2.6 E(AL)-.54 E/F3 9/Times-Roman@0 SF(,)A F2($EDIT)2.25 E(OR) +-.162 E F3(,)A F0(and)2.25 E/F4 10/Times-Italic@0 SF(emacs)2.5 E F0 +(as the editor)2.5 E 2.5(,i)-.4 G 2.5(nt)-2.5 G(hat order)-2.5 E(.)-.55 +E F1(Commands f)87 184.8 Q(or Changing T)-.25 E(ext)-.92 E +(delete\255char \(C\255d\))108 196.8 Q F0 .358 +(Delete the character at point.)144 208.8 R .358(If point is at the be) 5.358 F .358(ginning of the line, there are no characters in the)-.15 F -(line, and the last character typed w)144 592.8 Q(as not bound to)-.1 E -F1(delete\255char)2.5 E F0 2.5(,t)C(hen return)-2.5 E F3(EOF)2.5 E F4(.) -A F1(backward\255delete\255char \(Rubout\))108 604.8 Q F0 .552 -(Delete the character behind the cursor)144 616.8 R 5.553(.W)-.55 G .553 +(line, and the last character typed w)144 220.8 Q(as not bound to)-.1 E +F1(delete\255char)2.5 E F0 2.5(,t)C(hen return)-2.5 E F2(EOF)2.5 E F3(.) +A F1(backward\255delete\255char \(Rubout\))108 232.8 Q F0 .552 +(Delete the character behind the cursor)144 244.8 R 5.553(.W)-.55 G .553 (hen gi)-5.553 F -.15(ve)-.25 G 3.053(nan).15 G .553(umeric ar)-3.053 F .553(gument, sa)-.18 F .853 -.15(ve t)-.2 H .553(he deleted te).15 F -.553(xt on)-.15 F(the kill ring.)144 628.8 Q F1 -.25(fo)108 640.8 S +.553(xt on)-.15 F(the kill ring.)144 256.8 Q F1 -.25(fo)108 268.8 S (rward\255backward\255delete\255char).25 E F0 .474 -(Delete the character under the cursor)144 652.8 R 2.974(,u)-.4 G .474 +(Delete the character under the cursor)144 280.8 R 2.974(,u)-.4 G .474 (nless the cursor is at the end of the line, in which case the)-2.974 F -(character behind the cursor is deleted.)144 664.8 Q F1 -(quoted\255insert \(C\255q, C\255v\))108 676.8 Q F0 .778(Add the ne)144 -688.8 R .779(xt character typed to the line v)-.15 F 3.279 +(character behind the cursor is deleted.)144 292.8 Q F1 +(quoted\255insert \(C\255q, C\255v\))108 304.8 Q F0 .778(Add the ne)144 +316.8 R .779(xt character typed to the line v)-.15 F 3.279 (erbatim. This)-.15 F .779(is ho)3.279 F 3.279(wt)-.25 G 3.279(oi)-3.279 G .779(nsert characters lik)-3.279 F(e)-.1 E F1(C\255q)3.279 E F0 3.279 -(,f)C(or)-3.279 E -.15(ex)144 700.8 S(ample.).15 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(42)198.165 E 0 Cg EP -%%Page: 43 43 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(tab\255insert \(C\255v T)108 84 Q(AB\))-.9 -E F0(Insert a tab character)144 96 Q(.)-.55 E F1 -(self\255insert \(a, b, A, 1, !, ...\))108 108 Q F0 -(Insert the character typed.)144 120 Q F1(transpose\255chars \(C\255t\)) -108 132 Q F0 .322(Drag the character before point forw)144 144 R .321 -(ard o)-.1 F -.15(ve)-.15 G 2.821(rt).15 G .321 -(he character at point, mo)-2.821 F .321(ving point forw)-.15 F .321 -(ard as well.)-.1 F 1.182 -(If point is at the end of the line, then this transposes the tw)144 156 -R 3.683(oc)-.1 G 1.183(haracters before point.)-3.683 F(Ne)6.183 E -.05 -(ga)-.15 G(ti).05 E -.15(ve)-.25 G(ar)144 168 Q(guments ha)-.18 E .3 --.15(ve n)-.2 H 2.5(oe).15 G -.25(ff)-2.5 G(ect.).25 E F1 -(transpose\255w)108 180 Q(ords \(M\255t\))-.1 E F0 .024(Drag the w)144 -192 R .024(ord before point past the w)-.1 F .023(ord after point, mo) +(,f)C(or)-3.279 E -.15(ex)144 328.8 S(ample.).15 E F1 +(tab\255insert \(C\255v T)108 340.8 Q(AB\))-.9 E F0 +(Insert a tab character)144 352.8 Q(.)-.55 E F1 +(self\255insert \(a, b, A, 1, !, ...\))108 364.8 Q F0 +(Insert the character typed.)144 376.8 Q F1 +(transpose\255chars \(C\255t\))108 388.8 Q F0 .322 +(Drag the character before point forw)144 400.8 R .321(ard o)-.1 F -.15 +(ve)-.15 G 2.821(rt).15 G .321(he character at point, mo)-2.821 F .321 +(ving point forw)-.15 F .321(ard as well.)-.1 F 1.182 +(If point is at the end of the line, then this transposes the tw)144 +412.8 R 3.683(oc)-.1 G 1.183(haracters before point.)-3.683 F(Ne)6.183 E +-.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G(ar)144 424.8 Q(guments ha)-.18 E +.3 -.15(ve n)-.2 H 2.5(oe).15 G -.25(ff)-2.5 G(ect.).25 E F1 +(transpose\255w)108 436.8 Q(ords \(M\255t\))-.1 E F0 .024(Drag the w)144 +448.8 R .024(ord before point past the w)-.1 F .023(ord after point, mo) -.1 F .023(ving point o)-.15 F -.15(ve)-.15 G 2.523(rt).15 G .023(hat w) -2.523 F .023(ord as well.)-.1 F .023(If point)5.023 F -(is at the end of the line, this transposes the last tw)144 204 Q 2.5 -(ow)-.1 G(ords on the line.)-2.6 E F1(upcase\255w)108 216 Q -(ord \(M\255u\))-.1 E F0 1.698(Uppercase the current \(or follo)144 228 -R 1.698(wing\) w)-.25 F 4.198(ord. W)-.1 F 1.698(ith a ne)-.4 F -.05(ga) --.15 G(ti).05 E 1.999 -.15(ve a)-.25 H -.18(rg).15 G 1.699 -(ument, uppercase the pre).18 F(vious)-.25 E -.1(wo)144 240 S(rd, b).1 E -(ut do not mo)-.2 E .3 -.15(ve p)-.15 H(oint.).15 E F1(do)108 252 Q -(wncase\255w)-.1 E(ord \(M\255l\))-.1 E F0(Lo)144 264 Q 1.648 +(is at the end of the line, this transposes the last tw)144 460.8 Q 2.5 +(ow)-.1 G(ords on the line.)-2.6 E F1(upcase\255w)108 472.8 Q +(ord \(M\255u\))-.1 E F0 1.698(Uppercase the current \(or follo)144 +484.8 R 1.698(wing\) w)-.25 F 4.198(ord. W)-.1 F 1.698(ith a ne)-.4 F +-.05(ga)-.15 G(ti).05 E 1.999 -.15(ve a)-.25 H -.18(rg).15 G 1.699 +(ument, uppercase the pre).18 F(vious)-.25 E -.1(wo)144 496.8 S(rd, b).1 +E(ut do not mo)-.2 E .3 -.15(ve p)-.15 H(oint.).15 E F1(do)108 508.8 Q +(wncase\255w)-.1 E(ord \(M\255l\))-.1 E F0(Lo)144 520.8 Q 1.648 (wercase the current \(or follo)-.25 F 1.648(wing\) w)-.25 F 4.148 (ord. W)-.1 F 1.647(ith a ne)-.4 F -.05(ga)-.15 G(ti).05 E 1.947 -.15 (ve a)-.25 H -.18(rg).15 G 1.647(ument, lo).18 F 1.647(wercase the pre) --.25 F(vious)-.25 E -.1(wo)144 276 S(rd, b).1 E(ut do not mo)-.2 E .3 --.15(ve p)-.15 H(oint.).15 E F1(capitalize\255w)108 288 Q -(ord \(M\255c\))-.1 E F0 1.974(Capitalize the current \(or follo)144 300 -R 1.974(wing\) w)-.25 F 4.474(ord. W)-.1 F 1.974(ith a ne)-.4 F -.05(ga) --.15 G(ti).05 E 2.274 -.15(ve a)-.25 H -.18(rg).15 G 1.975 -(ument, capitalize the pre).18 F(vious)-.25 E -.1(wo)144 312 S(rd, b).1 -E(ut do not mo)-.2 E .3 -.15(ve p)-.15 H(oint.).15 E F1 -.1(ove)108 324 -S(rwrite\255mode).1 E F0 -.8(To)144 336 S .438(ggle o).8 F -.15(ve)-.15 -G .438(rwrite mode.).15 F -.4(Wi)5.438 G .438(th an e).4 F .438 +-.25 F(vious)-.25 E -.1(wo)144 532.8 S(rd, b).1 E(ut do not mo)-.2 E .3 +-.15(ve p)-.15 H(oint.).15 E F1(capitalize\255w)108 544.8 Q +(ord \(M\255c\))-.1 E F0 1.974(Capitalize the current \(or follo)144 +556.8 R 1.974(wing\) w)-.25 F 4.474(ord. W)-.1 F 1.974(ith a ne)-.4 F +-.05(ga)-.15 G(ti).05 E 2.274 -.15(ve a)-.25 H -.18(rg).15 G 1.975 +(ument, capitalize the pre).18 F(vious)-.25 E -.1(wo)144 568.8 S(rd, b) +.1 E(ut do not mo)-.2 E .3 -.15(ve p)-.15 H(oint.).15 E F1 -.1(ove)108 +580.8 S(rwrite\255mode).1 E F0 -.8(To)144 592.8 S .438(ggle o).8 F -.15 +(ve)-.15 G .438(rwrite mode.).15 F -.4(Wi)5.438 G .438(th an e).4 F .438 (xplicit positi)-.15 F .737 -.15(ve n)-.25 H .437(umeric ar).15 F .437 (gument, switches to o)-.18 F -.15(ve)-.15 G .437(rwrite mode.).15 F -.4 -(Wi)144 348 S .78(th an e).4 F .781(xplicit non-positi)-.15 F 1.081 -.15 -(ve n)-.25 H .781(umeric ar).15 F .781(gument, switches to insert mode.) --.18 F .781(This command af)5.781 F(fects)-.25 E(only)144 360 Q F1 -(emacs)4.395 E F0(mode;)4.395 E F1(vi)4.395 E F0 1.894(mode does o)4.395 -F -.15(ve)-.15 G 1.894(rwrite dif).15 F(ferently)-.25 E 6.894(.E)-.65 G -1.894(ach call to)-6.894 F/F2 10/Times-Italic@0 SF -.37(re)4.394 G -(adline\(\)).37 E F0 1.894(starts in insert)4.394 F 3.968(mode. In)144 -372 R -.15(ove)3.968 G 1.468(rwrite mode, characters bound to).15 F F1 -(self\255insert)3.969 E F0 1.469(replace the te)3.969 F 1.469 -(xt at point rather than)-.15 F .958(pushing the te)144 384 R .958 -(xt to the right.)-.15 F .957(Characters bound to)5.958 F F1 -(backward\255delete\255char)3.457 E F0 .957(replace the character)3.457 -F(before point with a space.)144 396 Q(By def)5 E -(ault, this command is unbound.)-.1 E F1(Killing and Y)87 412.8 Q -(anking)-.85 E(kill\255line \(C\255k\))108 424.8 Q F0(Kill the te)144 -436.8 Q(xt from point to the end of the line.)-.15 E F1 -(backward\255kill\255line \(C\255x Rubout\))108 448.8 Q F0(Kill backw) -144 460.8 Q(ard to the be)-.1 E(ginning of the line.)-.15 E F1 -(unix\255line\255discard \(C\255u\))108 472.8 Q F0(Kill backw)144 484.8 -Q(ard from point to the be)-.1 E(ginning of the line.)-.15 E -(The killed te)5 E(xt is sa)-.15 E -.15(ve)-.2 G 2.5(do).15 G 2.5(nt) --2.5 G(he kill-ring.)-2.5 E F1(kill\255whole\255line)108 496.8 Q F0 +(Wi)144 604.8 S .78(th an e).4 F .781(xplicit non-positi)-.15 F 1.081 +-.15(ve n)-.25 H .781(umeric ar).15 F .781 +(gument, switches to insert mode.)-.18 F .781(This command af)5.781 F +(fects)-.25 E(only)144 616.8 Q F1(emacs)4.395 E F0(mode;)4.395 E F1(vi) +4.395 E F0 1.894(mode does o)4.395 F -.15(ve)-.15 G 1.894(rwrite dif).15 +F(ferently)-.25 E 6.894(.E)-.65 G 1.894(ach call to)-6.894 F F4 -.37(re) +4.394 G(adline\(\)).37 E F0 1.894(starts in insert)4.394 F 3.968 +(mode. In)144 628.8 R -.15(ove)3.968 G 1.468 +(rwrite mode, characters bound to).15 F F1(self\255insert)3.969 E F0 +1.469(replace the te)3.969 F 1.469(xt at point rather than)-.15 F .958 +(pushing the te)144 640.8 R .958(xt to the right.)-.15 F .957 +(Characters bound to)5.958 F F1(backward\255delete\255char)3.457 E F0 +.957(replace the character)3.457 F(before point with a space.)144 652.8 +Q(By def)5 E(ault, this command is unbound.)-.1 E F1(Killing and Y)87 +669.6 Q(anking)-.85 E(kill\255line \(C\255k\))108 681.6 Q F0 +(Kill the te)144 693.6 Q(xt from point to the end of the line.)-.15 E F1 +(backward\255kill\255line \(C\255x Rubout\))108 705.6 Q F0(Kill backw) +144 717.6 Q(ard to the be)-.1 E(ginning of the line.)-.15 E +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(43)185.545 E 0 Cg EP +%%Page: 44 44 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(unix\255line\255discard \(C\255u\))108 84 Q +F0(Kill backw)144 96 Q(ard from point to the be)-.1 E +(ginning of the line.)-.15 E(The killed te)5 E(xt is sa)-.15 E -.15(ve) +-.2 G 2.5(do).15 G 2.5(nt)-2.5 G(he kill-ring.)-2.5 E F1 +(kill\255whole\255line)108 108 Q F0 (Kill all characters on the current line, no matter where point is.)144 -508.8 Q F1(kill\255w)108 520.8 Q(ord \(M\255d\))-.1 E F0 .728 -(Kill from point to the end of the current w)144 532.8 R .729 +120 Q F1(kill\255w)108 132 Q(ord \(M\255d\))-.1 E F0 .728 +(Kill from point to the end of the current w)144 144 R .729 (ord, or if between w)-.1 F .729(ords, to the end of the ne)-.1 F .729 -(xt w)-.15 F(ord.)-.1 E -.8(Wo)144 544.8 S +(xt w)-.15 F(ord.)-.1 E -.8(Wo)144 156 S (rd boundaries are the same as those used by).8 E F1 -.25(fo)2.5 G -(rward\255w).25 E(ord)-.1 E F0(.)A F1(backward\255kill\255w)108 556.8 Q -(ord \(M\255Rubout\))-.1 E F0(Kill the w)144 568.8 Q(ord behind point.) --.1 E -.8(Wo)5 G(rd boundaries are the same as those used by).8 E F1 -(backward\255w)2.5 E(ord)-.1 E F0(.)A F1(shell\255kill\255w)108 580.8 Q +(rward\255w).25 E(ord)-.1 E F0(.)A F1(backward\255kill\255w)108 168 Q +(ord \(M\255Rubout\))-.1 E F0(Kill the w)144 180 Q(ord behind point.)-.1 +E -.8(Wo)5 G(rd boundaries are the same as those used by).8 E F1 +(backward\255w)2.5 E(ord)-.1 E F0(.)A F1(shell\255kill\255w)108 192 Q (ord \(M\255d\))-.1 E F0 .729 -(Kill from point to the end of the current w)144 592.8 R .728 +(Kill from point to the end of the current w)144 204 R .728 (ord, or if between w)-.1 F .728(ords, to the end of the ne)-.1 F .728 -(xt w)-.15 F(ord.)-.1 E -.8(Wo)144 604.8 S +(xt w)-.15 F(ord.)-.1 E -.8(Wo)144 216 S (rd boundaries are the same as those used by).8 E F1(shell\255f)2.5 E (orward\255w)-.25 E(ord)-.1 E F0(.)A F1(shell\255backward\255kill\255w) -108 616.8 Q(ord \(M\255Rubout\))-.1 E F0 3.025(Kill the w)144 628.8 R -3.025(ord behind point.)-.1 F -.8(Wo)8.025 G 3.025 +108 228 Q(ord \(M\255Rubout\))-.1 E F0 3.025(Kill the w)144 240 R 3.025 +(ord behind point.)-.1 F -.8(Wo)8.025 G 3.025 (rd boundaries are the same as those used by).8 F F1(shell\255back-) -5.525 E(ward\255w)144 640.8 Q(ord)-.1 E F0(.)A F1(unix\255w)108 652.8 Q -(ord\255rubout \(C\255w\))-.1 E F0 .365(Kill the w)144 664.8 R .365 +5.525 E(ward\255w)144 252 Q(ord)-.1 E F0(.)A F1(unix\255w)108 264 Q +(ord\255rubout \(C\255w\))-.1 E F0 .365(Kill the w)144 276 R .365 (ord behind point, using white space as a w)-.1 F .364(ord boundary)-.1 F 5.364(.T)-.65 G .364(he killed te)-5.364 F .364(xt is sa)-.15 F -.15 (ve)-.2 G 2.864(do).15 G 2.864(nt)-2.864 G(he)-2.864 E(kill-ring.)144 -676.8 Q F1(unix\255\214lename\255rubout)108 688.8 Q F0 .166(Kill the w) -144 700.8 R .166 +288 Q F1(unix\255\214lename\255rubout)108 300 Q F0 .166(Kill the w)144 +312 R .166 (ord behind point, using white space and the slash character as the w) --.1 F .167(ord boundaries.)-.1 F(The)5.167 E(killed te)144 712.8 Q +-.1 F .167(ord boundaries.)-.1 F(The)5.167 E(killed te)144 324 Q (xt is sa)-.15 E -.15(ve)-.2 G 2.5(do).15 G 2.5(nt)-2.5 G(he kill-ring.) --2.5 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(43)198.165 E 0 Cg EP -%%Page: 44 44 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(delete\255horizontal\255space \(M\255\\\)) -108 84 Q F0(Delete all spaces and tabs around point.)144 96 Q F1 -(kill\255r)108 108 Q(egion)-.18 E F0(Kill the te)144 120 Q -(xt in the current re)-.15 E(gion.)-.15 E F1(copy\255r)108 132 Q -(egion\255as\255kill)-.18 E F0(Cop)144 144 Q 2.5(yt)-.1 G(he te)-2.5 E -(xt in the re)-.15 E(gion to the kill b)-.15 E(uf)-.2 E(fer)-.25 E(.) --.55 E F1(copy\255backward\255w)108 156 Q(ord)-.1 E F0(Cop)144 168 Q -4.801(yt)-.1 G 2.301(he w)-4.801 F 2.301(ord before point to the kill b) --.1 F(uf)-.2 E(fer)-.25 E 7.301(.T)-.55 G 2.301(he w)-7.301 F 2.3 -(ord boundaries are the same as)-.1 F F1(back-)4.8 E(ward\255w)144 180 Q -(ord)-.1 E F0(.)A F1(copy\255f)108 192 Q(orward\255w)-.25 E(ord)-.1 E F0 -(Cop)144 204 Q 4.507(yt)-.1 G 2.007(he w)-4.507 F 2.007(ord follo)-.1 F +-2.5 E F1(delete\255horizontal\255space \(M\255\\\))108 336 Q F0 +(Delete all spaces and tabs around point.)144 348 Q F1(kill\255r)108 360 +Q(egion)-.18 E F0(Kill the te)144 372 Q(xt in the current re)-.15 E +(gion.)-.15 E F1(copy\255r)108 384 Q(egion\255as\255kill)-.18 E F0(Cop) +144 396 Q 2.5(yt)-.1 G(he te)-2.5 E(xt in the re)-.15 E +(gion to the kill b)-.15 E(uf)-.2 E(fer)-.25 E(.)-.55 E F1 +(copy\255backward\255w)108 408 Q(ord)-.1 E F0(Cop)144 420 Q 4.801(yt)-.1 +G 2.301(he w)-4.801 F 2.301(ord before point to the kill b)-.1 F(uf)-.2 +E(fer)-.25 E 7.301(.T)-.55 G 2.301(he w)-7.301 F 2.3 +(ord boundaries are the same as)-.1 F F1(back-)4.8 E(ward\255w)144 432 Q +(ord)-.1 E F0(.)A F1(copy\255f)108 444 Q(orward\255w)-.25 E(ord)-.1 E F0 +(Cop)144 456 Q 4.507(yt)-.1 G 2.007(he w)-4.507 F 2.007(ord follo)-.1 F 2.007(wing point to the kill b)-.25 F(uf)-.2 E(fer)-.25 E 7.008(.T)-.55 G 2.008(he w)-7.008 F 2.008(ord boundaries are the same as)-.1 F F1 -.25 -(fo)4.508 G -.37(r-).25 G(ward\255w)144 216 Q(ord)-.1 E F0(.)A F1 -(yank \(C\255y\))108 228 Q F0 -1(Ya)144 240 S +(fo)4.508 G -.37(r-).25 G(ward\255w)144 468 Q(ord)-.1 E F0(.)A F1 +(yank \(C\255y\))108 480 Q F0 -1(Ya)144 492 S (nk the top of the kill ring into the b)1 E(uf)-.2 E(fer at point.)-.25 -E F1(yank\255pop \(M\255y\))108 252 Q F0 -(Rotate the kill ring, and yank the ne)144 264 Q 2.5(wt)-.25 G 2.5 +E F1(yank\255pop \(M\255y\))108 504 Q F0 +(Rotate the kill ring, and yank the ne)144 516 Q 2.5(wt)-.25 G 2.5 (op. Only)-2.5 F -.1(wo)2.5 G(rks follo).1 E(wing)-.25 E F1(yank)2.5 E -F0(or)2.5 E F1(yank\255pop)2.5 E F0(.)A F1(Numeric Ar)87 280.8 Q -(guments)-.1 E(digit\255ar)108 292.8 Q +F0(or)2.5 E F1(yank\255pop)2.5 E F0(.)A F1(Numeric Ar)87 532.8 Q +(guments)-.1 E(digit\255ar)108 544.8 Q (gument \(M\2550, M\2551, ..., M\255\255\))-.1 E F0 .642 -(Add this digit to the ar)144 304.8 R .641 +(Add this digit to the ar)144 556.8 R .641 (gument already accumulating, or start a ne)-.18 F 3.141(wa)-.25 G -.18 (rg)-3.141 G 3.141(ument. M\255\255).18 F .641(starts a ne)3.141 F(g-) --.15 E(ati)144 316.8 Q .3 -.15(ve a)-.25 H -.18(rg).15 G(ument.).18 E F1 -(uni)108 328.8 Q -.1(ve)-.1 G(rsal\255ar).1 E(gument)-.1 E F0 .778 -(This is another w)144 340.8 R .779(ay to specify an ar)-.1 F 3.279 +-.15 E(ati)144 568.8 Q .3 -.15(ve a)-.25 H -.18(rg).15 G(ument.).18 E F1 +(uni)108 580.8 Q -.1(ve)-.1 G(rsal\255ar).1 E(gument)-.1 E F0 .778 +(This is another w)144 592.8 R .779(ay to specify an ar)-.1 F 3.279 (gument. If)-.18 F .779(this command is follo)3.279 F .779 (wed by one or more digits,)-.25 F 1.376 (optionally with a leading minus sign, those digits de\214ne the ar)144 -352.8 R 3.876(gument. If)-.18 F 1.376(the command is fol-)3.876 F(lo)144 -364.8 Q 1.17(wed by digits, e)-.25 F -.15(xe)-.15 G(cuting).15 E F1(uni) +604.8 R 3.876(gument. If)-.18 F 1.376(the command is fol-)3.876 F(lo)144 +616.8 Q 1.17(wed by digits, e)-.25 F -.15(xe)-.15 G(cuting).15 E F1(uni) 3.67 E -.1(ve)-.1 G(rsal\255ar).1 E(gument)-.1 E F0(ag)3.67 E 1.17 (ain ends the numeric ar)-.05 F 1.17(gument, b)-.18 F 1.17(ut is other) --.2 F(-)-.2 E .899(wise ignored.)144 376.8 R .898 +-.2 F(-)-.2 E .899(wise ignored.)144 628.8 R .898 (As a special case, if this command is immediately follo)5.899 F .898 (wed by a character that is)-.25 F .243 -(neither a digit or minus sign, the ar)144 388.8 R .243 +(neither a digit or minus sign, the ar)144 640.8 R .243 (gument count for the ne)-.18 F .243(xt command is multiplied by four) --.15 F 5.243(.T)-.55 G(he)-5.243 E(ar)144 400.8 Q .378 +-.15 F 5.243(.T)-.55 G(he)-5.243 E(ar)144 652.8 Q .378 (gument count is initially one, so e)-.18 F -.15(xe)-.15 G .378 (cuting this function the \214rst time mak).15 F .378(es the ar)-.1 F -.378(gument count)-.18 F(four)144 412.8 Q 2.5(,as)-.4 G(econd time mak) +.378(gument count)-.18 F(four)144 664.8 Q 2.5(,as)-.4 G(econd time mak) -2.5 E(es the ar)-.1 E(gument count sixteen, and so on.)-.18 E F1 -(Completing)87 429.6 Q(complete \(T)108 441.6 Q(AB\))-.9 E F0 1.137 -(Attempt to perform completion on the te)144 453.6 R 1.137 +(Completing)87 681.6 Q(complete \(T)108 693.6 Q(AB\))-.9 E F0 1.137 +(Attempt to perform completion on the te)144 705.6 R 1.137 (xt before point.)-.15 F F1(Bash)6.137 E F0 1.137 -(attempts completion treating the)3.637 F(te)144 465.6 Q .533(xt as a v) +(attempts completion treating the)3.637 F(te)144 717.6 Q .533(xt as a v) -.15 F .533(ariable \(if the te)-.25 F .533(xt be)-.15 F .533(gins with) -.15 F F1($)3.033 E F0 .533(\), username \(if the te)B .532(xt be)-.15 F .532(gins with)-.15 F F1(~)3.032 E F0 .532(\), hostname \(if the)B(te) -144 477.6 Q .701(xt be)-.15 F .701(gins with)-.15 F F1(@)3.201 E F0 .701 -(\), or command \(including aliases and functions\) in turn.)B .702 -(If none of these pro-)5.701 F -(duces a match, \214lename completion is attempted.)144 489.6 Q F1 -(possible\255completions \(M\255?\))108 501.6 Q F0 -(List the possible completions of the te)144 513.6 Q(xt before point.) --.15 E F1(insert\255completions \(M\255*\))108 525.6 Q F0 .783 -(Insert all completions of the te)144 537.6 R .783 -(xt before point that w)-.15 F .783(ould ha)-.1 F 1.083 -.15(ve b)-.2 H -.783(een generated by).15 F F1(possible\255com-)3.282 E(pletions)144 -549.6 Q F0(.)A F1(menu\255complete)108 561.6 Q F0 .928(Similar to)144 -573.6 R F1(complete)3.428 E F0 3.428(,b)C .929(ut replaces the w)-3.628 -F .929(ord to be completed with a single match from the list of)-.1 F -1.194(possible completions.)144 585.6 R 1.194(Repeated e)6.194 F -.15 -(xe)-.15 G 1.194(cution of).15 F F1(menu\255complete)3.694 E F0 1.193 -(steps through the list of possible)3.694 F .828 -(completions, inserting each match in turn.)144 597.6 R .828 -(At the end of the list of completions, the bell is rung)5.828 F .727 -(\(subject to the setting of)144 609.6 R F1(bell\255style)3.227 E F0 -3.227(\)a)C .727(nd the original te)-3.227 F .727(xt is restored.)-.15 F -.727(An ar)5.727 F .727(gument of)-.18 F/F2 10/Times-Italic@0 SF(n)3.227 -E F0(mo)3.227 E -.15(ve)-.15 G(s).15 E F2(n)3.227 E F0 1.73 -(positions forw)144 621.6 R 1.73(ard in the list of matches; a ne)-.1 F --.05(ga)-.15 G(ti).05 E 2.03 -.15(ve a)-.25 H -.18(rg).15 G 1.73 -(ument may be used to mo).18 F 2.03 -.15(ve b)-.15 H(ackw).15 E(ard)-.1 -E(through the list.)144 633.6 Q(This command is intended to be bound to) -5 E F1 -.9(TA)2.5 G(B).9 E F0 2.5(,b)C(ut is unbound by def)-2.7 E -(ault.)-.1 E F1(menu\255complete\255backward)108 645.6 Q F0 .82 -(Identical to)144 657.6 R F1(menu\255complete)3.32 E F0 3.32(,b)C .82 -(ut mo)-3.52 F -.15(ve)-.15 G 3.32(sb).15 G(ackw)-3.32 E .82 -(ard through the list of possible completions, as if)-.1 F F1 -(menu\255complete)144 669.6 Q F0(had been gi)2.5 E -.15(ve)-.25 G 2.5 -(nan).15 G -2.25 -.15(eg a)-2.5 H(ti).15 E .3 -.15(ve a)-.25 H -.18(rg) -.15 G 2.5(ument. This).18 F(command is unbound by def)2.5 E(ault.)-.1 E -F1(delete\255char\255or\255list)108 681.6 Q F0 .234 -(Deletes the character under the cursor if not at the be)144 693.6 R -.234(ginning or end of the line \(lik)-.15 F(e)-.1 E F1(delete\255char) -2.735 E F0(\).)A .425(If at the end of the line, beha)144 705.6 R -.15 -(ve)-.2 G 2.925(si).15 G .425(dentically to)-2.925 F F1 -(possible\255completions)2.925 E F0 5.425(.T)C .425 -(his command is unbound)-5.425 F(by def)144 717.6 Q(ault.)-.1 E -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(44)198.165 E 0 Cg EP +144 729.6 Q 2.025(xt be)-.15 F 2.025(gins with)-.15 F F1(@)4.525 E F0 +2.025(\), or command \(including aliases and functions\) in turn.)B +2.026(If none of these)7.026 F(GNU Bash 4.2)72 768 Q(2012 No)136.385 E +-.15(ve)-.15 G(mber 24).15 E(44)185.545 E 0 Cg EP %%Page: 45 45 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(complete\255\214lename \(M\255/\))108 84 Q -F0(Attempt \214lename completion on the te)144 96 Q(xt before point.) --.15 E F1(possible\255\214lename\255completions \(C\255x /\))108 108 Q -F0(List the possible completions of the te)144 120 Q +-.35 E(produces a match, \214lename completion is attempted.)144 84 Q/F1 +10/Times-Bold@0 SF(possible\255completions \(M\255?\))108 96 Q F0 +(List the possible completions of the te)144 108 Q(xt before point.)-.15 +E F1(insert\255completions \(M\255*\))108 120 Q F0 .783 +(Insert all completions of the te)144 132 R .783(xt before point that w) +-.15 F .783(ould ha)-.1 F 1.083 -.15(ve b)-.2 H .783(een generated by) +.15 F F1(possible\255com-)3.282 E(pletions)144 144 Q F0(.)A F1 +(menu\255complete)108 156 Q F0 .928(Similar to)144 168 R F1(complete) +3.428 E F0 3.428(,b)C .929(ut replaces the w)-3.628 F .929 +(ord to be completed with a single match from the list of)-.1 F 1.194 +(possible completions.)144 180 R 1.194(Repeated e)6.194 F -.15(xe)-.15 G +1.194(cution of).15 F F1(menu\255complete)3.694 E F0 1.193 +(steps through the list of possible)3.694 F .828 +(completions, inserting each match in turn.)144 192 R .828 +(At the end of the list of completions, the bell is rung)5.828 F .727 +(\(subject to the setting of)144 204 R F1(bell\255style)3.227 E F0 3.227 +(\)a)C .727(nd the original te)-3.227 F .727(xt is restored.)-.15 F .727 +(An ar)5.727 F .727(gument of)-.18 F/F2 10/Times-Italic@0 SF(n)3.227 E +F0(mo)3.227 E -.15(ve)-.15 G(s).15 E F2(n)3.227 E F0 1.73 +(positions forw)144 216 R 1.73(ard in the list of matches; a ne)-.1 F +-.05(ga)-.15 G(ti).05 E 2.03 -.15(ve a)-.25 H -.18(rg).15 G 1.73 +(ument may be used to mo).18 F 2.03 -.15(ve b)-.15 H(ackw).15 E(ard)-.1 +E(through the list.)144 228 Q(This command is intended to be bound to)5 +E F1 -.9(TA)2.5 G(B).9 E F0 2.5(,b)C(ut is unbound by def)-2.7 E(ault.) +-.1 E F1(menu\255complete\255backward)108 240 Q F0 .82(Identical to)144 +252 R F1(menu\255complete)3.32 E F0 3.32(,b)C .82(ut mo)-3.52 F -.15(ve) +-.15 G 3.32(sb).15 G(ackw)-3.32 E .82 +(ard through the list of possible completions, as if)-.1 F F1 +(menu\255complete)144 264 Q F0(had been gi)2.5 E -.15(ve)-.25 G 2.5(nan) +.15 G -2.25 -.15(eg a)-2.5 H(ti).15 E .3 -.15(ve a)-.25 H -.18(rg).15 G +2.5(ument. This).18 F(command is unbound by def)2.5 E(ault.)-.1 E F1 +(delete\255char\255or\255list)108 276 Q F0 .234 +(Deletes the character under the cursor if not at the be)144 288 R .234 +(ginning or end of the line \(lik)-.15 F(e)-.1 E F1(delete\255char)2.735 +E F0(\).)A .425(If at the end of the line, beha)144 300 R -.15(ve)-.2 G +2.925(si).15 G .425(dentically to)-2.925 F F1(possible\255completions) +2.925 E F0 5.425(.T)C .425(his command is unbound)-5.425 F(by def)144 +312 Q(ault.)-.1 E F1(complete\255\214lename \(M\255/\))108 324 Q F0 +(Attempt \214lename completion on the te)144 336 Q(xt before point.)-.15 +E F1(possible\255\214lename\255completions \(C\255x /\))108 348 Q F0 +(List the possible completions of the te)144 360 Q (xt before point, treating it as a \214lename.)-.15 E F1 -(complete\255user)108 132 Q(name \(M\255~\))-.15 E F0 -(Attempt completion on the te)144 144 Q +(complete\255user)108 372 Q(name \(M\255~\))-.15 E F0 +(Attempt completion on the te)144 384 Q (xt before point, treating it as a username.)-.15 E F1(possible\255user) -108 156 Q(name\255completions \(C\255x ~\))-.15 E F0 -(List the possible completions of the te)144 168 Q +108 396 Q(name\255completions \(C\255x ~\))-.15 E F0 +(List the possible completions of the te)144 408 Q (xt before point, treating it as a username.)-.15 E F1(complete\255v)108 -180 Q(ariable \(M\255$\))-.1 E F0(Attempt completion on the te)144 192 Q +420 Q(ariable \(M\255$\))-.1 E F0(Attempt completion on the te)144 432 Q (xt before point, treating it as a shell v)-.15 E(ariable.)-.25 E F1 -(possible\255v)108 204 Q(ariable\255completions \(C\255x $\))-.1 E F0 -(List the possible completions of the te)144 216 Q +(possible\255v)108 444 Q(ariable\255completions \(C\255x $\))-.1 E F0 +(List the possible completions of the te)144 456 Q (xt before point, treating it as a shell v)-.15 E(ariable.)-.25 E F1 -(complete\255hostname \(M\255@\))108 228 Q F0 -(Attempt completion on the te)144 240 Q +(complete\255hostname \(M\255@\))108 468 Q F0 +(Attempt completion on the te)144 480 Q (xt before point, treating it as a hostname.)-.15 E F1 -(possible\255hostname\255completions \(C\255x @\))108 252 Q F0 -(List the possible completions of the te)144 264 Q +(possible\255hostname\255completions \(C\255x @\))108 492 Q F0 +(List the possible completions of the te)144 504 Q (xt before point, treating it as a hostname.)-.15 E F1 -(complete\255command \(M\255!\))108 276 Q F0 .58 -(Attempt completion on the te)144 288 R .581 +(complete\255command \(M\255!\))108 516 Q F0 .58 +(Attempt completion on the te)144 528 R .581 (xt before point, treating it as a command name.)-.15 F .581 -(Command comple-)5.581 F .715(tion attempts to match the te)144 300 R +(Command comple-)5.581 F .715(tion attempts to match the te)144 540 R .715(xt ag)-.15 F .715(ainst aliases, reserv)-.05 F .715(ed w)-.15 F .715(ords, shell functions, shell b)-.1 F .715(uiltins, and)-.2 F -(\214nally e)144 312 Q -.15(xe)-.15 G +(\214nally e)144 552 Q -.15(xe)-.15 G (cutable \214lenames, in that order).15 E(.)-.55 E F1 -(possible\255command\255completions \(C\255x !\))108 324 Q F0 -(List the possible completions of the te)144 336 Q +(possible\255command\255completions \(C\255x !\))108 564 Q F0 +(List the possible completions of the te)144 576 Q (xt before point, treating it as a command name.)-.15 E F1 -(dynamic\255complete\255history \(M\255T)108 348 Q(AB\))-.9 E F0 .424 -(Attempt completion on the te)144 360 R .425 +(dynamic\255complete\255history \(M\255T)108 588 Q(AB\))-.9 E F0 .424 +(Attempt completion on the te)144 600 R .425 (xt before point, comparing the te)-.15 F .425(xt ag)-.15 F .425 (ainst lines from the history list)-.05 F -(for possible completion matches.)144 372 Q F1(dab)108 384 Q(br)-.1 E +(for possible completion matches.)144 612 Q F1(dab)108 624 Q(br)-.1 E -.15(ev)-.18 G(\255expand).15 E F0 .611 -(Attempt menu completion on the te)144 396 R .611 +(Attempt menu completion on the te)144 636 R .611 (xt before point, comparing the te)-.15 F .61(xt ag)-.15 F .61 (ainst lines from the his-)-.05 F -(tory list for possible completion matches.)144 408 Q F1 -(complete\255into\255braces \(M\255{\))108 420 Q F0 .4(Perform \214lena\ +(tory list for possible completion matches.)144 648 Q F1 +(complete\255into\255braces \(M\255{\))108 660 Q F0 .4(Perform \214lena\ me completion and insert the list of possible completions enclosed with\ -in braces so)144 432 R(the list is a)144 444 Q -.25(va)-.2 G +in braces so)144 672 R(the list is a)144 684 Q -.25(va)-.2 G (ilable to the shell \(see).25 E F1(Brace Expansion)2.5 E F0(abo)2.5 E --.15(ve)-.15 G(\).).15 E F1 -.25(Ke)87 460.8 S(yboard Macr).25 E(os)-.18 -E(start\255kbd\255macr)108 472.8 Q 2.5(o\()-.18 G(C\255x \()-2.5 E(\)) -.833 E F0(Be)144 484.8 Q(gin sa)-.15 E +-.15(ve)-.15 G(\).).15 E F1 -.25(Ke)87 700.8 S(yboard Macr).25 E(os)-.18 +E F0(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 +E(45)185.545 E 0 Cg EP +%%Page: 46 46 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(start\255kbd\255macr)108 84 Q 2.5(o\()-.18 +G(C\255x \()-2.5 E(\)).833 E F0(Be)144 96 Q(gin sa)-.15 E (ving the characters typed into the current k)-.2 E -.15(ey)-.1 G -(board macro.).15 E F1(end\255kbd\255macr)108 496.8 Q 2.5(o\()-.18 G -(C\255x \))-2.5 E(\)).833 E F0(Stop sa)144 508.8 Q +(board macro.).15 E F1(end\255kbd\255macr)108 108 Q 2.5(o\()-.18 G +(C\255x \))-2.5 E(\)).833 E F0(Stop sa)144 120 Q (ving the characters typed into the current k)-.2 E -.15(ey)-.1 G (board macro and store the de\214nition.).15 E F1 -(call\255last\255kbd\255macr)108 520.8 Q 2.5(o\()-.18 G(C\255x e\))-2.5 -E F0(Re-e)144 532.8 Q -.15(xe)-.15 G 1(cute the last k).15 F -.15(ey)-.1 -G .999(board macro de\214ned, by making the characters in the macro app\ -ear as if).15 F .662(typed at the k)144 544.8 R -.15(ey)-.1 G(board.).15 -E F1(print\255last\255kbd\255macr)5.663 E 3.163(o\()-.18 G(\))-3.163 E -F0 .663(Print the last k)3.163 F -.15(ey)-.1 G .663 +(call\255last\255kbd\255macr)108 132 Q 2.5(o\()-.18 G(C\255x e\))-2.5 E +F0(Re-e)144 144 Q -.15(xe)-.15 G 1(cute the last k).15 F -.15(ey)-.1 G +.999(board macro de\214ned, by making the characters in the macro appea\ +r as if).15 F .662(typed at the k)144 156 R -.15(ey)-.1 G(board.).15 E +F1(print\255last\255kbd\255macr)5.663 E 3.163(o\()-.18 G(\))-3.163 E F0 +.663(Print the last k)3.163 F -.15(ey)-.1 G .663 (board macro de\214ned in a for).15 F(-)-.2 E(mat suitable for the)144 -556.8 Q/F2 10/Times-Italic@0 SF(inputr)2.5 E(c)-.37 E F0(\214le.)2.5 E -F1(Miscellaneous)87 573.6 Q -.18(re)108 585.6 S.18 E +168 Q/F2 10/Times-Italic@0 SF(inputr)2.5 E(c)-.37 E F0(\214le.)2.5 E F1 +(Miscellaneous)87 184.8 Q -.18(re)108 196.8 S.18 E (ead\255init\255\214le \(C\255x C\255r\))-.18 E F0 1.777 -(Read in the contents of the)144 597.6 R F2(inputr)4.277 E(c)-.37 E F0 +(Read in the contents of the)144 208.8 R F2(inputr)4.277 E(c)-.37 E F0 1.776(\214le, and incorporate an)4.276 F 4.276(yb)-.15 G 1.776 (indings or v)-4.276 F 1.776(ariable assignments)-.25 F(found there.)144 -609.6 Q F1(abort \(C\255g\))108 621.6 Q F0 3.248 -(Abort the current editing command and ring the terminal')144 633.6 R +220.8 Q F1(abort \(C\255g\))108 232.8 Q F0 3.248 +(Abort the current editing command and ring the terminal')144 244.8 R 5.749(sb)-.55 G 3.249(ell \(subject to the setting of)-5.749 F F1 -(bell\255style)144 645.6 Q F0(\).)A F1(do\255upper)108 657.6 Q +(bell\255style)144 256.8 Q F0(\).)A F1(do\255upper)108 268.8 Q (case\255v)-.18 E(ersion \(M\255a, M\255b, M\255)-.1 E F2(x)A F1 2.5(,.) -C(..\))-2.5 E F0 1.756(If the meta\214ed character)144 669.6 R F2(x) +C(..\))-2.5 E F0 1.756(If the meta\214ed character)144 280.8 R F2(x) 4.256 E F0 1.755(is lo)4.256 F 1.755 (wercase, run the command that is bound to the corresponding)-.25 F -(uppercase character)144 681.6 Q(.)-.55 E F1(pr)108 693.6 Q -(e\214x\255meta \(ESC\))-.18 E F0(Metafy the ne)144 705.6 Q +(uppercase character)144 292.8 Q(.)-.55 E F1(pr)108 304.8 Q +(e\214x\255meta \(ESC\))-.18 E F0(Metafy the ne)144 316.8 Q (xt character typed.)-.15 E/F3 9/Times-Bold@0 SF(ESC)5 E F1(f)2.25 E F0 -(is equi)2.5 E -.25(va)-.25 G(lent to).25 E F1(Meta\255f)2.5 E F0(.)A -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(45)198.165 E 0 Cg EP -%%Page: 46 46 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(undo \(C\255_, C\255x C\255u\))108 84 Q F0 -(Incremental undo, separately remembered for each line.)144 96 Q F1 --2.29 -.18(re v)108 108 T(ert\255line \(M\255r\)).08 E F0 1.095 -(Undo all changes made to this line.)144 120 R 1.095(This is lik)6.095 F -3.595(ee)-.1 G -.15(xe)-3.745 G 1.095(cuting the).15 F F1(undo)3.595 E +(is equi)2.5 E -.25(va)-.25 G(lent to).25 E F1(Meta\255f)2.5 E F0(.)A F1 +(undo \(C\255_, C\255x C\255u\))108 328.8 Q F0 +(Incremental undo, separately remembered for each line.)144 340.8 Q F1 +-2.29 -.18(re v)108 352.8 T(ert\255line \(M\255r\)).08 E F0 1.095 +(Undo all changes made to this line.)144 364.8 R 1.095(This is lik)6.095 +F 3.595(ee)-.1 G -.15(xe)-3.745 G 1.095(cuting the).15 F F1(undo)3.595 E F0 1.095(command enough times to)3.595 F -(return the line to its initial state.)144 132 Q F1 -(tilde\255expand \(M\255&\))108 144 Q F0(Perform tilde e)144 156 Q +(return the line to its initial state.)144 376.8 Q F1 +(tilde\255expand \(M\255&\))108 388.8 Q F0(Perform tilde e)144 400.8 Q (xpansion on the current w)-.15 E(ord.)-.1 E F1 -(set\255mark \(C\255@, M\255\))108 168 Q F0 -(Set the mark to the point.)144 180 Q(If a numeric ar)5 E +(set\255mark \(C\255@, M\255\))108 412.8 Q F0 +(Set the mark to the point.)144 424.8 Q(If a numeric ar)5 E (gument is supplied, the mark is set to that position.)-.18 E F1 -(exchange\255point\255and\255mark \(C\255x C\255x\))108 192 Q F0(Sw)144 -204 Q .283(ap the point with the mark.)-.1 F .283 +(exchange\255point\255and\255mark \(C\255x C\255x\))108 436.8 Q F0(Sw) +144 448.8 Q .283(ap the point with the mark.)-.1 F .283 (The current cursor position is set to the sa)5.283 F -.15(ve)-.2 G 2.782(dp).15 G .282(osition, and the old)-2.782 F(cursor position is sa) -144 216 Q -.15(ve)-.2 G 2.5(da).15 G 2.5(st)-2.5 G(he mark.)-2.5 E F1 -(character\255sear)108 228 Q(ch \(C\255]\))-.18 E F0 3.035(Ac)144 240 S -.535(haracter is read and point is mo)-3.035 F -.15(ve)-.15 G 3.035(dt) -.15 G 3.035(ot)-3.035 G .535(he ne)-3.035 F .535 +144 460.8 Q -.15(ve)-.2 G 2.5(da).15 G 2.5(st)-2.5 G(he mark.)-2.5 E F1 +(character\255sear)108 472.8 Q(ch \(C\255]\))-.18 E F0 3.035(Ac)144 +484.8 S .535(haracter is read and point is mo)-3.035 F -.15(ve)-.15 G +3.035(dt).15 G 3.035(ot)-3.035 G .535(he ne)-3.035 F .535 (xt occurrence of that character)-.15 F 5.536(.A)-.55 G(ne)-2.5 E -.05 (ga)-.15 G(ti).05 E .836 -.15(ve c)-.25 H(ount).15 E(searches for pre) -144 252 Q(vious occurrences.)-.25 E F1(character\255sear)108 264 Q -(ch\255backward \(M\255C\255]\))-.18 E F0 3.544(Ac)144 276 S 1.044 +144 496.8 Q(vious occurrences.)-.25 E F1(character\255sear)108 508.8 Q +(ch\255backward \(M\255C\255]\))-.18 E F0 3.544(Ac)144 520.8 S 1.044 (haracter is read and point is mo)-3.544 F -.15(ve)-.15 G 3.544(dt).15 G 3.544(ot)-3.544 G 1.044(he pre)-3.544 F 1.044 (vious occurrence of that character)-.25 F 6.043(.A)-.55 G(ne)-2.5 E -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G -(count searches for subsequent occurrences.)144 288 Q F1 -(skip\255csi\255sequence)108 300 Q F0 1.826 -(Read enough characters to consume a multi-k)144 312 R 2.126 -.15(ey s) --.1 H 1.827(equence such as those de\214ned for k).15 F -.15(ey)-.1 G -4.327(sl).15 G(ik)-4.327 E(e)-.1 E .791(Home and End.)144 324 R .791 -(Such sequences be)5.791 F .791 +(count searches for subsequent occurrences.)144 532.8 Q F1 +(skip\255csi\255sequence)108 544.8 Q F0 1.826 +(Read enough characters to consume a multi-k)144 556.8 R 2.126 -.15 +(ey s)-.1 H 1.827(equence such as those de\214ned for k).15 F -.15(ey) +-.1 G 4.327(sl).15 G(ik)-4.327 E(e)-.1 E .791(Home and End.)144 568.8 R +.791(Such sequences be)5.791 F .791 (gin with a Control Sequence Indicator \(CSI\), usually ESC\255[.)-.15 F -.331(If this sequence is bound to "\\[", k)144 336 R -.15(ey)-.1 G 2.831 -(sp).15 G .331(roducing such sequences will ha)-2.831 F .632 -.15(ve n) --.2 H 2.832(oe).15 G -.25(ff)-2.832 G .332(ect unless e).25 F(xplic-) --.15 E .026(itly bound to a readline command, instead of inserting stra\ -y characters into the editing b)144 348 R(uf)-.2 E(fer)-.25 E 5.026(.T) --.55 G(his)-5.026 E(is unbound by def)144 360 Q(ault, b)-.1 E +.331(If this sequence is bound to "\\[", k)144 580.8 R -.15(ey)-.1 G +2.831(sp).15 G .331(roducing such sequences will ha)-2.831 F .632 -.15 +(ve n)-.2 H 2.832(oe).15 G -.25(ff)-2.832 G .332(ect unless e).25 F +(xplic-)-.15 E .026(itly bound to a readline command, instead of insert\ +ing stray characters into the editing b)144 592.8 R(uf)-.2 E(fer)-.25 E +5.026(.T)-.55 G(his)-5.026 E(is unbound by def)144 604.8 Q(ault, b)-.1 E (ut usually bound to ESC\255[.)-.2 E F1(insert\255comment \(M\255#\))108 -372 Q F0 -.4(Wi)144 384 S .48(thout a numeric ar).4 F .48(gument, the v) --.18 F .481(alue of the readline)-.25 F F1(comment\255begin)2.981 E F0 --.25(va)2.981 G .481(riable is inserted at the).25 F(be)144 396 Q .098 +616.8 Q F0 -.4(Wi)144 628.8 S .48(thout a numeric ar).4 F .48 +(gument, the v)-.18 F .481(alue of the readline)-.25 F F1 +(comment\255begin)2.981 E F0 -.25(va)2.981 G .481 +(riable is inserted at the).25 F(be)144 640.8 Q .098 (ginning of the current line.)-.15 F .098(If a numeric ar)5.098 F .097 (gument is supplied, this command acts as a toggle:)-.18 F(if)5.097 E -.321(the characters at the be)144 408 R .321 +.321(the characters at the be)144 652.8 R .321 (ginning of the line do not match the v)-.15 F .321(alue of)-.25 F F1 (comment\255begin)2.821 E F0 2.822(,t)C .322(he v)-2.822 F .322(alue is) --.25 F .832(inserted, otherwise the characters in)144 420 R F1 +-.25 F .832(inserted, otherwise the characters in)144 664.8 R F1 (comment\255begin)3.332 E F0 .831(are deleted from the be)3.332 F .831 (ginning of the line.)-.15 F 1.468 -(In either case, the line is accepted as if a ne)144 432 R 1.468 +(In either case, the line is accepted as if a ne)144 676.8 R 1.468 (wline had been typed.)-.25 F 1.469(The def)6.469 F 1.469(ault v)-.1 F -1.469(alue of)-.25 F F1(com-)3.969 E(ment\255begin)144 444 Q F0 .84 +1.469(alue of)-.25 F F1(com-)3.969 E(ment\255begin)144 688.8 Q F0 .84 (causes this command to mak)3.34 F 3.339(et)-.1 G .839 (he current line a shell comment.)-3.339 F .839(If a numeric ar)5.839 F -(gu-)-.18 E(ment causes the comment character to be remo)144 456 Q -.15 -(ve)-.15 G(d, the line will be e).15 E -.15(xe)-.15 G -(cuted by the shell.).15 E F1(glob\255complete\255w)108 468 Q -(ord \(M\255g\))-.1 E F0 .791(The w)144 480 R .791 -(ord before point is treated as a pattern for pathname e)-.1 F .792 -(xpansion, with an asterisk implicitly)-.15 F 2.5(appended. This)144 492 -R(pattern is used to generate a list of matching \214lenames for possib\ -le completions.)2.5 E F1(glob\255expand\255w)108 504 Q(ord \(C\255x *\)) --.1 E F0 .176(The w)144 516 R .176 -(ord before point is treated as a pattern for pathname e)-.1 F .176 -(xpansion, and the list of matching \214le-)-.15 F .516 -(names is inserted, replacing the w)144 528 R 3.016(ord. If)-.1 F 3.016 +(gu-)-.18 E(ment causes the comment character to be remo)144 700.8 Q +-.15(ve)-.15 G(d, the line will be e).15 E -.15(xe)-.15 G +(cuted by the shell.).15 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15 +(ve)-.15 G(mber 24).15 E(46)185.545 E 0 Cg EP +%%Page: 47 47 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(glob\255complete\255w)108 84 Q +(ord \(M\255g\))-.1 E F0 .791(The w)144 96 R .791 +(ord before point is treated as a pattern for pathname e)-.1 F .792 +(xpansion, with an asterisk implicitly)-.15 F 2.5(appended. This)144 108 +R(pattern is used to generate a list of matching \214lenames for possib\ +le completions.)2.5 E F1(glob\255expand\255w)108 120 Q(ord \(C\255x *\)) +-.1 E F0 .176(The w)144 132 R .176 +(ord before point is treated as a pattern for pathname e)-.1 F .176 +(xpansion, and the list of matching \214le-)-.15 F .516 +(names is inserted, replacing the w)144 144 R 3.016(ord. If)-.1 F 3.016 (an)3.016 G .516(umeric ar)-3.016 F .516 (gument is supplied, an asterisk is appended)-.18 F(before pathname e) -144 540 Q(xpansion.)-.15 E F1(glob\255list\255expansions \(C\255x g\)) -108 552 Q F0 .923(The list of e)144 564 R .923(xpansions that w)-.15 F +144 156 Q(xpansion.)-.15 E F1(glob\255list\255expansions \(C\255x g\)) +108 168 Q F0 .923(The list of e)144 180 R .923(xpansions that w)-.15 F .923(ould ha)-.1 F 1.223 -.15(ve b)-.2 H .923(een generated by).15 F F1 (glob\255expand\255w)3.423 E(ord)-.1 E F0 .923(is displayed, and)3.423 F -.872(the line is redra)144 576 R 3.372(wn. If)-.15 F 3.372(an)3.372 G +.872(the line is redra)144 192 R 3.372(wn. If)-.15 F 3.372(an)3.372 G .872(umeric ar)-3.372 F .872 (gument is supplied, an asterisk is appended before pathname)-.18 F -.15 -(ex)144 588 S(pansion.).15 E F1(dump\255functions)108 600 Q F0 .627 -(Print all of the functions and their k)144 612 R .927 -.15(ey b)-.1 H +(ex)144 204 S(pansion.).15 E F1(dump\255functions)108 216 Q F0 .627 +(Print all of the functions and their k)144 228 R .927 -.15(ey b)-.1 H .626(indings to the readline output stream.).15 F .626(If a numeric ar) 5.626 F(gu-)-.18 E -(ment is supplied, the output is formatted in such a w)144 624 Q +(ment is supplied, the output is formatted in such a w)144 240 Q (ay that it can be made part of an)-.1 E/F2 10/Times-Italic@0 SF(inputr) -2.5 E(c)-.37 E F0(\214le.)2.5 E F1(dump\255v)108 636 Q(ariables)-.1 E F0 -1.799(Print all of the settable readline v)144 648 R 1.799 +2.5 E(c)-.37 E F0(\214le.)2.5 E F1(dump\255v)108 252 Q(ariables)-.1 E F0 +1.799(Print all of the settable readline v)144 264 R 1.799 (ariables and their v)-.25 F 1.8(alues to the readline output stream.) --.25 F 1.8(If a)6.8 F .305(numeric ar)144 660 R .304 +-.25 F 1.8(If a)6.8 F .305(numeric ar)144 276 R .304 (gument is supplied, the output is formatted in such a w)-.18 F .304 -(ay that it can be made part of an)-.1 F F2(inputr)144 672 Q(c)-.37 E F0 -(\214le.)2.5 E F1(dump\255macr)108 684 Q(os)-.18 E F0 .592 -(Print all of the readline k)144 696 R .892 -.15(ey s)-.1 H .592 +(ay that it can be made part of an)-.1 F F2(inputr)144 288 Q(c)-.37 E F0 +(\214le.)2.5 E F1(dump\255macr)108 300 Q(os)-.18 E F0 .592 +(Print all of the readline k)144 312 R .892 -.15(ey s)-.1 H .592 (equences bound to macros and the strings the).15 F 3.093(yo)-.15 G -3.093(utput. If)-3.093 F 3.093(an)3.093 G(umeric)-3.093 E(ar)144 708 Q +3.093(utput. If)-3.093 F 3.093(an)3.093 G(umeric)-3.093 E(ar)144 324 Q .528(gument is supplied, the output is formatted in such a w)-.18 F .528 (ay that it can be made part of an)-.1 F F2(inputr)3.027 E(c)-.37 E F0 -(\214le.)144 720 Q(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(46) -198.165 E 0 Cg EP -%%Page: 47 47 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(display\255shell\255v)108 84 Q -(ersion \(C\255x C\255v\))-.1 E F0(Display v)144 96 Q +(\214le.)144 336 Q F1(display\255shell\255v)108 348 Q +(ersion \(C\255x C\255v\))-.1 E F0(Display v)144 360 Q (ersion information about the current instance of)-.15 E F1(bash)2.5 E -F0(.)A F1(Pr)87 112.8 Q(ogrammable Completion)-.18 E F0 .146(When w)108 -124.8 R .147(ord completion is attempted for an ar)-.1 F .147 +F0(.)A F1(Pr)87 376.8 Q(ogrammable Completion)-.18 E F0 .146(When w)108 +388.8 R .147(ord completion is attempted for an ar)-.1 F .147 (gument to a command for which a completion speci\214cation \(a)-.18 F -/F2 10/Times-Italic@0 SF(compspec)108 136.8 Q F0 3.829(\)h)C 1.329 +F2(compspec)108 400.8 Q F0 3.829(\)h)C 1.329 (as been de\214ned using the)-3.829 F F1(complete)3.829 E F0 -.2(bu) 3.829 G 1.329(iltin \(see).2 F/F3 9/Times-Bold@0 SF 1.329(SHELL B)3.829 F(UIL)-.09 E 1.329(TIN COMMANDS)-.828 F F0(belo)3.579 E 1.328(w\), the) --.25 F(programmable completion f)108 148.8 Q(acilities are in)-.1 E -.2 +-.25 F(programmable completion f)108 412.8 Q(acilities are in)-.1 E -.2 (vo)-.4 G -.1(ke).2 G(d.).1 E .497 -(First, the command name is identi\214ed.)108 165.6 R .497 +(First, the command name is identi\214ed.)108 429.6 R .497 (If the command w)5.497 F .498 (ord is the empty string \(completion attempted at)-.1 F .234(the be)108 -177.6 R .233(ginning of an empty line\), an)-.15 F 2.733(yc)-.15 G .233 +441.6 R .233(ginning of an empty line\), an)-.15 F 2.733(yc)-.15 G .233 (ompspec de\214ned with the)-2.733 F F12.733 E F0 .233(option to) 2.733 F F1(complete)2.733 E F0 .233(is used.)2.733 F .233(If a comp-) 5.233 F .481(spec has been de\214ned for that command, the compspec is \ -used to generate the list of possible completions)108 189.6 R .823 -(for the w)108 201.6 R 3.323(ord. If)-.1 F .823(the command w)3.323 F +used to generate the list of possible completions)108 453.6 R .823 +(for the w)108 465.6 R 3.323(ord. If)-.1 F .823(the command w)3.323 F .822(ord is a full pathname, a compspec for the full pathname is search\ -ed for)-.1 F 2.866(\214rst. If)108 213.6 R .367(no compspec is found fo\ +ed for)-.1 F 2.866(\214rst. If)108 477.6 R .367(no compspec is found fo\ r the full pathname, an attempt is made to \214nd a compspec for the po\ -rtion)2.866 F(follo)108 225.6 Q .299(wing the \214nal slash.)-.25 F .298 +rtion)2.866 F(follo)108 489.6 Q .299(wing the \214nal slash.)-.25 F .298 (If those searches do not result in a compspec, an)5.299 F 2.798(yc)-.15 G .298(ompspec de\214ned with the)-2.798 F F12.798 E F0(option to) -108 237.6 Q F1(complete)2.5 E F0(is used as the def)2.5 E(ault.)-.1 E +108 501.6 Q F1(complete)2.5 E F0(is used as the def)2.5 E(ault.)-.1 E .817(Once a compspec has been found, it is used to generate the list of\ - matching w)108 254.4 R 3.317(ords. If)-.1 F 3.317(ac)3.317 G .817 -(ompspec is not)-3.317 F(found, the def)108 266.4 Q(ault)-.1 E F1(bash) + matching w)108 518.4 R 3.317(ords. If)-.1 F 3.317(ac)3.317 G .817 +(ompspec is not)-3.317 F(found, the def)108 530.4 Q(ault)-.1 E F1(bash) 2.5 E F0(completion as described abo)2.5 E .3 -.15(ve u)-.15 H(nder).15 E F1(Completing)2.5 E F0(is performed.)2.5 E .464 -(First, the actions speci\214ed by the compspec are used.)108 283.2 R +(First, the actions speci\214ed by the compspec are used.)108 547.2 R .463(Only matches which are pre\214x)5.464 F .463(ed by the w)-.15 F -.463(ord being)-.1 F .595(completed are returned.)108 295.2 R .595 +.463(ord being)-.1 F .595(completed are returned.)108 559.2 R .595 (When the)5.595 F F13.095 E F0(or)3.095 E F13.095 E F0 .596 (option is used for \214lename or directory name completion, the)3.095 F -(shell v)108 307.2 Q(ariable)-.25 E F3(FIGNORE)2.5 E F0 -(is used to \214lter the matches.)2.25 E(An)108 324 Q 4.084(yc)-.15 G +(shell v)108 571.2 Q(ariable)-.25 E F3(FIGNORE)2.5 E F0 +(is used to \214lter the matches.)2.25 E(An)108 588 Q 4.084(yc)-.15 G 1.584(ompletions speci\214ed by a pathname e)-4.084 F 1.584 (xpansion pattern to the)-.15 F F14.084 E F0 1.584 -(option are generated ne)4.084 F 4.084(xt. The)-.15 F -.1(wo)108 336 S +(option are generated ne)4.084 F 4.084(xt. The)-.15 F -.1(wo)108 600 S .554(rds generated by the pattern need not match the w).1 F .555 (ord being completed.)-.1 F(The)5.555 E F3(GLOBIGNORE)3.055 E F0 .555 (shell v)2.805 F(ari-)-.25 E -(able is not used to \214lter the matches, b)108 348 Q(ut the)-.2 E F3 -(FIGNORE)2.5 E F0 -.25(va)2.25 G(riable is used.).25 E(Ne)108 364.8 Q +(able is not used to \214lter the matches, b)108 612 Q(ut the)-.2 E F3 +(FIGNORE)2.5 E F0 -.25(va)2.25 G(riable is used.).25 E(Ne)108 628.8 Q .321(xt, the string speci\214ed as the ar)-.15 F .321(gument to the)-.18 F F12.821 E F0 .32(option is considered.)2.821 F .32 (The string is \214rst split using the)5.32 F .412(characters in the)108 -376.8 R F3(IFS)2.912 E F0 .412(special v)2.662 F .412 +640.8 R F3(IFS)2.912 E F0 .412(special v)2.662 F .412 (ariable as delimiters.)-.25 F .412(Shell quoting is honored.)5.412 F .413(Each w)5.412 F .413(ord is then e)-.1 F(xpanded)-.15 E .092 -(using brace e)108 388.8 R .092(xpansion, tilde e)-.15 F .092 +(using brace e)108 652.8 R .092(xpansion, tilde e)-.15 F .092 (xpansion, parameter and v)-.15 F .092(ariable e)-.25 F .091 (xpansion, command substitution, and arith-)-.15 F 1.396(metic e)108 -400.8 R 1.396(xpansion, as described abo)-.15 F 1.696 -.15(ve u)-.15 H +664.8 R 1.396(xpansion, as described abo)-.15 F 1.696 -.15(ve u)-.15 H (nder).15 E F3(EXP)3.896 E(ANSION)-.666 E/F4 9/Times-Roman@0 SF(.)A F0 1.396(The results are split using the rules described)5.896 F(abo)108 -412.8 Q .51 -.15(ve u)-.15 H(nder).15 E F1 -.75(Wo)2.71 G .21 +676.8 Q .51 -.15(ve u)-.15 H(nder).15 E F1 -.75(Wo)2.71 G .21 (rd Splitting).75 F F0 5.21(.T)C .209(he results of the e)-5.21 F .209 (xpansion are pre\214x-matched ag)-.15 F .209(ainst the w)-.05 F .209 -(ord being com-)-.1 F(pleted, and the matching w)108 424.8 Q +(ord being com-)-.1 F(pleted, and the matching w)108 688.8 Q (ords become the possible completions.)-.1 E 1.237 -(After these matches ha)108 441.6 R 1.537 -.15(ve b)-.2 H 1.237 +(After these matches ha)108 705.6 R 1.537 -.15(ve b)-.2 H 1.237 (een generated, an).15 F 3.737(ys)-.15 G 1.238 (hell function or command speci\214ed with the)-3.737 F F13.738 E -F0(and)3.738 E F13.738 E F0 3.376(options is in)108 453.6 R -.2 +F0(and)3.738 E F13.738 E F0 3.376(options is in)108 717.6 R -.2 (vo)-.4 G -.1(ke).2 G 5.875(d. When).1 F 3.375 (the command or function is in)5.875 F -.2(vo)-.4 G -.1(ke).2 G 3.375 (d, the).1 F F3(COMP_LINE)5.875 E F4(,)A F3(COMP_POINT)5.625 E F4(,)A F3 -(COMP_KEY)108 465.6 Q F4(,)A F0(and)2.407 E F3(COMP_TYPE)2.657 E F0 -.25 +(COMP_KEY)108 729.6 Q F4(,)A F0(and)2.407 E F3(COMP_TYPE)2.657 E F0 -.25 (va)2.407 G .157(riables are assigned v).25 F .157 (alues as described abo)-.25 F .457 -.15(ve u)-.15 H(nder).15 E F1 .158 -(Shell V)2.658 F(ariables)-.92 E F0 5.158(.I)C(f)-5.158 E 3.486(as)108 -477.6 S .986(hell function is being in)-3.486 F -.2(vo)-.4 G -.1(ke).2 G -.986(d, the).1 F F3(COMP_W)3.486 E(ORDS)-.09 E F0(and)3.236 E F3 -(COMP_CW)3.486 E(ORD)-.09 E F0 -.25(va)3.236 G .986 -(riables are also set.).25 F(When)5.985 E .346 -(the function or command is in)108 489.6 R -.2(vo)-.4 G -.1(ke).2 G .346 -(d, the \214rst ar).1 F .346(gument \()-.18 F F1($1)A F0 2.847(\)i)C -2.847(st)-2.847 G .347(he name of the command whose ar)-2.847 F(guments) --.18 E .264(are being completed, the second ar)108 501.6 R .264 -(gument \()-.18 F F1($2)A F0 2.764(\)i)C 2.764(st)-2.764 G .264(he w) --2.764 F .263(ord being completed, and the third ar)-.1 F .263 -(gument \()-.18 F F1($3)A F0 2.763(\)i)C(s)-2.763 E .628(the w)108 513.6 -R .628(ord preceding the w)-.1 F .629 +(Shell V)2.658 F(ariables)-.92 E F0 5.158(.I)C(f)-5.158 E(GNU Bash 4.2) +72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(47)185.545 E 0 +Cg EP +%%Page: 48 48 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E 3.486(as)108 84 S .986(hell function is being in)-3.486 F -.2(vo) +-.4 G -.1(ke).2 G .986(d, the).1 F/F1 9/Times-Bold@0 SF(COMP_W)3.486 E +(ORDS)-.09 E F0(and)3.236 E F1(COMP_CW)3.486 E(ORD)-.09 E F0 -.25(va) +3.236 G .986(riables are also set.).25 F(When)5.985 E .346 +(the function or command is in)108 96 R -.2(vo)-.4 G -.1(ke).2 G .346 +(d, the \214rst ar).1 F .346(gument \()-.18 F/F2 10/Times-Bold@0 SF($1)A +F0 2.847(\)i)C 2.847(st)-2.847 G .347(he name of the command whose ar) +-2.847 F(guments)-.18 E .264(are being completed, the second ar)108 108 +R .264(gument \()-.18 F F2($2)A F0 2.764(\)i)C 2.764(st)-2.764 G .264 +(he w)-2.764 F .263(ord being completed, and the third ar)-.1 F .263 +(gument \()-.18 F F2($3)A F0 2.763(\)i)C(s)-2.763 E .628(the w)108 120 R +.628(ord preceding the w)-.1 F .629 (ord being completed on the current command line.)-.1 F .629 -(No \214ltering of the generated)5.629 F .715(completions ag)108 525.6 R +(No \214ltering of the generated)5.629 F .715(completions ag)108 132 R .715(ainst the w)-.05 F .714(ord being completed is performed; the func\ tion or command has complete free-)-.1 F(dom in generating the matches.) -108 537.6 Q(An)108 554.4 Q 2.937(yf)-.15 G .437 -(unction speci\214ed with)-2.937 F F12.937 E F0 .437(is in)2.937 F --.2(vo)-.4 G -.1(ke).2 G 2.937<648c>.1 G 2.937(rst. The)-2.937 F .437 -(function may use an)2.937 F 2.937(yo)-.15 G 2.937(ft)-2.937 G .437 -(he shell f)-2.937 F .438(acilities, including)-.1 F(the)108 566.4 Q F1 -(compgen)2.957 E F0 -.2(bu)2.957 G .457(iltin described belo).2 F 1.756 --.65(w, t)-.25 H 2.956(og).65 G .456(enerate the matches.)-2.956 F .456 -(It must put the possible completions in the)5.456 F F3(COMPREPL)108 -578.4 Q(Y)-.828 E F0(array v)2.25 E(ariable, one per array element.)-.25 -E(Ne)108 595.2 Q .08(xt, an)-.15 F 2.58(yc)-.15 G .08 -(ommand speci\214ed with the)-2.58 F F12.58 E F0 .081 +108 144 Q(An)108 160.8 Q 2.937(yf)-.15 G .437(unction speci\214ed with) +-2.937 F F22.937 E F0 .437(is in)2.937 F -.2(vo)-.4 G -.1(ke).2 G +2.937<648c>.1 G 2.937(rst. The)-2.937 F .437(function may use an)2.937 F +2.937(yo)-.15 G 2.937(ft)-2.937 G .437(he shell f)-2.937 F .438 +(acilities, including)-.1 F(the)108 172.8 Q F2(compgen)2.957 E F0 -.2 +(bu)2.957 G .457(iltin described belo).2 F 1.756 -.65(w, t)-.25 H 2.956 +(og).65 G .456(enerate the matches.)-2.956 F .456 +(It must put the possible completions in the)5.456 F F1(COMPREPL)108 +184.8 Q(Y)-.828 E F0(array v)2.25 E(ariable, one per array element.)-.25 +E(Ne)108 201.6 Q .08(xt, an)-.15 F 2.58(yc)-.15 G .08 +(ommand speci\214ed with the)-2.58 F F22.58 E F0 .081 (option is in)2.581 F -.2(vo)-.4 G -.1(ke).2 G 2.581(di).1 G 2.581(na) -2.581 G 2.581(ne)-2.581 G -.4(nv)-2.581 G .081(ironment equi).4 F -.25 -(va)-.25 G .081(lent to command sub-).25 F 2.859(stitution. It)108 607.2 +(va)-.25 G .081(lent to command sub-).25 F 2.859(stitution. It)108 213.6 R .359(should print a list of completions, one per line, to the standar\ d output.)2.859 F .358(Backslash may be used)5.359 F(to escape a ne)108 -619.2 Q(wline, if necessary)-.25 E(.)-.65 E .376 -(After all of the possible completions are generated, an)108 636 R 2.877 -<798c>-.15 G .377(lter speci\214ed with the)-2.877 F F12.877 E F0 -.377(option is applied to the)2.877 F 3.182(list. The)108 648 R .682 -(\214lter is a pattern as used for pathname e)3.182 F .681(xpansion; a) --.15 F F1(&)3.181 E F0 .681(in the pattern is replaced with the te)3.181 -F .681(xt of)-.15 F .522(the w)108 660 R .522(ord being completed.)-.1 F -3.022(Al)5.522 G(iteral)-3.022 E F1(&)3.022 E F0 .523 +225.6 Q(wline, if necessary)-.25 E(.)-.65 E .376 +(After all of the possible completions are generated, an)108 242.4 R +2.877<798c>-.15 G .377(lter speci\214ed with the)-2.877 F F22.877 +E F0 .377(option is applied to the)2.877 F 3.182(list. The)108 254.4 R +.682(\214lter is a pattern as used for pathname e)3.182 F .681 +(xpansion; a)-.15 F F2(&)3.181 E F0 .681 +(in the pattern is replaced with the te)3.181 F .681(xt of)-.15 F .522 +(the w)108 266.4 R .522(ord being completed.)-.1 F 3.022(Al)5.522 G +(iteral)-3.022 E F2(&)3.022 E F0 .523 (may be escaped with a backslash; the backslash is remo)3.022 F -.15(ve) --.15 G 3.023(db).15 G(efore)-3.023 E .85(attempting a match.)108 672 R +-.15 G 3.023(db).15 G(efore)-3.023 E .85(attempting a match.)108 278.4 R (An)5.85 E 3.35(yc)-.15 G .849 (ompletion that matches the pattern will be remo)-3.35 F -.15(ve)-.15 G 3.349(df).15 G .849(rom the list.)-3.349 F 3.349(Al)5.849 G(eading) --3.349 E F1(!)3.349 E F0(ne)108 684 Q -.05(ga)-.15 G +-3.349 E F2(!)3.349 E F0(ne)108 290.4 Q -.05(ga)-.15 G (tes the pattern; in this case an).05 E 2.5(yc)-.15 G (ompletion not matching the pattern will be remo)-2.5 E -.15(ve)-.15 G -(d.).15 E(Finally)108 700.8 Q 3.086(,a)-.65 G .886 -.15(ny p)-3.086 H -.586(re\214x and suf).15 F .587(\214x speci\214ed with the)-.25 F F1 -3.087 E F0(and)3.087 E F13.087 E F0 .587 +(d.).15 E(Finally)108 307.2 Q 3.086(,a)-.65 G .886 -.15(ny p)-3.086 H +.586(re\214x and suf).15 F .587(\214x speci\214ed with the)-.25 F F2 +3.087 E F0(and)3.087 E F23.087 E F0 .587 (options are added to each member of the com-)3.087 F(pletion list, and\ the result is returned to the readline completion code as the list of \ -possible completions.)108 712.8 Q .247(If the pre)108 729.6 R .247 +possible completions.)108 319.2 Q .247(If the pre)108 336 R .247 (viously-applied actions do not generate an)-.25 F 2.747(ym)-.15 G .247 -(atches, and the)-2.747 F F1 .247(\255o dir)2.747 F(names)-.15 E F0 .247 -(option w)2.747 F .246(as supplied to)-.1 F(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(47)198.165 E 0 Cg EP -%%Page: 48 48 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(complete)108 84 Q F0(when the compspec w) -2.5 E(as de\214ned, directory name completion is attempted.)-.1 E .461 -(If the)108 100.8 R F1 .462(\255o plusdirs)2.961 F F0 .462(option w) -2.962 F .462(as supplied to)-.1 F F1(complete)2.962 E F0 .462 +(atches, and the)-2.747 F F2 .247(\255o dir)2.747 F(names)-.15 E F0 .247 +(option w)2.747 F .246(as supplied to)-.1 F F2(complete)108 348 Q F0 +(when the compspec w)2.5 E +(as de\214ned, directory name completion is attempted.)-.1 E .461 +(If the)108 364.8 R F2 .462(\255o plusdirs)2.961 F F0 .462(option w) +2.962 F .462(as supplied to)-.1 F F2(complete)2.962 E F0 .462 (when the compspec w)2.962 F .462(as de\214ned, directory name com-)-.1 -F(pletion is attempted and an)108 112.8 Q 2.5(ym)-.15 G +F(pletion is attempted and an)108 376.8 Q 2.5(ym)-.15 G (atches are added to the results of the other actions.)-2.5 E .56 -(By def)108 129.6 R .56(ault, if a compspec is found, whate)-.1 F -.15 +(By def)108 393.6 R .56(ault, if a compspec is found, whate)-.1 F -.15 (ve)-.25 G 3.06(ri).15 G 3.06(tg)-3.06 G .559 (enerates is returned to the completion code as the full set)-3.06 F -.631(of possible completions.)108 141.6 R .631(The def)5.631 F(ault)-.1 -E F1(bash)3.131 E F0 .631 +.631(of possible completions.)108 405.6 R .631(The def)5.631 F(ault)-.1 +E F2(bash)3.131 E F0 .631 (completions are not attempted, and the readline def)3.131 F .632 -(ault of \214le-)-.1 F .559(name completion is disabled.)108 153.6 R -.559(If the)5.559 F F1 .559(\255o bashdefault)3.059 F F0 .559(option w) -3.059 F .559(as supplied to)-.1 F F1(complete)3.058 E F0 .558 -(when the compspec)3.058 F -.1(wa)108 165.6 S 3.171(sd).1 G .671 -(e\214ned, the)-3.171 F F1(bash)3.171 E F0(def)3.171 E .671 +(ault of \214le-)-.1 F .559(name completion is disabled.)108 417.6 R +.559(If the)5.559 F F2 .559(\255o bashdefault)3.059 F F0 .559(option w) +3.059 F .559(as supplied to)-.1 F F2(complete)3.058 E F0 .558 +(when the compspec)3.058 F -.1(wa)108 429.6 S 3.171(sd).1 G .671 +(e\214ned, the)-3.171 F F2(bash)3.171 E F0(def)3.171 E .671 (ault completions are attempted if the compspec generates no matches.) --.1 F .672(If the)5.672 F F13.172 E(default)108 177.6 Q F0 1.207 -(option w)3.707 F 1.207(as supplied to)-.1 F F1(complete)3.707 E F0 +-.1 F .672(If the)5.672 F F23.172 E(default)108 441.6 Q F0 1.207 +(option w)3.707 F 1.207(as supplied to)-.1 F F2(complete)3.707 E F0 1.207(when the compspec w)3.707 F 1.207(as de\214ned, readline')-.1 F 3.707(sd)-.55 G(ef)-3.707 E 1.206(ault completion)-.1 F (will be performed if the compspec \(and, if attempted, the def)108 -189.6 Q(ault)-.1 E F1(bash)2.5 E F0(completions\) generate no matches.) +453.6 Q(ault)-.1 E F2(bash)2.5 E F0(completions\) generate no matches.) 2.5 E .245(When a compspec indicates that directory name completion is \ -desired, the programmable completion func-)108 206.4 R .633(tions force\ +desired, the programmable completion func-)108 470.4 R .633(tions force\ readline to append a slash to completed names which are symbolic links\ - to directories, subject)108 218.4 R 2.761(to the v)108 230.4 R 2.761 -(alue of the)-.25 F F1(mark\255dir)5.261 E(ectories)-.18 E F0 2.761 + to directories, subject)108 482.4 R 2.761(to the v)108 494.4 R 2.761 +(alue of the)-.25 F F2(mark\255dir)5.261 E(ectories)-.18 E F0 2.761 (readline v)5.261 F 2.761(ariable, re)-.25 F -.05(ga)-.15 G 2.762 -(rdless of the setting of the).05 F F1(mark-sym-)5.262 E(link)108 242.4 +(rdless of the setting of the).05 F F2(mark-sym-)5.262 E(link)108 506.4 Q(ed\255dir)-.1 E(ectories)-.18 E F0(readline v)2.5 E(ariable.)-.25 E .191(There is some support for dynamically modifying completions.)108 -259.2 R .19(This is most useful when used in combina-)5.191 F 1.33 -(tion with a def)108 271.2 R 1.33(ault completion speci\214ed with)-.1 F -F1 1.33(complete -D)3.83 F F0 6.33(.I)C(t')-6.33 E 3.83(sp)-.55 G 1.33 +523.2 R .19(This is most useful when used in combina-)5.191 F 1.33 +(tion with a def)108 535.2 R 1.33(ault completion speci\214ed with)-.1 F +F2 1.33(complete -D)3.83 F F0 6.33(.I)C(t')-6.33 E 3.83(sp)-.55 G 1.33 (ossible for shell functions e)-3.83 F -.15(xe)-.15 G 1.33(cuted as).15 F .93(completion handlers to indicate that completion should be retried\ - by returning an e)108 283.2 R .93(xit status of 124.)-.15 F .93(If a) + by returning an e)108 547.2 R .93(xit status of 124.)-.15 F .93(If a) 5.93 F .1(shell function returns 124, and changes the compspec associat\ -ed with the command on which completion is)108 295.2 R .666 -(being attempted \(supplied as the \214rst ar)108 307.2 R .665 +ed with the command on which completion is)108 559.2 R .666 +(being attempted \(supplied as the \214rst ar)108 571.2 R .665 (gument when the function is e)-.18 F -.15(xe)-.15 G .665 (cuted\), programmable completion).15 F .083(restarts from the be)108 -319.2 R .084(ginning, with an attempt to \214nd a ne)-.15 F 2.584(wc) +583.2 R .084(ginning, with an attempt to \214nd a ne)-.15 F 2.584(wc) -.25 G .084(ompspec for that command.)-2.584 F .084(This allo)5.084 F -.084(ws a set of)-.25 F(completions to be b)108 331.2 Q(uilt dynamicall\ +.084(ws a set of)-.25 F(completions to be b)108 595.2 Q(uilt dynamicall\ y as completion is attempted, rather than being loaded all at once.)-.2 -E -.15(Fo)108 348 S 2.637(ri).15 G .137 +E -.15(Fo)108 612 S 2.637(ri).15 G .137 (nstance, assuming that there is a library of compspecs, each k)-2.637 F .137(ept in a \214le corresponding to the name of)-.1 F -(the command, the follo)108 360 Q(wing def)-.25 E +(the command, the follo)108 624 Q(wing def)-.25 E (ault completion function w)-.1 E(ould load completions dynamically:)-.1 -E/F2 10/Courier@0 SF(_completion_loader\(\))108 376.8 Q({)108 388.8 Q 6 -(.")144 400.8 S +E/F3 10/Courier@0 SF(_completion_loader\(\))108 640.8 Q({)108 652.8 Q 6 +(.")144 664.8 S (/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124)-6 E(})108 -412.8 Q(complete -D -F _completion_loader)108 424.8 Q/F3 10.95 -/Times-Bold@0 SF(HIST)72 453.6 Q(OR)-.197 E(Y)-.383 E F0 .371(When the) -108 465.6 R F1 .371(\255o history)2.871 F F0 .371(option to the)2.871 F -F1(set)2.872 E F0 -.2(bu)2.872 G .372(iltin is enabled, the shell pro).2 -F .372(vides access to the)-.15 F/F4 10/Times-Italic@0 SF .372 -(command history)2.872 F F0(,)A .305(the list of commands pre)108 477.6 -R .305(viously typed.)-.25 F .305(The v)5.305 F .304(alue of the)-.25 F -/F5 9/Times-Bold@0 SF(HISTSIZE)2.804 E F0 -.25(va)2.554 G .304 -(riable is used as the number of com-).25 F .429(mands to sa)108 489.6 R -.729 -.15(ve i)-.2 H 2.929(nah).15 G .429(istory list.)-2.929 F .429 -(The te)5.429 F .429(xt of the last)-.15 F F5(HISTSIZE)2.93 E F0 .43 -(commands \(def)2.68 F .43(ault 500\) is sa)-.1 F -.15(ve)-.2 G 2.93 -(d. The).15 F(shell)2.93 E .287 +676.8 Q(complete -D -F _completion_loader)108 688.8 Q F0(GNU Bash 4.2)72 +768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(48)185.545 E 0 Cg +EP +%%Page: 49 49 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10.95/Times-Bold@0 SF(HIST)72 84 Q(OR)-.197 E(Y)-.383 E F0 +.371(When the)108 96 R/F2 10/Times-Bold@0 SF .371(\255o history)2.871 F +F0 .371(option to the)2.871 F F2(set)2.872 E F0 -.2(bu)2.872 G .372 +(iltin is enabled, the shell pro).2 F .372(vides access to the)-.15 F/F3 +10/Times-Italic@0 SF .372(command history)2.872 F F0(,)A .305 +(the list of commands pre)108 108 R .305(viously typed.)-.25 F .305 +(The v)5.305 F .304(alue of the)-.25 F/F4 9/Times-Bold@0 SF(HISTSIZE) +2.804 E F0 -.25(va)2.554 G .304(riable is used as the number of com-).25 +F .429(mands to sa)108 120 R .729 -.15(ve i)-.2 H 2.929(nah).15 G .429 +(istory list.)-2.929 F .429(The te)5.429 F .429(xt of the last)-.15 F F4 +(HISTSIZE)2.93 E F0 .43(commands \(def)2.68 F .43(ault 500\) is sa)-.1 F +-.15(ve)-.2 G 2.93(d. The).15 F(shell)2.93 E .287 (stores each command in the history list prior to parameter and v)108 -501.6 R .287(ariable e)-.25 F .287(xpansion \(see)-.15 F F5(EXP)2.787 E -(ANSION)-.666 E F0(abo)2.537 E -.15(ve)-.15 G(\)).15 E -.2(bu)108 513.6 -S 4.065(ta).2 G 1.565(fter history e)-4.065 F 1.565 +132 R .287(ariable e)-.25 F .287(xpansion \(see)-.15 F F4(EXP)2.787 E +(ANSION)-.666 E F0(abo)2.537 E -.15(ve)-.15 G(\)).15 E -.2(bu)108 144 S +4.065(ta).2 G 1.565(fter history e)-4.065 F 1.565 (xpansion is performed, subject to the v)-.15 F 1.565 -(alues of the shell v)-.25 F(ariables)-.25 E F5(HISTIGNORE)4.065 E F0 -(and)3.816 E F5(HISTCONTR)108 525.6 Q(OL)-.27 E/F6 9/Times-Roman@0 SF(.) -A F0 .082 +(alues of the shell v)-.25 F(ariables)-.25 E F4(HISTIGNORE)4.065 E F0 +(and)3.816 E F4(HISTCONTR)108 156 Q(OL)-.27 E/F5 9/Times-Roman@0 SF(.)A +F0 .082 (On startup, the history is initialized from the \214le named by the v) -108 542.4 R(ariable)-.25 E F5(HISTFILE)2.582 E F0(\(def)2.332 E(ault)-.1 -E F4(~/.bash_history)2.582 E F0(\).)A .315(The \214le named by the v)108 -554.4 R .315(alue of)-.25 F F5(HISTFILE)2.815 E F0 .315 +108 172.8 R(ariable)-.25 E F4(HISTFILE)2.582 E F0(\(def)2.332 E(ault)-.1 +E F3(~/.bash_history)2.582 E F0(\).)A .315(The \214le named by the v)108 +184.8 R .315(alue of)-.25 F F4(HISTFILE)2.815 E F0 .315 (is truncated, if necessary)2.565 F 2.815(,t)-.65 G 2.815(oc)-2.815 G .315(ontain no more than the number of)-2.815 F .659 -(lines speci\214ed by the v)108 566.4 R .659(alue of)-.25 F F5 -(HISTFILESIZE)3.158 E F6(.)A F0(If)5.158 E F1(HISTFILESIZE)3.158 E F0 -.658(is unset, or set to null, a non-numeric)3.158 F -.25(va)108 578.4 S +(lines speci\214ed by the v)108 196.8 R .659(alue of)-.25 F F4 +(HISTFILESIZE)3.158 E F5(.)A F0(If)5.158 E F2(HISTFILESIZE)3.158 E F0 +.658(is unset, or set to null, a non-numeric)3.158 F -.25(va)108 208.8 S .142(lue, or a numeric v).25 F .142 (alue less than zero, the history \214le is not truncated.)-.25 F .142 -(When the history \214le is read, lines)5.142 F(be)108 590.4 Q 1.605 +(When the history \214le is read, lines)5.142 F(be)108 220.8 Q 1.605 (ginning with the history comment character follo)-.15 F 1.604 (wed immediately by a digit are interpreted as time-)-.25 F .098 -(stamps for the preceding history line.)108 602.4 R .098 +(stamps for the preceding history line.)108 232.8 R .098 (These timestamps are optionally displayed depending on the v)5.098 F -.098(alue of)-.25 F(the)108 614.4 Q F5(HISTTIMEFORMA)3.559 E(T)-.855 E +.098(alue of)-.25 F(the)108 244.8 Q F4(HISTTIMEFORMA)3.559 E(T)-.855 E F0 -.25(va)3.309 G 3.559(riable. When).25 F 3.559(as)3.559 G 1.059 -(hell with history enabled e)-3.559 F 1.059(xits, the last)-.15 F F5 +(hell with history enabled e)-3.559 F 1.059(xits, the last)-.15 F F4 ($HISTSIZE)3.559 E F0 1.058(lines are)3.309 F .158 -(copied from the history list to)108 626.4 R F5($HISTFILE)2.658 E F6(.)A -F0 .158(If the)4.658 F F1(histappend)2.658 E F0 .159 -(shell option is enabled \(see the description of)2.659 F F1(shopt)108 -638.4 Q F0(under)2.582 E F5 .082(SHELL B)2.582 F(UIL)-.09 E .082 +(copied from the history list to)108 256.8 R F4($HISTFILE)2.658 E F5(.)A +F0 .158(If the)4.658 F F2(histappend)2.658 E F0 .159 +(shell option is enabled \(see the description of)2.659 F F2(shopt)108 +268.8 Q F0(under)2.582 E F4 .082(SHELL B)2.582 F(UIL)-.09 E .082 (TIN COMMANDS)-.828 F F0(belo)2.332 E .082 (w\), the lines are appended to the history \214le, otherwise the)-.25 F -.196(history \214le is o)108 650.4 R -.15(ve)-.15 G 2.696(rwritten. If) -.15 F F5(HISTFILE)2.696 E F0 .197(is unset, or if the history \214le is\ +.196(history \214le is o)108 280.8 R -.15(ve)-.15 G 2.696(rwritten. If) +.15 F F4(HISTFILE)2.696 E F0 .197(is unset, or if the history \214le is\ unwritable, the history is not sa)2.446 F -.15(ve)-.2 G(d.).15 E .584 -(If the)108 662.4 R F5(HISTTIMEFORMA)3.084 E(T)-.855 E F0 -.25(va)2.834 +(If the)108 292.8 R F4(HISTTIMEFORMA)3.084 E(T)-.855 E F0 -.25(va)2.834 G .584 (riable is set, time stamps are written to the history \214le, mark).25 -F .583(ed with the his-)-.1 F 1.147(tory comment character)108 674.4 R +F .583(ed with the his-)-.1 F 1.147(tory comment character)108 304.8 R 3.647(,s)-.4 G 3.647(ot)-3.647 G(he)-3.647 E 3.647(ym)-.15 G 1.147 (ay be preserv)-3.647 F 1.147(ed across shell sessions.)-.15 F 1.148 (This uses the history comment)6.148 F 1.377 -(character to distinguish timestamps from other history lines.)108 686.4 +(character to distinguish timestamps from other history lines.)108 316.8 R 1.377(After sa)6.377 F 1.377(ving the history)-.2 F 3.876(,t)-.65 G 1.376(he history \214le is)-3.876 F .756 -(truncated to contain no more than)108 698.4 R F5(HISTFILESIZE)3.257 E -F0 3.257(lines. If)3.007 F F5(HISTFILESIZE)3.257 E F0 .757 -(is unset, or set to null, a non-)3.007 F(numeric v)108 710.4 Q +(truncated to contain no more than)108 328.8 R F4(HISTFILESIZE)3.257 E +F0 3.257(lines. If)3.007 F F4(HISTFILESIZE)3.257 E F0 .757 +(is unset, or set to null, a non-)3.007 F(numeric v)108 340.8 Q (alue, or a numeric v)-.25 E (alue less than zero, the history \214le is not truncated.)-.25 E 1.294 -(The b)108 727.2 R 1.294(uiltin command)-.2 F F1(fc)3.794 E F0(\(see) -3.794 E F5 1.293(SHELL B)3.794 F(UIL)-.09 E 1.293(TIN COMMANDS)-.828 F +(The b)108 357.6 R 1.294(uiltin command)-.2 F F2(fc)3.794 E F0(\(see) +3.794 E F4 1.293(SHELL B)3.794 F(UIL)-.09 E 1.293(TIN COMMANDS)-.828 F F0(belo)3.543 E 1.293(w\) may be used to list or edit and re-)-.25 F -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(48)198.165 E 0 Cg EP -%%Page: 49 49 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E -.15(exe)108 84 S .673(cute a portion of the history list.).15 F -(The)5.673 E/F1 10/Times-Bold@0 SF(history)3.173 E F0 -.2(bu)3.173 G -.673(iltin may be used to display or modify the history list).2 F .28 -(and manipulate the history \214le.)108 96 R .279 +-.15(exe)108 369.6 S .673(cute a portion of the history list.).15 F(The) +5.673 E F2(history)3.173 E F0 -.2(bu)3.173 G .673 +(iltin may be used to display or modify the history list).2 F .28 +(and manipulate the history \214le.)108 381.6 R .279 (When using command-line editing, search commands are a)5.279 F -.25(va) --.2 G .279(ilable in each).25 F(editing mode that pro)108 108 Q -(vide access to the history list.)-.15 E 1.485(The shell allo)108 124.8 +-.2 G .279(ilable in each).25 F(editing mode that pro)108 393.6 Q +(vide access to the history list.)-.15 E 1.485(The shell allo)108 410.4 R 1.485(ws control o)-.25 F -.15(ve)-.15 G 3.986(rw).15 G 1.486 (hich commands are sa)-3.986 F -.15(ve)-.2 G 3.986(do).15 G 3.986(nt) --3.986 G 1.486(he history list.)-3.986 F(The)6.486 E/F2 9/Times-Bold@0 -SF(HISTCONTR)3.986 E(OL)-.27 E F0(and)3.736 E F2(HISTIGNORE)108 136.8 Q -F0 -.25(va)2.708 G .458(riables may be set to cause the shell to sa).25 -F .757 -.15(ve o)-.2 H .457(nly a subset of the commands entered.).15 F -(The)5.457 E F1(cmdhist)108 148.8 Q F0 .75 +-3.986 G 1.486(he history list.)-3.986 F(The)6.486 E F4(HISTCONTR)3.986 +E(OL)-.27 E F0(and)3.736 E F4(HISTIGNORE)108 422.4 Q F0 -.25(va)2.708 G +.458(riables may be set to cause the shell to sa).25 F .757 -.15(ve o) +-.2 H .457(nly a subset of the commands entered.).15 F(The)5.457 E F2 +(cmdhist)108 434.4 Q F0 .75 (shell option, if enabled, causes the shell to attempt to sa)3.25 F 1.05 -.15(ve e)-.2 H .75(ach line of a multi-line command in).15 F 1.077 -(the same history entry)108 160.8 R 3.577(,a)-.65 G 1.077 +(the same history entry)108 446.4 R 3.577(,a)-.65 G 1.077 (dding semicolons where necessary to preserv)-3.577 F 3.577(es)-.15 G -1.077(yntactic correctness.)-3.577 F(The)6.077 E F1(lithist)3.576 E F0 -.373(shell option causes the shell to sa)108 172.8 R .674 -.15(ve t)-.2 +1.077(yntactic correctness.)-3.577 F(The)6.077 E F2(lithist)3.576 E F0 +.373(shell option causes the shell to sa)108 458.4 R .674 -.15(ve t)-.2 H .374(he command with embedded ne).15 F .374 (wlines instead of semicolons.)-.25 F .374(See the)5.374 F .319 -(description of the)108 184.8 R F1(shopt)2.819 E F0 -.2(bu)2.819 G .318 -(iltin belo).2 F 2.818(wu)-.25 G(nder)-2.818 E F2 .318(SHELL B)2.818 F +(description of the)108 470.4 R F2(shopt)2.819 E F0 -.2(bu)2.819 G .318 +(iltin belo).2 F 2.818(wu)-.25 G(nder)-2.818 E F4 .318(SHELL B)2.818 F (UIL)-.09 E .318(TIN COMMANDS)-.828 F F0 .318 (for information on setting and)2.568 F(unsetting shell options.)108 -196.8 Q/F3 10.95/Times-Bold@0 SF(HIST)72 213.6 Q(OR)-.197 E 2.738(YE) --.383 G(XP)-2.738 E(ANSION)-.81 E F0 .61(The shell supports a history e) -108 225.6 R .611(xpansion feature that is similar to the history e)-.15 -F .611(xpansion in)-.15 F F1(csh.)3.111 E F0 .611(This section)5.611 F -.871(describes what syntax features are a)108 237.6 R -.25(va)-.2 G -3.371(ilable. This).25 F .871(feature is enabled by def)3.371 F .87 +482.4 Q F1(HIST)72 499.2 Q(OR)-.197 E 2.738(YE)-.383 G(XP)-2.738 E +(ANSION)-.81 E F0 .61(The shell supports a history e)108 511.2 R .611 +(xpansion feature that is similar to the history e)-.15 F .611 +(xpansion in)-.15 F F2(csh.)3.111 E F0 .611(This section)5.611 F .871 +(describes what syntax features are a)108 523.2 R -.25(va)-.2 G 3.371 +(ilable. This).25 F .871(feature is enabled by def)3.371 F .87 (ault for interacti)-.1 F 1.17 -.15(ve s)-.25 H .87(hells, and).15 F -2.013(can be disabled using the)108 249.6 R F1(+H)4.514 E F0 2.014 -(option to the)4.514 F F1(set)4.514 E F0 -.2(bu)4.514 G 2.014 -(iltin command \(see).2 F F2 2.014(SHELL B)4.514 F(UIL)-.09 E 2.014 -(TIN COMMANDS)-.828 F F0(belo)108 261.6 Q 2.5(w\). Non-interacti)-.25 F +2.013(can be disabled using the)108 535.2 R F2(+H)4.514 E F0 2.014 +(option to the)4.514 F F2(set)4.514 E F0 -.2(bu)4.514 G 2.014 +(iltin command \(see).2 F F4 2.014(SHELL B)4.514 F(UIL)-.09 E 2.014 +(TIN COMMANDS)-.828 F F0(belo)108 547.2 Q 2.5(w\). Non-interacti)-.25 F .3 -.15(ve s)-.25 H(hells do not perform history e).15 E -(xpansion by def)-.15 E(ault.)-.1 E 1.306(History e)108 278.4 R 1.306 +(xpansion by def)-.15 E(ault.)-.1 E 1.306(History e)108 564 R 1.306 (xpansions introduce w)-.15 F 1.306(ords from the history list into the\ input stream, making it easy to repeat)-.1 F .209 -(commands, insert the ar)108 290.4 R .209(guments to a pre)-.18 F .21 +(commands, insert the ar)108 576 R .209(guments to a pre)-.18 F .21 (vious command into the current input line, or \214x errors in pre)-.25 -F(vious)-.25 E(commands quickly)108 302.4 Q(.)-.65 E 1.164(History e)108 -319.2 R 1.163(xpansion is performed immediately after a complete line i\ -s read, before the shell breaks it into)-.15 F -.1(wo)108 331.2 S 3.2 +F(vious)-.25 E(commands quickly)108 588 Q(.)-.65 E 1.164(History e)108 +604.8 R 1.163(xpansion is performed immediately after a complete line i\ +s read, before the shell breaks it into)-.15 F -.1(wo)108 616.8 S 3.2 (rds. It).1 F(tak)3.2 E .7(es place in tw)-.1 F 3.2(op)-.1 G 3.2 (arts. The)-3.2 F .7 (\214rst is to determine which line from the history list to use during) -3.2 F 4.368(substitution. The)108 343.2 R 1.868(second is to select por\ +3.2 F 4.368(substitution. The)108 628.8 R 1.868(second is to select por\ tions of that line for inclusion into the current one.)4.368 F 1.867 -(The line)6.867 F .662(selected from the history is the)108 355.2 R/F4 -10/Times-Italic@0 SF -.15(ev)3.162 G(ent).15 E F0 3.162(,a)C .663 -(nd the portions of that line that are acted upon are)-3.162 F F4(wor) -3.163 E(ds)-.37 E F0 5.663(.V)C(arious)-6.773 E F4(modi\214er)108 367.2 +(The line)6.867 F .662(selected from the history is the)108 640.8 R F3 +-.15(ev)3.162 G(ent).15 E F0 3.162(,a)C .663 +(nd the portions of that line that are acted upon are)-3.162 F F3(wor) +3.163 E(ds)-.37 E F0 5.663(.V)C(arious)-6.773 E F3(modi\214er)108 652.8 Q(s)-.1 E F0 .227(are a)2.727 F -.25(va)-.2 G .227 (ilable to manipulate the selected w).25 F 2.727(ords. The)-.1 F .226 (line is brok)2.726 F .226(en into w)-.1 F .226(ords in the same f)-.1 F -(ashion)-.1 E .351(as when reading input, so that se)108 379.2 R -.15 -(ve)-.25 G(ral).15 E F4(metac)2.852 E(har)-.15 E(acter)-.15 E F0 .352 +(ashion)-.1 E .351(as when reading input, so that se)108 664.8 R -.15 +(ve)-.25 G(ral).15 E F3(metac)2.852 E(har)-.15 E(acter)-.15 E F0 .352 (-separated w)B .352(ords surrounded by quotes are considered)-.1 F .625 -(one w)108 391.2 R 3.125(ord. History)-.1 F -.15(ex)3.125 G .624 +(one w)108 676.8 R 3.125(ord. History)-.1 F -.15(ex)3.125 G .624 (pansions are introduced by the appearance of the history e).15 F .624 -(xpansion character)-.15 F 3.124(,w)-.4 G(hich)-3.124 E(is)108 403.2 Q -F1(!)3.333 E F0(by def)3.333 E 2.5(ault. Only)-.1 F(backslash \()2.5 E -F1(\\).833 E F0 2.5(\)a).833 G(nd single quotes can quote the history e) --2.5 E(xpansion character)-.15 E(.)-.55 E(Se)108 420 Q -.15(ve)-.25 G +(xpansion character)-.15 F 3.124(,w)-.4 G(hich)-3.124 E(is)108 688.8 Q +F2(!)3.333 E F0(by def)3.333 E 2.5(ault. Only)-.1 F(backslash \()2.5 E +F2(\\).833 E F0 2.5(\)a).833 G(nd single quotes can quote the history e) +-2.5 E(xpansion character)-.15 E(.)-.55 E(Se)108 705.6 Q -.15(ve)-.25 G .03(ral characters inhibit history e).15 F .03 (xpansion if found immediately follo)-.15 F .03(wing the history e)-.25 -F .03(xpansion character)-.15 F(,)-.4 E -2.15 -.25(ev e)108 432 T 3.163 -(ni).25 G 3.163(fi)-3.163 G 3.162(ti)-3.163 G 3.162(su)-3.162 G .662 -(nquoted: space, tab, ne)-3.162 F .662(wline, carriage return, and)-.25 -F F1(=)3.162 E F0 5.662(.I)C 3.162(ft)-5.662 G(he)-3.162 E F1(extglob) -3.162 E F0 .662(shell option is enabled,)3.162 F F1(\()3.162 E F0 -(will also inhibit e)108 444 Q(xpansion.)-.15 E(Se)108 460.8 Q -.15(ve) --.25 G .109(ral shell options settable with the).15 F F1(shopt)2.609 E -F0 -.2(bu)2.609 G .11(iltin may be used to tailor the beha).2 F .11 -(vior of history e)-.2 F(xpansion.)-.15 E 1.143(If the)108 472.8 R F1 +F .03(xpansion character)-.15 F(,)-.4 E -2.15 -.25(ev e)108 717.6 T +3.163(ni).25 G 3.163(fi)-3.163 G 3.162(ti)-3.163 G 3.162(su)-3.162 G +.662(nquoted: space, tab, ne)-3.162 F .662(wline, carriage return, and) +-.25 F F2(=)3.162 E F0 5.662(.I)C 3.162(ft)-5.662 G(he)-3.162 E F2 +(extglob)3.162 E F0 .662(shell option is enabled,)3.162 F F2(\()3.162 E +F0(will also inhibit e)108 729.6 Q(xpansion.)-.15 E(GNU Bash 4.2)72 768 +Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(49)185.545 E 0 Cg EP +%%Page: 50 50 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(Se)108 84 Q -.15(ve)-.25 G .109 +(ral shell options settable with the).15 F/F1 10/Times-Bold@0 SF(shopt) +2.609 E F0 -.2(bu)2.609 G .11(iltin may be used to tailor the beha).2 F +.11(vior of history e)-.2 F(xpansion.)-.15 E 1.143(If the)108 96 R F1 (histv)3.643 E(erify)-.1 E F0 1.143 (shell option is enabled \(see the description of the)3.643 F F1(shopt) 3.643 E F0 -.2(bu)3.643 G 1.143(iltin belo).2 F 1.143(w\), and)-.25 F F1 -.18(re)3.643 G(adline).18 E F0(is)3.642 E .461(being used, history sub\ -stitutions are not immediately passed to the shell parser)108 484.8 R +stitutions are not immediately passed to the shell parser)108 108 R 5.461(.I)-.55 G .461(nstead, the e)-5.461 F .461(xpanded line)-.15 F -1.516(is reloaded into the)108 496.8 R F1 -.18(re)4.016 G(adline).18 E -F0 1.516(editing b)4.016 F(uf)-.2 E 1.516 -(fer for further modi\214cation.)-.25 F(If)6.516 E F1 -.18(re)4.015 G -(adline).18 E F0 1.515(is being used, and the)4.015 F F1(histr)108 508.8 -Q(eedit)-.18 E F0 1.202(shell option is enabled, a f)3.702 F 1.202 +1.516(is reloaded into the)108 120 R F1 -.18(re)4.016 G(adline).18 E F0 +1.516(editing b)4.016 F(uf)-.2 E 1.516(fer for further modi\214cation.) +-.25 F(If)6.516 E F1 -.18(re)4.015 G(adline).18 E F0 1.515 +(is being used, and the)4.015 F F1(histr)108 132 Q(eedit)-.18 E F0 1.202 +(shell option is enabled, a f)3.702 F 1.202 (ailed history substitution will be reloaded into the)-.1 F F1 -.18(re) -3.702 G(adline).18 E F0(editing)3.702 E -.2(bu)108 520.8 S -.25(ff).2 G +3.702 G(adline).18 E F0(editing)3.702 E -.2(bu)108 144 S -.25(ff).2 G 1.161(er for correction.).25 F(The)6.161 E F13.661 E F0 1.161 (option to the)3.661 F F1(history)3.661 E F0 -.2(bu)3.661 G 1.16 -(iltin command may be used to see what a history).2 F -.15(ex)108 532.8 -S .055(pansion will do before using it.).15 F(The)5.055 E F12.555 -E F0 .055(option to the)2.555 F F1(history)2.556 E F0 -.2(bu)2.556 G -.056(iltin may be used to add commands to the).2 F -(end of the history list without actually e)108 544.8 Q -.15(xe)-.15 G +(iltin command may be used to see what a history).2 F -.15(ex)108 156 S +.055(pansion will do before using it.).15 F(The)5.055 E F12.555 E +F0 .055(option to the)2.555 F F1(history)2.556 E F0 -.2(bu)2.556 G .056 +(iltin may be used to add commands to the).2 F +(end of the history list without actually e)108 168 Q -.15(xe)-.15 G (cuting them, so that the).15 E 2.5(ya)-.15 G(re a)-2.5 E -.25(va)-.2 G -(ilable for subsequent recall.).25 E 2.2(The shell allo)108 561.6 R 2.2 +(ilable for subsequent recall.).25 E 2.2(The shell allo)108 184.8 R 2.2 (ws control of the v)-.25 F 2.2(arious characters used by the history e) -.25 F 2.2(xpansion mechanism \(see the)-.15 F 1.146(description of)108 -573.6 R F1(histchars)3.646 E F0(abo)3.646 E 1.446 -.15(ve u)-.15 H(nder) +196.8 R F1(histchars)3.646 E F0(abo)3.646 E 1.446 -.15(ve u)-.15 H(nder) .15 E F1 1.146(Shell V)3.646 F(ariables)-.92 E F0 3.646(\). The)B 1.147 (shell uses the history comment character to)3.646 F -(mark history timestamps when writing the history \214le.)108 585.6 Q F1 -(Ev)87 602.4 Q(ent Designators)-.1 E F0 .205(An e)108 614.4 R -.15(ve) +(mark history timestamps when writing the history \214le.)108 208.8 Q F1 +(Ev)87 225.6 Q(ent Designators)-.1 E F0 .205(An e)108 237.6 R -.15(ve) -.25 G .204(nt designator is a reference to a command line entry in the\ history list.).15 F .204(Unless the reference is abso-)5.204 F(lute, e) -108 626.4 Q -.15(ve)-.25 G(nts are relati).15 E .3 -.15(ve t)-.25 H 2.5 -(ot).15 G(he current position in the history list.)-2.5 E F1(!)108 643.2 +108 249.6 Q -.15(ve)-.25 G(nts are relati).15 E .3 -.15(ve t)-.25 H 2.5 +(ot).15 G(he current position in the history list.)-2.5 E F1(!)108 266.4 Q F0 1.607(Start a history substitution, e)32.67 F 1.607 (xcept when follo)-.15 F 1.607(wed by a)-.25 F F1(blank)4.107 E F0 4.107 (,n)C -.25(ew)-4.107 G 1.608(line, carriage return, = or \().25 F -(\(when the)144 655.2 Q F1(extglob)2.5 E F0 +(\(when the)144 278.4 Q F1(extglob)2.5 E F0 (shell option is enabled using the)2.5 E F1(shopt)2.5 E F0 -.2(bu)2.5 G -(iltin\).).2 E F1(!)108 667.2 Q F4(n)A F0(Refer to command line)27.67 E -F4(n)2.5 E F0(.).24 E F1<21ad>108 679.2 Q F4(n)A F0 -(Refer to the current command minus)21.97 E F4(n)2.5 E F0(.).24 E F1(!!) -108 691.2 Q F0(Refer to the pre)29.34 E(vious command.)-.25 E -(This is a synon)5 E(ym for `!\2551'.)-.15 E F1(!)108 703.2 Q F4(string) +(iltin\).).2 E F1(!)108 290.4 Q/F2 10/Times-Italic@0 SF(n)A F0 +(Refer to command line)27.67 E F2(n)2.5 E F0(.).24 E F1<21ad>108 302.4 Q +F2(n)A F0(Refer to the current command minus)21.97 E F2(n)2.5 E F0(.).24 +E F1(!!)108 314.4 Q F0(Refer to the pre)29.34 E(vious command.)-.25 E +(This is a synon)5 E(ym for `!\2551'.)-.15 E F1(!)108 326.4 Q F2(string) A F0 .865(Refer to the most recent command preceding the current positi\ -on in the history list starting with)9.33 F F4(string)144 715.2 Q F0(.) -.22 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(49)198.165 E 0 Cg EP -%%Page: 50 50 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(!?)108 84 Q/F2 10/Times-Italic@0 SF(string) -A F1([?])A F0 1.503(Refer to the most recent command preceding the curr\ -ent position in the history list containing)144 96 R F2(string)144 108 Q -F0 5(.T).22 G(he trailing)-5 E F1(?)2.5 E F0(may be omitted if)2.5 E F2 -(string)2.84 E F0(is follo)2.72 E(wed immediately by a ne)-.25 E(wline.) --.25 E/F3 12/Times-Bold@0 SF(^)108 125 Q F2(string1)-5 I F3(^)5 I F2 -(string2)-5 I F3(^)5 I F0 .784(Quick substitution.)144 132 R .784 -(Repeat the pre)5.784 F .784(vious command, replacing)-.25 F F2(string1) -3.624 E F0(with)3.283 E F2(string2)3.283 E F0 5.783(.E).02 G(qui)-5.783 -E -.25(va)-.25 G .783(lent to).25 F -.74(``)144 144 S(!!:s/).74 E F2 -(string1)A F0(/)A F2(string2)A F0(/')A 2.5('\()-.74 G(see)-2.5 E F1 -(Modi\214ers)2.5 E F0(belo)2.5 E(w\).)-.25 E F1(!#)108 156 Q F0 +on in the history list starting with)9.33 F F2(string)144 338.4 Q F0(.) +.22 E F1(!?)108 350.4 Q F2(string)A F1([?])A F0 1.503(Refer to the most\ + recent command preceding the current position in the history list cont\ +aining)144 362.4 R F2(string)144 374.4 Q F0 5(.T).22 G(he trailing)-5 E +F1(?)2.5 E F0(may be omitted if)2.5 E F2(string)2.84 E F0(is follo)2.72 +E(wed immediately by a ne)-.25 E(wline.)-.25 E/F3 12/Times-Bold@0 SF(^) +108 391.4 Q F2(string1)-5 I F3(^)5 I F2(string2)-5 I F3(^)5 I F0 .784 +(Quick substitution.)144 398.4 R .784(Repeat the pre)5.784 F .784 +(vious command, replacing)-.25 F F2(string1)3.624 E F0(with)3.283 E F2 +(string2)3.283 E F0 5.783(.E).02 G(qui)-5.783 E -.25(va)-.25 G .783 +(lent to).25 F -.74(``)144 410.4 S(!!:s/).74 E F2(string1)A F0(/)A F2 +(string2)A F0(/')A 2.5('\()-.74 G(see)-2.5 E F1(Modi\214ers)2.5 E F0 +(belo)2.5 E(w\).)-.25 E F1(!#)108 422.4 Q F0 (The entire command line typed so f)27.67 E(ar)-.1 E(.)-.55 E F1 -.75 -(Wo)87 172.8 S(rd Designators).75 E F0 -.8(Wo)108 184.8 S 1.313 +(Wo)87 439.2 S(rd Designators).75 E F0 -.8(Wo)108 451.2 S 1.313 (rd designators are used to select desired w).8 F 1.314(ords from the e) -.1 F -.15(ve)-.25 G 3.814(nt. A).15 F F1(:)3.814 E F0 1.314 (separates the e)3.814 F -.15(ve)-.25 G 1.314(nt speci\214cation).15 F -.53(from the w)108 196.8 R .529(ord designator)-.1 F 5.529(.I)-.55 G +.53(from the w)108 463.2 R .529(ord designator)-.1 F 5.529(.I)-.55 G 3.029(tm)-5.529 G .529(ay be omitted if the w)-3.029 F .529 (ord designator be)-.1 F .529(gins with a)-.15 F F1(^)3.029 E F0(,)A F1 ($)3.029 E F0(,)A F1(*)3.029 E F0(,)A F13.029 E F0 3.029(,o)C(r) -3.029 E F1(%)3.029 E F0 5.529(.W)C(ords)-6.329 E 1.3 -(are numbered from the be)108 208.8 R 1.3 +(are numbered from the be)108 475.2 R 1.3 (ginning of the line, with the \214rst w)-.15 F 1.301 (ord being denoted by 0 \(zero\).)-.1 F -.8(Wo)6.301 G 1.301(rds are).8 -F(inserted into the current line separated by single spaces.)108 220.8 Q -F1 2.5(0\()108 237.6 S(zer)-2.5 E(o\))-.18 E F0(The zeroth w)144 249.6 Q -2.5(ord. F)-.1 F(or the shell, this is the command w)-.15 E(ord.)-.1 E -F2(n)108.36 261.6 Q F0(The)30.64 E F2(n)2.5 E F0(th w)A(ord.)-.1 E F1(^) -108 273.6 Q F0(The \214rst ar)32.67 E 2.5(gument. That)-.18 F(is, w)2.5 -E(ord 1.)-.1 E F1($)108 285.6 Q F0(The last ar)31 E(gument.)-.18 E F1(%) -108 297.6 Q F0(The w)26 E(ord matched by the most recent `?)-.1 E F2 -(string)A F0(?' search.)A F2(x)108.77 309.6 Q F1A F2(y)A F0 2.5(Ar) -20.65 G(ange of w)-2.5 E(ords; `\255)-.1 E F2(y)A F0 2.5('a)C(bbre)-2.5 -E(viates `0\255)-.25 E F2(y)A F0('.)A F1(*)108 321.6 Q F0 .316 +F(inserted into the current line separated by single spaces.)108 487.2 Q +F1 2.5(0\()108 504 S(zer)-2.5 E(o\))-.18 E F0(The zeroth w)144 516 Q 2.5 +(ord. F)-.1 F(or the shell, this is the command w)-.15 E(ord.)-.1 E F2 +(n)108.36 528 Q F0(The)30.64 E F2(n)2.5 E F0(th w)A(ord.)-.1 E F1(^)108 +540 Q F0(The \214rst ar)32.67 E 2.5(gument. That)-.18 F(is, w)2.5 E +(ord 1.)-.1 E F1($)108 552 Q F0(The last ar)31 E(gument.)-.18 E F1(%)108 +564 Q F0(The w)26 E(ord matched by the most recent `?)-.1 E F2(string)A +F0(?' search.)A F2(x)108.77 576 Q F1A F2(y)A F0 2.5(Ar)20.65 G +(ange of w)-2.5 E(ords; `\255)-.1 E F2(y)A F0 2.5('a)C(bbre)-2.5 E +(viates `0\255)-.25 E F2(y)A F0('.)A F1(*)108 588 Q F0 .316 (All of the w)31 F .316(ords b)-.1 F .316(ut the zeroth.)-.2 F .315 (This is a synon)5.315 F .315(ym for `)-.15 F F2(1\255$)A F0 2.815 ('. It)B .315(is not an error to use)2.815 F F1(*)2.815 E F0 .315 -(if there is)2.815 F(just one w)144 333.6 Q(ord in the e)-.1 E -.15(ve) +(if there is)2.815 F(just one w)144 600 Q(ord in the e)-.1 E -.15(ve) -.25 G(nt; the empty string is returned in that case.).15 E F1(x*)108 -345.6 Q F0(Abbre)26 E(viates)-.25 E F2(x\255$)2.5 E F0(.)A F1<78ad>108 -357.6 Q F0(Abbre)25.3 E(viates)-.25 E F2(x\255$)2.5 E F0(lik)2.5 E(e)-.1 -E F1(x*)2.5 E F0 2.5(,b)C(ut omits the last w)-2.7 E(ord.)-.1 E(If a w) -108 374.4 Q(ord designator is supplied without an e)-.1 E -.15(ve)-.25 G +612 Q F0(Abbre)26 E(viates)-.25 E F2(x\255$)2.5 E F0(.)A F1<78ad>108 624 +Q F0(Abbre)25.3 E(viates)-.25 E F2(x\255$)2.5 E F0(lik)2.5 E(e)-.1 E F1 +(x*)2.5 E F0 2.5(,b)C(ut omits the last w)-2.7 E(ord.)-.1 E(If a w)108 +640.8 Q(ord designator is supplied without an e)-.1 E -.15(ve)-.25 G (nt speci\214cation, the pre).15 E(vious command is used as the e)-.25 E --.15(ve)-.25 G(nt.).15 E F1(Modi\214ers)87 391.2 Q F0 .183 -(After the optional w)108 403.2 R .183(ord designator)-.1 F 2.683(,t)-.4 +-.15(ve)-.25 G(nt.).15 E F1(Modi\214ers)87 657.6 Q F0 .183 +(After the optional w)108 669.6 R .183(ord designator)-.1 F 2.683(,t)-.4 G .184(here may appear a sequence of one or more of the follo)-2.683 F -.184(wing modi\214ers,)-.25 F(each preceded by a `:'.)108 415.2 Q F1(h) -108 432 Q F0(Remo)30.44 E .3 -.15(ve a t)-.15 H +.184(wing modi\214ers,)-.25 F(each preceded by a `:'.)108 681.6 Q F1(h) +108 698.4 Q F0(Remo)30.44 E .3 -.15(ve a t)-.15 H (railing \214lename component, lea).15 E(ving only the head.)-.2 E F1(t) -108 444 Q F0(Remo)32.67 E .3 -.15(ve a)-.15 H -(ll leading \214lename components, lea).15 E(ving the tail.)-.2 E F1(r) -108 456 Q F0(Remo)31.56 E .3 -.15(ve a t)-.15 H(railing suf).15 E -(\214x of the form)-.25 E F2(.xxx)2.5 E F0 2.5(,l)C(ea)-2.5 E -(ving the basename.)-.2 E F1(e)108 468 Q F0(Remo)31.56 E .3 -.15(ve a) --.15 H(ll b).15 E(ut the trailing suf)-.2 E(\214x.)-.25 E F1(p)108 480 Q -F0(Print the ne)30.44 E 2.5(wc)-.25 G(ommand b)-2.5 E(ut do not e)-.2 E --.15(xe)-.15 G(cute it.).15 E F1(q)108 492 Q F0(Quote the substituted w) -30.44 E(ords, escaping further substitutions.)-.1 E F1(x)108 504 Q F0 +108 710.4 Q F0(Remo)32.67 E .3 -.15(ve a)-.15 H +(ll leading \214lename components, lea).15 E(ving the tail.)-.2 E +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(50)185.545 E 0 Cg EP +%%Page: 51 51 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(r)108 84 Q F0(Remo)31.56 E .3 -.15(ve a t) +-.15 H(railing suf).15 E(\214x of the form)-.25 E/F2 10/Times-Italic@0 +SF(.xxx)2.5 E F0 2.5(,l)C(ea)-2.5 E(ving the basename.)-.2 E F1(e)108 96 +Q F0(Remo)31.56 E .3 -.15(ve a)-.15 H(ll b).15 E(ut the trailing suf)-.2 +E(\214x.)-.25 E F1(p)108 108 Q F0(Print the ne)30.44 E 2.5(wc)-.25 G +(ommand b)-2.5 E(ut do not e)-.2 E -.15(xe)-.15 G(cute it.).15 E F1(q) +108 120 Q F0(Quote the substituted w)30.44 E +(ords, escaping further substitutions.)-.1 E F1(x)108 132 Q F0 (Quote the substituted w)31 E(ords as with)-.1 E F1(q)2.5 E F0 2.5(,b)C (ut break into w)-2.7 E(ords at)-.1 E F1(blanks)2.5 E F0(and ne)2.5 E -(wlines.)-.25 E F1(s/)108 516 Q F2(old)A F1(/)A F2(ne)A(w)-.15 E F1(/)A -F0(Substitute)144 528 Q F2(ne)3.082 E(w)-.15 E F0 .221 +(wlines.)-.25 E F1(s/)108 144 Q F2(old)A F1(/)A F2(ne)A(w)-.15 E F1(/)A +F0(Substitute)144 156 Q F2(ne)3.082 E(w)-.15 E F0 .221 (for the \214rst occurrence of)3.032 F F2(old)2.951 E F0 .221(in the e) 3.491 F -.15(ve)-.25 G .221(nt line.).15 F(An)5.221 E 2.721(yd)-.15 G -.221(elimiter can be used in place)-2.721 F .616(of /.)144 540 R .617 +.221(elimiter can be used in place)-2.721 F .616(of /.)144 168 R .617 (The \214nal delimiter is optional if it is the last character of the e) 5.616 F -.15(ve)-.25 G .617(nt line.).15 F .617(The delimiter may)5.617 -F .666(be quoted in)144 552 R F2(old)3.396 E F0(and)3.936 E F2(ne)3.526 +F .666(be quoted in)144 180 R F2(old)3.396 E F0(and)3.936 E F2(ne)3.526 E(w)-.15 E F0 .666(with a single backslash.)3.476 F .666 (If & appears in)5.666 F F2(ne)3.166 E(w)-.15 E F0 3.166(,i).31 G 3.166 (ti)-3.166 G 3.166(sr)-3.166 G .666(eplaced by)-3.166 F F2(old)3.166 E -F0 5.666(.A).77 G .274(single backslash will quote the &.)144 564 R(If) +F0 5.666(.A).77 G .274(single backslash will quote the &.)144 192 R(If) 5.274 E F2(old)3.004 E F0 .274(is null, it is set to the last)3.544 F F2 (old)3.005 E F0 .275(substituted, or)3.545 F 2.775(,i)-.4 G 2.775(fn) -2.775 G 2.775(op)-2.775 G(re)-2.775 E(vi-)-.25 E -(ous history substitutions took place, the last)144 576 Q F2(string)2.84 +(ous history substitutions took place, the last)144 204 Q F2(string)2.84 E F0(in a)2.72 E F1(!?)2.5 E F2(string)A F1([?])A F0(search.)5 E F1(&) -108 588 Q F0(Repeat the pre)27.67 E(vious substitution.)-.25 E F1(g)108 -600 Q F0 .398(Cause changes to be applied o)31 F -.15(ve)-.15 G 2.898 +108 216 Q F0(Repeat the pre)27.67 E(vious substitution.)-.25 E F1(g)108 +228 Q F0 .398(Cause changes to be applied o)31 F -.15(ve)-.15 G 2.898 (rt).15 G .398(he entire e)-2.898 F -.15(ve)-.25 G .398(nt line.).15 F .397(This is used in conjunction with `)5.398 F F1(:s)A F0 2.897('\()C -(e.g.,)-2.897 E(`)144 612 Q F1(:gs/)A F2(old)A F1(/)A F2(ne)A(w)-.15 E +(e.g.,)-2.897 E(`)144 240 Q F1(:gs/)A F2(old)A F1(/)A F2(ne)A(w)-.15 E F1(/)A F0 1.218('\) or `)B F1(:&)A F0 3.718('. If)B 1.218(used with `) 3.718 F F1(:s)A F0 1.218(', an)B 3.718(yd)-.15 G 1.219 (elimiter can be used in place of /, and the \214nal)-3.718 F .09 -(delimiter is optional if it is the last character of the e)144 624 R +(delimiter is optional if it is the last character of the e)144 252 R -.15(ve)-.25 G .089(nt line.).15 F(An)5.089 E F1(a)2.589 E F0 .089 -(may be used as a synon)2.589 F .089(ym for)-.15 F F1(g)144 636 Q F0(.)A -F1(G)108 648 Q F0(Apply the follo)28.22 E(wing `)-.25 E F1(s)A F0 2.5 +(may be used as a synon)2.589 F .089(ym for)-.15 F F1(g)144 264 Q F0(.)A +F1(G)108 276 Q F0(Apply the follo)28.22 E(wing `)-.25 E F1(s)A F0 2.5 ('m)C(odi\214er once to each w)-2.5 E(ord in the e)-.1 E -.15(ve)-.25 G -(nt line.).15 E/F4 10.95/Times-Bold@0 SF(SHELL B)72 664.8 Q(UIL)-.11 E -(TIN COMMANDS)-1.007 E F0 .062(Unless otherwise noted, each b)108 676.8 +(nt line.).15 E/F3 10.95/Times-Bold@0 SF(SHELL B)72 292.8 Q(UIL)-.11 E +(TIN COMMANDS)-1.007 E F0 .062(Unless otherwise noted, each b)108 304.8 R .062(uiltin command documented in this section as accepting options p\ -receded by)-.2 F F1108 688.8 Q F0(accepts)2.534 E F12.534 E F0 +receded by)-.2 F F1108 316.8 Q F0(accepts)2.534 E F12.534 E F0 .034(to signify the end of the options.)2.534 F(The)5.034 E F1(:)2.534 E F0(,)A F1(true)2.534 E F0(,)A F1(false)2.534 E F0 2.534(,a)C(nd)-2.534 E F1(test)2.534 E F0 -.2(bu)2.534 G .033(iltins do not accept options and) -.2 F .077(do not treat)108 700.8 R F12.577 E F0(specially)2.577 E +.2 F .077(do not treat)108 328.8 R F12.577 E F0(specially)2.577 E 5.077(.T)-.65 G(he)-5.077 E F1(exit)2.577 E F0(,)A F1(logout)2.577 E F0 (,)A F1(br)2.577 E(eak)-.18 E F0(,)A F1(continue)2.577 E F0(,)A F1(let) 2.577 E F0 2.577(,a)C(nd)-2.577 E F1(shift)2.577 E F0 -.2(bu)2.577 G -.077(iltins accept and process ar).2 F(gu-)-.18 E .32(ments be)108 712.8 +.077(iltins accept and process ar).2 F(gu-)-.18 E .32(ments be)108 340.8 R .32(ginning with)-.15 F F12.82 E F0 .32(without requiring)2.82 F F12.82 E F0 5.319(.O)C .319(ther b)-5.319 F .319 (uiltins that accept ar)-.2 F .319(guments b)-.18 F .319 (ut are not speci\214ed as)-.2 F 1.143(accepting options interpret ar) -108 724.8 R 1.143(guments be)-.18 F 1.143(ginning with)-.15 F F1 +108 352.8 R 1.143(guments be)-.18 F 1.143(ginning with)-.15 F F1 3.643 E F0 1.143(as in)3.643 F -.25(va)-.4 G 1.143 (lid options and require).25 F F13.644 E F0 1.144(to pre)3.644 F --.15(ve)-.25 G 1.144(nt this).15 F(GNU Bash 4.2)72 768 Q(2012 July 14) -149.005 E(50)198.165 E 0 Cg EP -%%Page: 51 51 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E(interpretation.)108 84 Q/F1 10/Times-Bold@0 SF(:)108 102 Q F0([) -2.5 E/F2 10/Times-Italic@0 SF(ar)A(guments)-.37 E F0(])A .452(No ef)144 -114 R .452(fect; the command does nothing be)-.25 F .452(yond e)-.15 F +-.15(ve)-.25 G 1.144(nt this).15 F(interpretation.)108 364.8 Q F1(:)108 +382.8 Q F0([)2.5 E F2(ar)A(guments)-.37 E F0(])A .452(No ef)144 394.8 R +.452(fect; the command does nothing be)-.25 F .452(yond e)-.15 F (xpanding)-.15 E F2(ar)3.282 E(guments)-.37 E F0 .451(and performing an) -3.221 F 2.951(ys)-.15 G(peci\214ed)-2.951 E 2.5(redirections. A)144 126 -R(zero e)2.5 E(xit code is returned.)-.15 E F1(.)110.5 142.8 Q F2 +3.221 F 2.951(ys)-.15 G(peci\214ed)-2.951 E 2.5(redirections. A)144 +406.8 R(zero e)2.5 E(xit code is returned.)-.15 E F1(.)110.5 423.6 Q F2 (\214lename)6.666 E F0([)2.5 E F2(ar)A(guments)-.37 E F0(])A F1(sour)108 -154.8 Q(ce)-.18 E F2(\214lename)2.5 E F0([)2.5 E F2(ar)A(guments)-.37 E -F0(])A 1.02(Read and e)144 166.8 R -.15(xe)-.15 G 1.02 +435.6 Q(ce)-.18 E F2(\214lename)2.5 E F0([)2.5 E F2(ar)A(guments)-.37 E +F0(])A 1.02(Read and e)144 447.6 R -.15(xe)-.15 G 1.02 (cute commands from).15 F F2(\214lename)5.43 E F0 1.02 (in the current shell en)3.7 F 1.02(vironment and return the e)-.4 F -(xit)-.15 E 1.458(status of the last command e)144 178.8 R -.15(xe)-.15 +(xit)-.15 E 1.458(status of the last command e)144 459.6 R -.15(xe)-.15 G 1.458(cuted from).15 F F2(\214lename)3.958 E F0 6.458(.I).18 G(f) -6.458 E F2(\214lename)5.868 E F0 1.458 -(does not contain a slash, \214le-)4.138 F .608(names in)144 190.8 R/F3 +(does not contain a slash, \214le-)4.138 F .608(names in)144 471.6 R/F4 9/Times-Bold@0 SF -.666(PA)3.108 G(TH)-.189 E F0 .608 (are used to \214nd the directory containing)2.858 F F2(\214lename)3.108 -E F0 5.608(.T).18 G .608(he \214le searched for in)-5.608 F F3 -.666(PA) -3.108 G(TH)-.189 E F0 .833(need not be e)144 202.8 R -.15(xe)-.15 G +E F0 5.608(.T).18 G .608(he \214le searched for in)-5.608 F F4 -.666(PA) +3.108 G(TH)-.189 E F0 .833(need not be e)144 483.6 R -.15(xe)-.15 G 3.333(cutable. When).15 F F1(bash)3.333 E F0 .832(is not in)3.333 F F2 .832(posix mode)3.332 F F0 3.332(,t)C .832 (he current directory is searched if no)-3.332 F .981 -(\214le is found in)144 214.8 R F3 -.666(PA)3.481 G(TH)-.189 E/F4 9 +(\214le is found in)144 495.6 R F4 -.666(PA)3.481 G(TH)-.189 E/F5 9 /Times-Roman@0 SF(.)A F0 .981(If the)5.481 F F1(sour)3.481 E(cepath)-.18 E F0 .981(option to the)3.481 F F1(shopt)3.481 E F0 -.2(bu)3.481 G .981 -(iltin command is turned of).2 F .982(f, the)-.25 F F3 -.666(PA)144 -226.8 S(TH)-.189 E F0 .112(is not searched.)2.363 F .112(If an)5.112 F +(iltin command is turned of).2 F .982(f, the)-.25 F F4 -.666(PA)144 +507.6 S(TH)-.189 E F0 .112(is not searched.)2.363 F .112(If an)5.112 F (y)-.15 E F2(ar)2.612 E(guments)-.37 E F0 .112(are supplied, the)2.612 F 2.612(yb)-.15 G .112(ecome the positional parameters when)-2.612 F F2 -(\214lename)144 238.8 Q F0 .341(is e)2.841 F -.15(xe)-.15 G 2.841 +(\214lename)144 519.6 Q F0 .341(is e)2.841 F -.15(xe)-.15 G 2.841 (cuted. Otherwise).15 F .341(the positional parameters are unchanged.) 2.841 F .342(The return status is the)5.342 F .716 -(status of the last command e)144 250.8 R .716 +(status of the last command e)144 531.6 R .716 (xited within the script \(0 if no commands are e)-.15 F -.15(xe)-.15 G -.716(cuted\), and f).15 F .715(alse if)-.1 F F2(\214lename)145.91 262.8 -Q F0(is not found or cannot be read.)2.68 E F1(alias)108 279.6 Q F0([) +.716(cuted\), and f).15 F .715(alse if)-.1 F F2(\214lename)145.91 543.6 +Q F0(is not found or cannot be read.)2.68 E F1(alias)108 560.4 Q F0([) 2.5 E F1A F0 2.5(][)C F2(name)-2.5 E F0([=)A F2(value)A F0 2.5(].) -C(..])-2.5 E F1(Alias)144 291.6 Q F0 2.724(with no ar)5.224 F 2.724 +C(..])-2.5 E F1(Alias)144 572.4 Q F0 2.724(with no ar)5.224 F 2.724 (guments or with the)-.18 F F15.224 E F0 2.724 (option prints the list of aliases in the form)5.224 F F1(alias)5.225 E -F2(name)144 303.6 Q F0(=)A F2(value)A F0 .58(on standard output.)3.08 F +F2(name)144 584.4 Q F0(=)A F2(value)A F0 .58(on standard output.)3.08 F .58(When ar)5.58 F .58 (guments are supplied, an alias is de\214ned for each)-.18 F F2(name) -3.08 E F0(whose)144 315.6 Q F2(value)2.895 E F0 .395(is gi)2.895 F -.15 +3.08 E F0(whose)144 596.4 Q F2(value)2.895 E F0 .395(is gi)2.895 F -.15 (ve)-.25 G 2.895(n. A).15 F .395(trailing space in)2.895 F F2(value) 5.395 E F0 .395(causes the ne)2.895 F .395(xt w)-.15 F .395 (ord to be check)-.1 F .395(ed for alias sub-)-.1 F .054 -(stitution when the alias is e)144 327.6 R 2.554(xpanded. F)-.15 F .054 +(stitution when the alias is e)144 608.4 R 2.554(xpanded. F)-.15 F .054 (or each)-.15 F F2(name)2.554 E F0 .054(in the ar)2.554 F .054 (gument list for which no)-.18 F F2(value)2.554 E F0 .053(is sup-)2.553 -F 1.313(plied, the name and v)144 339.6 R 1.314 +F 1.313(plied, the name and v)144 620.4 R 1.314 (alue of the alias is printed.)-.25 F F1(Alias)6.314 E F0 1.314 (returns true unless a)3.814 F F2(name)3.814 E F0 1.314(is gi)3.814 F -.15(ve)-.25 G 3.814(nf).15 G(or)-3.814 E -(which no alias has been de\214ned.)144 351.6 Q F1(bg)108 368.4 Q F0([) +(which no alias has been de\214ned.)144 632.4 Q F1(bg)108 649.2 Q F0([) 2.5 E F2(jobspec)A F0(...])2.5 E .745(Resume each suspended job)144 -380.4 R F2(jobspec)3.245 E F0 .745 +661.2 R F2(jobspec)3.245 E F0 .745 (in the background, as if it had been started with)3.245 F F1(&)3.244 E -F0 5.744(.I)C(f)-5.744 E F2(job-)4.984 E(spec)144 392.4 Q F0 .671 +F0 5.744(.I)C(f)-5.744 E F2(job-)4.984 E(spec)144 673.2 Q F0 .671 (is not present, the shell')3.481 F 3.171(sn)-.55 G .672(otion of the) -3.171 F F2(curr)3.172 E .672(ent job)-.37 F F0 .672(is used.)3.172 F F1 (bg)5.672 E F2(jobspec)4.912 E F0 .672(returns 0 unless run)3.482 F .419 -(when job control is disabled or)144 404.4 R 2.919(,w)-.4 G .419 +(when job control is disabled or)144 685.2 R 2.919(,w)-.4 G .419 (hen run with job control enabled, an)-2.919 F 2.918(ys)-.15 G (peci\214ed)-2.918 E F2(jobspec)2.918 E F0 -.1(wa)2.918 G 2.918(sn).1 G -(ot)-2.918 E(found or w)144 416.4 Q(as started without job control.)-.1 -E F1(bind)108 433.2 Q F0([)2.5 E F1A F2 -.1(ke)2.5 G(ymap)-.2 E F0 -2.5(][)C F1(\255lpsvPSVX)-2.5 E F0(])A F1(bind)108 445.2 Q F0([)2.5 E F1 -A F2 -.1(ke)2.5 G(ymap)-.2 E F0 2.5(][)C F1-2.5 E F2 -(function)2.5 E F0 2.5(][)C F1-2.5 E F2(function)2.5 E F0 2.5(][)C -F1-2.5 E F2 -.1(ke)2.5 G(yseq)-.2 E F0(])A F1(bind)108 457.2 Q F0 -([)2.5 E F1A F2 -.1(ke)2.5 G(ymap)-.2 E F0(])A F12.5 E F2 -(\214lename)2.5 E F1(bind)108 469.2 Q F0([)2.5 E F1A F2 -.1(ke)2.5 -G(ymap)-.2 E F0(])A F12.5 E F2 -.1(ke)2.5 G(yseq)-.2 E F0(:)A F2 -(shell\255command)A F1(bind)108 481.2 Q F0([)2.5 E F1A F2 -.1(ke) -2.5 G(ymap)-.2 E F0(])A F2 -.1(ke)2.5 G(yseq)-.2 E F0(:)A F2 -(function\255name)A F1(bind)108 493.2 Q F2 -.37(re)2.5 G -(adline\255command).37 E F0 .238(Display current)144 505.2 R F1 -.18(re) -2.738 G(adline).18 E F0 -.1(ke)2.738 G 2.738(ya)-.05 G .239 +(ot)-2.918 E(found or w)144 697.2 Q(as started without job control.)-.1 +E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(51)185.545 E 0 Cg EP +%%Page: 52 52 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(bind)108 84 Q F0([)2.5 E F1A/F2 10 +/Times-Italic@0 SF -.1(ke)2.5 G(ymap)-.2 E F0 2.5(][)C F1(\255lpsvPSVX) +-2.5 E F0(])A F1(bind)108 96 Q F0([)2.5 E F1A F2 -.1(ke)2.5 G +(ymap)-.2 E F0 2.5(][)C F1-2.5 E F2(function)2.5 E F0 2.5(][)C F1 +-2.5 E F2(function)2.5 E F0 2.5(][)C F1-2.5 E F2 -.1(ke)2.5 +G(yseq)-.2 E F0(])A F1(bind)108 108 Q F0([)2.5 E F1A F2 -.1(ke)2.5 +G(ymap)-.2 E F0(])A F12.5 E F2(\214lename)2.5 E F1(bind)108 120 Q +F0([)2.5 E F1A F2 -.1(ke)2.5 G(ymap)-.2 E F0(])A F12.5 E F2 +-.1(ke)2.5 G(yseq)-.2 E F0(:)A F2(shell\255command)A F1(bind)108 132 Q +F0([)2.5 E F1A F2 -.1(ke)2.5 G(ymap)-.2 E F0(])A F2 -.1(ke)2.5 G +(yseq)-.2 E F0(:)A F2(function\255name)A F1(bind)108 144 Q F2 -.37(re) +2.5 G(adline\255command).37 E F0 .238(Display current)144 156 R F1 -.18 +(re)2.738 G(adline).18 E F0 -.1(ke)2.738 G 2.738(ya)-.05 G .239 (nd function bindings, bind a k)-2.738 F .539 -.15(ey s)-.1 H .239 (equence to a).15 F F1 -.18(re)2.739 G(adline).18 E F0 .239(function or) -2.739 F .476(macro, or set a)144 517.2 R F1 -.18(re)2.976 G(adline).18 E +2.739 F .476(macro, or set a)144 168 R F1 -.18(re)2.976 G(adline).18 E F0 -.25(va)2.976 G 2.976(riable. Each).25 F .476(non-option ar)2.976 F .475(gument is a command as it w)-.18 F .475(ould appear in)-.1 F F2 -(.inputr)144 529.2 Q(c)-.37 E F0 2.983(,b).31 G .484 +(.inputr)144 180 Q(c)-.37 E F0 2.983(,b).31 G .484 (ut each binding or command must be passed as a separate ar)-3.183 F .484(gument; e.g., '"\\C\255x\\C\255r":)-.18 F 2.5 -(re\255read\255init\255\214le'. Options,)144 541.2 R(if supplied, ha)2.5 -E .3 -.15(ve t)-.2 H(he follo).15 E(wing meanings:)-.25 E F1144 -553.2 Q F2 -.1(ke)2.5 G(ymap)-.2 E F0(Use)180 565.2 Q F2 -.1(ke)5.159 G -(ymap)-.2 E F0 2.659(as the k)5.349 F -.15(ey)-.1 G 2.658(map to be af) -.15 F 2.658(fected by the subsequent bindings.)-.25 F(Acceptable)7.658 E -F2 -.1(ke)180 577.2 S(ymap)-.2 E F0 3.192(names are)5.882 F F2 3.192 +(re\255read\255init\255\214le'. Options,)144 192 R(if supplied, ha)2.5 E +.3 -.15(ve t)-.2 H(he follo).15 E(wing meanings:)-.25 E F1144 204 +Q F2 -.1(ke)2.5 G(ymap)-.2 E F0(Use)180 216 Q F2 -.1(ke)5.159 G(ymap)-.2 +E F0 2.659(as the k)5.349 F -.15(ey)-.1 G 2.658(map to be af).15 F 2.658 +(fected by the subsequent bindings.)-.25 F(Acceptable)7.658 E F2 -.1(ke) +180 228 S(ymap)-.2 E F0 3.192(names are)5.882 F F2 3.192 (emacs, emacs\255standar)5.692 F 3.193 (d, emacs\255meta, emacs\255ctlx, vi, vi\255mo)-.37 F(ve)-.1 E(,)-.1 E -(vi\255command)180 589.2 Q F0 4.43(,a)C(nd)-4.43 E F2(vi\255insert)4.429 -E F0(.).68 E F2(vi)6.929 E F0 1.929(is equi)4.429 F -.25(va)-.25 G 1.929 +(vi\255command)180 240 Q F0 4.43(,a)C(nd)-4.43 E F2(vi\255insert)4.429 E +F0(.).68 E F2(vi)6.929 E F0 1.929(is equi)4.429 F -.25(va)-.25 G 1.929 (lent to).25 F F2(vi\255command)4.429 E F0(;)A F2(emacs)4.429 E F0 1.929 (is equi)4.429 F -.25(va)-.25 G 1.929(lent to).25 F F2(emacs\255standar) -180 601.2 Q(d)-.37 E F0(.)A F1144 613.2 Q F0 -(List the names of all)27.52 E F1 -.18(re)2.5 G(adline).18 E F0 -(functions.)2.5 E F1144 625.2 Q F0(Display)24.74 E F1 -.18(re)2.5 -G(adline).18 E F0(function names and bindings in such a w)2.5 E -(ay that the)-.1 E 2.5(yc)-.15 G(an be re-read.)-2.5 E F1144 637.2 -Q F0(List current)24.19 E F1 -.18(re)2.5 G(adline).18 E F0 -(function names and bindings.)2.5 E F1144 649.2 Q F0(Display)26.41 -E F1 -.18(re)3.655 G(adline).18 E F0 -.1(ke)3.655 G 3.655(ys)-.05 G -1.155(equences bound to macros and the strings the)-3.655 F 3.655(yo) --.15 G 1.155(utput in such a)-3.655 F -.1(wa)180 661.2 S 2.5(yt).1 G -(hat the)-2.5 E 2.5(yc)-.15 G(an be re-read.)-2.5 E F1144 673.2 Q -F0(Display)24.74 E F1 -.18(re)2.5 G(adline).18 E F0 -.1(ke)2.5 G 2.5(ys) --.05 G(equences bound to macros and the strings the)-2.5 E 2.5(yo)-.15 G -(utput.)-2.5 E F1144 685.2 Q F0(Display)25.3 E F1 -.18(re)2.5 G +180 252 Q(d)-.37 E F0(.)A F1144 264 Q F0(List the names of all) +27.52 E F1 -.18(re)2.5 G(adline).18 E F0(functions.)2.5 E F1144 +276 Q F0(Display)24.74 E F1 -.18(re)2.5 G(adline).18 E F0 +(function names and bindings in such a w)2.5 E(ay that the)-.1 E 2.5(yc) +-.15 G(an be re-read.)-2.5 E F1144 288 Q F0(List current)24.19 E +F1 -.18(re)2.5 G(adline).18 E F0(function names and bindings.)2.5 E F1 +144 300 Q F0(Display)26.41 E F1 -.18(re)3.655 G(adline).18 E F0 +-.1(ke)3.655 G 3.655(ys)-.05 G 1.155 +(equences bound to macros and the strings the)-3.655 F 3.655(yo)-.15 G +1.155(utput in such a)-3.655 F -.1(wa)180 312 S 2.5(yt).1 G(hat the)-2.5 +E 2.5(yc)-.15 G(an be re-read.)-2.5 E F1144 324 Q F0(Display)24.74 +E F1 -.18(re)2.5 G(adline).18 E F0 -.1(ke)2.5 G 2.5(ys)-.05 G +(equences bound to macros and the strings the)-2.5 E 2.5(yo)-.15 G +(utput.)-2.5 E F1144 336 Q F0(Display)25.3 E F1 -.18(re)2.5 G (adline).18 E F0 -.25(va)2.5 G(riable names and v).25 E (alues in such a w)-.25 E(ay that the)-.1 E 2.5(yc)-.15 G -(an be re-read.)-2.5 E F1144 697.2 Q F0(List current)23.08 E F1 --.18(re)2.5 G(adline).18 E F0 -.25(va)2.5 G(riable names and v).25 E -(alues.)-.25 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(51)198.165 E -0 Cg EP -%%Page: 52 52 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF144 84 Q/F2 10/Times-Italic@0 SF -(\214lename)2.5 E F0(Read k)180 96 Q .3 -.15(ey b)-.1 H(indings from).15 -E F2(\214lename)2.5 E F0(.)A F1144 108 Q F2(function)2.5 E F0 -(Query about which k)180 120 Q -.15(ey)-.1 G 2.5(si).15 G -1.9 -.4(nv o) --2.5 H .2 -.1(ke t).4 H(he named).1 E F2(function)2.5 E F0(.)A F1 -144 132 Q F2(function)2.5 E F0(Unbind all k)180 144 Q -.15(ey)-.1 G 2.5 -(sb).15 G(ound to the named)-2.5 E F2(function)2.5 E F0(.)A F1144 -156 Q F2 -.1(ke)2.5 G(yseq)-.2 E F0(Remo)180 168 Q .3 -.15(ve a)-.15 H -.3 -.15(ny c).15 H(urrent binding for).15 E F2 -.1(ke)2.5 G(yseq)-.2 E -F0(.)A F1144 180 Q F2 -.1(ke)2.5 G(yseq)-.2 E F1(:)A F2 -(shell\255command)A F0(Cause)180 192 Q F2(shell\255command)4.325 E F0 -1.825(to be e)4.325 F -.15(xe)-.15 G 1.825(cuted whene).15 F -.15(ve) --.25 G(r).15 E F2 -.1(ke)4.325 G(yseq)-.2 E F0 1.825(is entered.)4.325 F -(When)6.825 E F2(shell\255com-)4.325 E(mand)180 204 Q F0 1.764(is e) -4.264 F -.15(xe)-.15 G 1.765(cuted, the shell sets the).15 F/F3 9 -/Times-Bold@0 SF(READLINE_LINE)4.265 E F0 -.25(va)4.015 G 1.765 -(riable to the contents of the).25 F F1 -.18(re)180 216 S(adline).18 E -F0 1.353(line b)3.853 F(uf)-.2 E 1.353(fer and the)-.25 F F3 -(READLINE_POINT)3.853 E F0 -.25(va)3.603 G 1.353 +(an be re-read.)-2.5 E F1144 348 Q F0(List current)23.08 E F1 -.18 +(re)2.5 G(adline).18 E F0 -.25(va)2.5 G(riable names and v).25 E(alues.) +-.25 E F1144 360 Q F2(\214lename)2.5 E F0(Read k)180 372 Q .3 -.15 +(ey b)-.1 H(indings from).15 E F2(\214lename)2.5 E F0(.)A F1144 +384 Q F2(function)2.5 E F0(Query about which k)180 396 Q -.15(ey)-.1 G +2.5(si).15 G -1.9 -.4(nv o)-2.5 H .2 -.1(ke t).4 H(he named).1 E F2 +(function)2.5 E F0(.)A F1144 408 Q F2(function)2.5 E F0 +(Unbind all k)180 420 Q -.15(ey)-.1 G 2.5(sb).15 G(ound to the named) +-2.5 E F2(function)2.5 E F0(.)A F1144 432 Q F2 -.1(ke)2.5 G(yseq) +-.2 E F0(Remo)180 444 Q .3 -.15(ve a)-.15 H .3 -.15(ny c).15 H +(urrent binding for).15 E F2 -.1(ke)2.5 G(yseq)-.2 E F0(.)A F1144 +456 Q F2 -.1(ke)2.5 G(yseq)-.2 E F1(:)A F2(shell\255command)A F0(Cause) +180 468 Q F2(shell\255command)4.325 E F0 1.825(to be e)4.325 F -.15(xe) +-.15 G 1.825(cuted whene).15 F -.15(ve)-.25 G(r).15 E F2 -.1(ke)4.325 G +(yseq)-.2 E F0 1.825(is entered.)4.325 F(When)6.825 E F2(shell\255com-) +4.325 E(mand)180 480 Q F0 1.764(is e)4.264 F -.15(xe)-.15 G 1.765 +(cuted, the shell sets the).15 F/F3 9/Times-Bold@0 SF(READLINE_LINE) +4.265 E F0 -.25(va)4.015 G 1.765(riable to the contents of the).25 F F1 +-.18(re)180 492 S(adline).18 E F0 1.353(line b)3.853 F(uf)-.2 E 1.353 +(fer and the)-.25 F F3(READLINE_POINT)3.853 E F0 -.25(va)3.603 G 1.353 (riable to the current location of the).25 F 2.011(insertion point.)180 -228 R 2.011(If the e)7.011 F -.15(xe)-.15 G 2.011 +504 R 2.011(If the e)7.011 F -.15(xe)-.15 G 2.011 (cuted command changes the v).15 F 2.011(alue of)-.25 F F3 -(READLINE_LINE)4.512 E F0(or)4.262 E F3(READLINE_POINT)180 240 Q/F4 9 +(READLINE_LINE)4.512 E F0(or)4.262 E F3(READLINE_POINT)180 516 Q/F4 9 /Times-Roman@0 SF(,)A F0(those ne)2.25 E 2.5(wv)-.25 G -(alues will be re\215ected in the editing state.)-2.75 E F1144 252 +(alues will be re\215ected in the editing state.)-2.75 E F1144 528 Q F0 .83(List all k)23.08 F 1.13 -.15(ey s)-.1 H .829 (equences bound to shell commands and the associated commands in a for) -.15 F(-)-.2 E(mat that can be reused as input.)180 264 Q(The return v) -144 280.8 Q(alue is 0 unless an unrecognized option is gi)-.25 E -.15 +.15 F(-)-.2 E(mat that can be reused as input.)180 540 Q(The return v) +144 556.8 Q(alue is 0 unless an unrecognized option is gi)-.25 E -.15 (ve)-.25 G 2.5(no).15 G 2.5(ra)-2.5 G 2.5(ne)-2.5 G(rror occurred.)-2.5 -E F1(br)108 297.6 Q(eak)-.18 E F0([)2.5 E F2(n)A F0(])A .054 -(Exit from within a)144 309.6 R F1 -.25(fo)2.554 G(r).25 E F0(,)A F1 +E F1(br)108 573.6 Q(eak)-.18 E F0([)2.5 E F2(n)A F0(])A .054 +(Exit from within a)144 585.6 R F1 -.25(fo)2.554 G(r).25 E F0(,)A F1 (while)2.554 E F0(,)A F1(until)2.555 E F0 2.555(,o)C(r)-2.555 E F1 (select)2.555 E F0 2.555(loop. If)2.555 F F2(n)2.555 E F0 .055 (is speci\214ed, break)2.555 F F2(n)2.555 E F0(le)2.555 E -.15(ve)-.25 G (ls.).15 E F2(n)5.415 E F0 .055(must be)2.795 F/F5 10/Symbol SF2.555 -E F0(1.)2.555 E(If)144 321.6 Q F2(n)3.075 E F0 .215(is greater than the\ +E F0(1.)2.555 E(If)144 597.6 Q F2(n)3.075 E F0 .215(is greater than the\ number of enclosing loops, all enclosing loops are e)2.955 F 2.714 (xited. The)-.15 F .214(return v)2.714 F(alue)-.25 E(is 0 unless)144 -333.6 Q F2(n)2.5 E F0(is not greater than or equal to 1.)2.5 E F1 -.2 -(bu)108 350.4 S(iltin).2 E F2(shell\255b)2.5 E(uiltin)-.2 E F0([)2.5 E -F2(ar)A(guments)-.37 E F0(])A(Ex)144 362.4 Q .792 +609.6 Q F2(n)2.5 E F0(is not greater than or equal to 1.)2.5 E F1 -.2 +(bu)108 626.4 S(iltin).2 E F2(shell\255b)2.5 E(uiltin)-.2 E F0([)2.5 E +F2(ar)A(guments)-.37 E F0(])A(Ex)144 638.4 Q .792 (ecute the speci\214ed shell b)-.15 F .792(uiltin, passing it)-.2 F F2 (ar)3.293 E(guments)-.37 E F0 3.293(,a).27 G .793(nd return its e)-3.293 F .793(xit status.)-.15 F .793(This is useful)5.793 F .616 (when de\214ning a function whose name is the same as a shell b)144 -374.4 R .615(uiltin, retaining the functionality of)-.2 F .57(the b)144 -386.4 R .57(uiltin within the function.)-.2 F(The)5.57 E F1(cd)3.07 E F0 +650.4 R .615(uiltin, retaining the functionality of)-.2 F .57(the b)144 +662.4 R .57(uiltin within the function.)-.2 F(The)5.57 E F1(cd)3.07 E F0 -.2(bu)3.07 G .57(iltin is commonly rede\214ned this w).2 F(ay)-.1 E -5.57(.T)-.65 G .57(he return status)-5.57 F(is f)144 398.4 Q(alse if)-.1 +5.57(.T)-.65 G .57(he return status)-5.57 F(is f)144 674.4 Q(alse if)-.1 E F2(shell\255b)2.84 E(uiltin)-.2 E F0(is not a shell b)2.74 E -(uiltin command.)-.2 E F1(caller)108 415.2 Q F0([)2.5 E F2 -.2(ex)C(pr) -.2 E F0(])A .254(Returns the conte)144 427.2 R .254(xt of an)-.15 F +(uiltin command.)-.2 E F1(caller)108 691.2 Q F0([)2.5 E F2 -.2(ex)C(pr) +.2 E F0(])A .254(Returns the conte)144 703.2 R .254(xt of an)-.15 F 2.754(ya)-.15 G(cti)-2.754 E .554 -.15(ve s)-.25 H .254 (ubroutine call \(a shell function or a script e).15 F -.15(xe)-.15 G -.254(cuted with the).15 F F1(.)2.753 E F0(or)2.753 E F1(sour)144 439.2 Q +.254(cuted with the).15 F F1(.)2.753 E F0(or)2.753 E F1(sour)144 715.2 Q (ce)-.18 E F0 -.2(bu)2.824 G 2.824(iltins\). W).2 F(ithout)-.4 E F2 -.2 (ex)2.824 G(pr).2 E F0(,)A F1(caller)2.824 E F0 .324 (displays the line number and source \214lename of the current)2.824 F -.254(subroutine call.)144 451.2 R .254(If a non-ne)5.254 F -.05(ga)-.15 -G(ti).05 E .554 -.15(ve i)-.25 H(nte).15 E .253(ger is supplied as)-.15 -F F2 -.2(ex)2.753 G(pr).2 E F0(,)A F1(caller)2.753 E F0 .253 -(displays the line number)2.753 F 2.753(,s)-.4 G(ub-)-2.753 E 1.327(rou\ -tine name, and source \214le corresponding to that position in the curr\ -ent e)144 463.2 R -.15(xe)-.15 G 1.328(cution call stack.).15 F .001 -(This e)144 475.2 R .001(xtra information may be used, for e)-.15 F .001 -(xample, to print a stack trace.)-.15 F(The current frame is frame)5 E -3.019(0. The)144 487.2 R .519(return v)3.019 F .519 -(alue is 0 unless the shell is not e)-.25 F -.15(xe)-.15 G .52 -(cuting a subroutine call or).15 F F2 -.2(ex)3.02 G(pr).2 E F0 .52 -(does not corre-)3.02 F(spond to a v)144 499.2 Q -(alid position in the call stack.)-.25 E F1(cd)108 516 Q F0([)2.5 E F1 -A F0(|[)A F1A F0([)2.5 E F1A F0(]]] [)A F2(dir)A F0(]) -A .322(Change the current directory to)144 528 R F2(dir)2.822 E F0 5.322 -(.i)C(f)-5.322 E F2(dir)2.822 E F0 .321(is not supplied, the v)2.822 F -.321(alue of the)-.25 F F3(HOME)2.821 E F0 .321(shell v)2.571 F .321 -(ariable is)-.25 F 1.035(the def)144 540 R 3.535(ault. An)-.1 F 3.535 -(ya)-.15 G 1.035(dditional ar)-3.535 F 1.035(guments follo)-.18 F(wing) --.25 E F2(dir)3.535 E F0 1.035(are ignored.)3.535 F 1.036(The v)6.035 F -(ariable)-.25 E F3(CDP)3.536 E -.855(AT)-.666 G(H).855 E F0(de\214nes) -3.286 E .85(the search path for the directory containing)144 552 R F2 -(dir)3.35 E F0 3.35(:e).73 G .849(ach directory name in)-3.35 F F3(CDP) -3.349 E -.855(AT)-.666 G(H).855 E F0 .849(is searched for)3.099 F F2 -(dir)144 564 Q F0 5.664(.A)C(lternati)-5.664 E .964 -.15(ve d)-.25 H -.665(irectory names in).15 F F3(CDP)3.165 E -.855(AT)-.666 G(H).855 E F0 +1.68(subroutine call.)144 727.2 R 1.68(If a non-ne)6.68 F -.05(ga)-.15 G +(ti).05 E 1.98 -.15(ve i)-.25 H(nte).15 E 1.68(ger is supplied as)-.15 F +F2 -.2(ex)4.18 G(pr).2 E F0(,)A F1(caller)4.18 E F0 1.68 +(displays the line number)4.18 F(,)-.4 E(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(52)185.545 E 0 Cg EP +%%Page: 53 53 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E .335(subroutine name, and source \214le corresponding to that po\ +sition in the current e)144 84 R -.15(xe)-.15 G .335(cution call stack.) +.15 F .001(This e)144 96 R .001(xtra information may be used, for e)-.15 +F .001(xample, to print a stack trace.)-.15 F +(The current frame is frame)5 E 3.019(0. The)144 108 R .519(return v) +3.019 F .519(alue is 0 unless the shell is not e)-.25 F -.15(xe)-.15 G +.52(cuting a subroutine call or).15 F/F1 10/Times-Italic@0 SF -.2(ex) +3.02 G(pr).2 E F0 .52(does not corre-)3.02 F(spond to a v)144 120 Q +(alid position in the call stack.)-.25 E/F2 10/Times-Bold@0 SF(cd)108 +136.8 Q F0([)2.5 E F2A F0(|[)A F2A F0([)2.5 E F2A F0 +(]]] [)A F1(dir)A F0(])A .322(Change the current directory to)144 148.8 +R F1(dir)2.822 E F0 5.322(.i)C(f)-5.322 E F1(dir)2.822 E F0 .321 +(is not supplied, the v)2.822 F .321(alue of the)-.25 F/F3 9 +/Times-Bold@0 SF(HOME)2.821 E F0 .321(shell v)2.571 F .321(ariable is) +-.25 F 1.035(the def)144 160.8 R 3.535(ault. An)-.1 F 3.535(ya)-.15 G +1.035(dditional ar)-3.535 F 1.035(guments follo)-.18 F(wing)-.25 E F1 +(dir)3.535 E F0 1.035(are ignored.)3.535 F 1.036(The v)6.035 F(ariable) +-.25 E F3(CDP)3.536 E -.855(AT)-.666 G(H).855 E F0(de\214nes)3.286 E .85 +(the search path for the directory containing)144 172.8 R F1(dir)3.35 E +F0 3.35(:e).73 G .849(ach directory name in)-3.35 F F3(CDP)3.349 E -.855 +(AT)-.666 G(H).855 E F0 .849(is searched for)3.099 F F1(dir)144 184.8 Q +F0 5.664(.A)C(lternati)-5.664 E .964 -.15(ve d)-.25 H .665 +(irectory names in).15 F F3(CDP)3.165 E -.855(AT)-.666 G(H).855 E F0 .665(are separated by a colon \(:\).)2.915 F 3.165(An)5.665 G .665 -(ull directory name)-3.165 F(in)144 576 Q F3(CDP)4.163 E -.855(AT)-.666 -G(H).855 E F0 1.663(is the same as the current directory)3.913 F 4.162 -(,i)-.65 G 1.662(.e., `)-4.162 F(`)-.74 E F1(.)A F0 -.74('')C 6.662(.I) -.74 G(f)-6.662 E F2(dir)4.512 E F0(be)4.892 E 1.662 -(gins with a slash \(/\), then)-.15 F F3(CDP)144 588 Q -.855(AT)-.666 G -(H).855 E F0 .347(is not used. The)2.597 F F12.847 E F0 .347 -(option causes)2.847 F F1(cd)2.847 E F0 .347(to use the ph)2.847 F .347 +(ull directory name)-3.165 F(in)144 196.8 Q F3(CDP)4.163 E -.855(AT) +-.666 G(H).855 E F0 1.663(is the same as the current directory)3.913 F +4.162(,i)-.65 G 1.662(.e., `)-4.162 F(`)-.74 E F2(.)A F0 -.74('')C 6.662 +(.I).74 G(f)-6.662 E F1(dir)4.512 E F0(be)4.892 E 1.662 +(gins with a slash \(/\), then)-.15 F F3(CDP)144 208.8 Q -.855(AT)-.666 +G(H).855 E F0 .347(is not used. The)2.597 F F22.847 E F0 .347 +(option causes)2.847 F F2(cd)2.847 E F0 .347(to use the ph)2.847 F .347 (ysical directory structure by resolving)-.05 F 1.12 -(symbolic links while tra)144 600 R -.15(ve)-.2 G(rsing).15 E F2(dir) -3.62 E F0 1.12(and before processing instances of)3.62 F F2(..)3.62 E F0 -(in)3.62 E F2(dir)3.62 E F0 1.12(\(see also the)3.62 F F13.62 E F0 -.395(option to the)144 612 R F1(set)2.895 E F0 -.2(bu)2.895 G .395 -(iltin command\); the).2 F F12.895 E F0 .395 +(symbolic links while tra)144 220.8 R -.15(ve)-.2 G(rsing).15 E F1(dir) +3.62 E F0 1.12(and before processing instances of)3.62 F F1(..)3.62 E F0 +(in)3.62 E F1(dir)3.62 E F0 1.12(\(see also the)3.62 F F23.62 E F0 +.395(option to the)144 232.8 R F2(set)2.895 E F0 -.2(bu)2.895 G .395 +(iltin command\); the).2 F F22.895 E F0 .395 (option forces symbolic links to be follo)2.895 F .395(wed by resolv-) --.25 F .444(ing the link after processing instances of)144 624 R F2(..) -2.943 E F0(in)2.943 E F2(dir)2.943 E F0 5.443(.I)C(f)-5.443 E F2(..) -2.943 E F0 .443(appears in)2.943 F F2(dir)2.943 E F0 2.943(,i)C 2.943 +-.25 F .444(ing the link after processing instances of)144 244.8 R F1 +(..)2.943 E F0(in)2.943 E F1(dir)2.943 E F0 5.443(.I)C(f)-5.443 E F1(..) +2.943 E F0 .443(appears in)2.943 F F1(dir)2.943 E F0 2.943(,i)C 2.943 (ti)-2.943 G 2.943(sp)-2.943 G .443(rocessed by remo)-2.943 F(ving)-.15 -E .744(the immediately pre)144 636 R .744(vious pathname component from) --.25 F F2(dir)3.244 E F0 3.244(,b)C .744(ack to a slash or the be)-3.244 -F .744(ginning of)-.15 F F2(dir)3.244 E F0(.)A 1.466(If the)144 648 R F1 -3.966 E F0 1.466(option is supplied with)3.966 F F13.965 E -F0 3.965(,a)C 1.465(nd the current w)-3.965 F 1.465 +E .744(the immediately pre)144 256.8 R .744 +(vious pathname component from)-.25 F F1(dir)3.244 E F0 3.244(,b)C .744 +(ack to a slash or the be)-3.244 F .744(ginning of)-.15 F F1(dir)3.244 E +F0(.)A 1.466(If the)144 268.8 R F23.966 E F0 1.466 +(option is supplied with)3.966 F F23.965 E F0 3.965(,a)C 1.465 +(nd the current w)-3.965 F 1.465 (orking directory cannot be successfully)-.1 F .012 -(determined after a successful directory change,)144 660 R F1(cd)2.512 E -F0 .012(will return an unsuccessful status.)2.512 F .013(An ar)5.013 F -(gument)-.18 E(of)144 672 Q F12.672 E F0 .172(is con)2.672 F -.15 +(determined after a successful directory change,)144 280.8 R F2(cd)2.512 +E F0 .012(will return an unsuccessful status.)2.512 F .013(An ar)5.013 F +(gument)-.18 E(of)144 292.8 Q F22.672 E F0 .172(is con)2.672 F -.15 (ve)-.4 G .172(rted to).15 F F3($OLDPWD)2.672 E F0 .171 (before the directory change is attempted.)2.421 F .171 -(If a non-empty directory)5.171 F .743(name from)144 684 R F3(CDP)3.243 -E -.855(AT)-.666 G(H).855 E F0 .743(is used, or if)2.993 F F13.244 E -F0 .744(is the \214rst ar)3.244 F .744 +(If a non-empty directory)5.171 F .743(name from)144 304.8 R F3(CDP) +3.243 E -.855(AT)-.666 G(H).855 E F0 .743(is used, or if)2.993 F F2 +3.244 E F0 .744(is the \214rst ar)3.244 F .744 (gument, and the directory change is successful,)-.18 F .594 -(the absolute pathname of the ne)144 696 R 3.094(ww)-.25 G .594 +(the absolute pathname of the ne)144 316.8 R 3.094(ww)-.25 G .594 (orking directory is written to the standard output.)-3.194 F .594 -(The return)5.594 F -.25(va)144 708 S(lue is true if the directory w).25 -E(as successfully changed; f)-.1 E(alse otherwise.)-.1 E(GNU Bash 4.2)72 -768 Q(2012 July 14)149.005 E(52)198.165 E 0 Cg EP -%%Page: 53 53 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(command)108 84 Q F0([)2.5 E F1(\255pVv)A F0 -(])A/F2 10/Times-Italic@0 SF(command)2.5 E F0([)2.5 E F2(ar)A(g)-.37 E -F0(...])2.5 E(Run)144 96 Q F2(command)2.956 E F0(with)3.527 E F2(ar) -3.087 E(gs)-.37 E F0 .257 +(The return)5.594 F -.25(va)144 328.8 S(lue is true if the directory w) +.25 E(as successfully changed; f)-.1 E(alse otherwise.)-.1 E F2(command) +108 345.6 Q F0([)2.5 E F2(\255pVv)A F0(])A F1(command)2.5 E F0([)2.5 E +F1(ar)A(g)-.37 E F0(...])2.5 E(Run)144 357.6 Q F1(command)2.956 E F0 +(with)3.527 E F1(ar)3.087 E(gs)-.37 E F0 .257 (suppressing the normal shell function lookup. Only b)3.027 F .257 -(uiltin commands or)-.2 F .502(commands found in the)144 108 R/F3 9 -/Times-Bold@0 SF -.666(PA)3.002 G(TH)-.189 E F0 .502(are e)2.752 F -.15 -(xe)-.15 G 3.002(cuted. If).15 F(the)3.002 E F13.002 E F0 .502 -(option is gi)3.002 F -.15(ve)-.25 G .501(n, the search for).15 F F2 -(command)3.201 E F0(is)3.771 E .399(performed using a def)144 120 R .399 -(ault v)-.1 F .399(alue for)-.25 F F3 -.666(PA)2.899 G(TH)-.189 E F0 .4 +(uiltin commands or)-.2 F .502(commands found in the)144 369.6 R F3 +-.666(PA)3.002 G(TH)-.189 E F0 .502(are e)2.752 F -.15(xe)-.15 G 3.002 +(cuted. If).15 F(the)3.002 E F23.002 E F0 .502(option is gi)3.002 +F -.15(ve)-.25 G .501(n, the search for).15 F F1(command)3.201 E F0(is) +3.771 E .399(performed using a def)144 381.6 R .399(ault v)-.1 F .399 +(alue for)-.25 F F3 -.666(PA)2.899 G(TH)-.189 E F0 .4 (that is guaranteed to \214nd all of the standard utilities.)2.649 F(If) -5.4 E .175(either the)144 132 R F12.675 E F0(or)2.675 E F1 -2.675 E F0 .175(option is supplied, a description of)2.675 F F2(command) -2.875 E F0 .174(is printed.)3.445 F(The)5.174 E F12.674 E F0 .174 -(option causes)2.674 F 3.317(as)144 144 S .817(ingle w)-3.317 F .817 +5.4 E .175(either the)144 393.6 R F22.675 E F0(or)2.675 E F2 +2.675 E F0 .175(option is supplied, a description of)2.675 F F1(command) +2.875 E F0 .174(is printed.)3.445 F(The)5.174 E F22.674 E F0 .174 +(option causes)2.674 F 3.317(as)144 405.6 S .817(ingle w)-3.317 F .817 (ord indicating the command or \214lename used to in)-.1 F -.2(vo)-.4 G --.1(ke).2 G F2(command)3.618 E F0 .818(to be displayed; the)4.088 F F1 -144 156 Q F0 .25(option produces a more v)2.75 F .25 -(erbose description.)-.15 F .249(If the)5.25 F F12.749 E F0(or) -2.749 E F12.749 E F0 .249(option is supplied, the e)2.749 F .249 -(xit status)-.15 F 1.004(is 0 if)144 168 R F2(command)3.704 E F0 -.1(wa) -4.274 G 3.504(sf).1 G 1.005(ound, and 1 if not.)-3.504 F 1.005 -(If neither option is supplied and an error occurred or)6.005 F F2 -(command)144.2 180 Q F0 1.599(cannot be found, the e)4.869 F 1.599 +-.1(ke).2 G F1(command)3.618 E F0 .818(to be displayed; the)4.088 F F2 +144 417.6 Q F0 .25(option produces a more v)2.75 F .25 +(erbose description.)-.15 F .249(If the)5.25 F F22.749 E F0(or) +2.749 E F22.749 E F0 .249(option is supplied, the e)2.749 F .249 +(xit status)-.15 F 1.004(is 0 if)144 429.6 R F1(command)3.704 E F0 -.1 +(wa)4.274 G 3.504(sf).1 G 1.005(ound, and 1 if not.)-3.504 F 1.005 +(If neither option is supplied and an error occurred or)6.005 F F1 +(command)144.2 441.6 Q F0 1.599(cannot be found, the e)4.869 F 1.599 (xit status is 127.)-.15 F 1.599(Otherwise, the e)6.599 F 1.598 -(xit status of the)-.15 F F1(command)4.098 E F0 -.2(bu)144 192 S -(iltin is the e).2 E(xit status of)-.15 E F2(command)2.5 E F0(.).77 E F1 -(compgen)108 208.8 Q F0([)2.5 E F2(option)A F0 2.5(][)C F2(wor)-2.5 E(d) --.37 E F0(])A .012(Generate possible completion matches for)144 220.8 R -F2(wor)2.513 E(d)-.37 E F0 .013(according to the)2.513 F F2(option)2.513 +(xit status of the)-.15 F F2(command)4.098 E F0 -.2(bu)144 453.6 S +(iltin is the e).2 E(xit status of)-.15 E F1(command)2.5 E F0(.).77 E F2 +(compgen)108 470.4 Q F0([)2.5 E F1(option)A F0 2.5(][)C F1(wor)-2.5 E(d) +-.37 E F0(])A .012(Generate possible completion matches for)144 482.4 R +F1(wor)2.513 E(d)-.37 E F0 .013(according to the)2.513 F F1(option)2.513 E F0 .013(s, which may be an)B 2.513(yo)-.15 G(ption)-2.513 E .982 -(accepted by the)144 232.8 R F1(complete)3.482 E F0 -.2(bu)3.481 G .981 -(iltin with the e).2 F .981(xception of)-.15 F F13.481 E F0(and) -3.481 E F13.481 E F0 3.481(,a)C .981(nd write the matches to the) --3.481 F 1.415(standard output.)144 244.8 R 1.415(When using the)6.415 F -F13.915 E F0(or)3.915 E F13.915 E F0 1.415(options, the v) +(accepted by the)144 494.4 R F2(complete)3.482 E F0 -.2(bu)3.481 G .981 +(iltin with the e).2 F .981(xception of)-.15 F F23.481 E F0(and) +3.481 E F23.481 E F0 3.481(,a)C .981(nd write the matches to the) +-3.481 F 1.415(standard output.)144 506.4 R 1.415(When using the)6.415 F +F23.915 E F0(or)3.915 E F23.915 E F0 1.415(options, the v) 3.915 F 1.415(arious shell v)-.25 F 1.415(ariables set by the pro-)-.25 -F(grammable completion f)144 256.8 Q(acilities, while a)-.1 E -.25(va) +F(grammable completion f)144 518.4 Q(acilities, while a)-.1 E -.25(va) -.2 G(ilable, will not ha).25 E .3 -.15(ve u)-.2 H(seful v).15 E(alues.) --.25 E .352(The matches will be generated in the same w)144 280.8 R .352 +-.25 E .352(The matches will be generated in the same w)144 542.4 R .352 (ay as if the programmable completion code had gen-)-.1 F .02(erated th\ em directly from a completion speci\214cation with the same \215ags.)144 -292.8 R(If)5.02 E F2(wor)2.52 E(d)-.37 E F0 .02(is speci\214ed, only) -2.52 F(those completions matching)144 304.8 Q F2(wor)2.5 E(d)-.37 E F0 -(will be displayed.)2.5 E(The return v)144 328.8 Q +554.4 R(If)5.02 E F1(wor)2.52 E(d)-.37 E F0 .02(is speci\214ed, only) +2.52 F(those completions matching)144 566.4 Q F1(wor)2.5 E(d)-.37 E F0 +(will be displayed.)2.5 E(The return v)144 590.4 Q (alue is true unless an in)-.25 E -.25(va)-.4 G -(lid option is supplied, or no matches were generated.).25 E F1 -(complete)108 345.6 Q F0([)3.729 E F1(\255abcdefgjksuv)A F0 3.729(][)C -F1-3.729 E F2(comp-option)3.729 E F0 3.729(][)C F1(\255DE)-3.729 E -F0 3.728(][)C F1-3.728 E F2(action)3.728 E F0 3.728(][)C F1 --3.728 E F2(globpat)3.728 E F0 3.728(][)C F1-3.728 E F2(wor)3.728 -E(dlist)-.37 E F0 3.728(][)C F1-3.728 E F2(func-)3.728 E(tion)108 -357.6 Q F0 2.5(][)C F1-2.5 E F2(command)2.5 E F0(])A([)144 369.6 Q -F1A F2(\214lterpat)2.5 E F0 2.5(][)C F1-2.5 E F2(pr)2.5 E -(e\214x)-.37 E F0 2.5(][)C F1-2.5 E F2(suf)2.5 E<8c78>-.18 E F0(]) -A F2(name)2.5 E F0([)2.5 E F2(name ...)A F0(])A F1(complete \255pr)108 -381.6 Q F0([)2.5 E F1(\255DE)A F0 2.5(][)C F2(name)-2.5 E F0(...])2.5 E -.634(Specify ho)144 393.6 R 3.134(wa)-.25 G -.18(rg)-3.134 G .634 -(uments to each).18 F F2(name)3.134 E F0 .634(should be completed.)3.134 -F .633(If the)5.634 F F13.133 E F0 .633 +(lid option is supplied, or no matches were generated.).25 E F2 +(complete)108 607.2 Q F0([)3.729 E F2(\255abcdefgjksuv)A F0 3.729(][)C +F2-3.729 E F1(comp-option)3.729 E F0 3.729(][)C F2(\255DE)-3.729 E +F0 3.728(][)C F2-3.728 E F1(action)3.728 E F0 3.728(][)C F2 +-3.728 E F1(globpat)3.728 E F0 3.728(][)C F2-3.728 E F1(wor)3.728 +E(dlist)-.37 E F0 3.728(][)C F2-3.728 E F1(func-)3.728 E(tion)108 +619.2 Q F0 2.5(][)C F2-2.5 E F1(command)2.5 E F0(])A([)144 631.2 Q +F2A F1(\214lterpat)2.5 E F0 2.5(][)C F2-2.5 E F1(pr)2.5 E +(e\214x)-.37 E F0 2.5(][)C F2-2.5 E F1(suf)2.5 E<8c78>-.18 E F0(]) +A F1(name)2.5 E F0([)2.5 E F1(name ...)A F0(])A F2(complete \255pr)108 +643.2 Q F0([)2.5 E F2(\255DE)A F0 2.5(][)C F1(name)-2.5 E F0(...])2.5 E +.634(Specify ho)144 655.2 R 3.134(wa)-.25 G -.18(rg)-3.134 G .634 +(uments to each).18 F F1(name)3.134 E F0 .634(should be completed.)3.134 +F .633(If the)5.634 F F23.133 E F0 .633 (option is supplied, or if no)3.133 F .139(options are supplied, e)144 -405.6 R .139(xisting completion speci\214cations are printed in a w)-.15 +667.2 R .139(xisting completion speci\214cations are printed in a w)-.15 F .14(ay that allo)-.1 F .14(ws them to be)-.25 F .31(reused as input.) -144 417.6 R(The)5.31 E F12.81 E F0 .31(option remo)2.81 F -.15(ve) --.15 G 2.81(sac).15 G .31(ompletion speci\214cation for each)-2.81 F F2 +144 679.2 R(The)5.31 E F22.81 E F0 .31(option remo)2.81 F -.15(ve) +-.15 G 2.81(sac).15 G .31(ompletion speci\214cation for each)-2.81 F F1 (name)2.81 E F0 2.81(,o)C 1.11 -.4(r, i)-2.81 H 2.81(fn).4 G(o)-2.81 E -F2(name)2.81 E F0(s)A 1.346 -(are supplied, all completion speci\214cations.)144 429.6 R(The)6.347 E -F13.847 E F0 1.347(option indicates that the remaining options) -3.847 F .5(and actions should apply to the `)144 441.6 R(`def)-.74 E +F1(name)2.81 E F0(s)A 1.346 +(are supplied, all completion speci\214cations.)144 691.2 R(The)6.347 E +F23.847 E F0 1.347(option indicates that the remaining options) +3.847 F .5(and actions should apply to the `)144 703.2 R(`def)-.74 E (ault')-.1 E 3('c)-.74 G .5 (ommand completion; that is, completion attempted on)-3 F 3.455(ac)144 -453.6 S .955(ommand for which no completion has pre)-3.455 F .955 -(viously been de\214ned.)-.25 F(The)5.955 E F13.455 E F0 .955 -(option indicates that)3.455 F .065 -(the remaining options and actions should apply to `)144 465.6 R -(`empty')-.74 E 2.564('c)-.74 G .064 -(ommand completion; that is, comple-)-2.564 F -(tion attempted on a blank line.)144 477.6 Q 1.437 +715.2 S .955(ommand for which no completion has pre)-3.455 F .955 +(viously been de\214ned.)-.25 F(The)5.955 E F23.455 E F0 .955 +(option indicates that)3.455 F 3.009 +(the remaining options and actions should apply to `)144 727.2 R +(`empty')-.74 E 5.509('c)-.74 G 3.009(ommand completion; that is,)-5.509 +F(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(53)185.545 E 0 Cg EP +%%Page: 54 54 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(completion attempted on a blank line.)144 84 Q 1.437 (The process of applying these completion speci\214cations when w)144 -501.6 R 1.438(ord completion is attempted is)-.1 F(described abo)144 -513.6 Q .3 -.15(ve u)-.15 H(nder).15 E F1(Pr)2.5 E +108 R 1.438(ord completion is attempted is)-.1 F(described abo)144 120 Q +.3 -.15(ve u)-.15 H(nder).15 E/F1 10/Times-Bold@0 SF(Pr)2.5 E (ogrammable Completion)-.18 E F0(.)A .556 -(Other options, if speci\214ed, ha)144 537.6 R .856 -.15(ve t)-.2 H .555 +(Other options, if speci\214ed, ha)144 144 R .856 -.15(ve t)-.2 H .555 (he follo).15 F .555(wing meanings.)-.25 F .555(The ar)5.555 F .555 (guments to the)-.18 F F13.055 E F0(,)A F13.055 E F0 3.055 (,a)C(nd)-3.055 E F13.055 E F0 .722(options \(and, if necessary) -144 549.6 R 3.222(,t)-.65 G(he)-3.222 E F13.222 E F0(and)3.222 E -F13.222 E F0 .723 -(options\) should be quoted to protect them from e)3.222 F(xpan-)-.15 E -(sion before the)144 561.6 Q F1(complete)2.5 E F0 -.2(bu)2.5 G -(iltin is in).2 E -.2(vo)-.4 G -.1(ke).2 G(d.).1 E F1144 573.6 Q -F2(comp-option)2.5 E F0(The)184 585.6 Q F2(comp-option)2.791 E F0 .291 -(controls se)2.791 F -.15(ve)-.25 G .291(ral aspects of the compspec') -.15 F 2.791(sb)-.55 G(eha)-2.791 E .291(vior be)-.2 F .291 -(yond the simple)-.15 F(generation of completions.)184 597.6 Q F2 -(comp-option)5 E F0(may be one of:)2.5 E F1(bashdefault)184 609.6 Q F0 -.281(Perform the rest of the def)224 621.6 R(ault)-.1 E F1(bash)2.781 E -F0 .281(completions if the compspec generates no)2.781 F(matches.)224 -633.6 Q F1(default)184 645.6 Q F0 2.876(Use readline')10 F 5.376(sd)-.55 -G(ef)-5.376 E 2.875 +144 156 R 3.222(,t)-.65 G(he)-3.222 E F13.222 E F0(and)3.222 E F1 +3.222 E F0 .723(options\) should be quoted to protect them from e) +3.222 F(xpan-)-.15 E(sion before the)144 168 Q F1(complete)2.5 E F0 -.2 +(bu)2.5 G(iltin is in).2 E -.2(vo)-.4 G -.1(ke).2 G(d.).1 E F1144 +180 Q/F2 10/Times-Italic@0 SF(comp-option)2.5 E F0(The)184 192 Q F2 +(comp-option)2.791 E F0 .291(controls se)2.791 F -.15(ve)-.25 G .291 +(ral aspects of the compspec').15 F 2.791(sb)-.55 G(eha)-2.791 E .291 +(vior be)-.2 F .291(yond the simple)-.15 F(generation of completions.) +184 204 Q F2(comp-option)5 E F0(may be one of:)2.5 E F1(bashdefault)184 +216 Q F0 .281(Perform the rest of the def)224 228 R(ault)-.1 E F1(bash) +2.781 E F0 .281(completions if the compspec generates no)2.781 F +(matches.)224 240 Q F1(default)184 252 Q F0 2.876(Use readline')10 F +5.376(sd)-.55 G(ef)-5.376 E 2.875 (ault \214lename completion if the compspec generates no)-.1 F(matches.) -224 657.6 Q F1(dir)184 669.6 Q(names)-.15 E F0(Perform directory name c\ -ompletion if the compspec generates no matches.)224 681.6 Q F1 -(\214lenames)184 693.6 Q F0 -.7(Te)224 705.6 S .137(ll readline that th\ -e compspec generates \214lenames, so it can perform an).7 F 2.637<798c> --.15 G(le-)-2.637 E .134(name\255speci\214c processing \(lik)224 717.6 R -2.634(ea)-.1 G .134(dding a slash to directory names, quoting spe-) --2.634 F .45(cial characters, or suppressing trailing spaces\).)224 -729.6 R .45(Intended to be used with shell)5.45 F(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(53)198.165 E 0 Cg EP -%%Page: 54 54 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E(functions.)224 84 Q/F1 10/Times-Bold@0 SF(noquote)184 96 Q F0 -.7 -(Te)5.55 G .814(ll readline not to quote the completed w).7 F .814 -(ords if the)-.1 F 3.314(ya)-.15 G .814(re \214lenames \(quoting)-3.314 -F(\214lenames is the def)224 108 Q(ault\).)-.1 E F1(nospace)184 120 Q F0 +224 264 Q F1(dir)184 276 Q(names)-.15 E F0(Perform directory name compl\ +etion if the compspec generates no matches.)224 288 Q F1(\214lenames)184 +300 Q F0 -.7(Te)224 312 S .137(ll readline that the compspec generates \ +\214lenames, so it can perform an).7 F 2.637<798c>-.15 G(le-)-2.637 E +.134(name\255speci\214c processing \(lik)224 324 R 2.634(ea)-.1 G .134 +(dding a slash to directory names, quoting spe-)-2.634 F .45 +(cial characters, or suppressing trailing spaces\).)224 336 R .45 +(Intended to be used with shell)5.45 F(functions.)224 348 Q F1(noquote) +184 360 Q F0 -.7(Te)5.55 G .814 +(ll readline not to quote the completed w).7 F .814(ords if the)-.1 F +3.314(ya)-.15 G .814(re \214lenames \(quoting)-3.314 F +(\214lenames is the def)224 372 Q(ault\).)-.1 E F1(nospace)184 384 Q F0 -.7(Te)6.11 G .22(ll readline not to append a space \(the def).7 F .22 (ault\) to w)-.1 F .22(ords completed at the end)-.1 F(of the line.)224 -132 Q F1(plusdirs)184 144 Q F0 1.985(After an)5.54 F 4.485(ym)-.15 G +396 Q F1(plusdirs)184 408 Q F0 1.985(After an)5.54 F 4.485(ym)-.15 G 1.985(atches de\214ned by the compspec are generated, directory name) --4.485 F .583(completion is attempted and an)224 156 R 3.084(ym)-.15 G +-4.485 F .583(completion is attempted and an)224 420 R 3.084(ym)-.15 G .584(atches are added to the results of the other)-3.084 F(actions.)224 -168 Q F1144 180 Q/F2 10/Times-Italic@0 SF(action)2.5 E F0(The)184 -192 Q F2(action)2.5 E F0(may be one of the follo)2.5 E +432 Q F1144 444 Q F2(action)2.5 E F0(The)184 456 Q F2(action)2.5 E +F0(may be one of the follo)2.5 E (wing to generate a list of possible completions:)-.25 E F1(alias)184 -204 Q F0(Alias names.)20.55 E(May also be speci\214ed as)5 E F12.5 -E F0(.)A F1(arrayv)184 216 Q(ar)-.1 E F0(Array v)224 228 Q -(ariable names.)-.25 E F1 4.7(binding Readline)184 240 R F0 -.1(ke)2.5 G -2.5(yb)-.05 G(inding names.)-2.5 E F1 -.2(bu)184 252 S(iltin).2 E F0 +468 Q F0(Alias names.)20.55 E(May also be speci\214ed as)5 E F12.5 +E F0(.)A F1(arrayv)184 480 Q(ar)-.1 E F0(Array v)224 492 Q +(ariable names.)-.25 E F1 4.7(binding Readline)184 504 R F0 -.1(ke)2.5 G +2.5(yb)-.05 G(inding names.)-2.5 E F1 -.2(bu)184 516 S(iltin).2 E F0 (Names of shell b)11.85 E(uiltin commands.)-.2 E -(May also be speci\214ed as)5 E F12.5 E F0(.)A F1(command)184 264 -Q F0(Command names.)224 276 Q(May also be speci\214ed as)5 E F12.5 -E F0(.)A F1(dir)184 288 Q(ectory)-.18 E F0(Directory names.)224 300 Q -(May also be speci\214ed as)5 E F12.5 E F0(.)A F1(disabled)184 312 -Q F0(Names of disabled shell b)224 324 Q(uiltins.)-.2 E F1(enabled)184 -336 Q F0(Names of enabled shell b)6.66 E(uiltins.)-.2 E F1(export)184 -348 Q F0(Names of e)12.23 E(xported shell v)-.15 E 2.5(ariables. May) +(May also be speci\214ed as)5 E F12.5 E F0(.)A F1(command)184 528 +Q F0(Command names.)224 540 Q(May also be speci\214ed as)5 E F12.5 +E F0(.)A F1(dir)184 552 Q(ectory)-.18 E F0(Directory names.)224 564 Q +(May also be speci\214ed as)5 E F12.5 E F0(.)A F1(disabled)184 576 +Q F0(Names of disabled shell b)224 588 Q(uiltins.)-.2 E F1(enabled)184 +600 Q F0(Names of enabled shell b)6.66 E(uiltins.)-.2 E F1(export)184 +612 Q F0(Names of e)12.23 E(xported shell v)-.15 E 2.5(ariables. May) -.25 F(also be speci\214ed as)2.5 E F12.5 E F0(.)A F1(\214le)184 -360 Q F0(File names.)27.22 E(May also be speci\214ed as)5 E F12.5 -E F0(.)A F1(function)184 372 Q F0(Names of shell functions.)224 384 Q F1 -(gr)184 396 Q(oup)-.18 E F0(Group names.)14.62 E +624 Q F0(File names.)27.22 E(May also be speci\214ed as)5 E F12.5 +E F0(.)A F1(function)184 636 Q F0(Names of shell functions.)224 648 Q F1 +(gr)184 660 Q(oup)-.18 E F0(Group names.)14.62 E (May also be speci\214ed as)5 E F12.5 E F0(.)A F1(helptopic)184 -408 Q F0(Help topics as accepted by the)224 420 Q F1(help)2.5 E F0 -.2 -(bu)2.5 G(iltin.).2 E F1(hostname)184 432 Q F0(Hostnames, as tak)224 444 +672 Q F0(Help topics as accepted by the)224 684 Q F1(help)2.5 E F0 -.2 +(bu)2.5 G(iltin.).2 E F1(hostname)184 696 Q F0(Hostnames, as tak)224 708 Q(en from the \214le speci\214ed by the)-.1 E/F3 9/Times-Bold@0 SF -(HOSTFILE)2.5 E F0(shell v)2.25 E(ariable.)-.25 E F1(job)184 456 Q F0 +(HOSTFILE)2.5 E F0(shell v)2.25 E(ariable.)-.25 E(GNU Bash 4.2)72 768 Q +(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(54)185.545 E 0 Cg EP +%%Page: 55 55 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(job)184 84 Q F0 (Job names, if job control is acti)26.11 E -.15(ve)-.25 G 5(.M).15 G -(ay also be speci\214ed as)-5 E F12.5 E F0(.)A F1 -.1(ke)184 468 S -(yw).1 E(ord)-.1 E F0(Shell reserv)224 480 Q(ed w)-.15 E 2.5(ords. May) +(ay also be speci\214ed as)-5 E F12.5 E F0(.)A F1 -.1(ke)184 96 S +(yw).1 E(ord)-.1 E F0(Shell reserv)224 108 Q(ed w)-.15 E 2.5(ords. May) -.1 F(also be speci\214ed as)2.5 E F12.5 E F0(.)A F1(running)184 -492 Q F0(Names of running jobs, if job control is acti)5.54 E -.15(ve) --.25 G(.).15 E F1(ser)184 504 Q(vice)-.1 E F0(Service names.)10.67 E -(May also be speci\214ed as)5 E F12.5 E F0(.)A F1(setopt)184 516 Q +120 Q F0(Names of running jobs, if job control is acti)5.54 E -.15(ve) +-.25 G(.).15 E F1(ser)184 132 Q(vice)-.1 E F0(Service names.)10.67 E +(May also be speci\214ed as)5 E F12.5 E F0(.)A F1(setopt)184 144 Q F0 -1.11(Va)14.45 G(lid ar)1.11 E(guments for the)-.18 E F12.5 E F0(option to the)2.5 E F1(set)2.5 E F0 -.2(bu)2.5 G(iltin.).2 E F1 -(shopt)184 528 Q F0(Shell option names as accepted by the)16.66 E F1 -(shopt)2.5 E F0 -.2(bu)2.5 G(iltin.).2 E F1(signal)184 540 Q F0 -(Signal names.)14.99 E F1(stopped)184 552 Q F0 +(shopt)184 156 Q F0(Shell option names as accepted by the)16.66 E F1 +(shopt)2.5 E F0 -.2(bu)2.5 G(iltin.).2 E F1(signal)184 168 Q F0 +(Signal names.)14.99 E F1(stopped)184 180 Q F0 (Names of stopped jobs, if job control is acti)6.66 E -.15(ve)-.25 G(.) -.15 E F1(user)184 564 Q F0(User names.)21.67 E -(May also be speci\214ed as)5 E F12.5 E F0(.)A F1 -.1(va)184 576 S +.15 E F1(user)184 192 Q F0(User names.)21.67 E +(May also be speci\214ed as)5 E F12.5 E F0(.)A F1 -.1(va)184 204 S (riable).1 E F0(Names of all shell v)5.1 E 2.5(ariables. May)-.25 F -(also be speci\214ed as)2.5 E F12.5 E F0(.)A F1144 588 Q F2 -(command)2.5 E(command)184 600 Q F0 1.056(is e)3.556 F -.15(xe)-.15 G -1.056(cuted in a subshell en).15 F 1.056 +(also be speci\214ed as)2.5 E F12.5 E F0(.)A F1144 216 Q/F2 +10/Times-Italic@0 SF(command)2.5 E(command)184 228 Q F0 1.056(is e)3.556 +F -.15(xe)-.15 G 1.056(cuted in a subshell en).15 F 1.056 (vironment, and its output is used as the possible)-.4 F(completions.) -184 612 Q F1144 624 Q F2(function)2.5 E F0 .113 -(The shell function)184 636 R F2(function)2.614 E F0 .114(is e)2.614 F +184 240 Q F1144 252 Q F2(function)2.5 E F0 .113 +(The shell function)184 264 R F2(function)2.614 E F0 .114(is e)2.614 F -.15(xe)-.15 G .114(cuted in the current shell en).15 F 2.614 -(vironment. When)-.4 F .114(the func-)2.614 F .817(tion is e)184 648 R +(vironment. When)-.4 F .114(the func-)2.614 F .817(tion is e)184 276 R -.15(xe)-.15 G .817(cuted, the \214rst ar).15 F .817(gument \()-.18 F F1 ($1)A F0 3.316(\)i)C 3.316(st)-3.316 G .816 (he name of the command whose ar)-3.316 F(guments)-.18 E 1.407 -(are being completed, the second ar)184 660 R 1.407(gument \()-.18 F F1 +(are being completed, the second ar)184 288 R 1.407(gument \()-.18 F F1 ($2)A F0 3.907(\)i)C 3.907(st)-3.907 G 1.407(he w)-3.907 F 1.407 -(ord being completed, and the)-.1 F .104(third ar)184 672 R .104 +(ord being completed, and the)-.1 F .104(third ar)184 300 R .104 (gument \()-.18 F F1($3)A F0 2.604(\)i)C 2.604(st)-2.604 G .104(he w) -2.604 F .104(ord preceding the w)-.1 F .103 -(ord being completed on the current com-)-.1 F .101(mand line.)184 684 R +(ord being completed on the current com-)-.1 F .101(mand line.)184 312 R .101(When it \214nishes, the possible completions are retrie)5.101 F -.15(ve)-.25 G 2.602(df).15 G .102(rom the v)-2.602 F .102(alue of the) --.25 F F3(COMPREPL)184 696 Q(Y)-.828 E F0(array v)2.25 E(ariable.)-.25 E -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(54)198.165 E 0 Cg EP -%%Page: 55 55 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF144 84 Q/F2 10/Times-Italic@0 SF -(globpat)2.5 E F0 1.008(The pathname e)184 96 R 1.008(xpansion pattern) --.15 F F2(globpat)3.507 E F0 1.007(is e)3.507 F 1.007 -(xpanded to generate the possible comple-)-.15 F(tions.)184 108 Q F1 -144 120 Q F2(pr)2.5 E(e\214x)-.37 E(pr)184 132 Q(e\214x)-.37 E F0 -.534(is added at the be)3.034 F .534 +-.25 F/F3 9/Times-Bold@0 SF(COMPREPL)184 324 Q(Y)-.828 E F0(array v)2.25 +E(ariable.)-.25 E F1144 336 Q F2(globpat)2.5 E F0 1.008 +(The pathname e)184 348 R 1.008(xpansion pattern)-.15 F F2(globpat)3.507 +E F0 1.007(is e)3.507 F 1.007(xpanded to generate the possible comple-) +-.15 F(tions.)184 360 Q F1144 372 Q F2(pr)2.5 E(e\214x)-.37 E(pr) +184 384 Q(e\214x)-.37 E F0 .534(is added at the be)3.034 F .534 (ginning of each possible completion after all other options ha)-.15 F --.15(ve)-.2 G(been applied.)184 144 Q F1144 156 Q F2(suf)2.5 E +-.15(ve)-.2 G(been applied.)184 396 Q F1144 408 Q F2(suf)2.5 E 2.81(\214x suf)-.18 F<8c78>-.18 E F0 (is appended to each possible completion after all other options ha)2.5 -E .3 -.15(ve b)-.2 H(een applied.).15 E F1144 168 Q F2(wor)2.5 E -(dlist)-.37 E F0(The)184 180 Q F2(wor)3.64 E(dlist)-.37 E F0 1.14 -(is split using the characters in the)3.64 F/F3 9/Times-Bold@0 SF(IFS) -3.64 E F0 1.139(special v)3.39 F 1.139(ariable as delimiters, and)-.25 F -2.007(each resultant w)184 192 R 2.007(ord is e)-.1 F 4.507 -(xpanded. The)-.15 F 2.008(possible completions are the members of the) -4.507 F(resultant list which match the w)184 204 Q(ord being completed.) --.1 E F1144 216 Q F2(\214lterpat)2.5 E(\214lterpat)184 228 Q F0 -.456(is a pattern as used for pathname e)2.956 F 2.956(xpansion. It)-.15 -F .455(is applied to the list of possible)2.956 F 1.596 -(completions generated by the preceding options and ar)184 240 R 1.596 -(guments, and each completion)-.18 F(matching)184 252 Q F2(\214lterpat) +E .3 -.15(ve b)-.2 H(een applied.).15 E F1144 420 Q F2(wor)2.5 E +(dlist)-.37 E F0(The)184 432 Q F2(wor)3.64 E(dlist)-.37 E F0 1.14 +(is split using the characters in the)3.64 F F3(IFS)3.64 E F0 1.139 +(special v)3.39 F 1.139(ariable as delimiters, and)-.25 F 2.007 +(each resultant w)184 444 R 2.007(ord is e)-.1 F 4.507(xpanded. The)-.15 +F 2.008(possible completions are the members of the)4.507 F +(resultant list which match the w)184 456 Q(ord being completed.)-.1 E +F1144 468 Q F2(\214lterpat)2.5 E(\214lterpat)184 480 Q F0 .456 +(is a pattern as used for pathname e)2.956 F 2.956(xpansion. It)-.15 F +.455(is applied to the list of possible)2.956 F 1.596 +(completions generated by the preceding options and ar)184 492 R 1.596 +(guments, and each completion)-.18 F(matching)184 504 Q F2(\214lterpat) 3.205 E F0 .705(is remo)3.205 F -.15(ve)-.15 G 3.205(df).15 G .704 (rom the list.)-3.205 F 3.204(Al)5.704 G(eading)-3.204 E F1(!)3.204 E F0 (in)3.204 E F2(\214lterpat)3.204 E F0(ne)3.204 E -.05(ga)-.15 G .704 -(tes the pattern;).05 F(in this case, an)184 264 Q 2.5(yc)-.15 G +(tes the pattern;).05 F(in this case, an)184 516 Q 2.5(yc)-.15 G (ompletion not matching)-2.5 E F2(\214lterpat)2.5 E F0(is remo)2.5 E --.15(ve)-.15 G(d.).15 E .466(The return v)144 280.8 R .466 +-.15(ve)-.15 G(d.).15 E .466(The return v)144 532.8 R .466 (alue is true unless an in)-.25 F -.25(va)-.4 G .466 (lid option is supplied, an option other than).25 F F12.967 E F0 (or)2.967 E F12.967 E F0 .467(is sup-)2.967 F 1.362 -(plied without a)144 292.8 R F2(name)3.862 E F0(ar)3.862 E 1.361 +(plied without a)144 544.8 R F2(name)3.862 E F0(ar)3.862 E 1.361 (gument, an attempt is made to remo)-.18 F 1.661 -.15(ve a c)-.15 H -1.361(ompletion speci\214cation for a).15 F F2(name)144 304.8 Q F0 +1.361(ompletion speci\214cation for a).15 F F2(name)144 556.8 Q F0 (for which no speci\214cation e)2.5 E (xists, or an error occurs adding a completion speci\214cation.)-.15 E -F1(compopt)108 321.6 Q F0([)2.5 E F1A F2(option)2.5 E F0 2.5(][)C +F1(compopt)108 573.6 Q F0([)2.5 E F1A F2(option)2.5 E F0 2.5(][)C F1(\255DE)-2.5 E F0 2.5(][)C F1(+o)-2.5 E F2(option)2.5 E F0 2.5(][)C F2 -(name)-2.5 E F0(])A .447(Modify completion options for each)144 333.6 R +(name)-2.5 E F0(])A .447(Modify completion options for each)144 585.6 R F2(name)2.947 E F0 .447(according to the)2.947 F F2(option)2.947 E F0 .447(s, or for the currently-e)B -.15(xe)-.15 G(cuting).15 E .726 -(completion if no)144 345.6 R F2(name)3.226 E F0 3.226(sa)C .726 +(completion if no)144 597.6 R F2(name)3.226 E F0 3.226(sa)C .726 (re supplied.)-3.226 F .725(If no)5.725 F F2(option)3.225 E F0 3.225(sa) C .725(re gi)-3.225 F -.15(ve)-.25 G .725 -(n, display the completion options for).15 F(each)144 357.6 Q F2(name) +(n, display the completion options for).15 F(each)144 609.6 Q F2(name) 3.223 E F0 .723(or the current completion.)3.223 F .724(The possible v) 5.724 F .724(alues of)-.25 F F2(option)3.224 E F0 .724(are those v)3.224 -F .724(alid for the)-.25 F F1(com-)3.224 E(plete)144 369.6 Q F0 -.2(bu) +F .724(alid for the)-.25 F F1(com-)3.224 E(plete)144 621.6 Q F0 -.2(bu) 2.798 G .298(iltin described abo).2 F -.15(ve)-.15 G 5.297(.T).15 G(he) -5.297 E F12.797 E F0 .297 (option indicates that the remaining options should apply to)2.797 F -1.227(the `)144 381.6 R(`def)-.74 E(ault')-.1 E 3.727('c)-.74 G 1.228(o\ +1.227(the `)144 633.6 R(`def)-.74 E(ault')-.1 E 3.727('c)-.74 G 1.228(o\ mmand completion; that is, completion attempted on a command for which \ -no)-3.727 F 2.178(completion has pre)144 393.6 R 2.178 +no)-3.727 F 2.178(completion has pre)144 645.6 R 2.178 (viously been de\214ned.)-.25 F(The)7.178 E F14.678 E F0 2.177 (option indicates that the remaining options)4.677 F(should apply to `) -144 405.6 Q(`empty')-.74 E 2.5('c)-.74 G +144 657.6 Q(`empty')-.74 E 2.5('c)-.74 G (ommand completion; that is, completion attempted on a blank line.)-2.5 -E 1.387(The return v)144 429.6 R 1.387(alue is true unless an in)-.25 F +E 1.387(The return v)144 681.6 R 1.387(alue is true unless an in)-.25 F -.25(va)-.4 G 1.388 (lid option is supplied, an attempt is made to modify the).25 F -(options for a)144 441.6 Q F2(name)2.5 E F0 +(options for a)144 693.6 Q F2(name)2.5 E F0 (for which no completion speci\214cation e)2.5 E -(xists, or an output error occurs.)-.15 E F1(continue)108 458.4 Q F0([) -2.5 E F2(n)A F0(])A 1.754(Resume the ne)144 470.4 R 1.754 +(xists, or an output error occurs.)-.15 E(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(55)185.545 E 0 Cg EP +%%Page: 56 56 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(continue)108 84 Q F0([)2.5 E/F2 10 +/Times-Italic@0 SF(n)A F0(])A 1.754(Resume the ne)144 96 R 1.754 (xt iteration of the enclosing)-.15 F F1 -.25(fo)4.254 G(r).25 E F0(,)A F1(while)4.254 E F0(,)A F1(until)4.254 E F0 4.254(,o)C(r)-4.254 E F1 (select)4.254 E F0 4.253(loop. If)4.254 F F2(n)4.613 E F0 1.753 -(is speci\214ed,)4.493 F 1.208(resume at the)144 482.4 R F2(n)3.709 E F0 -1.209(th enclosing loop.)B F2(n)6.569 E F0 1.209(must be)3.949 F/F4 10 +(is speci\214ed,)4.493 F 1.208(resume at the)144 108 R F2(n)3.709 E F0 +1.209(th enclosing loop.)B F2(n)6.569 E F0 1.209(must be)3.949 F/F3 10 /Symbol SF3.709 E F0 3.709(1. If)3.709 F F2(n)4.069 E F0 1.209 (is greater than the number of enclosing)3.949 F .514 -(loops, the last enclosing loop \(the `)144 494.4 R(`top-le)-.74 E -.15 +(loops, the last enclosing loop \(the `)144 120 R(`top-le)-.74 E -.15 (ve)-.25 G(l').15 E 3.014('l)-.74 G .514(oop\) is resumed.)-3.014 F .513 (The return v)5.513 F .513(alue is 0 unless)-.25 F F2(n)3.013 E F0(is) -3.013 E(not greater than or equal to 1.)144 506.4 Q F1(declar)108 523.2 -Q(e)-.18 E F0([)2.5 E F1(\255aAfFgilnrtux)A F0 2.5(][)C F1-2.5 E -F0 2.5(][)C F2(name)-2.5 E F0([=)A F2(value)A F0 2.5(].)C(..])-2.5 E F1 -(typeset)108 535.2 Q F0([)2.5 E F1(\255aAfFgilnrtux)A F0 2.5(][)C F1 +3.013 E(not greater than or equal to 1.)144 132 Q F1(declar)108 148.8 Q +(e)-.18 E F0([)2.5 E F1(\255aAfFgilnrtux)A F0 2.5(][)C F1-2.5 E F0 +2.5(][)C F2(name)-2.5 E F0([=)A F2(value)A F0 2.5(].)C(..])-2.5 E F1 +(typeset)108 160.8 Q F0([)2.5 E F1(\255aAfFgilnrtux)A F0 2.5(][)C F1 -2.5 E F0 2.5(][)C F2(name)-2.5 E F0([=)A F2(value)A F0 2.5(].)C -(..])-2.5 E 1.264(Declare v)144 547.2 R 1.264(ariables and/or gi)-.25 F +(..])-2.5 E 1.264(Declare v)144 172.8 R 1.264(ariables and/or gi)-.25 F 1.564 -.15(ve t)-.25 H 1.264(hem attrib).15 F 3.765(utes. If)-.2 F(no) 3.765 E F2(name)3.765 E F0 3.765(sa)C 1.265(re gi)-3.765 F -.15(ve)-.25 G 3.765(nt).15 G 1.265(hen display the v)-3.765 F 1.265(alues of)-.25 F --.25(va)144 559.2 S 3.483(riables. The).25 F F13.483 E F0 .983 +-.25(va)144 184.8 S 3.483(riables. The).25 F F13.483 E F0 .983 (option will display the attrib)3.483 F .983(utes and v)-.2 F .982 (alues of each)-.25 F F2(name)3.482 E F0 5.982(.W).18 G(hen)-5.982 E F1 -3.482 E F0 .982(is used)3.482 F(with)144 571.2 Q F2(name)3.579 E +3.482 E F0 .982(is used)3.482 F(with)144 196.8 Q F2(name)3.579 E F0(ar)3.579 E 1.079(guments, additional options are ignored.)-.18 F (When)6.079 E F13.579 E F0 1.079(is supplied without)3.579 F F2 (name)3.58 E F0(ar)3.58 E(gu-)-.18 E .151 -(ments, it will display the attrib)144 583.2 R .151(utes and v)-.2 F +(ments, it will display the attrib)144 208.8 R .151(utes and v)-.2 F .151(alues of all v)-.25 F .15(ariables ha)-.25 F .15(ving the attrib) -.2 F .15(utes speci\214ed by the)-.2 F .046(additional options.)144 -595.2 R .046(If no other options are supplied with)5.046 F F12.547 +220.8 R .046(If no other options are supplied with)5.046 F F12.547 E F0(,)A F1(declar)2.547 E(e)-.18 E F0 .047(will display the attrib) -2.547 F .047(utes and)-.2 F -.25(va)144 607.2 S 1.363 +2.547 F .047(utes and)-.2 F -.25(va)144 232.8 S 1.363 (lues of all shell v).25 F 3.863(ariables. The)-.25 F F13.863 E F0 1.362(option will restrict the display to shell functions.)3.863 F(The) 6.362 E F13.862 E F0 2.422(option inhibits the display of functio\ -n de\214nitions; only the function name and attrib)144 619.2 R 2.423 -(utes are)-.2 F 2.664(printed. If)144 631.2 R(the)2.664 E F1(extdeb) +n de\214nitions; only the function name and attrib)144 244.8 R 2.423 +(utes are)-.2 F 2.664(printed. If)144 256.8 R(the)2.664 E F1(extdeb) 2.664 E(ug)-.2 E F0 .164(shell option is enabled using)2.664 F F1(shopt) 2.664 E F0 2.664(,t)C .163(he source \214le name and line number)-2.664 -F 1.288(where the function is de\214ned are displayed as well.)144 643.2 +F 1.288(where the function is de\214ned are displayed as well.)144 268.8 R(The)6.288 E F13.788 E F0 1.288(option implies)3.788 F F1 3.788 E F0 6.288(.T)C(he)-6.288 E F13.789 E F0(option)3.789 E .491 -(forces v)144 655.2 R .491 +(forces v)144 280.8 R .491 (ariables to be created or modi\214ed at the global scope, e)-.25 F -.15 (ve)-.25 G 2.99(nw).15 G(hen)-2.99 E F1(declar)2.99 E(e)-.18 E F0 .49 (is e)2.99 F -.15(xe)-.15 G .49(cuted in a).15 F .124(shell function.) -144 667.2 R .124(It is ignored in all other cases.)5.124 F .125 +144 292.8 R .124(It is ignored in all other cases.)5.124 F .125 (The follo)5.125 F .125(wing options can be used to restrict output)-.25 -F(to v)144 679.2 Q(ariables with the speci\214ed attrib)-.25 E +F(to v)144 304.8 Q(ariables with the speci\214ed attrib)-.25 E (ute or to gi)-.2 E .3 -.15(ve v)-.25 H(ariables attrib)-.1 E(utes:)-.2 -E F1144 691.2 Q F0(Each)25.3 E F2(name)2.5 E F0(is an inde)2.5 E +E F1144 316.8 Q F0(Each)25.3 E F2(name)2.5 E F0(is an inde)2.5 E -.15(xe)-.15 G 2.5(da).15 G(rray v)-2.5 E(ariable \(see)-.25 E F1 -(Arrays)2.5 E F0(abo)2.5 E -.15(ve)-.15 G(\).).15 E F1144 703.2 Q +(Arrays)2.5 E F0(abo)2.5 E -.15(ve)-.15 G(\).).15 E F1144 328.8 Q F0(Each)23.08 E F2(name)2.5 E F0(is an associati)2.5 E .3 -.15(ve a)-.25 H(rray v).15 E(ariable \(see)-.25 E F1(Arrays)2.5 E F0(abo)2.5 E -.15 -(ve)-.15 G(\).).15 E F1144 715.2 Q F0(Use function names only) -26.97 E(.)-.65 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(55)198.165 -E 0 Cg EP -%%Page: 56 56 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF144 84 Q F0 .558(The v)27.52 F .558 +(ve)-.15 G(\).).15 E F1144 340.8 Q F0(Use function names only) +26.97 E(.)-.65 E F1144 352.8 Q F0 .558(The v)27.52 F .558 (ariable is treated as an inte)-.25 F .558(ger; arithmetic e)-.15 F -.25 -(va)-.25 G .558(luation \(see).25 F/F2 9/Times-Bold@0 SF .557 -(ARITHMETIC EV)3.058 F(ALU)-1.215 E(A-)-.54 E(TION)180 96 Q F0(abo)2.25 -E -.15(ve)-.15 G 2.5(\)i).15 G 2.5(sp)-2.5 G(erformed when the v)-2.5 E -(ariable is assigned a v)-.25 E(alue.)-.25 E F1144 108 Q F0 .909 -(When the v)27.52 F .909(ariable is assigned a v)-.25 F .909 +(va)-.25 G .558(luation \(see).25 F/F4 9/Times-Bold@0 SF .557 +(ARITHMETIC EV)3.058 F(ALU)-1.215 E(A-)-.54 E(TION)180 364.8 Q F0(abo) +2.25 E -.15(ve)-.15 G 2.5(\)i).15 G 2.5(sp)-2.5 G(erformed when the v) +-2.5 E(ariable is assigned a v)-.25 E(alue.)-.25 E F1144 376.8 Q +F0 .909(When the v)27.52 F .909(ariable is assigned a v)-.25 F .909 (alue, all upper)-.25 F .909(-case characters are con)-.2 F -.15(ve)-.4 -G .91(rted to lo).15 F(wer)-.25 E(-)-.2 E 2.5(case. The)180 120 R(upper) -2.5 E(-case attrib)-.2 E(ute is disabled.)-.2 E F1144 132 Q F0(Gi) -24.74 E 1.62 -.15(ve e)-.25 H(ach).15 E/F3 10/Times-Italic@0 SF(name) -3.82 E F0(the)3.82 E F3(namer)3.819 E(ef)-.37 E F0(attrib)3.819 E 1.319 +G .91(rted to lo).15 F(wer)-.25 E(-)-.2 E 2.5(case. The)180 388.8 R +(upper)2.5 E(-case attrib)-.2 E(ute is disabled.)-.2 E F1144 400.8 +Q F0(Gi)24.74 E 1.62 -.15(ve e)-.25 H(ach).15 E F2(name)3.82 E F0(the) +3.82 E F2(namer)3.819 E(ef)-.37 E F0(attrib)3.819 E 1.319 (ute, making it a name reference to another v)-.2 F(ariable.)-.25 E -1.032(That other v)180 144 R 1.033(ariable is de\214ned by the v)-.25 F -1.033(alue of)-.25 F F3(name)3.533 E F0 6.033(.A)C 1.033 -(ll references and assignments to)-6.033 F F3(name)180 156 Q F0 4.033 +1.032(That other v)180 412.8 R 1.033(ariable is de\214ned by the v)-.25 +F 1.033(alue of)-.25 F F2(name)3.533 E F0 6.033(.A)C 1.033 +(ll references and assignments to)-6.033 F F2(name)180 424.8 Q F0 4.033 (,e)C 1.533(xcept for changing the)-4.183 F F14.032 E F0(attrib) 4.032 E 1.532(ute itself, are performed on the v)-.2 F 1.532 -(ariable refer)-.25 F(-)-.2 E(enced by)180 168 Q F3(name)2.5 E F0 1.1 +(ariable refer)-.25 F(-)-.2 E(enced by)180 436.8 Q F2(name)2.5 E F0 1.1 -.55('s v)D 2.5(alue. The).3 F F12.5 E F0(attrib)2.5 E -(ute cannot be applied to array v)-.2 E(ariables.)-.25 E F1144 180 -Q F0(Mak)25.86 E(e)-.1 E F3(name)5.046 E F0 5.046(sr)C(eadonly)-5.046 E -7.546(.T)-.65 G 2.546(hese names cannot then be assigned v)-7.546 F -2.547(alues by subsequent)-.25 F(assignment statements or unset.)180 192 -Q F1144 204 Q F0(Gi)26.97 E .73 -.15(ve e)-.25 H(ach).15 E F3 -(name)2.93 E F0(the)2.929 E F3(tr)2.929 E(ace)-.15 E F0(attrib)2.929 E -2.929(ute. T)-.2 F .429(raced functions inherit the)-.35 F F1(DEB)2.929 -E(UG)-.1 E F0(and)2.929 E F1(RETURN)2.929 E F0 -(traps from the calling shell.)180 216 Q(The trace attrib)5 E -(ute has no special meaning for v)-.2 E(ariables.)-.25 E F1144 228 -Q F0 .909(When the v)24.74 F .909(ariable is assigned a v)-.25 F .909 -(alue, all lo)-.25 F(wer)-.25 E .909(-case characters are con)-.2 F -.15 -(ve)-.4 G .91(rted to upper).15 F(-)-.2 E 2.5(case. The)180 240 R(lo)2.5 -E(wer)-.25 E(-case attrib)-.2 E(ute is disabled.)-.2 E F1144 252 Q -F0(Mark)25.3 E F3(name)2.5 E F0 2.5(sf)C(or e)-2.5 E -(xport to subsequent commands via the en)-.15 E(vironment.)-.4 E .121 -(Using `+' instead of `\255' turns of)144 268.8 R 2.621(ft)-.25 G .121 -(he attrib)-2.621 F .121(ute instead, with the e)-.2 F .12 -(xceptions that)-.15 F F1(+a)2.62 E F0 .12(may not be used)2.62 F .644 -(to destro)144 280.8 R 3.144(ya)-.1 G 3.144(na)-3.144 G .644(rray v) +(ute cannot be applied to array v)-.2 E(ariables.)-.25 E F1144 +448.8 Q F0(Mak)25.86 E(e)-.1 E F2(name)5.046 E F0 5.046(sr)C(eadonly) +-5.046 E 7.546(.T)-.65 G 2.546(hese names cannot then be assigned v) +-7.546 F 2.547(alues by subsequent)-.25 F +(assignment statements or unset.)180 460.8 Q F1144 472.8 Q F0(Gi) +26.97 E .73 -.15(ve e)-.25 H(ach).15 E F2(name)2.93 E F0(the)2.929 E F2 +(tr)2.929 E(ace)-.15 E F0(attrib)2.929 E 2.929(ute. T)-.2 F .429 +(raced functions inherit the)-.35 F F1(DEB)2.929 E(UG)-.1 E F0(and)2.929 +E F1(RETURN)2.929 E F0(traps from the calling shell.)180 484.8 Q +(The trace attrib)5 E(ute has no special meaning for v)-.2 E(ariables.) +-.25 E F1144 496.8 Q F0 .909(When the v)24.74 F .909 +(ariable is assigned a v)-.25 F .909(alue, all lo)-.25 F(wer)-.25 E .909 +(-case characters are con)-.2 F -.15(ve)-.4 G .91(rted to upper).15 F(-) +-.2 E 2.5(case. The)180 508.8 R(lo)2.5 E(wer)-.25 E(-case attrib)-.2 E +(ute is disabled.)-.2 E F1144 520.8 Q F0(Mark)25.3 E F2(name)2.5 E +F0 2.5(sf)C(or e)-2.5 E(xport to subsequent commands via the en)-.15 E +(vironment.)-.4 E .121(Using `+' instead of `\255' turns of)144 537.6 R +2.621(ft)-.25 G .121(he attrib)-2.621 F .121(ute instead, with the e)-.2 +F .12(xceptions that)-.15 F F1(+a)2.62 E F0 .12(may not be used)2.62 F +.644(to destro)144 549.6 R 3.144(ya)-.1 G 3.144(na)-3.144 G .644(rray v) -3.144 F .644(ariable and)-.25 F F1(+r)3.145 E F0 .645(will not remo) 3.145 F .945 -.15(ve t)-.15 H .645(he readonly attrib).15 F 3.145 -(ute. When)-.2 F .645(used in a func-)3.145 F(tion,)144 292.8 Q F1 +(ute. When)-.2 F .645(used in a func-)3.145 F(tion,)144 561.6 Q F1 (declar)2.835 E(e)-.18 E F0(and)2.835 E F1(typeset)2.835 E F0(mak)2.835 -E 2.835(ee)-.1 G(ach)-2.835 E F3(name)2.835 E F0 .335 +E 2.835(ee)-.1 G(ach)-2.835 E F2(name)2.835 E F0 .335 (local, as with the)2.835 F F1(local)2.835 E F0 .335 (command, unless the)2.835 F F12.835 E F0(option)2.835 E .133 -(is supplied.)144 304.8 R .133(If a v)5.133 F .133 -(ariable name is follo)-.25 F .134(wed by =)-.25 F F3(value)A F0 2.634 +(is supplied.)144 573.6 R .133(If a v)5.133 F .133 +(ariable name is follo)-.25 F .134(wed by =)-.25 F F2(value)A F0 2.634 (,t)C .134(he v)-2.634 F .134(alue of the v)-.25 F .134 -(ariable is set to)-.25 F F3(value)2.634 E F0 5.134(.T)C(he)-5.134 E -.801(return v)144 316.8 R .801(alue is 0 unless an in)-.25 F -.25(va)-.4 +(ariable is set to)-.25 F F2(value)2.634 E F0 5.134(.T)C(he)-5.134 E +.801(return v)144 585.6 R .801(alue is 0 unless an in)-.25 F -.25(va)-.4 G .8 (lid option is encountered, an attempt is made to de\214ne a function) -.25 F(using)144 328.8 Q/F4 10/Courier@0 SF 1.038(\255f foo=bar)3.538 F +.25 F(using)144 597.6 Q/F5 10/Courier@0 SF 1.038(\255f foo=bar)3.538 F F0 3.538(,a)C 3.538(na)-3.538 G 1.038(ttempt is made to assign a v) -3.538 F 1.038(alue to a readonly v)-.25 F 1.039(ariable, an attempt is) --.25 F .974(made to assign a v)144 340.8 R .974(alue to an array v)-.25 +-.25 F .974(made to assign a v)144 609.6 R .974(alue to an array v)-.25 F .974(ariable without using the compound assignment syntax \(see)-.25 F -F1(Arrays)144 352.8 Q F0(abo)2.86 E -.15(ve)-.15 G .36(\), one of the) -.15 F F3(names)2.86 E F0 .36(is not a v)2.86 F .36(alid shell v)-.25 F +F1(Arrays)144 621.6 Q F0(abo)2.86 E -.15(ve)-.15 G .36(\), one of the) +.15 F F2(names)2.86 E F0 .36(is not a v)2.86 F .36(alid shell v)-.25 F .36(ariable name, an attempt is made to turn of)-.25 F(f)-.25 E .057 -(readonly status for a readonly v)144 364.8 R .057 +(readonly status for a readonly v)144 633.6 R .057 (ariable, an attempt is made to turn of)-.25 F 2.556(fa)-.25 G .056 (rray status for an array v)-2.556 F(ari-)-.25 E -(able, or an attempt is made to display a non-e)144 376.8 Q +(able, or an attempt is made to display a non-e)144 645.6 Q (xistent function with)-.15 E F12.5 E F0(.)A F1 -(dirs [\255clpv] [+)108 393.6 Q F3(n)A F1 2.5(][)C-2.5 E F3(n)A F1 -(])A F0 -.4(Wi)144 405.6 S .328 +(dirs [\255clpv] [+)108 662.4 Q F2(n)A F1 2.5(][)C-2.5 E F2(n)A F1 +(])A F0 -.4(Wi)144 674.4 S .328 (thout options, displays the list of currently remembered directories.) .4 F .329(The def)5.329 F .329(ault display is on a)-.1 F 1.238 -(single line with directory names separated by spaces.)144 417.6 R 1.238 -(Directories are added to the list with the)6.238 F F1(pushd)144 429.6 Q +(single line with directory names separated by spaces.)144 686.4 R 1.238 +(Directories are added to the list with the)6.238 F F1(pushd)144 698.4 Q F0(command; the)2.5 E F1(popd)2.5 E F0(command remo)2.5 E -.15(ve)-.15 G -2.5(se).15 G(ntries from the list.)-2.5 E F1144 441.6 Q F0 -(Clears the directory stack by deleting all of the entries.)25.86 E F1 -144 453.6 Q F0 .881 +2.5(se).15 G(ntries from the list.)-2.5 E F1144 710.4 Q F0 +(Clears the directory stack by deleting all of the entries.)25.86 E +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(56)185.545 E 0 Cg EP +%%Page: 57 57 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF144 84 Q F0 .881 (Produces a listing using full pathnames; the def)27.52 F .882 (ault listing format uses a tilde to denote)-.1 F(the home directory)180 -465.6 Q(.)-.65 E F1144 477.6 Q F0 +96 Q(.)-.65 E F1144 108 Q F0 (Print the directory stack with one entry per line.)24.74 E F1144 -489.6 Q F0 .273(Print the directory stack with one entry per line, pre\ +120 Q F0 .273(Print the directory stack with one entry per line, pre\ \214xing each entry with its inde)25.3 F 2.772(xi)-.15 G 2.772(nt)-2.772 -G(he)-2.772 E(stack.)180 501.6 Q F1(+)144 513.6 Q F3(n)A F0 1.564 -(Displays the)25.3 F F3(n)4.064 E F0 1.565 +G(he)-2.772 E(stack.)180 132 Q F1(+)144 144 Q/F2 10/Times-Italic@0 SF(n) +A F0 1.564(Displays the)25.3 F F2(n)4.064 E F0 1.565 (th entry counting from the left of the list sho)B 1.565(wn by)-.25 F F1 (dirs)4.065 E F0 1.565(when in)4.065 F -.2(vo)-.4 G -.1(ke).2 G(d).1 E -(without options, starting with zero.)180 525.6 Q F1144 537.6 Q F3 -(n)A F0 1.194(Displays the)25.3 F F3(n)3.694 E F0 1.194 +(without options, starting with zero.)180 156 Q F1144 168 Q F2(n)A +F0 1.194(Displays the)25.3 F F2(n)3.694 E F0 1.194 (th entry counting from the right of the list sho)B 1.194(wn by)-.25 F F1(dirs)3.694 E F0 1.194(when in)3.694 F -.2(vo)-.4 G -.1(ke).2 G(d).1 E -(without options, starting with zero.)180 549.6 Q .257(The return v)144 -566.4 R .258(alue is 0 unless an in)-.25 F -.25(va)-.4 G .258 -(lid option is supplied or).25 F F3(n)2.758 E F0(inde)2.758 E -.15(xe) +(without options, starting with zero.)180 180 Q .257(The return v)144 +196.8 R .258(alue is 0 unless an in)-.25 F -.25(va)-.4 G .258 +(lid option is supplied or).25 F F2(n)2.758 E F0(inde)2.758 E -.15(xe) -.15 G 2.758(sb).15 G -.15(ey)-2.758 G .258(ond the end of the direc-) -.15 F(tory stack.)144 578.4 Q F1(diso)108 595.2 Q(wn)-.1 E F0([)2.5 E F1 -(\255ar)A F0 2.5(][)C F1-2.5 E F0 2.5(][)C F3(jobspec)-2.5 E F0 -(...])2.5 E -.4(Wi)144 607.2 S .122(thout options, remo).4 F .422 -.15 -(ve e)-.15 H(ach).15 E F3(jobspec)4.362 E F0 .122 +.15 F(tory stack.)144 208.8 Q F1(diso)108 225.6 Q(wn)-.1 E F0([)2.5 E F1 +(\255ar)A F0 2.5(][)C F1-2.5 E F0 2.5(][)C F2(jobspec)-2.5 E F0 +(...])2.5 E -.4(Wi)144 237.6 S .122(thout options, remo).4 F .422 -.15 +(ve e)-.15 H(ach).15 E F2(jobspec)4.362 E F0 .122 (from the table of acti)2.932 F .422 -.15(ve j)-.25 H 2.622(obs. If).15 -F F3(jobspec)4.362 E F0 .121(is not present, and)2.932 F(neither)144 -619.2 Q F13.836 E F0(nor)3.836 E F13.836 E F0 1.336 +F F2(jobspec)4.362 E F0 .121(is not present, and)2.932 F(neither)144 +249.6 Q F13.836 E F0(nor)3.836 E F13.836 E F0 1.336 (is supplied, the shell')3.836 F 3.836(sn)-.55 G 1.336(otion of the) --3.836 F F3(curr)3.836 E 1.336(ent job)-.37 F F0 1.337(is used.)3.836 F +-3.836 F F2(curr)3.836 E 1.336(ent job)-.37 F F0 1.337(is used.)3.836 F 1.337(If the)6.337 F F13.837 E F0 1.337(option is)3.837 F(gi)144 -631.2 Q -.15(ve)-.25 G .141(n, each).15 F F3(jobspec)4.381 E F0 .141 +261.6 Q -.15(ve)-.25 G .141(n, each).15 F F2(jobspec)4.381 E F0 .141 (is not remo)2.951 F -.15(ve)-.15 G 2.641(df).15 G .141 (rom the table, b)-2.641 F .141(ut is mark)-.2 F .141(ed so that)-.1 F -F2(SIGHUP)2.641 E F0 .14(is not sent to the)2.39 F .004 -(job if the shell recei)144 643.2 R -.15(ve)-.25 G 2.504(sa).15 G F2 -(SIGHUP)A/F5 9/Times-Roman@0 SF(.)A F0 .004(If no)4.504 F F3(jobspec) +/F3 9/Times-Bold@0 SF(SIGHUP)2.641 E F0 .14(is not sent to the)2.39 F +.004(job if the shell recei)144 273.6 R -.15(ve)-.25 G 2.504(sa).15 G F3 +(SIGHUP)A/F4 9/Times-Roman@0 SF(.)A F0 .004(If no)4.504 F F2(jobspec) 4.244 E F0 .004(is present, and neither the)2.814 F F12.504 E F0 .005(nor the)2.504 F F12.505 E F0 .005(option is)2.505 F 1.229 -(supplied, the)144 655.2 R F3(curr)3.729 E 1.229(ent job)-.37 F F0 1.229 -(is used.)3.729 F 1.229(If no)6.229 F F3(jobspec)5.469 E F0 1.229 +(supplied, the)144 285.6 R F2(curr)3.729 E 1.229(ent job)-.37 F F0 1.229 +(is used.)3.729 F 1.229(If no)6.229 F F2(jobspec)5.469 E F0 1.229 (is supplied, the)4.039 F F13.729 E F0 1.228(option means to remo) -3.729 F 1.528 -.15(ve o)-.15 H(r).15 E .656(mark all jobs; the)144 667.2 -R F13.156 E F0 .657(option without a)3.156 F F3(jobspec)4.897 E F0 +3.729 F 1.528 -.15(ve o)-.15 H(r).15 E .656(mark all jobs; the)144 297.6 +R F13.156 E F0 .657(option without a)3.156 F F2(jobspec)4.897 E F0 (ar)3.467 E .657(gument restricts operation to running jobs.)-.18 F(The) -5.657 E(return v)144 679.2 Q(alue is 0 unless a)-.25 E F3(jobspec)4.24 E -F0(does not specify a v)2.81 E(alid job)-.25 E(.)-.4 E F1(echo)108 696 Q -F0([)2.5 E F1(\255neE)A F0 2.5(][)C F3(ar)-2.5 E(g)-.37 E F0(...])2.5 E -.425(Output the)144 708 R F3(ar)2.925 E(g)-.37 E F0 .424 +5.657 E(return v)144 309.6 Q(alue is 0 unless a)-.25 E F2(jobspec)4.24 E +F0(does not specify a v)2.81 E(alid job)-.25 E(.)-.4 E F1(echo)108 326.4 +Q F0([)2.5 E F1(\255neE)A F0 2.5(][)C F2(ar)-2.5 E(g)-.37 E F0(...])2.5 +E .425(Output the)144 338.4 R F2(ar)2.925 E(g)-.37 E F0 .424 (s, separated by spaces, follo)B .424(wed by a ne)-.25 F 2.924 -(wline. The)-.25 F .424(return status is 0 unless a write)2.924 F 1.824 -(error occurs.)144 720 R(If)6.824 E F14.324 E F0 1.824 -(is speci\214ed, the trailing ne)4.324 F 1.824(wline is suppressed.)-.25 -F 1.825(If the)6.825 F F14.325 E F0 1.825(option is gi)4.325 F --.15(ve)-.25 G(n,).15 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(56) -198.165 E 0 Cg EP -%%Page: 57 57 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E 1.143(interpretation of the follo)144 84 R 1.143 -(wing backslash-escaped characters is enabled.)-.25 F(The)6.143 E/F1 10 -/Times-Bold@0 SF3.642 E F0 1.142(option disables)3.642 F 2.435 -(the interpretation of these escape characters, e)144 96 R -.15(ve)-.25 -G 4.935(no).15 G 4.935(ns)-4.935 G 2.436(ystems where the)-4.935 F 4.936 -(ya)-.15 G 2.436(re interpreted by)-4.936 F(def)144 108 Q 3.455 -(ault. The)-.1 F F1(xpg_echo)3.455 E F0 .955 -(shell option may be used to dynamically determine whether or not)3.455 -F F1(echo)3.455 E F0 -.15(ex)144 120 S .048 -(pands these escape characters by def).15 F(ault.)-.1 E F1(echo)5.048 E -F0 .048(does not interpret)2.548 F F12.548 E F0 .048 -(to mean the end of options.)2.548 F F1(echo)144 132 Q F0 -(interprets the follo)2.5 E(wing escape sequences:)-.25 E F1(\\a)144 144 -Q F0(alert \(bell\))28.22 E F1(\\b)144 156 Q F0(backspace)27.66 E F1 -(\\c)144 168 Q F0(suppress further output)28.78 E F1(\\e)144 180 Q(\\E) -144 192 Q F0(an escape character)26.55 E F1(\\f)144 204 Q F0(form feed) -29.89 E F1(\\n)144 216 Q F0(ne)27.66 E 2.5(wl)-.25 G(ine)-2.5 E F1(\\r) -144 228 Q F0(carriage return)28.78 E F1(\\t)144 240 Q F0(horizontal tab) -29.89 E F1(\\v)144 252 Q F0 -.15(ve)28.22 G(rtical tab).15 E F1(\\\\)144 -264 Q F0(backslash)30.44 E F1(\\0)144 276 Q/F2 10/Times-Italic@0 SF(nnn) -A F0(the eight-bit character whose v)13.22 E(alue is the octal v)-.25 E -(alue)-.25 E F2(nnn)2.5 E F0(\(zero to three octal digits\))2.5 E F1 -(\\x)144 288 Q F2(HH)A F0(the eight-bit character whose v)13.78 E -(alue is the he)-.25 E(xadecimal v)-.15 E(alue)-.25 E F2(HH)2.5 E F0 -(\(one or tw)2.5 E 2.5(oh)-.1 G .3 -.15(ex d)-2.5 H(igits\)).15 E F1 -(\\u)144 300 Q F2(HHHH)A F0 1.507 -(the Unicode \(ISO/IEC 10646\) character whose v)180 312 R 1.506 +(wline. The)-.25 F .424(return status is 0 unless a write)2.924 F .307 +(error occurs.)144 350.4 R(If)5.307 E F12.807 E F0 .307 +(is speci\214ed, the trailing ne)2.807 F .308(wline is suppressed.)-.25 +F .308(If the)5.308 F F12.808 E F0 .308(option is gi)2.808 F -.15 +(ve)-.25 G .308(n, inter).15 F(-)-.2 E 1.349(pretation of the follo)144 +362.4 R 1.348(wing backslash-escaped characters is enabled.)-.25 F(The) +6.348 E F13.848 E F0 1.348(option disables the)3.848 F 1.054 +(interpretation of these escape characters, e)144 374.4 R -.15(ve)-.25 G +3.555(no).15 G 3.555(ns)-3.555 G 1.055(ystems where the)-3.555 F 3.555 +(ya)-.15 G 1.055(re interpreted by def)-3.555 F(ault.)-.1 E(The)144 +386.4 Q F1(xpg_echo)3.459 E F0 .959 +(shell option may be used to dynamically determine whether or not)3.459 +F F1(echo)3.458 E F0 -.15(ex)3.458 G(pands).15 E .715 +(these escape characters by def)144 398.4 R(ault.)-.1 E F1(echo)5.715 E +F0 .716(does not interpret)3.215 F F13.216 E F0 .716 +(to mean the end of options.)3.216 F F1(echo)5.716 E F0 +(interprets the follo)144 410.4 Q(wing escape sequences:)-.25 E F1(\\a) +144 422.4 Q F0(alert \(bell\))28.22 E F1(\\b)144 434.4 Q F0(backspace) +27.66 E F1(\\c)144 446.4 Q F0(suppress further output)28.78 E F1(\\e)144 +458.4 Q(\\E)144 470.4 Q F0(an escape character)26.55 E F1(\\f)144 482.4 +Q F0(form feed)29.89 E F1(\\n)144 494.4 Q F0(ne)27.66 E 2.5(wl)-.25 G +(ine)-2.5 E F1(\\r)144 506.4 Q F0(carriage return)28.78 E F1(\\t)144 +518.4 Q F0(horizontal tab)29.89 E F1(\\v)144 530.4 Q F0 -.15(ve)28.22 G +(rtical tab).15 E F1(\\\\)144 542.4 Q F0(backslash)30.44 E F1(\\0)144 +554.4 Q F2(nnn)A F0(the eight-bit character whose v)13.22 E +(alue is the octal v)-.25 E(alue)-.25 E F2(nnn)2.5 E F0 +(\(zero to three octal digits\))2.5 E F1(\\x)144 566.4 Q F2(HH)A F0 +(the eight-bit character whose v)13.78 E(alue is the he)-.25 E +(xadecimal v)-.15 E(alue)-.25 E F2(HH)2.5 E F0(\(one or tw)2.5 E 2.5(oh) +-.1 G .3 -.15(ex d)-2.5 H(igits\)).15 E F1(\\u)144 578.4 Q F2(HHHH)A F0 +1.507(the Unicode \(ISO/IEC 10646\) character whose v)180 590.4 R 1.506 (alue is the he)-.25 F 1.506(xadecimal v)-.15 F(alue)-.25 E F2(HHHH) -4.006 E F0(\(one to four he)180 324 Q 2.5(xd)-.15 G(igits\))-2.5 E F1 -(\\U)144 336 Q F2(HHHHHHHH)A F0 .547 -(the Unicode \(ISO/IEC 10646\) character whose v)180 348 R .547 +4.006 E F0(\(one to four he)180 602.4 Q 2.5(xd)-.15 G(igits\))-2.5 E F1 +(\\U)144 614.4 Q F2(HHHHHHHH)A F0 .547 +(the Unicode \(ISO/IEC 10646\) character whose v)180 626.4 R .547 (alue is the he)-.25 F .548(xadecimal v)-.15 F(alue)-.25 E F2(HHHHH-) -3.048 E(HHH)180 360 Q F0(\(one to eight he)2.5 E 2.5(xd)-.15 G(igits\)) --2.5 E F1(enable)108 376.8 Q F0([)2.5 E F1A F0 2.5(][)C F1 -(\255dnps)-2.5 E F0 2.5(][)C F1-2.5 E F2(\214lename)2.5 E F0 2.5 -(][)C F2(name)-2.5 E F0(...])2.5 E .278(Enable and disable b)144 388.8 R +3.048 E(HHH)180 638.4 Q F0(\(one to eight he)2.5 E 2.5(xd)-.15 G +(igits\))-2.5 E F1(enable)108 655.2 Q F0([)2.5 E F1A F0 2.5(][)C +F1(\255dnps)-2.5 E F0 2.5(][)C F1-2.5 E F2(\214lename)2.5 E F0 2.5 +(][)C F2(name)-2.5 E F0(...])2.5 E .278(Enable and disable b)144 667.2 R .278(uiltin shell commands.)-.2 F .278(Disabling a b)5.278 F .278 (uiltin allo)-.2 F .278(ws a disk command which has)-.25 F .833 -(the same name as a shell b)144 400.8 R .834(uiltin to be e)-.2 F -.15 +(the same name as a shell b)144 679.2 R .834(uiltin to be e)-.2 F -.15 (xe)-.15 G .834(cuted without specifying a full pathname, e).15 F -.15 (ve)-.25 G 3.334(nt).15 G(hough)-3.334 E .99 -(the shell normally searches for b)144 412.8 R .989 +(the shell normally searches for b)144 691.2 R .989 (uiltins before disk commands.)-.2 F(If)5.989 E F13.489 E F0 .989 (is used, each)3.489 F F2(name)3.489 E F0 .989(is dis-)3.489 F 1.581 -(abled; otherwise,)144 424.8 R F2(names)4.082 E F0 1.582(are enabled.) +(abled; otherwise,)144 703.2 R F2(names)4.082 E F0 1.582(are enabled.) 4.082 F -.15(Fo)6.582 G 4.082(re).15 G 1.582(xample, to use the)-4.232 F -F1(test)4.082 E F0 1.582(binary found via the)4.082 F/F3 9/Times-Bold@0 -SF -.666(PA)4.082 G(TH)-.189 E F0 .081(instead of the shell b)144 436.8 -R .081(uiltin v)-.2 F .081(ersion, run)-.15 F/F4 10/Courier@0 SF .081 -(enable -n test)2.581 F F0 5.081(.T)C(he)-5.081 E F12.58 E F0 .08 -(option means to load the ne)2.58 F(w)-.25 E -.2(bu)144 448.8 S 1.524 +F1(test)4.082 E F0 1.582(binary found via the)4.082 F F3 -.666(PA)4.082 +G(TH)-.189 E F0 .081(instead of the shell b)144 715.2 R .081(uiltin v) +-.2 F .081(ersion, run)-.15 F/F5 10/Courier@0 SF .081(enable -n test) +2.581 F F0 5.081(.T)C(he)-5.081 E F12.58 E F0 .08 +(option means to load the ne)2.58 F(w)-.25 E -.2(bu)144 727.2 S 1.524 (iltin command).2 F F2(name)4.384 E F0 1.524(from shared object)4.204 F F2(\214lename)4.024 E F0 4.024(,o).18 G 4.024(ns)-4.024 G 1.524 -(ystems that support dynamic loading.)-4.024 F(The)144 460.8 Q F1 -2.867 E F0 .367(option will delete a b)2.867 F .367(uiltin pre)-.2 F -.367(viously loaded with)-.25 F F12.866 E F0 5.366(.I)C 2.866(fn) --5.366 G(o)-2.866 E F2(name)2.866 E F0(ar)2.866 E .366(guments are gi) --.18 F -.15(ve)-.25 G .366(n, or).15 F .398(if the)144 472.8 R F1 -2.898 E F0 .399(option is supplied, a list of shell b)2.899 F .399 -(uiltins is printed.)-.2 F -.4(Wi)5.399 G .399(th no other option ar).4 -F .399(guments, the)-.18 F .099(list consists of all enabled shell b)144 -484.8 R 2.598(uiltins. If)-.2 F F12.598 E F0 .098 -(is supplied, only disabled b)2.598 F .098(uiltins are printed.)-.2 F -(If)5.098 E F12.598 E F0 1.916 -(is supplied, the list printed includes all b)144 496.8 R 1.916 +(ystems that support dynamic loading.)-4.024 F(GNU Bash 4.2)72 768 Q +(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(57)185.545 E 0 Cg EP +%%Page: 58 58 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(The)144 84 Q/F1 10/Times-Bold@0 SF2.867 E F0 .367 +(option will delete a b)2.867 F .367(uiltin pre)-.2 F .367 +(viously loaded with)-.25 F F12.866 E F0 5.366(.I)C 2.866(fn) +-5.366 G(o)-2.866 E/F2 10/Times-Italic@0 SF(name)2.866 E F0(ar)2.866 E +.366(guments are gi)-.18 F -.15(ve)-.25 G .366(n, or).15 F .398(if the) +144 96 R F12.898 E F0 .399(option is supplied, a list of shell b) +2.899 F .399(uiltins is printed.)-.2 F -.4(Wi)5.399 G .399 +(th no other option ar).4 F .399(guments, the)-.18 F .099 +(list consists of all enabled shell b)144 108 R 2.598(uiltins. If)-.2 F +F12.598 E F0 .098(is supplied, only disabled b)2.598 F .098 +(uiltins are printed.)-.2 F(If)5.098 E F12.598 E F0 1.916 +(is supplied, the list printed includes all b)144 120 R 1.916 (uiltins, with an indication of whether or not each is)-.2 F 2.879 -(enabled. If)144 508.8 R F12.879 E F0 .379 +(enabled. If)144 132 R F12.879 E F0 .379 (is supplied, the output is restricted to the POSIX)2.879 F F2(special) 2.879 E F0 -.2(bu)2.878 G 2.878(iltins. The).2 F .378(return v)2.878 F -(alue)-.25 E .994(is 0 unless a)144 520.8 R F2(name)3.854 E F0 .994 +(alue)-.25 E .994(is 0 unless a)144 144 R F2(name)3.854 E F0 .994 (is not a shell b)3.674 F .994(uiltin or there is an error loading a ne) --.2 F 3.495(wb)-.25 G .995(uiltin from a shared)-3.695 F(object.)144 -532.8 Q F1 -2.3 -.15(ev a)108 549.6 T(l).15 E F0([)2.5 E F2(ar)A(g)-.37 -E F0(...])2.5 E(The)144 561.6 Q F2(ar)3.171 E(g)-.37 E F0 3.171(sa)C -.671(re read and concatenated together into a single command.)-3.171 F -.67(This command is then read)5.67 F .495(and e)144 573.6 R -.15(xe)-.15 -G .495(cuted by the shell, and its e).15 F .495 +-.2 F 3.495(wb)-.25 G .995(uiltin from a shared)-3.695 F(object.)144 156 +Q F1 -2.3 -.15(ev a)108 172.8 T(l).15 E F0([)2.5 E F2(ar)A(g)-.37 E F0 +(...])2.5 E(The)144 184.8 Q F2(ar)3.171 E(g)-.37 E F0 3.171(sa)C .671 +(re read and concatenated together into a single command.)-3.171 F .67 +(This command is then read)5.67 F .495(and e)144 196.8 R -.15(xe)-.15 G +.495(cuted by the shell, and its e).15 F .495 (xit status is returned as the v)-.15 F .495(alue of)-.25 F F1 -2.3 -.15 (ev a)2.995 H(l).15 E F0 5.495(.I)C 2.995(ft)-5.495 G .495(here are no) --2.995 F F2(ar)2.995 E(gs)-.37 E F0(,).27 E(or only null ar)144 585.6 Q +-2.995 F F2(ar)2.995 E(gs)-.37 E F0(,).27 E(or only null ar)144 208.8 Q (guments,)-.18 E F1 -2.3 -.15(ev a)2.5 H(l).15 E F0(returns 0.)2.5 E F1 -(exec)108 602.4 Q F0([)2.5 E F1(\255cl)A F0 2.5(][)C F1-2.5 E F2 +(exec)108 225.6 Q F0([)2.5 E F1(\255cl)A F0 2.5(][)C F1-2.5 E F2 (name)2.5 E F0 2.5(][)C F2(command)-2.5 E F0([)2.5 E F2(ar)A(guments) --.37 E F0(]])A(If)144 614.4 Q F2(command)3.006 E F0 .306 +-.37 E F0(]])A(If)144 237.6 Q F2(command)3.006 E F0 .306 (is speci\214ed, it replaces the shell.)3.576 F .305(No ne)5.305 F 2.805 (wp)-.25 G .305(rocess is created.)-2.805 F(The)5.305 E F2(ar)3.135 E -(guments)-.37 E F0(become)3.075 E .176(the ar)144 626.4 R .176 +(guments)-.37 E F0(become)3.075 E .176(the ar)144 249.6 R .176 (guments to)-.18 F F2(command)2.676 E F0 5.176(.I)C 2.676(ft)-5.176 G (he)-2.676 E F12.676 E F0 .176 (option is supplied, the shell places a dash at the be)2.676 F .177 -(ginning of)-.15 F .5(the zeroth ar)144 638.4 R .5(gument passed to)-.18 +(ginning of)-.15 F .5(the zeroth ar)144 261.6 R .5(gument passed to)-.18 F F2(command)3 E F0 5.499(.T).77 G .499(his is what)-5.499 F F2(lo)2.999 E(gin)-.1 E F0 .499(\(1\) does.).24 F(The)5.499 E F12.999 E F0 -.499(option causes)2.999 F F2(com-)3.199 E(mand)144 650.4 Q F0 .638 +.499(option causes)2.999 F F2(com-)3.199 E(mand)144 273.6 Q F0 .638 (to be e)3.908 F -.15(xe)-.15 G .638(cuted with an empty en).15 F 3.138 (vironment. If)-.4 F F13.138 E F0 .638 (is supplied, the shell passes)3.138 F F2(name)3.499 E F0 .639(as the) -3.319 F 1.078(zeroth ar)144 662.4 R 1.077(gument to the e)-.18 F -.15 +3.319 F 1.078(zeroth ar)144 285.6 R 1.077(gument to the e)-.18 F -.15 (xe)-.15 G 1.077(cuted command.).15 F(If)6.077 E F2(command)3.777 E F0 1.077(cannot be e)4.347 F -.15(xe)-.15 G 1.077(cuted for some reason, a) -.15 F(non-interacti)144 674.4 Q .876 -.15(ve s)-.25 H .576(hell e).15 F +.15 F(non-interacti)144 297.6 Q .876 -.15(ve s)-.25 H .576(hell e).15 F .576(xits, unless the)-.15 F F1(execfail)3.076 E F0 .577 (shell option is enabled.)3.077 F .577(In that case, it returns f)5.577 -F(ail-)-.1 E 2.505(ure. An)144 686.4 R(interacti)2.505 E .305 -.15(ve s) +F(ail-)-.1 E 2.505(ure. An)144 309.6 R(interacti)2.505 E .305 -.15(ve s) -.25 H .005(hell returns f).15 F .005(ailure if the \214le cannot be e) -.1 F -.15(xe)-.15 G 2.505(cuted. If).15 F F2(command)2.705 E F0 .005 -(is not speci\214ed,)3.275 F(an)144 698.4 Q 3.036(yr)-.15 G .536 +(is not speci\214ed,)3.275 F(an)144 321.6 Q 3.036(yr)-.15 G .536 (edirections tak)-3.036 F 3.036(ee)-.1 G -.25(ff)-3.036 G .536 (ect in the current shell, and the return status is 0.).25 F .536 -(If there is a redirection)5.536 F(error)144 710.4 Q 2.5(,t)-.4 G -(he return status is 1.)-2.5 E(GNU Bash 4.2)72 768 Q(2012 July 14) -149.005 E(57)198.165 E 0 Cg EP -%%Page: 58 58 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(exit)108 84 Q F0([)2.5 E/F2 10 -/Times-Italic@0 SF(n)A F0 6.29(]C)C .096(ause the shell to e)-6.29 F -.096(xit with a status of)-.15 F F2(n)2.596 E F0 5.096(.I)C(f)-5.096 E -F2(n)2.955 E F0 .095(is omitted, the e)2.835 F .095 -(xit status is that of the last command)-.15 F -.15(exe)144 96 S 2.5 -(cuted. A).15 F(trap on)2.5 E/F3 9/Times-Bold@0 SF(EXIT)2.5 E F0(is e) -2.25 E -.15(xe)-.15 G(cuted before the shell terminates.).15 E F1 -(export)108 112.8 Q F0([)2.5 E F1(\255fn)A F0 2.5(][).833 G F2(name)-2.5 -E F0([=)A F2(wor)A(d)-.37 E F0(]] ...)A F1(export \255p)108 124.8 Q F0 -.256(The supplied)144 136.8 R F2(names)3.117 E F0 .257(are mark)3.027 F -.257(ed for automatic e)-.1 F .257(xport to the en)-.15 F .257 -(vironment of subsequently e)-.4 F -.15(xe)-.15 G(cuted).15 E 2.627 -(commands. If)144 148.8 R(the)2.627 E F12.627 E F0 .127 -(option is gi)2.627 F -.15(ve)-.25 G .127(n, the).15 F F2(names)2.987 E -F0 .127(refer to functions.)2.897 F .127(If no)5.127 F F2(names)2.987 E -F0 .127(are gi)2.897 F -.15(ve)-.25 G .126(n, or if the).15 F F1 -144 160.8 Q F0 .048(option is supplied, a list of names of all e)2.547 F -.048(xported v)-.15 F .048(ariables is printed.)-.25 F(The)5.048 E F1 -2.548 E F0 .048(option causes the)2.548 F -.15(ex)144 172.8 S -1.447(port property to be remo).15 F -.15(ve)-.15 G 3.947(df).15 G 1.447 +(If there is a redirection)5.536 F(error)144 333.6 Q 2.5(,t)-.4 G +(he return status is 1.)-2.5 E F1(exit)108 350.4 Q F0([)2.5 E F2(n)A F0 +6.29(]C)C .096(ause the shell to e)-6.29 F .096(xit with a status of) +-.15 F F2(n)2.596 E F0 5.096(.I)C(f)-5.096 E F2(n)2.955 E F0 .095 +(is omitted, the e)2.835 F .095(xit status is that of the last command) +-.15 F -.15(exe)144 362.4 S 2.5(cuted. A).15 F(trap on)2.5 E/F3 9 +/Times-Bold@0 SF(EXIT)2.5 E F0(is e)2.25 E -.15(xe)-.15 G +(cuted before the shell terminates.).15 E F1(export)108 379.2 Q F0([)2.5 +E F1(\255fn)A F0 2.5(][).833 G F2(name)-2.5 E F0([=)A F2(wor)A(d)-.37 E +F0(]] ...)A F1(export \255p)108 391.2 Q F0 .256(The supplied)144 403.2 R +F2(names)3.117 E F0 .257(are mark)3.027 F .257(ed for automatic e)-.1 F +.257(xport to the en)-.15 F .257(vironment of subsequently e)-.4 F -.15 +(xe)-.15 G(cuted).15 E 2.627(commands. If)144 415.2 R(the)2.627 E F1 +2.627 E F0 .127(option is gi)2.627 F -.15(ve)-.25 G .127(n, the) +.15 F F2(names)2.987 E F0 .127(refer to functions.)2.897 F .127(If no) +5.127 F F2(names)2.987 E F0 .127(are gi)2.897 F -.15(ve)-.25 G .126 +(n, or if the).15 F F1144 427.2 Q F0 .048 +(option is supplied, a list of names of all e)2.547 F .048(xported v) +-.15 F .048(ariables is printed.)-.25 F(The)5.048 E F12.548 E F0 +.048(option causes the)2.548 F -.15(ex)144 439.2 S 1.447 +(port property to be remo).15 F -.15(ve)-.15 G 3.947(df).15 G 1.447 (rom each)-3.947 F F2(name)3.947 E F0 6.447(.I)C 3.947(fav)-6.447 G 1.447(ariable name is follo)-4.197 F 1.447(wed by =)-.25 F F2(wor)A(d) --.37 E F0 3.946(,t)C(he)-3.946 E -.25(va)144 184.8 S .741(lue of the v) +-.37 E F0 3.946(,t)C(he)-3.946 E -.25(va)144 451.2 S .741(lue of the v) .25 F .741(ariable is set to)-.25 F F2(wor)3.241 E(d)-.37 E F0(.)A F1 (export)5.741 E F0 .742(returns an e)3.242 F .742 (xit status of 0 unless an in)-.15 F -.25(va)-.4 G .742(lid option is) -.25 F .032(encountered, one of the)144 196.8 R F2(names)2.532 E F0 .032 +.25 F .032(encountered, one of the)144 463.2 R F2(names)2.532 E F0 .032 (is not a v)2.532 F .032(alid shell v)-.25 F .032(ariable name, or)-.25 F F12.531 E F0 .031(is supplied with a)2.531 F F2(name)2.891 E F0 -(that)2.711 E(is not a function.)144 208.8 Q F1(fc)108 225.6 Q F0([)2.5 -E F1A F2(ename)2.5 E F0 2.5(][)C F1(\255lnr)-2.5 E F0 2.5(][)C F2 +(that)2.711 E(is not a function.)144 475.2 Q F1(fc)108 492 Q F0([)2.5 E +F1A F2(ename)2.5 E F0 2.5(][)C F1(\255lnr)-2.5 E F0 2.5(][)C F2 <8c72>-2.5 E(st)-.1 E F0 2.5(][)C F2(last)-2.5 E F0(])A F1(fc \255s)108 -237.6 Q F0([)2.5 E F2(pat)A F0(=)A F2 -.37(re)C(p).37 E F0 2.5(][)C F2 +504 Q F0([)2.5 E F2(pat)A F0(=)A F2 -.37(re)C(p).37 E F0 2.5(][)C F2 (cmd)-2.5 E F0(])A .431 -(The \214rst form selects a range of commands from)144 249.6 R F2<8c72> +(The \214rst form selects a range of commands from)144 516 R F2<8c72> 4.842 E(st)-.1 E F0(to)3.612 E F2(last)3.022 E F0 .432 (from the history list and displays or)3.612 F .142(edits and re-e)144 -261.6 R -.15(xe)-.15 G .142(cutes them.).15 F F2 -.45(Fi)5.141 G -.1(rs) +528 R -.15(xe)-.15 G .142(cutes them.).15 F F2 -.45(Fi)5.141 G -.1(rs) .45 G(t).1 E F0(and)3.321 E F2(last)2.731 E F0 .141 (may be speci\214ed as a string \(to locate the last command)3.321 F(be) -144 273.6 Q .31(ginning with that string\) or as a number \(an inde)-.15 -F 2.811(xi)-.15 G .311(nto the history list, where a ne)-2.811 F -.05 -(ga)-.15 G(ti).05 E .611 -.15(ve n)-.25 H(umber).15 E .315 -(is used as an of)144 285.6 R .315 -(fset from the current command number\).)-.25 F(If)5.315 E F2(last)2.904 -E F0 .314(is not speci\214ed it is set to the cur)3.494 F(-)-.2 E .948 -(rent command for listing \(so that)144 297.6 R/F4 10/Courier@0 SF .948 -(fc \255l \25510)3.448 F F0 .948(prints the last 10 commands\) and to) -3.448 F F2<8c72>5.359 E(st)-.1 E F0(other)4.129 E(-)-.2 E 2.5(wise. If) -144 309.6 R F2<8c72>4.41 E(st)-.1 E F0 -(is not speci\214ed it is set to the pre)3.18 E -(vious command for editing and \25516 for listing.)-.25 E(The)144 333.6 -Q F12.522 E F0 .022 +144 540 Q .31(ginning with that string\) or as a number \(an inde)-.15 F +2.811(xi)-.15 G .311(nto the history list, where a ne)-2.811 F -.05(ga) +-.15 G(ti).05 E .611 -.15(ve n)-.25 H(umber).15 E .315(is used as an of) +144 552 R .315(fset from the current command number\).)-.25 F(If)5.315 E +F2(last)2.904 E F0 .314(is not speci\214ed it is set to the cur)3.494 F +(-)-.2 E .948(rent command for listing \(so that)144 564 R/F4 10 +/Courier@0 SF .948(fc \255l \25510)3.448 F F0 .948 +(prints the last 10 commands\) and to)3.448 F F2<8c72>5.359 E(st)-.1 E +F0(other)4.129 E(-)-.2 E 2.5(wise. If)144 576 R F2<8c72>4.41 E(st)-.1 E +F0(is not speci\214ed it is set to the pre)3.18 E +(vious command for editing and \25516 for listing.)-.25 E(The)144 600 Q +F12.522 E F0 .022 (option suppresses the command numbers when listing.)2.522 F(The)5.022 E F12.522 E F0 .022(option re)2.522 F -.15(ve)-.25 G .022 -(rses the order of).15 F .438(the commands.)144 345.6 R .438(If the) -5.438 F F12.938 E F0 .438(option is gi)2.938 F -.15(ve)-.25 G .438 +(rses the order of).15 F .438(the commands.)144 612 R .438(If the)5.438 +F F12.938 E F0 .438(option is gi)2.938 F -.15(ve)-.25 G .438 (n, the commands are listed on standard output.).15 F(Otherwise,)5.438 E -.335(the editor gi)144 357.6 R -.15(ve)-.25 G 2.835(nb).15 G(y)-2.835 E -F2(ename)3.025 E F0 .335(is in)3.015 F -.2(vo)-.4 G -.1(ke).2 G 2.835 -(do).1 G 2.835(na\214)-2.835 G .335(le containing those commands.)-2.835 -F(If)5.334 E F2(ename)3.024 E F0 .334(is not gi)3.014 F -.15(ve)-.25 G -(n,).15 E .63(the v)144 369.6 R .63(alue of the)-.25 F F3(FCEDIT)3.13 E -F0 -.25(va)2.88 G .631(riable is used, and the v).25 F .631(alue of)-.25 -F F3(EDIT)3.131 E(OR)-.162 E F0(if)2.881 E F3(FCEDIT)3.131 E F0 .631 -(is not set.)2.881 F .631(If nei-)5.631 F .951(ther v)144 381.6 R .951 +.335(the editor gi)144 624 R -.15(ve)-.25 G 2.835(nb).15 G(y)-2.835 E F2 +(ename)3.025 E F0 .335(is in)3.015 F -.2(vo)-.4 G -.1(ke).2 G 2.835(do) +.1 G 2.835(na\214)-2.835 G .335(le containing those commands.)-2.835 F +(If)5.334 E F2(ename)3.024 E F0 .334(is not gi)3.014 F -.15(ve)-.25 G +(n,).15 E .63(the v)144 636 R .63(alue of the)-.25 F F3(FCEDIT)3.13 E F0 +-.25(va)2.88 G .631(riable is used, and the v).25 F .631(alue of)-.25 F +F3(EDIT)3.131 E(OR)-.162 E F0(if)2.881 E F3(FCEDIT)3.131 E F0 .631 +(is not set.)2.881 F .631(If nei-)5.631 F .951(ther v)144 648 R .951 (ariable is set,)-.25 F F2(vi)5.117 E F0 .951(is used.)5.117 F .95 (When editing is complete, the edited commands are echoed and)5.951 F --.15(exe)144 393.6 S(cuted.).15 E .788(In the second form,)144 417.6 R -F2(command)3.288 E F0 .788(is re-e)3.288 F -.15(xe)-.15 G .788 +-.15(exe)144 660 S(cuted.).15 E .788(In the second form,)144 684 R F2 +(command)3.288 E F0 .788(is re-e)3.288 F -.15(xe)-.15 G .788 (cuted after each instance of).15 F F2(pat)3.288 E F0 .788 (is replaced by)3.288 F F2 -.37(re)3.289 G(p).37 E F0(.)A F2(Com-)5.789 -E(mand)144 429.6 Q F0 .347(is intepreted the same as)2.847 F F2<8c72> -2.847 E(st)-.1 E F0(abo)2.847 E -.15(ve)-.15 G 5.347(.A).15 G .347 +E(mand)144 696 Q F0 .347(is intepreted the same as)2.847 F F2<8c72>2.847 +E(st)-.1 E F0(abo)2.847 E -.15(ve)-.15 G 5.347(.A).15 G .347 (useful alias to use with this is)-2.5 F F4 .346(r='fc \255s')2.847 F F0 -2.846(,s)C 2.846(ot)-2.846 G(hat)-2.846 E(typing)144 441.6 Q F4 7.165 -(rc)3.665 G(c)-7.165 E F0 1.165(runs the last command be)3.665 F 1.166 +2.846(,s)C 2.846(ot)-2.846 G(hat)-2.846 E(typing)144 708 Q F4 7.165(rc) +3.665 G(c)-7.165 E F0 1.165(runs the last command be)3.665 F 1.166 (ginning with)-.15 F F4(cc)3.666 E F0 1.166(and typing)3.666 F F4(r) 3.666 E F0(re-e)3.666 E -.15(xe)-.15 G 1.166(cutes the last com-).15 F -(mand.)144 453.6 Q .142(If the \214rst form is used, the return v)144 -477.6 R .142(alue is 0 unless an in)-.25 F -.25(va)-.4 G .142 -(lid option is encountered or).25 F F2<8c72>4.552 E(st)-.1 E F0(or)3.322 -E F2(last)2.732 E F0 .454(specify history lines out of range.)144 489.6 -R .454(If the)5.454 F F12.954 E F0 .454 -(option is supplied, the return v)2.954 F .455(alue is the v)-.25 F .455 -(alue of the)-.25 F .788(last command e)144 501.6 R -.15(xe)-.15 G .788 -(cuted or f).15 F .787 +(mand.)144 720 Q(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G +(mber 24).15 E(58)185.545 E 0 Cg EP +%%Page: 59 59 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E .142(If the \214rst form is used, the return v)144 84 R .142 +(alue is 0 unless an in)-.25 F -.25(va)-.4 G .142 +(lid option is encountered or).25 F/F1 10/Times-Italic@0 SF<8c72>4.552 E +(st)-.1 E F0(or)3.322 E F1(last)2.732 E F0 .454 +(specify history lines out of range.)144 96 R .454(If the)5.454 F/F2 10 +/Times-Bold@0 SF2.954 E F0 .454(option is supplied, the return v) +2.954 F .455(alue is the v)-.25 F .455(alue of the)-.25 F .788 +(last command e)144 108 R -.15(xe)-.15 G .788(cuted or f).15 F .787 (ailure if an error occurs with the temporary \214le of commands.)-.1 F .787(If the)5.787 F 1.135 (second form is used, the return status is that of the command re-e)144 -513.6 R -.15(xe)-.15 G 1.136(cuted, unless).15 F F2(cmd)3.836 E F0 1.136 -(does not)4.406 F(specify a v)144 525.6 Q -(alid history line, in which case)-.25 E F1(fc)2.5 E F0(returns f)2.5 E -(ailure.)-.1 E F1(fg)108 542.4 Q F0([)2.5 E F2(jobspec)A F0(])A(Resume) -144 554.4 Q F2(jobspec)5.654 E F0 1.413(in the fore)4.224 F 1.413 +120 R -.15(xe)-.15 G 1.136(cuted, unless).15 F F1(cmd)3.836 E F0 1.136 +(does not)4.406 F(specify a v)144 132 Q +(alid history line, in which case)-.25 E F2(fc)2.5 E F0(returns f)2.5 E +(ailure.)-.1 E F2(fg)108 148.8 Q F0([)2.5 E F1(jobspec)A F0(])A(Resume) +144 160.8 Q F1(jobspec)5.654 E F0 1.413(in the fore)4.224 F 1.413 (ground, and mak)-.15 F 3.913(ei)-.1 G 3.913(tt)-3.913 G 1.413 -(he current job)-3.913 F 6.413(.I)-.4 G(f)-6.413 E F2(jobspec)5.653 E F0 -1.413(is not present, the)4.223 F(shell')144 566.4 Q 3.116(sn)-.55 G -.616(otion of the)-3.116 F F2(curr)3.116 E .616(ent job)-.37 F F0 .617 +(he current job)-3.913 F 6.413(.I)-.4 G(f)-6.413 E F1(jobspec)5.653 E F0 +1.413(is not present, the)4.223 F(shell')144 172.8 Q 3.116(sn)-.55 G +.616(otion of the)-3.116 F F1(curr)3.116 E .616(ent job)-.37 F F0 .617 (is used.)3.116 F .617(The return v)5.617 F .617 -(alue is that of the command placed into the)-.25 F(fore)144 578.4 Q +(alue is that of the command placed into the)-.25 F(fore)144 184.8 Q .363(ground, or f)-.15 F .363 (ailure if run when job control is disabled or)-.1 F 2.862(,w)-.4 G .362 -(hen run with job control enabled, if)-2.862 F F2(jobspec)145.74 590.4 Q -F0 .004(does not specify a v)2.814 F .004(alid job or)-.25 F F2(jobspec) +(hen run with job control enabled, if)-2.862 F F1(jobspec)145.74 196.8 Q +F0 .004(does not specify a v)2.814 F .004(alid job or)-.25 F F1(jobspec) 4.244 E F0 .004(speci\214es a job that w)2.814 F .004 -(as started without job control.)-.1 F F1(getopts)108 607.2 Q F2 -(optstring name)2.5 E F0([)2.5 E F2(ar)A(gs)-.37 E F0(])A F1(getopts)144 -619.2 Q F0 .793 -(is used by shell procedures to parse positional parameters.)3.294 F F2 +(as started without job control.)-.1 F F2(getopts)108 213.6 Q F1 +(optstring name)2.5 E F0([)2.5 E F1(ar)A(gs)-.37 E F0(])A F2(getopts)144 +225.6 Q F0 .793 +(is used by shell procedures to parse positional parameters.)3.294 F F1 (optstring)6.023 E F0 .793(contains the option)3.513 F .149 -(characters to be recognized; if a character is follo)144 631.2 R .15 +(characters to be recognized; if a character is follo)144 237.6 R .15 (wed by a colon, the option is e)-.25 F .15(xpected to ha)-.15 F .45 --.15(ve a)-.2 H(n).15 E(ar)144 643.2 Q .579 +-.15(ve a)-.2 H(n).15 E(ar)144 249.6 Q .579 (gument, which should be separated from it by white space.)-.18 F .578 (The colon and question mark char)5.579 F(-)-.2 E 1.665 -(acters may not be used as option characters.)144 655.2 R 1.665 -(Each time it is in)6.665 F -.2(vo)-.4 G -.1(ke).2 G(d,).1 E F1(getopts) +(acters may not be used as option characters.)144 261.6 R 1.665 +(Each time it is in)6.665 F -.2(vo)-.4 G -.1(ke).2 G(d,).1 E F2(getopts) 4.165 E F0 1.665(places the ne)4.165 F(xt)-.15 E .797 -(option in the shell v)144 667.2 R(ariable)-.25 E F2(name)3.297 E F0 -3.297(,i).18 G(nitializing)-3.297 E F2(name)3.657 E F0 .797 +(option in the shell v)144 273.6 R(ariable)-.25 E F1(name)3.297 E F0 +3.297(,i).18 G(nitializing)-3.297 E F1(name)3.657 E F0 .797 (if it does not e)3.477 F .796(xist, and the inde)-.15 F 3.296(xo)-.15 G -3.296(ft)-3.296 G .796(he ne)-3.296 F(xt)-.15 E(ar)144 679.2 Q .085 -(gument to be processed into the v)-.18 F(ariable)-.25 E F3(OPTIND)2.585 -E/F5 9/Times-Roman@0 SF(.)A F3(OPTIND)4.585 E F0 .085 -(is initialized to 1 each time the shell)2.335 F .846 -(or a shell script is in)144 691.2 R -.2(vo)-.4 G -.1(ke).2 G 3.345 -(d. When).1 F .845(an option requires an ar)3.345 F(gument,)-.18 E F1 +3.296(ft)-3.296 G .796(he ne)-3.296 F(xt)-.15 E(ar)144 285.6 Q .085 +(gument to be processed into the v)-.18 F(ariable)-.25 E/F3 9 +/Times-Bold@0 SF(OPTIND)2.585 E/F4 9/Times-Roman@0 SF(.)A F3(OPTIND) +4.585 E F0 .085(is initialized to 1 each time the shell)2.335 F .846 +(or a shell script is in)144 297.6 R -.2(vo)-.4 G -.1(ke).2 G 3.345 +(d. When).1 F .845(an option requires an ar)3.345 F(gument,)-.18 E F2 (getopts)3.345 E F0 .845(places that ar)3.345 F(gument)-.18 E .803 -(into the v)144 703.2 R(ariable)-.25 E F3(OPT)3.303 E(ARG)-.81 E F5(.)A +(into the v)144 309.6 R(ariable)-.25 E F3(OPT)3.303 E(ARG)-.81 E F4(.)A F0 .803(The shell does not reset)5.303 F F3(OPTIND)3.303 E F0 .804 (automatically; it must be manually)3.054 F .294 -(reset between multiple calls to)144 715.2 R F1(getopts)2.793 E F0 .293 +(reset between multiple calls to)144 321.6 R F2(getopts)2.793 E F0 .293 (within the same shell in)2.793 F -.2(vo)-.4 G .293(cation if a ne).2 F -2.793(ws)-.25 G .293(et of parameters)-2.793 F(is to be used.)144 727.2 -Q(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(58)198.165 E 0 Cg EP -%%Page: 59 59 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E 2.043(When the end of options is encountered,)144 84 R/F1 10 -/Times-Bold@0 SF(getopts)4.543 E F0 -.15(ex)4.543 G 2.043 -(its with a return v).15 F 2.044(alue greater than zero.)-.25 F/F2 9 -/Times-Bold@0 SF(OPTIND)144 96 Q F0(is set to the inde)2.25 E 2.5(xo) --.15 G 2.5(ft)-2.5 G(he \214rst non-option ar)-2.5 E(gument, and)-.18 E -/F3 10/Times-Italic@0 SF(name)2.5 E F0(is set to ?.)2.5 E F1(getopts)144 -120 Q F0 2.393(normally parses the positional parameters, b)4.893 F -2.392(ut if more ar)-.2 F 2.392(guments are gi)-.18 F -.15(ve)-.25 G -4.892(ni).15 G(n)-4.892 E F3(ar)4.892 E(gs)-.37 E F0(,).27 E F1(getopts) -144 132 Q F0(parses those instead.)2.5 E F1(getopts)144 156 Q F0 1.165 +2.793(ws)-.25 G .293(et of parameters)-2.793 F(is to be used.)144 333.6 +Q 2.043(When the end of options is encountered,)144 357.6 R F2(getopts) +4.543 E F0 -.15(ex)4.543 G 2.043(its with a return v).15 F 2.044 +(alue greater than zero.)-.25 F F3(OPTIND)144 369.6 Q F0 +(is set to the inde)2.25 E 2.5(xo)-.15 G 2.5(ft)-2.5 G +(he \214rst non-option ar)-2.5 E(gument, and)-.18 E F1(name)2.5 E F0 +(is set to ?.)2.5 E F2(getopts)144 393.6 Q F0 2.393 +(normally parses the positional parameters, b)4.893 F 2.392 +(ut if more ar)-.2 F 2.392(guments are gi)-.18 F -.15(ve)-.25 G 4.892 +(ni).15 G(n)-4.892 E F1(ar)4.892 E(gs)-.37 E F0(,).27 E F2(getopts)144 +405.6 Q F0(parses those instead.)2.5 E F2(getopts)144 429.6 Q F0 1.165 (can report errors in tw)3.665 F 3.665(ow)-.1 G 3.665(ays. If)-3.765 F -1.165(the \214rst character of)3.665 F F3(optstring)3.895 E F0 1.166 -(is a colon,)3.886 F F3(silent)4.006 E F0(error)4.346 E 1.071 -(reporting is used.)144 168 R 1.071 +1.165(the \214rst character of)3.665 F F1(optstring)3.895 E F0 1.166 +(is a colon,)3.886 F F1(silent)4.006 E F0(error)4.346 E 1.071 +(reporting is used.)144 441.6 R 1.071 (In normal operation, diagnostic messages are printed when in)6.071 F --.25(va)-.4 G 1.07(lid options or).25 F .393(missing option ar)144 180 R -.393(guments are encountered.)-.18 F .394(If the v)5.394 F(ariable)-.25 -E F2(OPTERR)2.894 E F0 .394(is set to 0, no error messages)2.644 F -(will be displayed, e)144 192 Q -.15(ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 -G(he \214rst character of)-2.5 E F3(optstring)2.73 E F0(is not a colon.) -2.72 E .667(If an in)144 216 R -.25(va)-.4 G .667(lid option is seen,) -.25 F F1(getopts)3.167 E F0 .667(places ? into)3.167 F F3(name)3.527 E -F0 .666(and, if not silent, prints an error message)3.347 F .399 -(and unsets)144 228 R F2(OPT)2.899 E(ARG)-.81 E/F4 9/Times-Roman@0 SF(.) -A F0(If)4.899 E F1(getopts)2.899 E F0 .399 -(is silent, the option character found is placed in)2.899 F F2(OPT)2.899 -E(ARG)-.81 E F0 .4(and no)2.65 F(diagnostic message is printed.)144 240 -Q 1.242(If a required ar)144 264 R 1.242(gument is not found, and)-.18 F -F1(getopts)3.741 E F0 1.241(is not silent, a question mark \()3.741 F F1 -(?).833 E F0 3.741(\)i).833 G 3.741(sp)-3.741 G 1.241(laced in)-3.741 F -F3(name)144 276 Q F0(,).18 E F2(OPT)2.734 E(ARG)-.81 E F0 .234 -(is unset, and a diagnostic message is printed.)2.484 F(If)5.234 E F1 -(getopts)2.734 E F0 .235(is silent, then a colon \()2.734 F F1(:).833 E -F0(\)).833 E(is placed in)144 288 Q F3(name)2.86 E F0(and)2.68 E F2(OPT) -2.5 E(ARG)-.81 E F0(is set to the option character found.)2.25 E F1 -(getopts)144 312 Q F0 .902 +-.25(va)-.4 G 1.07(lid options or).25 F .393(missing option ar)144 453.6 +R .393(guments are encountered.)-.18 F .394(If the v)5.394 F(ariable) +-.25 E F3(OPTERR)2.894 E F0 .394(is set to 0, no error messages)2.644 F +(will be displayed, e)144 465.6 Q -.15(ve)-.25 G 2.5(ni).15 G 2.5(ft) +-2.5 G(he \214rst character of)-2.5 E F1(optstring)2.73 E F0 +(is not a colon.)2.72 E .667(If an in)144 489.6 R -.25(va)-.4 G .667 +(lid option is seen,).25 F F2(getopts)3.167 E F0 .667(places ? into) +3.167 F F1(name)3.527 E F0 .666 +(and, if not silent, prints an error message)3.347 F .399(and unsets)144 +501.6 R F3(OPT)2.899 E(ARG)-.81 E F4(.)A F0(If)4.899 E F2(getopts)2.899 +E F0 .399(is silent, the option character found is placed in)2.899 F F3 +(OPT)2.899 E(ARG)-.81 E F0 .4(and no)2.65 F +(diagnostic message is printed.)144 513.6 Q 1.242(If a required ar)144 +537.6 R 1.242(gument is not found, and)-.18 F F2(getopts)3.741 E F0 +1.241(is not silent, a question mark \()3.741 F F2(?).833 E F0 3.741 +(\)i).833 G 3.741(sp)-3.741 G 1.241(laced in)-3.741 F F1(name)144 549.6 +Q F0(,).18 E F3(OPT)2.734 E(ARG)-.81 E F0 .234 +(is unset, and a diagnostic message is printed.)2.484 F(If)5.234 E F2 +(getopts)2.734 E F0 .235(is silent, then a colon \()2.734 F F2(:).833 E +F0(\)).833 E(is placed in)144 561.6 Q F1(name)2.86 E F0(and)2.68 E F3 +(OPT)2.5 E(ARG)-.81 E F0(is set to the option character found.)2.25 E F2 +(getopts)144 585.6 Q F0 .902 (returns true if an option, speci\214ed or unspeci\214ed, is found.) 3.402 F .902(It returns f)5.902 F .901(alse if the end of)-.1 F -(options is encountered or an error occurs.)144 324 Q F1(hash)108 340.8 -Q F0([)2.5 E F1(\255lr)A F0 2.5(][)C F1-2.5 E F3(\214lename)2.5 E -F0 2.5(][)C F1(\255dt)-2.5 E F0 2.5(][)C F3(name)-2.5 E F0(])A .858 -(Each time)144 352.8 R F1(hash)3.358 E F0 .858(is in)3.358 F -.2(vo)-.4 -G -.1(ke).2 G .858(d, the full pathname of the command).1 F F3(name) +(options is encountered or an error occurs.)144 597.6 Q F2(hash)108 +614.4 Q F0([)2.5 E F2(\255lr)A F0 2.5(][)C F2-2.5 E F1(\214lename) +2.5 E F0 2.5(][)C F2(\255dt)-2.5 E F0 2.5(][)C F1(name)-2.5 E F0(])A +.858(Each time)144 626.4 R F2(hash)3.358 E F0 .858(is in)3.358 F -.2(vo) +-.4 G -.1(ke).2 G .858(d, the full pathname of the command).1 F F1(name) 3.718 E F0 .858(is determined by searching)3.538 F .956 -(the directories in)144 364.8 R F1($P)3.456 E -.95(AT)-.74 G(H).95 E F0 +(the directories in)144 638.4 R F2($P)3.456 E -.95(AT)-.74 G(H).95 E F0 .956(and remembered.)3.456 F(An)5.956 E 3.456(yp)-.15 G(re)-3.456 E .956 -(viously-remembered pathname is discarded.)-.25 F .242(If the)144 376.8 -R F12.742 E F0 .243 -(option is supplied, no path search is performed, and)2.742 F F3 +(viously-remembered pathname is discarded.)-.25 F .242(If the)144 650.4 +R F22.742 E F0 .243 +(option is supplied, no path search is performed, and)2.742 F F1 (\214lename)4.653 E F0 .243(is used as the full \214lename)2.923 F 1.712 -(of the command.)144 388.8 R(The)6.712 E F14.212 E F0 1.711 +(of the command.)144 662.4 R(The)6.712 E F24.212 E F0 1.711 (option causes the shell to for)4.212 F 1.711 -(get all remembered locations.)-.18 F(The)6.711 E F14.211 E F0 -.833(option causes the shell to for)144 400.8 R .833 -(get the remembered location of each)-.18 F F3(name)3.333 E F0 5.833(.I) -C 3.333(ft)-5.833 G(he)-3.333 E F13.333 E F0 .833(option is sup-) -3.333 F .704(plied, the full pathname to which each)144 412.8 R F3(name) +(get all remembered locations.)-.18 F(The)6.711 E F24.211 E F0 +.833(option causes the shell to for)144 674.4 R .833 +(get the remembered location of each)-.18 F F1(name)3.333 E F0 5.833(.I) +C 3.333(ft)-5.833 G(he)-3.333 E F23.333 E F0 .833(option is sup-) +3.333 F .704(plied, the full pathname to which each)144 686.4 R F1(name) 3.204 E F0 .703(corresponds is printed.)3.204 F .703(If multiple)5.703 F -F3(name)3.203 E F0(ar)3.203 E(guments)-.18 E .795(are supplied with)144 -424.8 R F13.295 E F0 3.295(,t)C(he)-3.295 E F3(name)3.295 E F0 -.795(is printed before the hashed full pathname.)3.295 F(The)5.795 E F1 +F1(name)3.203 E F0(ar)3.203 E(guments)-.18 E .795(are supplied with)144 +698.4 R F23.295 E F0 3.295(,t)C(he)-3.295 E F1(name)3.295 E F0 +.795(is printed before the hashed full pathname.)3.295 F(The)5.795 E F2 3.295 E F0 .795(option causes)3.295 F .934 (output to be displayed in a format that may be reused as input.)144 -436.8 R .934(If no ar)5.934 F .934(guments are gi)-.18 F -.15(ve)-.25 G -.934(n, or if).15 F(only)144 448.8 Q F12.821 E F0 .321 +710.4 R .934(If no ar)5.934 F .934(guments are gi)-.18 F -.15(ve)-.25 G +.934(n, or if).15 F(only)144 722.4 Q F22.821 E F0 .321 (is supplied, information about remembered commands is printed.)2.821 F -.322(The return status is true)5.322 F(unless a)144 460.8 Q F3(name)2.86 -E F0(is not found or an in)2.68 E -.25(va)-.4 G(lid option is supplied.) -.25 E F1(help)108 477.6 Q F0([)2.5 E F1(\255dms)A F0 2.5(][)C F3 -(pattern)-2.5 E F0(])A .867(Display helpful information about b)144 -489.6 R .867(uiltin commands.)-.2 F(If)5.867 E F3(pattern)4.617 E F0 -.866(is speci\214ed,)3.607 F F1(help)3.366 E F0(gi)3.366 E -.15(ve)-.25 +.322(The return status is true)5.322 F(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(59)185.545 E 0 Cg EP +%%Page: 60 60 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(unless a)144 84 Q/F1 10/Times-Italic@0 SF(name)2.86 E F0 +(is not found or an in)2.68 E -.25(va)-.4 G(lid option is supplied.).25 +E/F2 10/Times-Bold@0 SF(help)108 100.8 Q F0([)2.5 E F2(\255dms)A F0 2.5 +(][)C F1(pattern)-2.5 E F0(])A .867(Display helpful information about b) +144 112.8 R .867(uiltin commands.)-.2 F(If)5.867 E F1(pattern)4.617 E F0 +.866(is speci\214ed,)3.607 F F2(help)3.366 E F0(gi)3.366 E -.15(ve)-.25 G 3.366(sd).15 G(etailed)-3.366 E .306(help on all commands matching)144 -501.6 R F3(pattern)2.806 E F0 2.807(;o).24 G .307 +124.8 R F1(pattern)2.806 E F0 2.807(;o).24 G .307 (therwise help for all the b)-2.807 F .307 -(uiltins and shell control struc-)-.2 F(tures is printed.)144 513.6 Q F1 -144 525.6 Q F0(Display a short description of each)24.74 E F3 -(pattern)2.5 E F1144 537.6 Q F0(Display the description of each) -21.97 E F3(pattern)2.5 E F0(in a manpage-lik)2.5 E 2.5(ef)-.1 G(ormat) --2.5 E F1144 549.6 Q F0 -(Display only a short usage synopsis for each)26.41 E F3(pattern)2.5 E -F0(The return status is 0 unless no command matches)144 566.4 Q F3 -(pattern)2.5 E F0(.).24 E F1(history [)108 583.2 Q F3(n)A F1(])A -(history \255c)108 595.2 Q(history \255d)108 607.2 Q F3(of)2.5 E(fset) --.18 E F1(history \255anrw)108 619.2 Q F0([)2.5 E F3(\214lename)A F0(])A -F1(history \255p)108 631.2 Q F3(ar)2.5 E(g)-.37 E F0([)2.5 E F3(ar)A 2.5 -(g.)-.37 G(..)-2.5 E F0(])A F1(history \255s)108 643.2 Q F3(ar)2.5 E(g) --.37 E F0([)2.5 E F3(ar)A 2.5(g.)-.37 G(..)-2.5 E F0(])A -.4(Wi)144 -655.2 S .752 +(uiltins and shell control struc-)-.2 F(tures is printed.)144 136.8 Q F2 +144 148.8 Q F0(Display a short description of each)24.74 E F1 +(pattern)2.5 E F2144 160.8 Q F0(Display the description of each) +21.97 E F1(pattern)2.5 E F0(in a manpage-lik)2.5 E 2.5(ef)-.1 G(ormat) +-2.5 E F2144 172.8 Q F0 +(Display only a short usage synopsis for each)26.41 E F1(pattern)2.5 E +F0(The return status is 0 unless no command matches)144 189.6 Q F1 +(pattern)2.5 E F0(.).24 E F2(history [)108 206.4 Q F1(n)A F2(])A +(history \255c)108 218.4 Q(history \255d)108 230.4 Q F1(of)2.5 E(fset) +-.18 E F2(history \255anrw)108 242.4 Q F0([)2.5 E F1(\214lename)A F0(])A +F2(history \255p)108 254.4 Q F1(ar)2.5 E(g)-.37 E F0([)2.5 E F1(ar)A 2.5 +(g.)-.37 G(..)-2.5 E F0(])A F2(history \255s)108 266.4 Q F1(ar)2.5 E(g) +-.37 E F0([)2.5 E F1(ar)A 2.5(g.)-.37 G(..)-2.5 E F0(])A -.4(Wi)144 +278.4 S .752 (th no options, display the command history list with line numbers.).4 F -.752(Lines listed with a)5.752 F F1(*)3.251 E F0(ha)3.251 E -.15(ve)-.2 -G .38(been modi\214ed.)144 667.2 R .38(An ar)5.38 F .38(gument of)-.18 F -F3(n)3.24 E F0 .38(lists only the last)3.12 F F3(n)3.24 E F0 2.88 -(lines. If)3.12 F .38(the shell v)2.88 F(ariable)-.25 E F2(HISTTIMEFOR-) -2.881 E(MA)144 679.2 Q(T)-.855 E F0 .265 -(is set and not null, it is used as a format string for)2.515 F F3 +.752(Lines listed with a)5.752 F F2(*)3.251 E F0(ha)3.251 E -.15(ve)-.2 +G .38(been modi\214ed.)144 290.4 R .38(An ar)5.38 F .38(gument of)-.18 F +F1(n)3.24 E F0 .38(lists only the last)3.12 F F1(n)3.24 E F0 2.88 +(lines. If)3.12 F .38(the shell v)2.88 F(ariable)-.25 E/F3 9 +/Times-Bold@0 SF(HISTTIMEFOR-)2.881 E(MA)144 302.4 Q(T)-.855 E F0 .265 +(is set and not null, it is used as a format string for)2.515 F F1 (strftime)2.764 E F0 .264(\(3\) to display the time stamp asso-)B 1.019 -(ciated with each displayed history entry)144 691.2 R 6.019(.N)-.65 G +(ciated with each displayed history entry)144 314.4 R 6.019(.N)-.65 G 3.519(oi)-6.019 G(nterv)-3.519 E 1.019 (ening blank is printed between the formatted)-.15 F .176 -(time stamp and the history line.)144 703.2 R(If)5.176 E F3(\214lename) +(time stamp and the history line.)144 326.4 R(If)5.176 E F1(\214lename) 2.676 E F0 .176 (is supplied, it is used as the name of the history \214le; if)2.676 F -(not, the v)144 715.2 Q(alue of)-.25 E F2(HISTFILE)2.5 E F0(is used.) +(not, the v)144 338.4 Q(alue of)-.25 E F3(HISTFILE)2.5 E F0(is used.) 2.25 E(Options, if supplied, ha)5 E .3 -.15(ve t)-.2 H(he follo).15 E -(wing meanings:)-.25 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(59) -198.165 E 0 Cg EP -%%Page: 60 60 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF144 84 Q F0 -(Clear the history list by deleting all the entries.)25.86 E F1144 -96 Q/F2 10/Times-Italic@0 SF(of)2.5 E(fset)-.18 E F0 -(Delete the history entry at position)180 108 Q F2(of)2.5 E(fset)-.18 E -F0(.)A F1144 120 Q F0 .598(Append the `)25.3 F(`ne)-.74 E(w')-.25 -E 3.098('h)-.74 G .598 +(wing meanings:)-.25 E F2144 350.4 Q F0 +(Clear the history list by deleting all the entries.)25.86 E F2144 +362.4 Q F1(of)2.5 E(fset)-.18 E F0(Delete the history entry at position) +180 374.4 Q F1(of)2.5 E(fset)-.18 E F0(.)A F2144 386.4 Q F0 .598 +(Append the `)25.3 F(`ne)-.74 E(w')-.25 E 3.098('h)-.74 G .598 (istory lines \(history lines entered since the be)-3.098 F .599 -(ginning of the current)-.15 F F1(bash)180 132 Q F0 -(session\) to the history \214le.)2.5 E F1144 144 Q F0 .854(Read \ -the history lines not already read from the history \214le into the cur\ -rent history list.)24.74 F .772 -(These are lines appended to the history \214le since the be)180 156 R -.773(ginning of the current)-.15 F F1(bash)3.273 E F0(ses-)3.273 E -(sion.)180 168 Q F1144 180 Q F0(Read the contents of the history \ -\214le and append them to the current history list.)25.86 E F1144 -192 Q F0(Write the current history list to the history \214le, o)23.08 E --.15(ve)-.15 G(rwriting the history \214le').15 E 2.5(sc)-.55 G -(ontents.)-2.5 E F1144 204 Q F0 .626 -(Perform history substitution on the follo)24.74 F(wing)-.25 E F2(ar) +(ginning of the current)-.15 F F2(bash)180 398.4 Q F0 +(session\) to the history \214le.)2.5 E F2144 410.4 Q F0 .854(Rea\ +d the history lines not already read from the history \214le into the c\ +urrent history list.)24.74 F .772 +(These are lines appended to the history \214le since the be)180 422.4 R +.773(ginning of the current)-.15 F F2(bash)3.273 E F0(ses-)3.273 E +(sion.)180 434.4 Q F2144 446.4 Q F0(Read the contents of the hist\ +ory \214le and append them to the current history list.)25.86 E F2 +144 458.4 Q F0(Write the current history list to the history \214le, o) +23.08 E -.15(ve)-.15 G(rwriting the history \214le').15 E 2.5(sc)-.55 G +(ontents.)-2.5 E F2144 470.4 Q F0 .626 +(Perform history substitution on the follo)24.74 F(wing)-.25 E F1(ar) 3.125 E(gs)-.37 E F0 .625(and display the result on the standard)3.125 F -2.975(output. Does)180 216 R .475 -(not store the results in the history list.)2.975 F(Each)5.475 E F2(ar) +2.975(output. Does)180 482.4 R .475 +(not store the results in the history list.)2.975 F(Each)5.475 E F1(ar) 2.975 E(g)-.37 E F0 .475(must be quoted to disable)2.975 F -(normal history e)180 228 Q(xpansion.)-.15 E F1144 240 Q F0 .363 -(Store the)26.41 F F2(ar)3.193 E(gs)-.37 E F0 .363 +(normal history e)180 494.4 Q(xpansion.)-.15 E F2144 506.4 Q F0 +.363(Store the)26.41 F F1(ar)3.193 E(gs)-.37 E F0 .363 (in the history list as a single entry)3.133 F 5.363(.T)-.65 G .362 -(he last command in the history list is)-5.363 F(remo)180 252 Q -.15(ve) --.15 G 2.5(db).15 G(efore the)-2.5 E F2(ar)2.83 E(gs)-.37 E F0 -(are added.)2.77 E .145(If the)144 268.8 R/F3 9/Times-Bold@0 SF -(HISTTIMEFORMA)2.645 E(T)-.855 E F0 -.25(va)2.395 G .145 +(he last command in the history list is)-5.363 F(remo)180 518.4 Q -.15 +(ve)-.15 G 2.5(db).15 G(efore the)-2.5 E F1(ar)2.83 E(gs)-.37 E F0 +(are added.)2.77 E .145(If the)144 535.2 R F3(HISTTIMEFORMA)2.645 E(T) +-.855 E F0 -.25(va)2.395 G .145 (riable is set, the time stamp information associated with each history) -.25 F .669(entry is written to the history \214le, mark)144 280.8 R .669 +.25 F .669(entry is written to the history \214le, mark)144 547.2 R .669 (ed with the history comment character)-.1 F 5.668(.W)-.55 G .668 -(hen the history)-5.668 F .955(\214le is read, lines be)144 292.8 R .956 +(hen the history)-5.668 F .955(\214le is read, lines be)144 559.2 R .956 (ginning with the history comment character follo)-.15 F .956 (wed immediately by a digit)-.25 F .416 -(are interpreted as timestamps for the pre)144 304.8 R .416 +(are interpreted as timestamps for the pre)144 571.2 R .416 (vious history line.)-.25 F .416(The return v)5.416 F .415 (alue is 0 unless an in)-.25 F -.25(va)-.4 G(lid).25 E .499(option is e\ ncountered, an error occurs while reading or writing the history \214le\ -, an in)144 316.8 R -.25(va)-.4 G(lid).25 E F2(of)3 E(fset)-.18 E F0(is) -3 E(supplied as an ar)144 328.8 Q(gument to)-.18 E F12.5 E F0 2.5 +, an in)144 583.2 R -.25(va)-.4 G(lid).25 E F1(of)3 E(fset)-.18 E F0(is) +3 E(supplied as an ar)144 595.2 Q(gument to)-.18 E F22.5 E F0 2.5 (,o)C 2.5(rt)-2.5 G(he history e)-2.5 E(xpansion supplied as an ar)-.15 -E(gument to)-.18 E F12.5 E F0 -.1(fa)2.5 G(ils.).1 E F1(jobs)108 -345.6 Q F0([)2.5 E F1(\255lnprs)A F0 2.5(][)C F2(jobspec)A F0(... ])2.5 -E F1(jobs \255x)108 357.6 Q F2(command)2.5 E F0([)2.5 E F2(ar)2.5 E(gs) --.37 E F0(... ])2.5 E(The \214rst form lists the acti)144 369.6 Q .3 --.15(ve j)-.25 H 2.5(obs. The).15 F(options ha)2.5 E .3 -.15(ve t)-.2 H -(he follo).15 E(wing meanings:)-.25 E F1144 381.6 Q F0 -(List process IDs in addition to the normal information.)27.52 E F1 -144 393.6 Q F0 .194(Display information only about jobs that ha) +E(gument to)-.18 E F22.5 E F0 -.1(fa)2.5 G(ils.).1 E F2(jobs)108 +612 Q F0([)2.5 E F2(\255lnprs)A F0 2.5(][)C F1(jobspec)A F0(... ])2.5 E +F2(jobs \255x)108 624 Q F1(command)2.5 E F0([)2.5 E F1(ar)2.5 E(gs)-.37 +E F0(... ])2.5 E(The \214rst form lists the acti)144 636 Q .3 -.15(ve j) +-.25 H 2.5(obs. The).15 F(options ha)2.5 E .3 -.15(ve t)-.2 H(he follo) +.15 E(wing meanings:)-.25 E F2144 648 Q F0 +(List process IDs in addition to the normal information.)27.52 E F2 +144 660 Q F0 .194(Display information only about jobs that ha) 24.74 F .494 -.15(ve c)-.2 H .193(hanged status since the user w).15 F -.193(as last noti-)-.1 F(\214ed of their status.)180 405.6 Q F1144 -417.6 Q F0(List only the process ID of the job')24.74 E 2.5(sp)-.55 G -(rocess group leader)-2.5 E(.)-.55 E F1144 429.6 Q F0 -(Display only running jobs.)25.86 E F1144 441.6 Q F0 -(Display only stopped jobs.)26.41 E(If)144 458.4 Q F2(jobspec)4.553 E F0 +.193(as last noti-)-.1 F(\214ed of their status.)180 672 Q F2144 +684 Q F0(List only the process ID of the job')24.74 E 2.5(sp)-.55 G +(rocess group leader)-2.5 E(.)-.55 E F2144 696 Q F0 +(Display only running jobs.)25.86 E F2144 708 Q F0 +(Display only stopped jobs.)26.41 E(If)144 724.8 Q F1(jobspec)4.553 E F0 .313(is gi)3.123 F -.15(ve)-.25 G .313 (n, output is restricted to information about that job).15 F 5.314(.T) --.4 G .314(he return status is 0 unless)-5.314 F(an in)144 470.4 Q -.25 -(va)-.4 G(lid option is encountered or an in).25 E -.25(va)-.4 G(lid).25 -E F2(jobspec)4.24 E F0(is supplied.)2.81 E .395(If the)144 487.2 R F1 -2.895 E F0 .394(option is supplied,)2.894 F F1(jobs)2.894 E F0 -.394(replaces an)2.894 F(y)-.15 E F2(jobspec)4.634 E F0 .394(found in) -3.204 F F2(command)3.094 E F0(or)3.664 E F2(ar)3.224 E(gs)-.37 E F0 .394 -(with the corre-)3.164 F(sponding process group ID, and e)144 499.2 Q --.15(xe)-.15 G(cutes).15 E F2(command)2.7 E F0(passing it)3.27 E F2(ar) +-.4 G .314(he return status is 0 unless)-5.314 F(GNU Bash 4.2)72 768 Q +(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(60)185.545 E 0 Cg EP +%%Page: 61 61 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(an in)144 84 Q -.25(va)-.4 G(lid option is encountered or an in) +.25 E -.25(va)-.4 G(lid).25 E/F1 10/Times-Italic@0 SF(jobspec)4.24 E F0 +(is supplied.)2.81 E .395(If the)144 100.8 R/F2 10/Times-Bold@0 SF +2.895 E F0 .394(option is supplied,)2.894 F F2(jobs)2.894 E F0 .394 +(replaces an)2.894 F(y)-.15 E F1(jobspec)4.634 E F0 .394(found in)3.204 +F F1(command)3.094 E F0(or)3.664 E F1(ar)3.224 E(gs)-.37 E F0 .394 +(with the corre-)3.164 F(sponding process group ID, and e)144 112.8 Q +-.15(xe)-.15 G(cutes).15 E F1(command)2.7 E F0(passing it)3.27 E F1(ar) 2.5 E(gs)-.37 E F0 2.5(,r).27 G(eturning its e)-2.5 E(xit status.)-.15 E -F1(kill)108 516 Q F0([)2.5 E F1A F2(sigspec)2.5 E F0(|)2.5 E F1 -2.5 E F2(signum)2.5 E F0(|)2.5 E F12.5 E F2(sigspec)A F0 2.5 -(][)C F2(pid)-2.5 E F0(|)2.5 E F2(jobspec)2.5 E F0 2.5(].)C(..)-2.5 E F1 -(kill \255l)108 528 Q F0([)2.5 E F2(sigspec)A F0(|)2.5 E F2 -.2(ex)2.5 G -(it_status).2 E F0(])A .119(Send the signal named by)144 540 R F2 -(sigspec)2.959 E F0(or)2.929 E F2(signum)2.959 E F0 .119 -(to the processes named by)2.939 F F2(pid)3.87 E F0(or)3.39 E F2 -(jobspec)2.62 E F0(.).31 E F2(sigspec)5.46 E F0(is)2.93 E .319 -(either a case-insensiti)144 552 R .619 -.15(ve s)-.25 H .319 -(ignal name such as).15 F F3(SIGKILL)2.819 E F0 .318 +F2(kill)108 129.6 Q F0([)2.5 E F2A F1(sigspec)2.5 E F0(|)2.5 E F2 +2.5 E F1(signum)2.5 E F0(|)2.5 E F22.5 E F1(sigspec)A F0 2.5 +(][)C F1(pid)-2.5 E F0(|)2.5 E F1(jobspec)2.5 E F0 2.5(].)C(..)-2.5 E F2 +(kill \255l)108 141.6 Q F0([)2.5 E F1(sigspec)A F0(|)2.5 E F1 -.2(ex)2.5 +G(it_status).2 E F0(])A .119(Send the signal named by)144 153.6 R F1 +(sigspec)2.959 E F0(or)2.929 E F1(signum)2.959 E F0 .119 +(to the processes named by)2.939 F F1(pid)3.87 E F0(or)3.39 E F1 +(jobspec)2.62 E F0(.).31 E F1(sigspec)5.46 E F0(is)2.93 E .319 +(either a case-insensiti)144 165.6 R .619 -.15(ve s)-.25 H .319 +(ignal name such as).15 F/F3 9/Times-Bold@0 SF(SIGKILL)2.819 E F0 .318 (\(with or without the)2.569 F F3(SIG)2.818 E F0 .318 -(pre\214x\) or a signal)2.568 F(number;)144 564 Q F2(signum)4.188 E F0 -1.349(is a signal number)4.168 F 6.349(.I)-.55 G(f)-6.349 E F2(sigspec) +(pre\214x\) or a signal)2.568 F(number;)144 177.6 Q F1(signum)4.188 E F0 +1.349(is a signal number)4.168 F 6.349(.I)-.55 G(f)-6.349 E F1(sigspec) 4.189 E F0 1.349(is not present, then)4.159 F F3(SIGTERM)3.849 E F0 -1.349(is assumed.)3.599 F(An)6.349 E(ar)144 576 Q .523(gument of)-.18 F -F13.023 E F0 .523(lists the signal names.)3.023 F .523(If an)5.523 -F 3.023(ya)-.15 G -.18(rg)-3.023 G .523(uments are supplied when).18 F -F13.023 E F0 .523(is gi)3.023 F -.15(ve)-.25 G .523(n, the names) -.15 F .28(of the signals corresponding to the ar)144 588 R .28 -(guments are listed, and the return status is 0.)-.18 F(The)5.28 E F2 --.2(ex)2.78 G(it_status).2 E F0(ar)144 600 Q .378(gument to)-.18 F F1 -2.878 E F0 .378 +1.349(is assumed.)3.599 F(An)6.349 E(ar)144 189.6 Q .523(gument of)-.18 +F F23.023 E F0 .523(lists the signal names.)3.023 F .523(If an) +5.523 F 3.023(ya)-.15 G -.18(rg)-3.023 G .523(uments are supplied when) +.18 F F23.023 E F0 .523(is gi)3.023 F -.15(ve)-.25 G .523 +(n, the names).15 F .28(of the signals corresponding to the ar)144 201.6 +R .28(guments are listed, and the return status is 0.)-.18 F(The)5.28 E +F1 -.2(ex)2.78 G(it_status).2 E F0(ar)144 213.6 Q .378(gument to)-.18 F +F22.878 E F0 .378 (is a number specifying either a signal number or the e)2.878 F .377 -(xit status of a process termi-)-.15 F .593(nated by a signal.)144 612 R -F1(kill)5.593 E F0 .593(returns true if at least one signal w)3.093 F +(xit status of a process termi-)-.15 F .593(nated by a signal.)144 225.6 +R F2(kill)5.593 E F0 .593(returns true if at least one signal w)3.093 F .593(as successfully sent, or f)-.1 F .594(alse if an error)-.1 F -(occurs or an in)144 624 Q -.25(va)-.4 G(lid option is encountered.).25 -E F1(let)108 640.8 Q F2(ar)2.5 E(g)-.37 E F0([)2.5 E F2(ar)A(g)-.37 E F0 -(...])2.5 E(Each)144 652.8 Q F2(ar)3.027 E(g)-.37 E F0 .197 +(occurs or an in)144 237.6 Q -.25(va)-.4 G(lid option is encountered.) +.25 E F2(let)108 254.4 Q F1(ar)2.5 E(g)-.37 E F0([)2.5 E F1(ar)A(g)-.37 +E F0(...])2.5 E(Each)144 266.4 Q F1(ar)3.027 E(g)-.37 E F0 .197 (is an arithmetic e)2.917 F .197(xpression to be e)-.15 F -.25(va)-.25 G .196(luated \(see).25 F F3 .196(ARITHMETIC EV)2.696 F(ALU)-1.215 E -.855 (AT)-.54 G(ION).855 E F0(abo)2.446 E -.15(ve)-.15 G 2.696(\). If).15 F -(the last)144 664.8 Q F2(ar)2.83 E(g)-.37 E F0 -.25(eva)2.72 G -(luates to 0,).25 E F1(let)2.5 E F0(returns 1; 0 is returned otherwise.) -2.5 E F1(local)108 681.6 Q F0([)2.5 E F2(option)A F0 2.5(][)C F2(name) --2.5 E F0([=)A F2(value)A F0 2.5(].)C(..])-2.5 E -.15(Fo)144 693.6 S +(the last)144 278.4 Q F1(ar)2.83 E(g)-.37 E F0 -.25(eva)2.72 G +(luates to 0,).25 E F2(let)2.5 E F0(returns 1; 0 is returned otherwise.) +2.5 E F2(local)108 295.2 Q F0([)2.5 E F1(option)A F0 2.5(][)C F1(name) +-2.5 E F0([=)A F1(value)A F0 2.5(].)C(..])-2.5 E -.15(Fo)144 307.2 S 2.56(re).15 G .06(ach ar)-2.56 F .06(gument, a local v)-.18 F .06 -(ariable named)-.25 F F2(name)2.92 E F0 .06(is created, and assigned) -2.74 F F2(value)2.56 E F0 5.06(.T).18 G(he)-5.06 E F2(option)2.56 E F0 -.06(can be)2.56 F(an)144 705.6 Q 3.153(yo)-.15 G 3.153(ft)-3.153 G .653 -(he options accepted by)-3.153 F F1(declar)3.153 E(e)-.18 E F0 5.652(.W) -C(hen)-5.652 E F1(local)3.152 E F0 .652 +(ariable named)-.25 F F1(name)2.92 E F0 .06(is created, and assigned) +2.74 F F1(value)2.56 E F0 5.06(.T).18 G(he)-5.06 E F1(option)2.56 E F0 +.06(can be)2.56 F(an)144 319.2 Q 3.153(yo)-.15 G 3.153(ft)-3.153 G .653 +(he options accepted by)-3.153 F F2(declar)3.153 E(e)-.18 E F0 5.652(.W) +C(hen)-5.652 E F2(local)3.152 E F0 .652 (is used within a function, it causes the v)3.152 F(ari-)-.25 E(able)144 -717.6 Q F2(name)3.72 E F0 .86(to ha)3.54 F 1.16 -.15(ve a v)-.2 H .861 +331.2 Q F1(name)3.72 E F0 .86(to ha)3.54 F 1.16 -.15(ve a v)-.2 H .861 (isible scope restricted to that function and its children.).15 F -.4 -(Wi)5.861 G .861(th no operands,).4 F F1(local)144 729.6 Q F0 1.165 +(Wi)5.861 G .861(th no operands,).4 F F2(local)144 343.2 Q F0 1.165 (writes a list of local v)3.665 F 1.165 (ariables to the standard output.)-.25 F 1.165(It is an error to use) -6.165 F F1(local)3.664 E F0 1.164(when not)3.664 F(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(60)198.165 E 0 Cg EP -%%Page: 61 61 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E .232(within a function.)144 84 R .233 -(The return status is 0 unless)5.232 F/F1 10/Times-Bold@0 SF(local)2.733 -E F0 .233(is used outside a function, an in)2.733 F -.25(va)-.4 G(lid) -.25 E/F2 10/Times-Italic@0 SF(name)3.093 E F0(is)2.913 E(supplied, or) -144 96 Q F2(name)2.5 E F0(is a readonly v)2.5 E(ariable.)-.25 E F1 -(logout)108 112.8 Q F0(Exit a login shell.)9.33 E F1(map\214le)108 129.6 -Q F0([)2.5 E F1A F2(count)2.5 E F0 2.5(][)C F1-2.5 E F2 -(origin)2.5 E F0 2.5(][)C F1-2.5 E F2(count)2.5 E F0 2.5(][)C F1 --2.5 E F0 2.5(][)C F1-2.5 E F2(fd)2.5 E F0 2.5(][)C F1 --2.5 E F2(callbac)2.5 E(k)-.2 E F0 2.5(][)C F1-2.5 E F2(quantum) -2.5 E F0 2.5(][)C F2(arr)-2.5 E(ay)-.15 E F0(])A F1 -.18(re)108 141.6 S -(adarray).18 E F0([)2.5 E F1A F2(count)2.5 E F0 2.5(][)C F1 --2.5 E F2(origin)2.5 E F0 2.5(][)C F1-2.5 E F2(count)2.5 E F0 2.5 -(][)C F1-2.5 E F0 2.5(][)C F1-2.5 E F2(fd)2.5 E F0 2.5(][)C -F1-2.5 E F2(callbac)2.5 E(k)-.2 E F0 2.5(][)C F1-2.5 E F2 -(quantum)2.5 E F0 2.5(][)C F2(arr)-2.5 E(ay)-.15 E F0(])A .351 -(Read lines from the standard input into the inde)144 153.6 R -.15(xe) --.15 G 2.851(da).15 G .351(rray v)-2.851 F(ariable)-.25 E F2(arr)2.85 E +6.165 F F2(local)3.664 E F0 1.164(when not)3.664 F .232 +(within a function.)144 355.2 R .233(The return status is 0 unless)5.232 +F F2(local)2.733 E F0 .233(is used outside a function, an in)2.733 F +-.25(va)-.4 G(lid).25 E F1(name)3.093 E F0(is)2.913 E(supplied, or)144 +367.2 Q F1(name)2.5 E F0(is a readonly v)2.5 E(ariable.)-.25 E F2 +(logout)108 384 Q F0(Exit a login shell.)9.33 E F2(map\214le)108 400.8 Q +F0([)2.5 E F2A F1(count)2.5 E F0 2.5(][)C F2-2.5 E F1 +(origin)2.5 E F0 2.5(][)C F2-2.5 E F1(count)2.5 E F0 2.5(][)C F2 +-2.5 E F0 2.5(][)C F2-2.5 E F1(fd)2.5 E F0 2.5(][)C F2 +-2.5 E F1(callbac)2.5 E(k)-.2 E F0 2.5(][)C F2-2.5 E F1(quantum) +2.5 E F0 2.5(][)C F1(arr)-2.5 E(ay)-.15 E F0(])A F2 -.18(re)108 412.8 S +(adarray).18 E F0([)2.5 E F2A F1(count)2.5 E F0 2.5(][)C F2 +-2.5 E F1(origin)2.5 E F0 2.5(][)C F2-2.5 E F1(count)2.5 E F0 2.5 +(][)C F2-2.5 E F0 2.5(][)C F2-2.5 E F1(fd)2.5 E F0 2.5(][)C +F2-2.5 E F1(callbac)2.5 E(k)-.2 E F0 2.5(][)C F2-2.5 E F1 +(quantum)2.5 E F0 2.5(][)C F1(arr)-2.5 E(ay)-.15 E F0(])A .351 +(Read lines from the standard input into the inde)144 424.8 R -.15(xe) +-.15 G 2.851(da).15 G .351(rray v)-2.851 F(ariable)-.25 E F1(arr)2.85 E (ay)-.15 E F0 2.85(,o).32 G 2.85(rf)-2.85 G .35(rom \214le descriptor) --2.85 F F2(fd)2.85 E F0 1.248(if the)144 165.6 R F13.748 E F0 -1.248(option is supplied.)3.748 F 1.249(The v)6.249 F(ariable)-.25 E/F3 -9/Times-Bold@0 SF(MAPFILE)3.749 E F0 1.249(is the def)3.499 F(ault)-.1 E -F2(arr)3.749 E(ay)-.15 E F0 6.249(.O)C 1.249(ptions, if supplied,)-6.249 -F(ha)144 177.6 Q .3 -.15(ve t)-.2 H(he follo).15 E(wing meanings:)-.25 E -F1144 189.6 Q F0(Cop)24.74 E 2.5(ya)-.1 G 2.5(tm)-2.5 G(ost)-2.5 E -F2(count)2.7 E F0 2.5(lines. If)3.18 F F2(count)2.5 E F0 -(is 0, all lines are copied.)2.5 E F1144 201.6 Q F0(Be)22.52 E -(gin assigning to)-.15 E F2(arr)2.83 E(ay)-.15 E F0(at inde)2.82 E(x) --.15 E F2(origin)2.5 E F0 5(.T).24 G(he def)-5 E(ault inde)-.1 E 2.5(xi) --.15 G 2.5(s0)-2.5 G(.)-2.5 E F1144 213.6 Q F0 -(Discard the \214rst)26.41 E F2(count)2.5 E F0(lines read.)2.5 E F1 -144 225.6 Q F0(Remo)26.97 E .3 -.15(ve a t)-.15 H(railing ne).15 E -(wline from each line read.)-.25 E F1144 237.6 Q F0 -(Read lines from \214le descriptor)24.74 E F2(fd)2.5 E F0 -(instead of the standard input.)2.5 E F1144 249.6 Q F0(Ev)23.08 E -(aluate)-.25 E F2(callbac)2.7 E(k)-.2 E F0(each time)3.17 E F2(quantum) -2.5 E F0(lines are read.)2.5 E(The)5 E F12.5 E F0 -(option speci\214es)2.5 E F2(quantum)2.5 E F0(.).32 E F1144 261.6 -Q F0(Specify the number of lines read between each call to)25.86 E F2 -(callbac)2.5 E(k)-.2 E F0(.).67 E(If)144 278.4 Q F12.968 E F0 .467 -(is speci\214ed without)2.967 F F12.967 E F0 2.967(,t)C .467 -(he def)-2.967 F .467(ault quantum is 5000.)-.1 F(When)5.467 E F2 +-2.85 F F1(fd)2.85 E F0 1.248(if the)144 436.8 R F23.748 E F0 +1.248(option is supplied.)3.748 F 1.249(The v)6.249 F(ariable)-.25 E F3 +(MAPFILE)3.749 E F0 1.249(is the def)3.499 F(ault)-.1 E F1(arr)3.749 E +(ay)-.15 E F0 6.249(.O)C 1.249(ptions, if supplied,)-6.249 F(ha)144 +448.8 Q .3 -.15(ve t)-.2 H(he follo).15 E(wing meanings:)-.25 E F2 +144 460.8 Q F0(Cop)24.74 E 2.5(ya)-.1 G 2.5(tm)-2.5 G(ost)-2.5 E F1 +(count)2.7 E F0 2.5(lines. If)3.18 F F1(count)2.5 E F0 +(is 0, all lines are copied.)2.5 E F2144 472.8 Q F0(Be)22.52 E +(gin assigning to)-.15 E F1(arr)2.83 E(ay)-.15 E F0(at inde)2.82 E(x) +-.15 E F1(origin)2.5 E F0 5(.T).24 G(he def)-5 E(ault inde)-.1 E 2.5(xi) +-.15 G 2.5(s0)-2.5 G(.)-2.5 E F2144 484.8 Q F0 +(Discard the \214rst)26.41 E F1(count)2.5 E F0(lines read.)2.5 E F2 +144 496.8 Q F0(Remo)26.97 E .3 -.15(ve a t)-.15 H(railing ne).15 E +(wline from each line read.)-.25 E F2144 508.8 Q F0 +(Read lines from \214le descriptor)24.74 E F1(fd)2.5 E F0 +(instead of the standard input.)2.5 E F2144 520.8 Q F0(Ev)23.08 E +(aluate)-.25 E F1(callbac)2.7 E(k)-.2 E F0(each time)3.17 E F1(quantum) +2.5 E F0(lines are read.)2.5 E(The)5 E F22.5 E F0 +(option speci\214es)2.5 E F1(quantum)2.5 E F0(.).32 E F2144 532.8 +Q F0(Specify the number of lines read between each call to)25.86 E F1 +(callbac)2.5 E(k)-.2 E F0(.).67 E(If)144 549.6 Q F22.968 E F0 .467 +(is speci\214ed without)2.967 F F22.967 E F0 2.967(,t)C .467 +(he def)-2.967 F .467(ault quantum is 5000.)-.1 F(When)5.467 E F1 (callbac)2.967 E(k)-.2 E F0 .467(is e)2.967 F -.25(va)-.25 G .467 -(luated, it is sup-).25 F .261(plied the inde)144 290.4 R 2.761(xo)-.15 +(luated, it is sup-).25 F .261(plied the inde)144 561.6 R 2.761(xo)-.15 G 2.761(ft)-2.761 G .261(he ne)-2.761 F .262(xt array element to be ass\ igned and the line to be assigned to that element)-.15 F .275 -(as additional ar)144 302.4 R(guments.)-.18 E F2(callbac)5.275 E(k)-.2 E +(as additional ar)144 573.6 R(guments.)-.18 E F1(callbac)5.275 E(k)-.2 E F0 .275(is e)2.775 F -.25(va)-.25 G .274 (luated after the line is read b).25 F .274 -(ut before the array element is)-.2 F(assigned.)144 314.4 Q -(If not supplied with an e)144 331.2 Q(xplicit origin,)-.15 E F1 -(map\214le)2.5 E F0(will clear)2.5 E F2(arr)2.5 E(ay)-.15 E F0 -(before assigning to it.)2.5 E F1(map\214le)144 348 Q F0 1.905 +(ut before the array element is)-.2 F(assigned.)144 585.6 Q +(If not supplied with an e)144 602.4 Q(xplicit origin,)-.15 E F2 +(map\214le)2.5 E F0(will clear)2.5 E F1(arr)2.5 E(ay)-.15 E F0 +(before assigning to it.)2.5 E F2(map\214le)144 619.2 Q F0 1.905 (returns successfully unless an in)4.405 F -.25(va)-.4 G 1.905 -(lid option or option ar).25 F 1.906(gument is supplied,)-.18 F F2(arr) -4.406 E(ay)-.15 E F0(is)4.406 E(in)144 360 Q -.25(va)-.4 G -(lid or unassignable, or if).25 E F2(arr)2.5 E(ay)-.15 E F0 +(lid option or option ar).25 F 1.906(gument is supplied,)-.18 F F1(arr) +4.406 E(ay)-.15 E F0(is)4.406 E(in)144 631.2 Q -.25(va)-.4 G +(lid or unassignable, or if).25 E F1(arr)2.5 E(ay)-.15 E F0 (is not an inde)2.5 E -.15(xe)-.15 G 2.5(da).15 G(rray)-2.5 E(.)-.65 E -F1(popd)108 376.8 Q F0<5bad>2.5 E F1(n)A F0 2.5(][)C(+)-2.5 E F2(n)A F0 -2.5(][)C-2.5 E F2(n)A F0(])A(Remo)144 388.8 Q -.15(ve)-.15 G 2.8(se) +F2(popd)108 648 Q F0<5bad>2.5 E F2(n)A F0 2.5(][)C(+)-2.5 E F1(n)A F0 +2.5(][)C-2.5 E F1(n)A F0(])A(Remo)144 660 Q -.15(ve)-.15 G 2.8(se) .15 G .3(ntries from the directory stack.)-2.8 F -.4(Wi)5.299 G .299 (th no ar).4 F .299(guments, remo)-.18 F -.15(ve)-.15 G 2.799(st).15 G .299(he top directory from the)-2.799 F 1.478(stack, and performs a)144 -400.8 R F1(cd)3.978 E F0 1.479(to the ne)3.978 F 3.979(wt)-.25 G 1.479 +672 R F2(cd)3.978 E F0 1.479(to the ne)3.978 F 3.979(wt)-.25 G 1.479 (op directory)-3.979 F 6.479(.A)-.65 G -.18(rg)-6.479 G 1.479 (uments, if supplied, ha).18 F 1.779 -.15(ve t)-.2 H 1.479(he follo).15 -F(wing)-.25 E(meanings:)144 412.8 Q F1144 424.8 Q F0 .551 +F(wing)-.25 E(meanings:)144 684 Q F2144 696 Q F0 .551 (Suppresses the normal change of directory when remo)24.74 F .551 (ving directories from the stack, so)-.15 F -(that only the stack is manipulated.)180 436.8 Q F1(+)144 448.8 Q F2(n)A -F0(Remo)25.3 E -.15(ve)-.15 G 2.64(st).15 G(he)-2.64 E F2(n)2.64 E F0 -.14(th entry counting from the left of the list sho)B .14(wn by)-.25 F -F1(dirs)2.64 E F0 2.64(,s)C .14(tarting with zero.)-2.64 F -.15(Fo)180 -460.8 S 2.5(re).15 G(xample:)-2.65 E/F4 10/Courier@0 SF(popd +0)2.5 E F0 -(remo)2.5 E -.15(ve)-.15 G 2.5(st).15 G(he \214rst directory)-2.5 E(,) --.65 E F4(popd +1)2.5 E F0(the second.)2.5 E F1144 472.8 Q F2(n)A F0 -(Remo)25.3 E -.15(ve)-.15 G 3.76(st).15 G(he)-3.76 E F2(n)3.76 E F0 -1.259(th entry counting from the right of the list sho)B 1.259(wn by) --.25 F F1(dirs)3.759 E F0 3.759(,s)C 1.259(tarting with)-3.759 F 2.5 -(zero. F)180 484.8 R(or e)-.15 E(xample:)-.15 E F4(popd -0)2.5 E F0 -(remo)2.5 E -.15(ve)-.15 G 2.5(st).15 G(he last directory)-2.5 E(,)-.65 -E F4(popd -1)2.5 E F0(the ne)2.5 E(xt to last.)-.15 E .643(If the)144 -501.6 R F1(popd)3.143 E F0 .643(command is successful, a)3.143 F F1 -(dirs)3.143 E F0 .644(is performed as well, and the return status is 0.) -3.143 F F1(popd)5.644 E F0 .416(returns f)144 513.6 R .416 -(alse if an in)-.1 F -.25(va)-.4 G .415 -(lid option is encountered, the directory stack is empty).25 F 2.915 +(that only the stack is manipulated.)180 708 Q(GNU Bash 4.2)72 768 Q +(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(61)185.545 E 0 Cg EP +%%Page: 62 62 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(+)144 84 Q/F2 10/Times-Italic@0 SF(n)A F0 +(Remo)25.3 E -.15(ve)-.15 G 2.64(st).15 G(he)-2.64 E F2(n)2.64 E F0 .14 +(th entry counting from the left of the list sho)B .14(wn by)-.25 F F1 +(dirs)2.64 E F0 2.64(,s)C .14(tarting with zero.)-2.64 F -.15(Fo)180 96 +S 2.5(re).15 G(xample:)-2.65 E/F3 10/Courier@0 SF(popd +0)2.5 E F0(remo) +2.5 E -.15(ve)-.15 G 2.5(st).15 G(he \214rst directory)-2.5 E(,)-.65 E +F3(popd +1)2.5 E F0(the second.)2.5 E F1144 108 Q F2(n)A F0(Remo) +25.3 E -.15(ve)-.15 G 3.76(st).15 G(he)-3.76 E F2(n)3.76 E F0 1.259 +(th entry counting from the right of the list sho)B 1.259(wn by)-.25 F +F1(dirs)3.759 E F0 3.759(,s)C 1.259(tarting with)-3.759 F 2.5(zero. F) +180 120 R(or e)-.15 E(xample:)-.15 E F3(popd -0)2.5 E F0(remo)2.5 E -.15 +(ve)-.15 G 2.5(st).15 G(he last directory)-2.5 E(,)-.65 E F3(popd -1)2.5 +E F0(the ne)2.5 E(xt to last.)-.15 E .643(If the)144 136.8 R F1(popd) +3.143 E F0 .643(command is successful, a)3.143 F F1(dirs)3.143 E F0 .644 +(is performed as well, and the return status is 0.)3.143 F F1(popd)5.644 +E F0 .416(returns f)144 148.8 R .416(alse if an in)-.1 F -.25(va)-.4 G +.415(lid option is encountered, the directory stack is empty).25 F 2.915 (,an)-.65 G(on-e)-2.915 E .415(xistent direc-)-.15 F -(tory stack entry is speci\214ed, or the directory change f)144 525.6 Q -(ails.)-.1 E F1(printf)108 542.4 Q F0([)2.5 E F1A F2(var)2.5 E F0 +(tory stack entry is speci\214ed, or the directory change f)144 160.8 Q +(ails.)-.1 E F1(printf)108 177.6 Q F0([)2.5 E F1A F2(var)2.5 E F0 (])A F2(format)2.5 E F0([)2.5 E F2(ar)A(guments)-.37 E F0(])A 1.436 -(Write the formatted)144 554.4 R F2(ar)3.936 E(guments)-.37 E F0 1.437 +(Write the formatted)144 189.6 R F2(ar)3.936 E(guments)-.37 E F0 1.437 (to the standard output under the control of the)3.936 F F2(format)3.937 E F0 6.437(.T)C(he)-6.437 E F13.937 E F0 .126 -(option causes the output to be assigned to the v)144 566.4 R(ariable) +(option causes the output to be assigned to the v)144 201.6 R(ariable) -.25 E F2(var)2.626 E F0 .126(rather than being printed to the standard) -2.626 F(output.)144 578.4 Q(The)144 602.4 Q F2(format)3.017 E F0 .517(i\ +2.626 F(output.)144 213.6 Q(The)144 237.6 Q F2(format)3.017 E F0 .517(i\ s a character string which contains three types of objects: plain chara\ cters, which are)3.017 F .704(simply copied to standard output, charact\ -er escape sequences, which are con)144 614.4 R -.15(ve)-.4 G .703 +er escape sequences, which are con)144 249.6 R -.15(ve)-.4 G .703 (rted and copied to).15 F .036(the standard output, and format speci\ -\214cations, each of which causes printing of the ne)144 626.4 R .037 -(xt successi)-.15 F -.15(ve)-.25 G F2(ar)144 638.4 Q(gument)-.37 E F0 +\214cations, each of which causes printing of the ne)144 261.6 R .037 +(xt successi)-.15 F -.15(ve)-.25 G F2(ar)144 273.6 Q(gument)-.37 E F0 5.532(.I)C 3.032(na)-5.532 G .532(ddition to the standard)-3.032 F F2 (printf)3.032 E F0 .532(\(1\) format speci\214cations,)B F1(printf)3.031 -E F0 .531(interprets the follo)3.031 F(w-)-.25 E(ing e)144 650.4 Q -(xtensions:)-.15 E F1(%b)144 662.4 Q F0(causes)20.44 E F1(printf)5.115 E +E F0 .531(interprets the follo)3.031 F(w-)-.25 E(ing e)144 285.6 Q +(xtensions:)-.15 E F1(%b)144 297.6 Q F0(causes)20.44 E F1(printf)5.115 E F0 2.615(to e)5.115 F 2.615 (xpand backslash escape sequences in the corresponding)-.15 F F2(ar) -5.115 E(gument)-.37 E F0(\(e)180 674.4 Q .608(xcept that)-.15 F F1(\\c) +5.115 E(gument)-.37 E F0(\(e)180 309.6 Q .608(xcept that)-.15 F F1(\\c) 3.108 E F0 .608(terminates output, backslashes in)3.108 F F1<5c08>3.108 E F0(,)A F1(\\")3.108 E F0 3.108(,a)C(nd)-3.108 E F1(\\?)3.108 E F0 .608 (are not remo)3.108 F -.15(ve)-.15 G .608(d, and octal).15 F(escapes be) -180 686.4 Q(ginning with)-.15 E F1(\\0)2.5 E F0 -(may contain up to four digits\).)2.5 E F1(%q)144 698.4 Q F0(causes) +180 321.6 Q(ginning with)-.15 E F1(\\0)2.5 E F0 +(may contain up to four digits\).)2.5 E F1(%q)144 333.6 Q F0(causes) 20.44 E F1(printf)2.51 E F0 .01(to output the corresponding)2.51 F F2 (ar)2.51 E(gument)-.37 E F0 .01(in a format that can be reused as shell) -2.51 F(input.)180 710.4 Q(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E -(61)198.165 E 0 Cg EP -%%Page: 62 62 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(%\()144 84 Q/F2 10/Times-Italic@0 SF -(datefmt)A F1(\)T)A F0(causes)180 96 Q F1(printf)4.404 E F0 1.904 +2.51 F(input.)180 345.6 Q F1(%\()144 357.6 Q F2(datefmt)A F1(\)T)A F0 +(causes)180 369.6 Q F1(printf)4.404 E F0 1.904 (to output the date-time string resulting from using)4.404 F F2(datefmt) -4.404 E F0 1.903(as a format)4.404 F .38(string for)180 108 R F2 +4.404 E F0 1.903(as a format)4.404 F .38(string for)180 381.6 R F2 (strftime)2.881 E F0 2.881(\(3\). The)B(corresponding)2.881 E F2(ar) 2.881 E(gument)-.37 E F0 .381(is an inte)2.881 F .381 (ger representing the number)-.15 F .458(of seconds since the epoch.)180 -120 R -1 -.8(Tw o)5.458 H .458(special ar)3.758 F .458(gument v)-.18 F +393.6 R -1 -.8(Tw o)5.458 H .458(special ar)3.758 F .458(gument v)-.18 F .458(alues may be used: -1 represents the)-.25 F -(current time, and -2 represents the time the shell w)180 132 Q(as in) --.1 E -.2(vo)-.4 G -.1(ke).2 G(d.).1 E(Ar)144 148.8 Q .463(guments to n\ +(current time, and -2 represents the time the shell w)180 405.6 Q(as in) +-.1 E -.2(vo)-.4 G -.1(ke).2 G(d.).1 E(Ar)144 422.4 Q .463(guments to n\ on-string format speci\214ers are treated as C constants, e)-.18 F .464 -(xcept that a leading plus or)-.15 F 1.259(minus sign is allo)144 160.8 +(xcept that a leading plus or)-.15 F 1.259(minus sign is allo)144 434.4 R 1.259 (wed, and if the leading character is a single or double quote, the v) --.25 F 1.258(alue is the)-.25 F(ASCII v)144 172.8 Q(alue of the follo) --.25 E(wing character)-.25 E(.)-.55 E(The)144 189.6 Q F2(format)3.423 E +-.25 F 1.258(alue is the)-.25 F(ASCII v)144 446.4 Q(alue of the follo) +-.25 E(wing character)-.25 E(.)-.55 E(The)144 463.2 Q F2(format)3.423 E F0 .923(is reused as necessary to consume all of the)3.423 F F2(ar)3.423 E(guments)-.37 E F0 5.923(.I)C 3.423(ft)-5.923 G(he)-3.423 E F2(format) -3.423 E F0 .924(requires more)3.424 F F2(ar)144 201.6 Q(guments)-.37 E +3.423 E F0 .924(requires more)3.424 F F2(ar)144 475.2 Q(guments)-.37 E F0 .033(than are supplied, the e)2.534 F .033 (xtra format speci\214cations beha)-.15 F .333 -.15(ve a)-.2 H 2.533(si) .15 G 2.533(faz)-2.533 G .033(ero v)-2.533 F .033(alue or null string,) --.25 F(as appropriate, had been supplied.)144 213.6 Q(The return v)5 E +-.25 F(as appropriate, had been supplied.)144 487.2 Q(The return v)5 E (alue is zero on success, non-zero on f)-.25 E(ailure.)-.1 E F1(pushd) -108 230.4 Q F0([)2.5 E F1A F0 2.5(][)C(+)-2.5 E F2(n)A F0 2.5(][)C --2.5 E F2(n)A F0(])A F1(pushd)108 242.4 Q F0([)2.5 E F1A F0 -2.5(][)C F2(dir)-2.5 E F0(])A .639(Adds a directory to the top of the d\ -irectory stack, or rotates the stack, making the ne)144 254.4 R 3.14(wt) --.25 G .64(op of the)-3.14 F 1.316(stack the current w)144 266.4 R 1.316 +108 504 Q F0([)2.5 E F1A F0 2.5(][)C(+)-2.5 E F2(n)A F0 2.5(][)C +-2.5 E F2(n)A F0(])A F1(pushd)108 516 Q F0([)2.5 E F1A F0 2.5 +(][)C F2(dir)-2.5 E F0(])A .639(Adds a directory to the top of the dire\ +ctory stack, or rotates the stack, making the ne)144 528 R 3.14(wt)-.25 +G .64(op of the)-3.14 F 1.316(stack the current w)144 540 R 1.316 (orking directory)-.1 F 6.316(.W)-.65 G 1.315(ith no ar)-6.716 F 1.315 (guments, e)-.18 F 1.315(xchanges the top tw)-.15 F 3.815(od)-.1 G 1.315 (irectories and)-3.815 F .871 -(returns 0, unless the directory stack is empty)144 278.4 R 5.871(.A) --.65 G -.18(rg)-5.871 G .872(uments, if supplied, ha).18 F 1.172 -.15 -(ve t)-.2 H .872(he follo).15 F .872(wing mean-)-.25 F(ings:)144 290.4 Q -F1144 302.4 Q F0 .902(Suppresses the normal change of directory w\ -hen adding directories to the stack, so that)24.74 F -(only the stack is manipulated.)180 314.4 Q F1(+)144 326.4 Q F2(n)A F0 -1.267(Rotates the stack so that the)25.3 F F2(n)3.767 E F0 1.268 +(returns 0, unless the directory stack is empty)144 552 R 5.871(.A)-.65 +G -.18(rg)-5.871 G .872(uments, if supplied, ha).18 F 1.172 -.15(ve t) +-.2 H .872(he follo).15 F .872(wing mean-)-.25 F(ings:)144 564 Q F1 +144 576 Q F0 .902(Suppresses the normal change of directory when \ +adding directories to the stack, so that)24.74 F +(only the stack is manipulated.)180 588 Q F1(+)144 600 Q F2(n)A F0 1.267 +(Rotates the stack so that the)25.3 F F2(n)3.767 E F0 1.268 (th directory \(counting from the left of the list sho)B 1.268(wn by) --.25 F F1(dirs)180 338.4 Q F0 2.5(,s)C -(tarting with zero\) is at the top.)-2.5 E F1144 350.4 Q F2(n)A F0 -.92(Rotates the stack so that the)25.3 F F2(n)3.42 E F0 .92 +-.25 F F1(dirs)180 612 Q F0 2.5(,s)C(tarting with zero\) is at the top.) +-2.5 E F1144 624 Q F2(n)A F0 .92(Rotates the stack so that the)25.3 +F F2(n)3.42 E F0 .92 (th directory \(counting from the right of the list sho)B .92(wn by)-.25 -F F1(dirs)180 362.4 Q F0 2.5(,s)C(tarting with zero\) is at the top.) --2.5 E F2(dir)144.35 374.4 Q F0(Adds)23.98 E F2(dir)3.137 E F0 .287 +F F1(dirs)180 636 Q F0 2.5(,s)C(tarting with zero\) is at the top.)-2.5 +E F2(dir)144.35 648 Q F0(Adds)23.98 E F2(dir)3.137 E F0 .287 (to the directory stack at the top, making it the ne)3.517 F 2.788(wc) -.25 G .288(urrent w)-2.788 F .288(orking directory as)-.1 F -(if it had been supplied as the ar)180 386.4 Q(gument to the)-.18 E F1 -(cd)2.5 E F0 -.2(bu)2.5 G(iltin.).2 E .489(If the)144 403.2 R F1(pushd) -2.989 E F0 .489(command is successful, a)2.989 F F1(dirs)2.988 E F0 .488 +(if it had been supplied as the ar)180 660 Q(gument to the)-.18 E F1(cd) +2.5 E F0 -.2(bu)2.5 G(iltin.).2 E .489(If the)144 676.8 R F1(pushd)2.989 +E F0 .489(command is successful, a)2.989 F F1(dirs)2.988 E F0 .488 (is performed as well.)2.988 F .488(If the \214rst form is used,)5.488 F -F1(pushd)2.988 E F0 1.039(returns 0 unless the cd to)144 415.2 R F2(dir) +F1(pushd)2.988 E F0 1.039(returns 0 unless the cd to)144 688.8 R F2(dir) 3.889 E F0 -.1(fa)4.269 G 3.539(ils. W).1 F 1.039(ith the second form,) -.4 F F1(pushd)3.54 E F0 1.04(returns 0 unless the directory)3.54 F .847 -(stack is empty)144 427.2 R 3.347(,an)-.65 G(on-e)-3.347 E .847(xistent\ +(stack is empty)144 700.8 R 3.347(,an)-.65 G(on-e)-3.347 E .847(xistent\ directory stack element is speci\214ed, or the directory change to the) --.15 F(speci\214ed ne)144 439.2 Q 2.5(wc)-.25 G(urrent directory f)-2.5 -E(ails.)-.1 E F1(pwd)108 456 Q F0([)2.5 E F1(\255LP)A F0(])A .844 -(Print the absolute pathname of the current w)144 468 R .845 +-.15 F(speci\214ed ne)144 712.8 Q 2.5(wc)-.25 G(urrent directory f)-2.5 +E(ails.)-.1 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G +(mber 24).15 E(62)185.545 E 0 Cg EP +%%Page: 63 63 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(pwd)108 84 Q F0([)2.5 E F1(\255LP)A F0(])A +.844(Print the absolute pathname of the current w)144 96 R .845 (orking directory)-.1 F 5.845(.T)-.65 G .845 (he pathname printed contains no)-5.845 F .182(symbolic links if the)144 -480 R F12.681 E F0 .181(option is supplied or the)2.681 F F1 .181 +108 R F12.681 E F0 .181(option is supplied or the)2.681 F F1 .181 (\255o ph)2.681 F(ysical)-.15 E F0 .181(option to the)2.681 F F1(set) 2.681 E F0 -.2(bu)2.681 G .181(iltin command is).2 F 3.263(enabled. If) -144 492 R(the)3.263 E F13.263 E F0 .763 +144 120 R(the)3.263 E F13.263 E F0 .763 (option is used, the pathname printed may contain symbolic links.)3.263 F .764(The return)5.764 F 1.36(status is 0 unless an error occurs while\ - reading the name of the current directory or an in)144 504 R -.25(va) --.4 G(lid).25 E(option is supplied.)144 516 Q F1 -.18(re)108 532.8 S(ad) -.18 E F0([)3.816 E F1(\255ers)A F0 3.816(][)C F1-3.816 E F2(aname) -3.816 E F0 3.816(][)C F1-3.816 E F2(delim)3.816 E F0 3.816(][)C F1 --3.816 E F2(te)3.816 E(xt)-.2 E F0 3.816(][)C F1-3.816 E F2 -(nc)3.816 E(har)-.15 E(s)-.1 E F0 3.817(][)C F1-3.817 E F2(nc) -3.817 E(har)-.15 E(s)-.1 E F0 3.817(][)C F1-3.817 E F2(pr)3.817 E -(ompt)-.45 E F0 3.817(][)C F1-3.817 E F2(timeout)3.817 E F0 3.817 -(][)C F1-3.817 E F2(fd)3.817 E F0(])A([)108 544.8 Q F2(name)A F0 -(...])2.5 E .516(One line is read from the standard input, or from the \ -\214le descriptor)144 556.8 R F2(fd)3.016 E F0 .516(supplied as an ar) -3.016 F .517(gument to)-.18 F(the)144 568.8 Q F12.539 E F0 .039 -(option, and the \214rst w)2.539 F .038(ord is assigned to the \214rst) --.1 F F2(name)2.538 E F0 2.538(,t).18 G .038(he second w)-2.538 F .038 -(ord to the second)-.1 F F2(name)2.538 E F0(,).18 E .42 -(and so on, with lefto)144 580.8 R -.15(ve)-.15 G 2.92(rw).15 G .42 -(ords and their interv)-3.02 F .42 + reading the name of the current directory or an in)144 132 R -.25(va) +-.4 G(lid).25 E(option is supplied.)144 144 Q F1 -.18(re)108 160.8 S(ad) +.18 E F0([)3.816 E F1(\255ers)A F0 3.816(][)C F1-3.816 E/F2 10 +/Times-Italic@0 SF(aname)3.816 E F0 3.816(][)C F1-3.816 E F2 +(delim)3.816 E F0 3.816(][)C F1-3.816 E F2(te)3.816 E(xt)-.2 E F0 +3.816(][)C F1-3.816 E F2(nc)3.816 E(har)-.15 E(s)-.1 E F0 3.817 +(][)C F1-3.817 E F2(nc)3.817 E(har)-.15 E(s)-.1 E F0 3.817(][)C F1 +-3.817 E F2(pr)3.817 E(ompt)-.45 E F0 3.817(][)C F1-3.817 E +F2(timeout)3.817 E F0 3.817(][)C F1-3.817 E F2(fd)3.817 E F0(])A +([)108 172.8 Q F2(name)A F0(...])2.5 E .516(One line is read from the s\ +tandard input, or from the \214le descriptor)144 184.8 R F2(fd)3.016 E +F0 .516(supplied as an ar)3.016 F .517(gument to)-.18 F(the)144 196.8 Q +F12.539 E F0 .039(option, and the \214rst w)2.539 F .038 +(ord is assigned to the \214rst)-.1 F F2(name)2.538 E F0 2.538(,t).18 G +.038(he second w)-2.538 F .038(ord to the second)-.1 F F2(name)2.538 E +F0(,).18 E .42(and so on, with lefto)144 208.8 R -.15(ve)-.15 G 2.92(rw) +.15 G .42(ords and their interv)-3.02 F .42 (ening separators assigned to the last)-.15 F F2(name)2.92 E F0 5.42(.I) -.18 G 2.92(ft)-5.42 G(here)-2.92 E .541(are fe)144 592.8 R .541(wer w) +.18 G 2.92(ft)-5.42 G(here)-2.92 E .541(are fe)144 220.8 R .541(wer w) -.25 F .541(ords read from the input stream than names, the remaining n\ -ames are assigned empty)-.1 F -.25(va)144 604.8 S 2.51(lues. The).25 F +ames are assigned empty)-.1 F -.25(va)144 232.8 S 2.51(lues. The).25 F .011(characters in)2.511 F/F3 9/Times-Bold@0 SF(IFS)2.511 E F0 .011 (are used to split the line into w)2.261 F 2.511(ords. The)-.1 F .011 (backslash character \()2.511 F F1(\\)A F0 2.511(\)m)C(ay)-2.511 E 1.891 -(be used to remo)144 616.8 R 2.191 -.15(ve a)-.15 H 2.191 -.15(ny s).15 +(be used to remo)144 244.8 R 2.191 -.15(ve a)-.15 H 2.191 -.15(ny s).15 H 1.891(pecial meaning for the ne).15 F 1.89 (xt character read and for line continuation.)-.15 F -(Options, if supplied, ha)144 628.8 Q .3 -.15(ve t)-.2 H(he follo).15 E -(wing meanings:)-.25 E F1144 640.8 Q F2(aname)2.5 E F0 1.049 -(The w)180 652.8 R 1.049 +(Options, if supplied, ha)144 256.8 Q .3 -.15(ve t)-.2 H(he follo).15 E +(wing meanings:)-.25 E F1144 268.8 Q F2(aname)2.5 E F0 1.049 +(The w)180 280.8 R 1.049 (ords are assigned to sequential indices of the array v)-.1 F(ariable) -.25 E F2(aname)3.55 E F0 3.55(,s).18 G 1.05(tarting at 0.)-3.55 F F2 -(aname)180.33 664.8 Q F0(is unset before an)2.68 E 2.5(yn)-.15 G .5 -.25 +(aname)180.33 292.8 Q F0(is unset before an)2.68 E 2.5(yn)-.15 G .5 -.25 (ew va)-2.5 H(lues are assigned.).25 E(Other)5 E F2(name)2.5 E F0(ar)2.5 -E(guments are ignored.)-.18 E F1144 676.8 Q F2(delim)2.5 E F0 -(The \214rst character of)180 688.8 Q F2(delim)2.5 E F0 +E(guments are ignored.)-.18 E F1144 304.8 Q F2(delim)2.5 E F0 +(The \214rst character of)180 316.8 Q F2(delim)2.5 E F0 (is used to terminate the input line, rather than ne)2.5 E(wline.)-.25 E -F1144 700.8 Q F0 .373 +F1144 328.8 Q F0 .373 (If the standard input is coming from a terminal,)25.86 F F1 -.18(re) 2.873 G(adline).18 E F0(\(see)2.873 E F3(READLINE)2.872 E F0(abo)2.622 E -.15(ve)-.15 G 2.872(\)i).15 G 2.872(su)-2.872 G(sed)-2.872 E .218 -(to obtain the line.)180 712.8 R .218 +(to obtain the line.)180 340.8 R .218 (Readline uses the current \(or def)5.218 F .218 (ault, if line editing w)-.1 F .218(as not pre)-.1 F(viously)-.25 E -(acti)180 724.8 Q -.15(ve)-.25 G 2.5(\)e).15 G(diting settings.)-2.5 E -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(62)198.165 E 0 Cg EP -%%Page: 63 63 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF144 84 Q/F2 10/Times-Italic@0 SF(te) -2.5 E(xt)-.2 E F0(If)10.78 E F1 -.18(re)2.716 G(adline).18 E F0 .216 -(is being used to read the line,)2.716 F F2(te)2.716 E(xt)-.2 E F0 .216 -(is placed into the editing b)2.716 F(uf)-.2 E .215(fer before edit-) --.25 F(ing be)180 96 Q(gins.)-.15 E F1144 108 Q F2(nc)2.5 E(har) --.15 E(s)-.1 E F1 -.18(re)180 120 S(ad).18 E F0 1.394 -(returns after reading)3.894 F F2(nc)3.894 E(har)-.15 E(s)-.1 E F0 1.395 -(characters rather than w)3.894 F 1.395(aiting for a complete line of) --.1 F(input, b)180 132 Q(ut honor a delimiter if fe)-.2 E(wer than)-.25 -E F2(nc)2.5 E(har)-.15 E(s)-.1 E F0 -(characters are read before the delimiter)2.5 E(.)-.55 E F1144 144 -Q F2(nc)2.5 E(har)-.15 E(s)-.1 E F1 -.18(re)180 156 S(ad).18 E F0 1.269 -(returns after reading e)3.77 F(xactly)-.15 E F2(nc)3.769 E(har)-.15 E -(s)-.1 E F0 1.269(characters rather than w)3.769 F 1.269 -(aiting for a complete)-.1 F .274 -(line of input, unless EOF is encountered or)180 168 R F1 -.18(re)2.775 -G(ad).18 E F0 .275(times out.)2.775 F .275(Delimiter characters encoun-) -5.275 F 1.003 -(tered in the input are not treated specially and do not cause)180 180 R -F1 -.18(re)3.502 G(ad).18 E F0 1.002(to return until)3.502 F F2(nc)3.502 -E(har)-.15 E(s)-.1 E F0(characters are read.)180 192 Q F1144 204 Q -F2(pr)2.5 E(ompt)-.45 E F0(Display)180 216 Q F2(pr)3.66 E(ompt)-.45 E F0 -1.161(on standard error)3.66 F 3.661(,w)-.4 G 1.161 +(acti)180 352.8 Q -.15(ve)-.25 G 2.5(\)e).15 G(diting settings.)-2.5 E +F1144 364.8 Q F2(te)2.5 E(xt)-.2 E F0(If)10.78 E F1 -.18(re)2.716 +G(adline).18 E F0 .216(is being used to read the line,)2.716 F F2(te) +2.716 E(xt)-.2 E F0 .216(is placed into the editing b)2.716 F(uf)-.2 E +.215(fer before edit-)-.25 F(ing be)180 376.8 Q(gins.)-.15 E F1144 +388.8 Q F2(nc)2.5 E(har)-.15 E(s)-.1 E F1 -.18(re)180 400.8 S(ad).18 E +F0 1.394(returns after reading)3.894 F F2(nc)3.894 E(har)-.15 E(s)-.1 E +F0 1.395(characters rather than w)3.894 F 1.395 +(aiting for a complete line of)-.1 F(input, b)180 412.8 Q +(ut honor a delimiter if fe)-.2 E(wer than)-.25 E F2(nc)2.5 E(har)-.15 E +(s)-.1 E F0(characters are read before the delimiter)2.5 E(.)-.55 E F1 +144 424.8 Q F2(nc)2.5 E(har)-.15 E(s)-.1 E F1 -.18(re)180 436.8 S +(ad).18 E F0 1.269(returns after reading e)3.77 F(xactly)-.15 E F2(nc) +3.769 E(har)-.15 E(s)-.1 E F0 1.269(characters rather than w)3.769 F +1.269(aiting for a complete)-.1 F .274 +(line of input, unless EOF is encountered or)180 448.8 R F1 -.18(re) +2.775 G(ad).18 E F0 .275(times out.)2.775 F .275 +(Delimiter characters encoun-)5.275 F 1.003 +(tered in the input are not treated specially and do not cause)180 460.8 +R F1 -.18(re)3.502 G(ad).18 E F0 1.002(to return until)3.502 F F2(nc) +3.502 E(har)-.15 E(s)-.1 E F0(characters are read.)180 472.8 Q F1 +144 484.8 Q F2(pr)2.5 E(ompt)-.45 E F0(Display)180 496.8 Q F2(pr)3.66 E +(ompt)-.45 E F0 1.161(on standard error)3.66 F 3.661(,w)-.4 G 1.161 (ithout a trailing ne)-3.661 F 1.161(wline, before attempting to read) --.25 F(an)180 228 Q 2.5(yi)-.15 G 2.5(nput. The)-2.5 F +-.25 F(an)180 508.8 Q 2.5(yi)-.15 G 2.5(nput. The)-2.5 F (prompt is displayed only if input is coming from a terminal.)2.5 E F1 -144 240 Q F0 .544(Backslash does not act as an escape character) +144 520.8 Q F0 .544(Backslash does not act as an escape character) 25.86 F 5.543(.T)-.55 G .543(he backslash is considered to be part of) --5.543 F(the line.)180 252 Q(In particular)5 E 2.5(,ab)-.4 G +-5.543 F(the line.)180 532.8 Q(In particular)5 E 2.5(,ab)-.4 G (ackslash-ne)-2.5 E(wline pair may not be used as a line continuation.) --.25 E F1144 264 Q F0(Silent mode.)26.41 E +-.25 E F1144 544.8 Q F0(Silent mode.)26.41 E (If input is coming from a terminal, characters are not echoed.)5 E F1 -144 276 Q F2(timeout)2.5 E F0(Cause)180 288 Q F1 -.18(re)3.548 G -(ad).18 E F0 1.048(to time out and return f)3.548 F 1.048 +144 556.8 Q F2(timeout)2.5 E F0(Cause)180 568.8 Q F1 -.18(re)3.548 +G(ad).18 E F0 1.048(to time out and return f)3.548 F 1.048 (ailure if a complete line of input is not read within)-.1 F F2(timeout) -180 300 Q F0(seconds.)3.497 E F2(timeout)5.997 E F0 .997 +180 580.8 Q F0(seconds.)3.497 E F2(timeout)5.997 E F0 .997 (may be a decimal number with a fractional portion follo)3.497 F(wing) --.25 E .576(the decimal point.)180 312 R .576(This option is only ef) +-.25 E .576(the decimal point.)180 592.8 R .576(This option is only ef) 5.576 F(fecti)-.25 E .876 -.15(ve i)-.25 H(f).15 E F1 -.18(re)3.076 G (ad).18 E F0 .576(is reading input from a terminal,)3.076 F .142 -(pipe, or other special \214le; it has no ef)180 324 R .142 +(pipe, or other special \214le; it has no ef)180 604.8 R .142 (fect when reading from re)-.25 F .142(gular \214les.)-.15 F(If)5.141 E -F2(timeout)2.641 E F0 .141(is 0,)2.641 F F1 -.18(re)180 336 S(ad).18 E +F2(timeout)2.641 E F0 .141(is 0,)2.641 F F1 -.18(re)180 616.8 S(ad).18 E F0 .61(returns immediately)3.11 F 3.11(,w)-.65 G .61 (ithout trying to read an)-3.11 F 3.11(yd)-.15 G 3.11(ata. The)-3.11 F --.15(ex)3.11 G .61(it statis is 0 if input is).15 F -.2(av)180 348 S +-.15(ex)3.11 G .61(it statis is 0 if input is).15 F -.2(av)180 628.8 S 1.224(ailable on the speci\214ed \214le descriptor)-.05 F 3.723(,n)-.4 G 1.223(on-zero otherwise.)-3.723 F 1.223(The e)6.223 F 1.223 -(xit status is greater)-.15 F(than 128 if the timeout is e)180 360 Q -(xceeded.)-.15 E F1144 372 Q F2(fd)2.5 E F0 +(xit status is greater)-.15 F(than 128 if the timeout is e)180 640.8 Q +(xceeded.)-.15 E F1144 652.8 Q F2(fd)2.5 E F0 (Read input from \214le descriptor)14.46 E F2(fd)2.5 E F0(.)A .191 -(If no)144 388.8 R F2(names)3.051 E F0 .191 +(If no)144 669.6 R F2(names)3.051 E F0 .191 (are supplied, the line read is assigned to the v)2.961 F(ariable)-.25 E -/F3 9/Times-Bold@0 SF(REPL)2.692 E(Y)-.828 E/F4 9/Times-Roman@0 SF(.)A -F0 .192(The return code is zero,)4.692 F 1.344 -(unless end-of-\214le is encountered,)144 400.8 R F1 -.18(re)3.844 G(ad) +F3(REPL)2.692 E(Y)-.828 E/F4 9/Times-Roman@0 SF(.)A F0 .192 +(The return code is zero,)4.692 F 1.344 +(unless end-of-\214le is encountered,)144 681.6 R F1 -.18(re)3.844 G(ad) .18 E F0 1.343 (times out \(in which case the return code is greater than)3.844 F .871 -(128\), a v)144 412.8 R .871 +(128\), a v)144 693.6 R .871 (ariable assignment error \(such as assigning to a readonly v)-.25 F .872(ariable\) occurs, or an in)-.25 F -.25(va)-.4 G(lid).25 E -(\214le descriptor is supplied as the ar)144 424.8 Q(gument to)-.18 E F1 -2.5 E F0(.)A F1 -.18(re)108 441.6 S(adonly).18 E F0([)2.5 E F1 -(\255aAf)A F0 2.5(][)C F1-2.5 E F0 2.5(][)C F2(name)-2.5 E F0([=)A -F2(wor)A(d)-.37 E F0 2.5(].)C(..])-2.5 E .77(The gi)144 453.6 R -.15(ve) --.25 G(n).15 E F2(names)3.27 E F0 .77(are mark)3.27 F .77 -(ed readonly; the v)-.1 F .77(alues of these)-.25 F F2(names)3.63 E F0 -.77(may not be changed by subse-)3.54 F 1.096(quent assignment.)144 -465.6 R 1.096(If the)6.096 F F13.596 E F0 1.097 -(option is supplied, the functions corresponding to the)3.596 F F2 -(names)3.597 E F0 1.097(are so)3.597 F(mark)144 477.6 Q 3.334(ed. The) --.1 F F13.334 E F0 .834(option restricts the v)3.334 F .834 +(\214le descriptor is supplied as the ar)144 705.6 Q(gument to)-.18 E F1 +2.5 E F0(.)A(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 +G(mber 24).15 E(63)185.545 E 0 Cg EP +%%Page: 64 64 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF -.18(re)108 84 S(adonly).18 E F0([)2.5 E F1 +(\255aAf)A F0 2.5(][)C F1-2.5 E F0 2.5(][)C/F2 10/Times-Italic@0 +SF(name)-2.5 E F0([=)A F2(wor)A(d)-.37 E F0 2.5(].)C(..])-2.5 E .77 +(The gi)144 96 R -.15(ve)-.25 G(n).15 E F2(names)3.27 E F0 .77(are mark) +3.27 F .77(ed readonly; the v)-.1 F .77(alues of these)-.25 F F2(names) +3.63 E F0 .77(may not be changed by subse-)3.54 F 1.096 +(quent assignment.)144 108 R 1.096(If the)6.096 F F13.596 E F0 +1.097(option is supplied, the functions corresponding to the)3.596 F F2 +(names)3.597 E F0 1.097(are so)3.597 F(mark)144 120 Q 3.334(ed. The)-.1 +F F13.334 E F0 .834(option restricts the v)3.334 F .834 (ariables to inde)-.25 F -.15(xe)-.15 G 3.334(da).15 G .834(rrays; the) -3.334 F F13.334 E F0 .834(option restricts the v)3.334 F(ari-) --.25 E .776(ables to associati)144 489.6 R 1.076 -.15(ve a)-.25 H 3.276 +-.25 E .776(ables to associati)144 132 R 1.076 -.15(ve a)-.25 H 3.276 (rrays. If).15 F .777(both options are supplied,)3.276 F F13.277 E F0(tak)3.277 E .777(es precedence.)-.1 F .777(If no)5.777 F F2(name) -3.637 E F0(ar)3.457 E(gu-)-.18 E .522(ments are gi)144 501.6 R -.15(ve) +3.637 E F0(ar)3.457 E(gu-)-.18 E .522(ments are gi)144 144 R -.15(ve) -.25 G .521(n, or if the).15 F F13.021 E F0 .521 (option is supplied, a list of all readonly names is printed.)3.021 F .521(The other)5.521 F .295(options may be used to restrict the output \ -to a subset of the set of readonly names.)144 513.6 R(The)5.296 E F1 -2.796 E F0(option)2.796 E .786 +to a subset of the set of readonly names.)144 156 R(The)5.296 E F1 +2.796 E F0(option)2.796 E .786 (causes output to be displayed in a format that may be reused as input.) -144 525.6 R .786(If a v)5.786 F .785(ariable name is fol-)-.25 F(lo)144 -537.6 Q .717(wed by =)-.25 F F2(wor)A(d)-.37 E F0 3.218(,t)C .718(he v) +144 168 R .786(If a v)5.786 F .785(ariable name is fol-)-.25 F(lo)144 +180 Q .717(wed by =)-.25 F F2(wor)A(d)-.37 E F0 3.218(,t)C .718(he v) -3.218 F .718(alue of the v)-.25 F .718(ariable is set to)-.25 F F2(wor) 3.218 E(d)-.37 E F0 5.718(.T)C .718(he return status is 0 unless an in) -5.718 F -.25(va)-.4 G(lid).25 E .26(option is encountered, one of the) -144 549.6 R F2(names)3.12 E F0 .26(is not a v)3.03 F .26(alid shell v) --.25 F .26(ariable name, or)-.25 F F12.76 E F0 .26 -(is supplied with a)2.76 F F2(name)144.36 561.6 Q F0 -(that is not a function.)2.68 E F1 -.18(re)108 578.4 S(tur).18 E(n)-.15 -E F0([)2.5 E F2(n)A F0(])A .02(Causes a function to stop e)144 590.4 R --.15(xe)-.15 G .02(cuting and return the v).15 F .021 -(alue speci\214ed by)-.25 F F2(n)2.881 E F0 .021(to its caller)2.761 F -5.021(.I)-.55 G(f)-5.021 E F2(n)2.881 E F0 .021(is omitted,)2.761 F .469 -(the return status is that of the last command e)144 602.4 R -.15(xe) +144 192 R F2(names)3.12 E F0 .26(is not a v)3.03 F .26(alid shell v)-.25 +F .26(ariable name, or)-.25 F F12.76 E F0 .26(is supplied with a) +2.76 F F2(name)144.36 204 Q F0(that is not a function.)2.68 E F1 -.18 +(re)108 220.8 S(tur).18 E(n)-.15 E F0([)2.5 E F2(n)A F0(])A .02 +(Causes a function to stop e)144 232.8 R -.15(xe)-.15 G .02 +(cuting and return the v).15 F .021(alue speci\214ed by)-.25 F F2(n) +2.881 E F0 .021(to its caller)2.761 F 5.021(.I)-.55 G(f)-5.021 E F2(n) +2.881 E F0 .021(is omitted,)2.761 F .469 +(the return status is that of the last command e)144 244.8 R -.15(xe) -.15 G .469(cuted in the function body).15 F 5.469(.I)-.65 G(f)-5.469 E F1 -.18(re)2.969 G(tur).18 E(n)-.15 E F0 .468(is used out-)2.969 F .466 -(side a function, b)144 614.4 R .466(ut during e)-.2 F -.15(xe)-.15 G +(side a function, b)144 256.8 R .466(ut during e)-.2 F -.15(xe)-.15 G .467(cution of a script by the).15 F F1(.)2.967 E F0(\()5.467 E F1(sour) A(ce)-.18 E F0 2.967(\)c)C .467(ommand, it causes the shell to)-2.967 F -.088(stop e)144 626.4 R -.15(xe)-.15 G .087 +.088(stop e)144 268.8 R -.15(xe)-.15 G .087 (cuting that script and return either).15 F F2(n)2.947 E F0 .087 (or the e)2.827 F .087(xit status of the last command e)-.15 F -.15(xe) --.15 G .087(cuted within).15 F .613(the script as the e)144 638.4 R .613 +-.15 G .087(cuted within).15 F .613(the script as the e)144 280.8 R .613 (xit status of the script.)-.15 F(If)5.613 E F2(n)3.113 E F0 .613 (is supplied, the return v)3.113 F .613 -(alue is its least signi\214cant 8)-.25 F 2.511(bits. The)144 650.4 R +(alue is its least signi\214cant 8)-.25 F 2.511(bits. The)144 292.8 R .011(return status is non-zero if)2.511 F F1 -.18(re)2.511 G(tur).18 E (n)-.15 E F0 .011(is supplied a non-numeric ar)2.511 F .01 -(gument, or is used outside)-.18 F 2.909(af)144 662.4 S .409 +(gument, or is used outside)-.18 F 2.909(af)144 304.8 S .409 (unction and not during e)-2.909 F -.15(xe)-.15 G .41 (cution of a script by).15 F F1(.)2.91 E F0(or)3.743 E F1(sour)2.91 E (ce)-.18 E F0 5.41(.A)C .71 -.15(ny c)-5.41 H .41 -(ommand associated with the).15 F F1(RETURN)144 674.4 Q F0(trap is e)2.5 +(ommand associated with the).15 F F1(RETURN)144 316.8 Q F0(trap is e)2.5 E -.15(xe)-.15 G(cuted before e).15 E -.15(xe)-.15 G -(cution resumes after the function or script.).15 E F1(set)108 691.2 Q +(cution resumes after the function or script.).15 E F1(set)108 333.6 Q F0([)2.5 E F1(\255\255abefhkmnptuvxBCEHPT)A F0 2.5(][)C F1-2.5 E F2(option\255name)2.5 E F0 2.5(][)C F2(ar)-2.5 E(g)-.37 E F0(...])2.5 E -F1(set)108 703.2 Q F0([)2.5 E F1(+abefhkmnptuvxBCEHPT)A F0 2.5(][)C F1 +F1(set)108 345.6 Q F0([)2.5 E F1(+abefhkmnptuvxBCEHPT)A F0 2.5(][)C F1 (+o)-2.5 E F2(option\255name)2.5 E F0 2.5(][)C F2(ar)-2.5 E(g)-.37 E F0 -(...])2.5 E -.4(Wi)144 715.2 S .836(thout options, the name and v).4 F +(...])2.5 E -.4(Wi)144 357.6 S .836(thout options, the name and v).4 F .835(alue of each shell v)-.25 F .835 (ariable are displayed in a format that can be)-.25 F .784 -(reused as input for setting or resetting the currently-set v)144 727.2 +(reused as input for setting or resetting the currently-set v)144 369.6 R 3.284(ariables. Read-only)-.25 F -.25(va)3.284 G .784 -(riables cannot be).25 F(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E -(63)198.165 E 0 Cg EP -%%Page: 64 64 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E 2.947(reset. In)144 84 R/F1 10/Times-Italic@0 SF .447(posix mode) +(riables cannot be).25 F 2.947(reset. In)144 381.6 R F2 .447(posix mode) 2.947 F F0 2.947(,o)C .447(nly shell v)-2.947 F .447 (ariables are listed.)-.25 F .447 (The output is sorted according to the current)5.447 F 3.53 -(locale. When)144 96 R 1.031(options are speci\214ed, the)3.53 F 3.531 -(ys)-.15 G 1.031(et or unset shell attrib)-3.531 F 3.531(utes. An)-.2 F -3.531(ya)-.15 G -.18(rg)-3.531 G 1.031(uments remaining).18 F 1.624 -(after option processing are treated as v)144 108 R 1.623 +(locale. When)144 393.6 R 1.031(options are speci\214ed, the)3.53 F +3.531(ys)-.15 G 1.031(et or unset shell attrib)-3.531 F 3.531(utes. An) +-.2 F 3.531(ya)-.15 G -.18(rg)-3.531 G 1.031(uments remaining).18 F +1.624(after option processing are treated as v)144 405.6 R 1.623 (alues for the positional parameters and are assigned, in)-.25 F(order) -144 120 Q 2.5(,t)-.4 G(o)-2.5 E/F2 10/Times-Bold@0 SF($1)2.5 E F0(,)A F2 -($2)2.5 E F0(,)A F2 2.5(... $)2.5 F F1(n)A F0 5(.O)C -(ptions, if speci\214ed, ha)-5 E .3 -.15(ve t)-.2 H(he follo).15 E -(wing meanings:)-.25 E F2144 132 Q F0 .539(Automatically mark v) -29.3 F .539 +144 417.6 Q 2.5(,t)-.4 G(o)-2.5 E F1($1)2.5 E F0(,)A F1($2)2.5 E F0(,)A +F1 2.5(... $)2.5 F F2(n)A F0 5(.O)C(ptions, if speci\214ed, ha)-5 E .3 +-.15(ve t)-.2 H(he follo).15 E(wing meanings:)-.25 E F1144 429.6 Q +F0 .539(Automatically mark v)29.3 F .539 (ariables and functions which are modi\214ed or created for e)-.25 F .54 -(xport to)-.15 F(the en)184 144 Q(vironment of subsequent commands.)-.4 -E F2144 156 Q F0 .132 +(xport to)-.15 F(the en)184 441.6 Q(vironment of subsequent commands.) +-.4 E F1144 453.6 Q F0 .132 (Report the status of terminated background jobs immediately)28.74 F 2.632(,r)-.65 G .131(ather than before the ne)-2.632 F(xt)-.15 E -(primary prompt.)184 168 Q(This is ef)5 E(fecti)-.25 E .3 -.15(ve o)-.25 -H(nly when job control is enabled.).15 E F2144 180 Q F0 .087 -(Exit immediately if a)29.86 F F1(pipeline)2.587 E F0 .087 -(\(which may consist of a single)2.587 F F1 .088(simple command)2.588 F -F0 .088(\), a)B F1(list)2.588 E F0 2.588(,o)C(r)-2.588 E(a)184 192 Q F1 -1.294(compound command)3.794 F F0(\(see)3.794 E/F3 9/Times-Bold@0 SF +(primary prompt.)184 465.6 Q(This is ef)5 E(fecti)-.25 E .3 -.15(ve o) +-.25 H(nly when job control is enabled.).15 E F1144 477.6 Q F0 +.087(Exit immediately if a)29.86 F F2(pipeline)2.587 E F0 .087 +(\(which may consist of a single)2.587 F F2 .088(simple command)2.588 F +F0 .088(\), a)B F2(list)2.588 E F0 2.588(,o)C(r)-2.588 E(a)184 489.6 Q +F2 1.294(compound command)3.794 F F0(\(see)3.794 E/F3 9/Times-Bold@0 SF 1.294(SHELL GRAMMAR)3.794 F F0(abo)3.544 E -.15(ve)-.15 G 3.793(\), e) .15 F 1.293(xits with a non-zero status.)-.15 F .079 -(The shell does not e)184 204 R .079(xit if the command that f)-.15 F -.08(ails is part of the command list immediately)-.1 F(follo)184 216 Q -1.655(wing a)-.25 F F2(while)4.155 E F0(or)4.155 E F2(until)4.155 E F0 +(The shell does not e)184 501.6 R .079(xit if the command that f)-.15 F +.08(ails is part of the command list immediately)-.1 F(follo)184 513.6 Q +1.655(wing a)-.25 F F1(while)4.155 E F0(or)4.155 E F1(until)4.155 E F0 -.1(ke)4.155 G(yw)-.05 E 1.655(ord, part of the test follo)-.1 F 1.654 -(wing the)-.25 F F2(if)4.154 E F0(or)4.154 E F2(elif)4.154 E F0(reserv) -4.154 E(ed)-.15 E -.1(wo)184 228 S .581(rds, part of an).1 F 3.081(yc) --.15 G .581(ommand e)-3.081 F -.15(xe)-.15 G .581(cuted in a).15 F F2 -(&&)3.081 E F0(or)3.081 E F2(||)3.081 E F0 .582(list e)3.082 F .582 -(xcept the command follo)-.15 F(wing)-.25 E .918(the \214nal)184 240 R -F2(&&)3.418 E F0(or)3.418 E F2(||)3.418 E F0 3.418(,a)C 1.218 -.15(ny c) +(wing the)-.25 F F1(if)4.154 E F0(or)4.154 E F1(elif)4.154 E F0(reserv) +4.154 E(ed)-.15 E -.1(wo)184 525.6 S .581(rds, part of an).1 F 3.081(yc) +-.15 G .581(ommand e)-3.081 F -.15(xe)-.15 G .581(cuted in a).15 F F1 +(&&)3.081 E F0(or)3.081 E F1(||)3.081 E F0 .582(list e)3.082 F .582 +(xcept the command follo)-.15 F(wing)-.25 E .918(the \214nal)184 537.6 R +F1(&&)3.418 E F0(or)3.418 E F1(||)3.418 E F0 3.418(,a)C 1.218 -.15(ny c) -3.418 H .918(ommand in a pipeline b).15 F .917 (ut the last, or if the command')-.2 F 3.417(sr)-.55 G(eturn)-3.417 E --.25(va)184 252 S .66(lue is being in).25 F -.15(ve)-.4 G .66(rted with) -.15 F F2(!)3.16 E F0 5.661(.I)C 3.161(fac)-5.661 G .661 +-.25(va)184 549.6 S .66(lue is being in).25 F -.15(ve)-.4 G .66 +(rted with).15 F F1(!)3.16 E F0 5.661(.I)C 3.161(fac)-5.661 G .661 (ompound command other than a subshell returns a)-3.161 F 1.113 -(non-zero status because a command f)184 264 R 1.112(ailed while)-.1 F -F23.612 E F0 -.1(wa)3.612 G 3.612(sb).1 G 1.112 -(eing ignored, the shell does)-3.612 F .177(not e)184 276 R 2.677 -(xit. A)-.15 F .177(trap on)2.677 F F2(ERR)2.677 E F0 2.677(,i)C 2.678 +(non-zero status because a command f)184 561.6 R 1.112(ailed while)-.1 F +F13.612 E F0 -.1(wa)3.612 G 3.612(sb).1 G 1.112 +(eing ignored, the shell does)-3.612 F .177(not e)184 573.6 R 2.677 +(xit. A)-.15 F .177(trap on)2.677 F F1(ERR)2.677 E F0 2.677(,i)C 2.678 (fs)-2.677 G .178(et, is e)-2.678 F -.15(xe)-.15 G .178 (cuted before the shell e).15 F 2.678(xits. This)-.15 F .178 -(option applies to)2.678 F .618(the shell en)184 288 R .617 +(option applies to)2.678 F .618(the shell en)184 585.6 R .617 (vironment and each subshell en)-.4 F .617(vironment separately \(see) --.4 F F3 .617(COMMAND EXE-)3.117 F .642(CUTION ENVIR)184 300 R(ONMENT) +-.4 F F3 .617(COMMAND EXE-)3.117 F .642(CUTION ENVIR)184 597.6 R(ONMENT) -.27 E F0(abo)2.893 E -.15(ve)-.15 G .643 (\), and may cause subshells to e).15 F .643(xit before e)-.15 F -.15 (xe)-.15 G .643(cuting all).15 F .016(the commands in the subshell.)184 -312 R .016(If a shell function e)5.016 F -.15(xe)-.15 G .015 -(cutes in a conte).15 F .015(xt where)-.15 F F22.515 E F0 .015 -(is being)2.515 F .347(ignored, e)184 324 R -.15(ve)-.25 G 2.847(ni).15 -G(f)-2.847 E F22.847 E F0 .347(is set, none of the commands e) +609.6 R .016(If a shell function e)5.016 F -.15(xe)-.15 G .015 +(cutes in a conte).15 F .015(xt where)-.15 F F12.515 E F0 .015 +(is being)2.515 F .347(ignored, e)184 621.6 R -.15(ve)-.25 G 2.847(ni) +.15 G(f)-2.847 E F12.847 E F0 .347(is set, none of the commands e) 2.847 F -.15(xe)-.15 G .348(cuted within the function body will).15 F -1.239(be af)184 336 R 1.239(fected by the)-.25 F F23.738 E F0 +1.239(be af)184 633.6 R 1.239(fected by the)-.25 F F13.738 E F0 3.738(setting. If)3.738 F 3.738(as)3.738 G 1.238(hell function sets) --3.738 F F23.738 E F0 1.238(while e)3.738 F -.15(xe)-.15 G 1.238 -(cuting in a conte).15 F(xt)-.15 E(where)184 348 Q F23.153 E F0 +-3.738 F F13.738 E F0 1.238(while e)3.738 F -.15(xe)-.15 G 1.238 +(cuting in a conte).15 F(xt)-.15 E(where)184 645.6 Q F13.153 E F0 .653(is ignored, that setting will not ha)3.153 F .954 -.15(ve a)-.2 H .954 -.15(ny e).15 H -.25(ff).15 G .654 (ect until the command containing).25 F(the function call completes.)184 -360 Q F2144 372 Q F0(Disable pathname e)30.97 E(xpansion.)-.15 E -F2144 384 Q F0 2.239(Remember the location of commands as the) +657.6 Q F1144 669.6 Q F0(Disable pathname e)30.97 E(xpansion.)-.15 +E F1144 681.6 Q F0 2.239(Remember the location of commands as the) 28.74 F 4.738(ya)-.15 G 2.238(re look)-4.738 F 2.238(ed up for e)-.1 F -.15(xe)-.15 G 4.738(cution. This).15 F(is)4.738 E(enabled by def)184 -396 Q(ault.)-.1 E F2144 408 Q F0 .513(All ar)28.74 F .514 +693.6 Q(ault.)-.1 E F1144 705.6 Q F0 .513(All ar)28.74 F .514 (guments in the form of assignment statements are placed in the en)-.18 F .514(vironment for a)-.4 F -(command, not just those that precede the command name.)184 420 Q F2 -144 432 Q F0 .149(Monitor mode.)25.97 F .149 -(Job control is enabled.)5.149 F .148(This option is on by def)5.149 F -.148(ault for interacti)-.1 F .448 -.15(ve s)-.25 H(hells).15 E .65 -(on systems that support it \(see)184 444 R F3 .651(JOB CONTR)3.151 F -(OL)-.27 E F0(abo)2.901 E -.15(ve)-.15 G 3.151(\). All).15 F .651 -(processes run in a separate)3.151 F .679(process group.)184 456 R .678 -(When a background job completes, the shell prints a line containing it\ -s)5.679 F -.15(ex)184 468 S(it status.).15 E F2144 480 Q F0 .652 -(Read commands b)28.74 F .652(ut do not e)-.2 F -.15(xe)-.15 G .652 -(cute them.).15 F .653(This may be used to check a shell script for) -5.652 F(syntax errors.)184 492 Q(This is ignored by interacti)5 E .3 --.15(ve s)-.25 H(hells.).15 E F2144 504 Q F1(option\255name)2.5 E -F0(The)184 516 Q F1(option\255name)2.5 E F0(can be one of the follo)2.5 -E(wing:)-.25 E F2(allexport)184 528 Q F0(Same as)224 540 Q F22.5 E -F0(.)A F2(braceexpand)184 552 Q F0(Same as)224 564 Q F22.5 E F0(.) -A F2(emacs)184 576 Q F0 .089 -(Use an emacs-style command line editing interf)13.9 F 2.589(ace. This) --.1 F .089(is enabled by def)2.589 F(ault)-.1 E .95 -(when the shell is interacti)224 588 R -.15(ve)-.25 G 3.45(,u).15 G .95 -(nless the shell is started with the)-3.45 F F2(\255\255noediting)3.45 E -F0 2.5(option. This)224 600 R(also af)2.5 E(fects the editing interf) --.25 E(ace used for)-.1 E F2 -.18(re)2.5 G(ad \255e).18 E F0(.)A F2(err) -184 612 Q(exit)-.18 E F0(Same as)11.31 E F22.5 E F0(.)A F2 -(errtrace)184 624 Q F0(Same as)5.03 E F22.5 E F0(.)A F2(functrace) -184 636 Q F0(Same as)224 648 Q F22.5 E F0(.)A F2(hashall)184 660 Q -F0(Same as)9.43 E F22.5 E F0(.)A F2(histexpand)184 672 Q F0 -(Same as)224 684 Q F22.5 E F0(.)A F2(history)184 696 Q F0 .587 -(Enable command history)10 F 3.087(,a)-.65 G 3.087(sd)-3.087 G .587 -(escribed abo)-3.087 F .887 -.15(ve u)-.15 H(nder).15 E F3(HIST)3.087 E -(OR)-.162 E(Y)-.315 E/F4 9/Times-Roman@0 SF(.)A F0 .587(This option is) -5.087 F(on by def)224 708 Q(ault in interacti)-.1 E .3 -.15(ve s)-.25 H -(hells.).15 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(64)198.165 E -0 Cg EP +(command, not just those that precede the command name.)184 717.6 Q +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(64)185.545 E 0 Cg EP %%Page: 65 65 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(ignor)184 84 Q(eeof)-.18 E F0 1.656(The ef) -224 96 R 1.656(fect is as if the shell command)-.25 F/F2 10/Courier@0 SF +-.35 E/F1 10/Times-Bold@0 SF144 84 Q F0 .149(Monitor mode.)25.97 F +.149(Job control is enabled.)5.149 F .148(This option is on by def)5.149 +F .148(ault for interacti)-.1 F .448 -.15(ve s)-.25 H(hells).15 E .65 +(on systems that support it \(see)184 96 R/F2 9/Times-Bold@0 SF .651 +(JOB CONTR)3.151 F(OL)-.27 E F0(abo)2.901 E -.15(ve)-.15 G 3.151 +(\). All).15 F .651(processes run in a separate)3.151 F .679 +(process group.)184 108 R .678(When a background job completes, the she\ +ll prints a line containing its)5.679 F -.15(ex)184 120 S(it status.).15 +E F1144 132 Q F0 .652(Read commands b)28.74 F .652(ut do not e)-.2 +F -.15(xe)-.15 G .652(cute them.).15 F .653 +(This may be used to check a shell script for)5.652 F(syntax errors.)184 +144 Q(This is ignored by interacti)5 E .3 -.15(ve s)-.25 H(hells.).15 E +F1144 156 Q/F3 10/Times-Italic@0 SF(option\255name)2.5 E F0(The) +184 168 Q F3(option\255name)2.5 E F0(can be one of the follo)2.5 E +(wing:)-.25 E F1(allexport)184 180 Q F0(Same as)224 192 Q F12.5 E +F0(.)A F1(braceexpand)184 204 Q F0(Same as)224 216 Q F12.5 E F0(.) +A F1(emacs)184 228 Q F0 .089 +(Use an emacs-style command line editing interf)13.9 F 2.589(ace. This) +-.1 F .089(is enabled by def)2.589 F(ault)-.1 E .95 +(when the shell is interacti)224 240 R -.15(ve)-.25 G 3.45(,u).15 G .95 +(nless the shell is started with the)-3.45 F F1(\255\255noediting)3.45 E +F0 2.5(option. This)224 252 R(also af)2.5 E(fects the editing interf) +-.25 E(ace used for)-.1 E F1 -.18(re)2.5 G(ad \255e).18 E F0(.)A F1(err) +184 264 Q(exit)-.18 E F0(Same as)11.31 E F12.5 E F0(.)A F1 +(errtrace)184 276 Q F0(Same as)5.03 E F12.5 E F0(.)A F1(functrace) +184 288 Q F0(Same as)224 300 Q F12.5 E F0(.)A F1(hashall)184 312 Q +F0(Same as)9.43 E F12.5 E F0(.)A F1(histexpand)184 324 Q F0 +(Same as)224 336 Q F12.5 E F0(.)A F1(history)184 348 Q F0 .587 +(Enable command history)10 F 3.087(,a)-.65 G 3.087(sd)-3.087 G .587 +(escribed abo)-3.087 F .887 -.15(ve u)-.15 H(nder).15 E F2(HIST)3.087 E +(OR)-.162 E(Y)-.315 E/F4 9/Times-Roman@0 SF(.)A F0 .587(This option is) +5.087 F(on by def)224 360 Q(ault in interacti)-.1 E .3 -.15(ve s)-.25 H +(hells.).15 E F1(ignor)184 372 Q(eeof)-.18 E F0 1.656(The ef)224 384 R +1.656(fect is as if the shell command)-.25 F/F5 10/Courier@0 SF (IGNOREEOF=10)4.157 E F0 1.657(had been e)4.157 F -.15(xe)-.15 G(cuted) -.15 E(\(see)224 108 Q F1(Shell V)2.5 E(ariables)-.92 E F0(abo)2.5 E -.15 -(ve)-.15 G(\).).15 E F1 -.1(ke)184 120 S(yw).1 E(ord)-.1 E F0(Same as) -224 132 Q F12.5 E F0(.)A F1(monitor)184 144 Q F0(Same as)5.56 E F1 -2.5 E F0(.)A F1(noclob)184 156 Q(ber)-.1 E F0(Same as)224 168 Q F1 -2.5 E F0(.)A F1(noexec)184 180 Q F0(Same as)11.12 E F12.5 E -F0(.)A F1(noglob)184 192 Q F0(Same as)11.1 E F12.5 E F0(.)A F1 -(nolog)184 204 Q F0(Currently ignored.)16.66 E F1(notify)184 216 Q F0 -(Same as)15 E F12.5 E F0(.)A F1(nounset)184 228 Q F0(Same as)6.66 -E F12.5 E F0(.)A F1(onecmd)184 240 Q F0(Same as)6.67 E F12.5 -E F0(.)A F1(ph)184 252 Q(ysical)-.15 E F0(Same as)5.14 E F12.5 E -F0(.)A F1(pipefail)184 264 Q F0 1.03(If set, the return v)7.77 F 1.029 +.15 E(\(see)224 396 Q F1(Shell V)2.5 E(ariables)-.92 E F0(abo)2.5 E -.15 +(ve)-.15 G(\).).15 E F1 -.1(ke)184 408 S(yw).1 E(ord)-.1 E F0(Same as) +224 420 Q F12.5 E F0(.)A F1(monitor)184 432 Q F0(Same as)5.56 E F1 +2.5 E F0(.)A F1(noclob)184 444 Q(ber)-.1 E F0(Same as)224 456 Q F1 +2.5 E F0(.)A F1(noexec)184 468 Q F0(Same as)11.12 E F12.5 E +F0(.)A F1(noglob)184 480 Q F0(Same as)11.1 E F12.5 E F0(.)A F1 +(nolog)184 492 Q F0(Currently ignored.)16.66 E F1(notify)184 504 Q F0 +(Same as)15 E F12.5 E F0(.)A F1(nounset)184 516 Q F0(Same as)6.66 +E F12.5 E F0(.)A F1(onecmd)184 528 Q F0(Same as)6.67 E F12.5 +E F0(.)A F1(ph)184 540 Q(ysical)-.15 E F0(Same as)5.14 E F12.5 E +F0(.)A F1(pipefail)184 552 Q F0 1.03(If set, the return v)7.77 F 1.029 (alue of a pipeline is the v)-.25 F 1.029 -(alue of the last \(rightmost\) com-)-.25 F 1.136(mand to e)224 276 R +(alue of the last \(rightmost\) com-)-.25 F 1.136(mand to e)224 564 R 1.136 (xit with a non-zero status, or zero if all commands in the pipeline) --.15 F -.15(ex)224 288 S(it successfully).15 E 5(.T)-.65 G -(his option is disabled by def)-5 E(ault.)-.1 E F1(posix)184 300 Q F0 +-.15 F -.15(ex)224 576 S(it successfully).15 E 5(.T)-.65 G +(his option is disabled by def)-5 E(ault.)-.1 E F1(posix)184 588 Q F0 2.091(Change the beha)17.77 F 2.091(vior of)-.2 F F1(bash)4.591 E F0 2.091(where the def)4.591 F 2.091(ault operation dif)-.1 F 2.091 -(fers from the)-.25 F(POSIX standard to match the standard \()224 312 Q -/F3 10/Times-Italic@0 SF(posix mode)A F0(\).)A F1(pri)184 324 Q(vileged) --.1 E F0(Same as)224 336 Q F12.5 E F0(.)A F1 -.1(ve)184 348 S -(rbose).1 E F0(Same as)7.33 E F12.5 E F0(.)A F1(vi)184 360 Q F0 -1.465(Use a vi-style command line editing interf)32.22 F 3.966 -(ace. This)-.1 F 1.466(also af)3.966 F 1.466(fects the editing)-.25 F -(interf)224 372 Q(ace used for)-.1 E F1 -.18(re)2.5 G(ad \255e).18 E F0 -(.)A F1(xtrace)184 384 Q F0(Same as)13.35 E F12.5 E F0(.)A(If)184 -402 Q F13.053 E F0 .553(is supplied with no)3.053 F F3 -(option\255name)3.053 E F0 3.053(,t)C .553(he v)-3.053 F .552 -(alues of the current options are printed.)-.25 F(If)5.552 E F1(+o)184 -414 Q F0 1.071(is supplied with no)3.571 F F3(option\255name)3.571 E F0 -3.571(,as)C 1.071(eries of)-3.571 F F1(set)3.572 E F0 1.072 -(commands to recreate the current)3.572 F -(option settings is displayed on the standard output.)184 426 Q F1 -144 438 Q F0 -.45(Tu)28.74 G 1.072(rn on).45 F F3(privile)4.822 E -.1 -(ge)-.4 G(d).1 E F0 3.572(mode. In)4.342 F 1.072(this mode, the)3.572 F -/F4 9/Times-Bold@0 SF($ENV)3.572 E F0(and)3.322 E F4($B)3.572 E(ASH_ENV) --.27 E F0 1.071(\214les are not pro-)3.322 F 1.5 -(cessed, shell functions are not inherited from the en)184 450 R 1.501 -(vironment, and the)-.4 F F4(SHELLOPTS)4.001 E/F5 9/Times-Roman@0 SF(,)A -F4 -.27(BA)184 462 S(SHOPTS).27 E F5(,)A F4(CDP)2.775 E -.855(AT)-.666 G -(H).855 E F5(,)A F0(and)2.775 E F4(GLOBIGNORE)3.025 E F0 -.25(va)2.775 G +(fers from the)-.25 F(POSIX standard to match the standard \()224 600 Q +F3(posix mode)A F0(\).)A F1(pri)184 612 Q(vileged)-.1 E F0(Same as)224 +624 Q F12.5 E F0(.)A F1 -.1(ve)184 636 S(rbose).1 E F0(Same as) +7.33 E F12.5 E F0(.)A F1(vi)184 648 Q F0 1.465 +(Use a vi-style command line editing interf)32.22 F 3.966(ace. This)-.1 +F 1.466(also af)3.966 F 1.466(fects the editing)-.25 F(interf)224 660 Q +(ace used for)-.1 E F1 -.18(re)2.5 G(ad \255e).18 E F0(.)A F1(xtrace)184 +672 Q F0(Same as)13.35 E F12.5 E F0(.)A(If)184 690 Q F13.053 +E F0 .553(is supplied with no)3.053 F F3(option\255name)3.053 E F0 3.053 +(,t)C .553(he v)-3.053 F .552(alues of the current options are printed.) +-.25 F(If)5.552 E F1(+o)184 702 Q F0 1.071(is supplied with no)3.571 F +F3(option\255name)3.571 E F0 3.571(,as)C 1.071(eries of)-3.571 F F1(set) +3.572 E F0 1.072(commands to recreate the current)3.572 F +(option settings is displayed on the standard output.)184 714 Q +(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E +(65)185.545 E 0 Cg EP +%%Page: 66 66 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF144 84 Q F0 -.45(Tu)28.74 G 1.072 +(rn on).45 F/F2 10/Times-Italic@0 SF(privile)4.822 E -.1(ge)-.4 G(d).1 E +F0 3.572(mode. In)4.342 F 1.072(this mode, the)3.572 F/F3 9/Times-Bold@0 +SF($ENV)3.572 E F0(and)3.322 E F3($B)3.572 E(ASH_ENV)-.27 E F0 1.071 +(\214les are not pro-)3.322 F 1.5 +(cessed, shell functions are not inherited from the en)184 96 R 1.501 +(vironment, and the)-.4 F F3(SHELLOPTS)4.001 E/F4 9/Times-Roman@0 SF(,)A +F3 -.27(BA)184 108 S(SHOPTS).27 E F4(,)A F3(CDP)2.775 E -.855(AT)-.666 G +(H).855 E F4(,)A F0(and)2.775 E F3(GLOBIGNORE)3.025 E F0 -.25(va)2.775 G .524(riables, if the).25 F 3.024(ya)-.15 G .524(ppear in the en)-3.024 F -(vironment,)-.4 E .379(are ignored.)184 474 R .379 +(vironment,)-.4 E .379(are ignored.)184 120 R .379 (If the shell is started with the ef)5.379 F(fecti)-.25 E .679 -.15 (ve u)-.25 H .38(ser \(group\) id not equal to the real).15 F .462 -(user \(group\) id, and the)184 486 R F12.961 E F0 .461 +(user \(group\) id, and the)184 132 R F12.961 E F0 .461 (option is not supplied, these actions are tak)2.961 F .461 -(en and the ef)-.1 F(fec-)-.25 E(ti)184 498 Q .694 -.15(ve u)-.25 H .394 +(en and the ef)-.1 F(fec-)-.25 E(ti)184 144 Q .694 -.15(ve u)-.25 H .394 (ser id is set to the real user id.).15 F .395(If the)5.395 F F1 2.895 E F0 .395(option is supplied at startup, the ef)2.895 F(fecti)-.25 -E -.15(ve)-.25 G .387(user id is not reset.)184 510 R -.45(Tu)5.387 G +E -.15(ve)-.25 G .387(user id is not reset.)184 156 R -.45(Tu)5.387 G .387(rning this option of).45 F 2.886(fc)-.25 G .386(auses the ef)-2.886 F(fecti)-.25 E .686 -.15(ve u)-.25 H .386(ser and group ids to be).15 F -(set to the real user and group ids.)184 522 Q F1144 534 Q F0 +(set to the real user and group ids.)184 168 Q F1144 180 Q F0 (Exit after reading and e)30.97 E -.15(xe)-.15 G(cuting one command.).15 -E F1144 546 Q F0 -.35(Tr)28.74 G .043(eat unset v).35 F .044(aria\ +E F1144 192 Q F0 -.35(Tr)28.74 G .043(eat unset v).35 F .044(aria\ bles and parameters other than the special parameters "@" and "*" as an) --.25 F .183(error when performing parameter e)184 558 R 2.683 +-.25 F .183(error when performing parameter e)184 204 R 2.683 (xpansion. If)-.15 F -.15(ex)2.683 G .182 (pansion is attempted on an unset v).15 F(ari-)-.25 E .746 -(able or parameter)184 570 R 3.246(,t)-.4 G .746 +(able or parameter)184 216 R 3.246(,t)-.4 G .746 (he shell prints an error message, and, if not interacti)-3.246 F -.15 (ve)-.25 G 3.246(,e).15 G .746(xits with a)-3.396 F(non-zero status.)184 -582 Q F1144 594 Q F0(Print shell input lines as the)29.3 E 2.5(ya) --.15 G(re read.)-2.5 E F1144 606 Q F0 .315(After e)29.3 F .315 -(xpanding each)-.15 F F3 .315(simple command)2.815 F F0(,)A F1 -.25(fo) +228 Q F1144 240 Q F0(Print shell input lines as the)29.3 E 2.5(ya) +-.15 G(re read.)-2.5 E F1144 252 Q F0 .315(After e)29.3 F .315 +(xpanding each)-.15 F F2 .315(simple command)2.815 F F0(,)A F1 -.25(fo) 2.815 G(r).25 E F0(command,)2.815 E F1(case)2.815 E F0(command,)2.815 E -F1(select)2.815 E F0(command,)2.815 E 1.235(or arithmetic)184 618 R F1 +F1(select)2.815 E F0(command,)2.815 E 1.235(or arithmetic)184 264 R F1 -.25(fo)3.736 G(r).25 E F0 1.236(command, display the e)3.736 F 1.236 -(xpanded v)-.15 F 1.236(alue of)-.25 F F4(PS4)3.736 E F5(,)A F0(follo) -3.486 E 1.236(wed by the com-)-.25 F(mand and its e)184 630 Q +(xpanded v)-.15 F 1.236(alue of)-.25 F F3(PS4)3.736 E F4(,)A F0(follo) +3.486 E 1.236(wed by the com-)-.25 F(mand and its e)184 276 Q (xpanded ar)-.15 E(guments or associated w)-.18 E(ord list.)-.1 E F1 -144 642 Q F0 2.579(The shell performs brace e)27.63 F 2.578 +144 288 Q F0 2.579(The shell performs brace e)27.63 F 2.578 (xpansion \(see)-.15 F F1 2.578(Brace Expansion)5.078 F F0(abo)5.078 E --.15(ve)-.15 G 5.078(\). This).15 F 2.578(is on by)5.078 F(def)184 654 Q -(ault.)-.1 E F1144 666 Q F0 .213(If set,)27.08 F F1(bash)2.713 E +-.15(ve)-.15 G 5.078(\). This).15 F 2.578(is on by)5.078 F(def)184 300 Q +(ault.)-.1 E F1144 312 Q F0 .213(If set,)27.08 F F1(bash)2.713 E F0 .213(does not o)2.713 F -.15(ve)-.15 G .214(rwrite an e).15 F .214 (xisting \214le with the)-.15 F F1(>)2.714 E F0(,)A F1(>&)2.714 E F0 2.714(,a)C(nd)-2.714 E F1(<>)2.714 E F0 .214(redirection opera-)2.714 F -3.054(tors. This)184 678 R .553(may be o)3.053 F -.15(ve)-.15 G .553 +3.054(tors. This)184 324 R .553(may be o)3.053 F -.15(ve)-.15 G .553 (rridden when creating output \214les by using the redirection opera-) -.15 F(tor)184 690 Q F1(>|)2.5 E F0(instead of)2.5 E F1(>)2.5 E F0(.)A F1 -144 702 Q F0 .103(If set, an)27.63 F 2.603(yt)-.15 G .103(rap on) +.15 F(tor)184 336 Q F1(>|)2.5 E F0(instead of)2.5 E F1(>)2.5 E F0(.)A F1 +144 348 Q F0 .103(If set, an)27.63 F 2.603(yt)-.15 G .103(rap on) -2.603 F F1(ERR)2.603 E F0 .104 (is inherited by shell functions, command substitutions, and com-)2.603 -F .839(mands e)184 714 R -.15(xe)-.15 G .839(cuted in a subshell en).15 +F .839(mands e)184 360 R -.15(xe)-.15 G .839(cuted in a subshell en).15 F 3.339(vironment. The)-.4 F F1(ERR)3.338 E F0 .838 -(trap is normally not inherited in)3.338 F(such cases.)184 726 Q -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(65)198.165 E 0 Cg EP -%%Page: 66 66 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF144 84 Q F0(Enable)26.52 E F1(!)3.031 -E F0 .531(style history substitution.)5.531 F .531 -(This option is on by def)5.531 F .532(ault when the shell is inter)-.1 -F(-)-.2 E(acti)184 96 Q -.15(ve)-.25 G(.).15 E F1144 108 Q F0 .96 +(trap is normally not inherited in)3.338 F(such cases.)184 372 Q F1 +144 384 Q F0(Enable)26.52 E F1(!)3.031 E F0 .531 +(style history substitution.)5.531 F .531(This option is on by def)5.531 +F .532(ault when the shell is inter)-.1 F(-)-.2 E(acti)184 396 Q -.15 +(ve)-.25 G(.).15 E F1144 408 Q F0 .96 (If set, the shell does not resolv)28.19 F 3.459(es)-.15 G .959 (ymbolic links when e)-3.459 F -.15(xe)-.15 G .959 (cuting commands such as).15 F F1(cd)3.459 E F0 2.821 -(that change the current w)184 120 R 2.822(orking directory)-.1 F 7.822 +(that change the current w)184 420 R 2.822(orking directory)-.1 F 7.822 (.I)-.65 G 5.322(tu)-7.822 G 2.822(ses the ph)-5.322 F 2.822 -(ysical directory structure)-.05 F 2.686(instead. By)184 132 R(def)2.686 +(ysical directory structure)-.05 F 2.686(instead. By)184 432 R(def)2.686 E(ault,)-.1 E F1(bash)2.686 E F0(follo)2.686 E .186 (ws the logical chain of directories when performing com-)-.25 F -(mands which change the current directory)184 144 Q(.)-.65 E F1144 -156 Q F0 .89(If set, an)27.63 F 3.39(yt)-.15 G .89(raps on)-3.39 F F1 +(mands which change the current directory)184 444 Q(.)-.65 E F1144 +456 Q F0 .89(If set, an)27.63 F 3.39(yt)-.15 G .89(raps on)-3.39 F F1 (DEB)3.39 E(UG)-.1 E F0(and)3.39 E F1(RETURN)3.39 E F0 .89 (are inherited by shell functions, command)3.39 F 1.932 -(substitutions, and commands e)184 168 R -.15(xe)-.15 G 1.932 +(substitutions, and commands e)184 468 R -.15(xe)-.15 G 1.932 (cuted in a subshell en).15 F 4.432(vironment. The)-.4 F F1(DEB)4.432 E -(UG)-.1 E F0(and)4.432 E F1(RETURN)184 180 Q F0 -(traps are normally not inherited in such cases.)2.5 E F1144 192 Q +(UG)-.1 E F0(and)4.432 E F1(RETURN)184 480 Q F0 +(traps are normally not inherited in such cases.)2.5 E F1144 492 Q F0 .4(If no ar)28.6 F .401(guments follo)-.18 F 2.901(wt)-.25 G .401 (his option, then the positional parameters are unset.)-2.901 F -(Otherwise,)5.401 E(the positional parameters are set to the)184 204 Q -/F2 10/Times-Italic@0 SF(ar)2.5 E(g)-.37 E F0(s, e)A -.15(ve)-.25 G 2.5 -(ni).15 G 2.5(fs)-2.5 G(ome of them be)-2.5 E(gin with a)-.15 E F1 -2.5 E F0(.)A F1144 216 Q F0 1.945 -(Signal the end of options, cause all remaining)34.3 F F2(ar)4.444 E(g) --.37 E F0 4.444(st)C 4.444(ob)-4.444 G 4.444(ea)-4.444 G 1.944 -(ssigned to the positional)-4.444 F 3.445(parameters. The)184 228 R F1 -3.445 E F0(and)3.445 E F13.445 E F0 .945 +(Otherwise,)5.401 E(the positional parameters are set to the)184 504 Q +F2(ar)2.5 E(g)-.37 E F0(s, e)A -.15(ve)-.25 G 2.5(ni).15 G 2.5(fs)-2.5 G +(ome of them be)-2.5 E(gin with a)-.15 E F12.5 E F0(.)A F1144 +516 Q F0 1.945(Signal the end of options, cause all remaining)34.3 F F2 +(ar)4.444 E(g)-.37 E F0 4.444(st)C 4.444(ob)-4.444 G 4.444(ea)-4.444 G +1.944(ssigned to the positional)-4.444 F 3.445(parameters. The)184 528 R +F13.445 E F0(and)3.445 E F13.445 E F0 .945 (options are turned of)3.445 F 3.445(f. If)-.25 F .946(there are no) 3.445 F F2(ar)3.446 E(g)-.37 E F0 .946(s, the positional)B -(parameters remain unchanged.)184 240 Q .425(The options are of)144 -256.8 R 2.925(fb)-.25 G 2.925(yd)-2.925 G(ef)-2.925 E .425 +(parameters remain unchanged.)184 540 Q .425(The options are of)144 +556.8 R 2.925(fb)-.25 G 2.925(yd)-2.925 G(ef)-2.925 E .425 (ault unless otherwise noted.)-.1 F .425 (Using + rather than \255 causes these options)5.425 F .177 -(to be turned of)144 268.8 R 2.677(f. The)-.25 F .178 +(to be turned of)144 568.8 R 2.677(f. The)-.25 F .178 (options can also be speci\214ed as ar)2.678 F .178(guments to an in) -.18 F -.2(vo)-.4 G .178(cation of the shell.).2 F(The)5.178 E .066 -(current set of options may be found in)144 280.8 R F1<24ad>2.566 E F0 +(current set of options may be found in)144 580.8 R F1<24ad>2.566 E F0 5.066(.T)C .066(he return status is al)-5.066 F -.1(wa)-.1 G .066 (ys true unless an in).1 F -.25(va)-.4 G .066(lid option).25 F -(is encountered.)144 292.8 Q F1(shift)108 309.6 Q F0([)2.5 E F2(n)A F0 -(])A .428(The positional parameters from)144 321.6 R F2(n)2.928 E F0 +(is encountered.)144 592.8 Q F1(shift)108 609.6 Q F0([)2.5 E F2(n)A F0 +(])A .428(The positional parameters from)144 621.6 R F2(n)2.928 E F0 .429(+1 ... are renamed to)B F1 .429($1 ....)2.929 F F0 -.15(Pa)5.429 G -.429(rameters represented by the num-).15 F(bers)144 333.6 Q F1($#)2.583 +.429(rameters represented by the num-).15 F(bers)144 633.6 Q F1($#)2.583 E F0(do)2.583 E .083(wn to)-.25 F F1($#)2.583 E F0A F2(n)A F0 .083 (+1 are unset.)B F2(n)5.443 E F0 .083(must be a non-ne)2.823 F -.05(ga) -.15 G(ti).05 E .382 -.15(ve n)-.25 H .082(umber less than or equal to) .15 F F1($#)2.582 E F0 5.082(.I)C(f)-5.082 E F2(n)2.942 E F0 .06 -(is 0, no parameters are changed.)144 345.6 R(If)5.06 E F2(n)2.92 E F0 +(is 0, no parameters are changed.)144 645.6 R(If)5.06 E F2(n)2.92 E F0 .06(is not gi)2.8 F -.15(ve)-.25 G .06(n, it is assumed to be 1.).15 F (If)5.06 E F2(n)2.92 E F0 .06(is greater than)2.8 F F1($#)2.56 E F0 2.56 -(,t)C(he)-2.56 E .144(positional parameters are not changed.)144 357.6 R +(,t)C(he)-2.56 E .144(positional parameters are not changed.)144 657.6 R .144(The return status is greater than zero if)5.144 F F2(n)3.003 E F0 .143(is greater than)2.883 F F1($#)2.643 E F0 -(or less than zero; otherwise 0.)144 369.6 Q F1(shopt)108 386.4 Q F0([) +(or less than zero; otherwise 0.)144 669.6 Q F1(shopt)108 686.4 Q F0([) 2.5 E F1(\255pqsu)A F0 2.5(][)C F1-2.5 E F0 2.5(][)C F2(optname) --2.5 E F0(...])2.5 E -.8(To)144 398.4 S .222(ggle the v).8 F .222 +-2.5 E F0(...])2.5 E -.8(To)144 698.4 S .222(ggle the v).8 F .222 (alues of v)-.25 F .222(ariables controlling optional shell beha)-.25 F (vior)-.2 E 5.222(.W)-.55 G .222(ith no options, or with the)-5.622 F F1 2.722 E F0 .721(option, a list of all settable options is display\ -ed, with an indication of whether or not each is set.)144 410.4 R(The) -144 422.4 Q F12.827 E F0 .327(option causes output to be displaye\ +ed, with an indication of whether or not each is set.)144 710.4 R(The) +144 722.4 Q F12.827 E F0 .327(option causes output to be displaye\ d in a form that may be reused as input.)2.827 F .328(Other options) -5.328 F(ha)144 434.4 Q .3 -.15(ve t)-.2 H(he follo).15 E(wing meanings:) --.25 E F1144 446.4 Q F0(Enable \(set\) each)26.41 E F2(optname)2.5 -E F0(.)A F1144 458.4 Q F0(Disable \(unset\) each)24.74 E F2 -(optname)2.5 E F0(.)A F1144 470.4 Q F0 .003(Suppresses normal out\ -put \(quiet mode\); the return status indicates whether the)24.74 F F2 -(optname)2.503 E F0(is)2.503 E .255(set or unset.)180 482.4 R .255 -(If multiple)5.255 F F2(optname)2.755 E F0(ar)2.755 E .256 -(guments are gi)-.18 F -.15(ve)-.25 G 2.756(nw).15 G(ith)-2.756 E F1 -2.756 E F0 2.756(,t)C .256(he return status is zero if)-2.756 F -(all)180 494.4 Q F2(optnames)2.5 E F0(are enabled; non-zero otherwise.) -2.5 E F1144 506.4 Q F0(Restricts the v)25.3 E(alues of)-.25 E F2 -(optname)2.5 E F0(to be those de\214ned for the)2.5 E F12.5 E F0 -(option to the)2.5 E F1(set)2.5 E F0 -.2(bu)2.5 G(iltin.).2 E .625 -(If either)144 523.2 R F13.125 E F0(or)3.124 E F13.124 E F0 -.624(is used with no)3.124 F F2(optname)3.124 E F0(ar)3.124 E(guments,) --.18 E F1(shopt)3.124 E F0(sho)3.124 E .624 -(ws only those options which are)-.25 F 2.233(set or unset, respecti)144 -535.2 R -.15(ve)-.25 G(ly).15 E 7.234(.U)-.65 G 2.234 -(nless otherwise noted, the)-7.234 F F1(shopt)4.734 E F0 2.234 -(options are disabled \(unset\) by)4.734 F(def)144 547.2 Q(ault.)-.1 E -1.544(The return status when listing options is zero if all)144 564 R F2 -(optnames)4.044 E F0 1.544(are enabled, non-zero otherwise.)4.044 F .696 +5.328 F(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G(mber 24) +.15 E(66)185.545 E 0 Cg EP +%%Page: 67 67 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E(ha)144 84 Q .3 -.15(ve t)-.2 H(he follo).15 E(wing meanings:)-.25 +E/F1 10/Times-Bold@0 SF144 96 Q F0(Enable \(set\) each)26.41 E/F2 +10/Times-Italic@0 SF(optname)2.5 E F0(.)A F1144 108 Q F0 +(Disable \(unset\) each)24.74 E F2(optname)2.5 E F0(.)A F1144 120 +Q F0 .003(Suppresses normal output \(quiet mode\); the return status in\ +dicates whether the)24.74 F F2(optname)2.503 E F0(is)2.503 E .255 +(set or unset.)180 132 R .255(If multiple)5.255 F F2(optname)2.755 E F0 +(ar)2.755 E .256(guments are gi)-.18 F -.15(ve)-.25 G 2.756(nw).15 G +(ith)-2.756 E F12.756 E F0 2.756(,t)C .256 +(he return status is zero if)-2.756 F(all)180 144 Q F2(optnames)2.5 E F0 +(are enabled; non-zero otherwise.)2.5 E F1144 156 Q F0 +(Restricts the v)25.3 E(alues of)-.25 E F2(optname)2.5 E F0 +(to be those de\214ned for the)2.5 E F12.5 E F0(option to the)2.5 +E F1(set)2.5 E F0 -.2(bu)2.5 G(iltin.).2 E .625(If either)144 172.8 R F1 +3.125 E F0(or)3.124 E F13.124 E F0 .624(is used with no) +3.124 F F2(optname)3.124 E F0(ar)3.124 E(guments,)-.18 E F1(shopt)3.124 +E F0(sho)3.124 E .624(ws only those options which are)-.25 F 2.233 +(set or unset, respecti)144 184.8 R -.15(ve)-.25 G(ly).15 E 7.234(.U) +-.65 G 2.234(nless otherwise noted, the)-7.234 F F1(shopt)4.734 E F0 +2.234(options are disabled \(unset\) by)4.734 F(def)144 196.8 Q(ault.) +-.1 E 1.544(The return status when listing options is zero if all)144 +213.6 R F2(optnames)4.044 E F0 1.544(are enabled, non-zero otherwise.) +4.044 F .696 (When setting or unsetting options, the return status is zero unless an) -144 576 R F2(optname)3.196 E F0 .696(is not a v)3.196 F .696(alid shell) --.25 F(option.)144 588 Q(The list of)144 604.8 Q F1(shopt)2.5 E F0 -(options is:)2.5 E F1(autocd)144 622.8 Q F0 .2 +144 225.6 R F2(optname)3.196 E F0 .696(is not a v)3.196 F .696 +(alid shell)-.25 F(option.)144 237.6 Q(The list of)144 254.4 Q F1(shopt) +2.5 E F0(options is:)2.5 E F1(autocd)144 272.4 Q F0 .2 (If set, a command name that is the name of a directory is e)11.11 F -.15(xe)-.15 G .199(cuted as if it were the ar).15 F(gu-)-.18 E -(ment to the)184 634.8 Q F1(cd)2.5 E F0 2.5(command. This)2.5 F +(ment to the)184 284.4 Q F1(cd)2.5 E F0 2.5(command. This)2.5 F (option is only used by interacti)2.5 E .3 -.15(ve s)-.25 H(hells.).15 E -F1(cdable_v)144 646.8 Q(ars)-.1 E F0 .155(If set, an ar)184 658.8 R .155 +F1(cdable_v)144 296.4 Q(ars)-.1 E F0 .155(If set, an ar)184 308.4 R .155 (gument to the)-.18 F F1(cd)2.655 E F0 -.2(bu)2.655 G .156 (iltin command that is not a directory is assumed to be the).2 F -(name of a v)184 670.8 Q(ariable whose v)-.25 E -(alue is the directory to change to.)-.25 E F1(cdspell)144 682.8 Q F0 +(name of a v)184 320.4 Q(ariable whose v)-.25 E +(alue is the directory to change to.)-.25 E F1(cdspell)144 332.4 Q F0 1.055 (If set, minor errors in the spelling of a directory component in a) 10.55 F F1(cd)3.555 E F0 1.055(command will be)3.555 F 3.987 -(corrected. The)184 694.8 R 1.487(errors check)3.987 F 1.487 +(corrected. The)184 344.4 R 1.487(errors check)3.987 F 1.487 (ed for are transposed characters, a missing character)-.1 F 3.988(,a) --.4 G(nd)-3.988 E .77(one character too man)184 706.8 R 4.57 -.65(y. I) +-.4 G(nd)-3.988 E .77(one character too man)184 356.4 R 4.57 -.65(y. I) -.15 H 3.27(fac).65 G .77 (orrection is found, the corrected \214lename is printed, and)-3.27 F -(the command proceeds.)184 718.8 Q +(the command proceeds.)184 368.4 Q (This option is only used by interacti)5 E .3 -.15(ve s)-.25 H(hells.) -.15 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(66)198.165 E 0 Cg EP -%%Page: 67 67 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(checkhash)144 84 Q F0 2.079(If set,)184 96 -R F1(bash)4.579 E F0 2.079 -(checks that a command found in the hash table e)4.579 F 2.08 -(xists before trying to)-.15 F -.15(exe)184 108 S(cute it.).15 E +.15 E F1(checkhash)144 380.4 Q F0 2.079(If set,)184 392.4 R F1(bash) +4.579 E F0 2.079(checks that a command found in the hash table e)4.579 F +2.08(xists before trying to)-.15 F -.15(exe)184 404.4 S(cute it.).15 E (If a hashed command no longer e)5 E -(xists, a normal path search is performed.)-.15 E F1(checkjobs)144 120 Q -F0 .449(If set,)184 132 R F1(bash)2.949 E F0 .449 +(xists, a normal path search is performed.)-.15 E F1(checkjobs)144 416.4 +Q F0 .449(If set,)184 428.4 R F1(bash)2.949 E F0 .449 (lists the status of an)2.949 F 2.949(ys)-.15 G .448 (topped and running jobs before e)-2.949 F .448(xiting an interacti)-.15 -F -.15(ve)-.25 G 3.438(shell. If)184 144 R(an)3.438 E 3.438(yj)-.15 G +F -.15(ve)-.25 G 3.438(shell. If)184 440.4 R(an)3.438 E 3.438(yj)-.15 G .938(obs are running, this causes the e)-3.438 F .938 (xit to be deferred until a second e)-.15 F .939(xit is)-.15 F 2.203 -(attempted without an interv)184 156 R 2.203(ening command \(see)-.15 F -/F2 9/Times-Bold@0 SF 2.203(JOB CONTR)4.703 F(OL)-.27 E F0(abo)4.453 E --.15(ve)-.15 G 4.703(\). The).15 F(shell)4.703 E(al)184 168 Q -.1(wa)-.1 -G(ys postpones e).1 E(xiting if an)-.15 E 2.5(yj)-.15 G -(obs are stopped.)-2.5 E F1(checkwinsize)144 180 Q F0 .796(If set,)184 -192 R F1(bash)3.296 E F0 .796(checks the windo)3.296 F 3.296(ws)-.25 G +(attempted without an interv)184 452.4 R 2.203(ening command \(see)-.15 +F/F3 9/Times-Bold@0 SF 2.203(JOB CONTR)4.703 F(OL)-.27 E F0(abo)4.453 E +-.15(ve)-.15 G 4.703(\). The).15 F(shell)4.703 E(al)184 464.4 Q -.1(wa) +-.1 G(ys postpones e).1 E(xiting if an)-.15 E 2.5(yj)-.15 G +(obs are stopped.)-2.5 E F1(checkwinsize)144 476.4 Q F0 .796(If set,)184 +488.4 R F1(bash)3.296 E F0 .796(checks the windo)3.296 F 3.296(ws)-.25 G .797(ize after each command and, if necessary)-3.296 F 3.297(,u)-.65 G -.797(pdates the)-3.297 F -.25(va)184 204 S(lues of).25 E F2(LINES)2.5 E -F0(and)2.25 E F2(COLUMNS)2.5 E/F3 9/Times-Roman@0 SF(.)A F1(cmdhist)144 -216 Q F0 1.202(If set,)6.11 F F1(bash)3.702 E F0 1.202(attempts to sa) -3.702 F 1.502 -.15(ve a)-.2 H 1.202 +.797(pdates the)-3.297 F -.25(va)184 500.4 S(lues of).25 E F3(LINES)2.5 +E F0(and)2.25 E F3(COLUMNS)2.5 E/F4 9/Times-Roman@0 SF(.)A F1(cmdhist) +144 512.4 Q F0 1.202(If set,)6.11 F F1(bash)3.702 E F0 1.202 +(attempts to sa)3.702 F 1.502 -.15(ve a)-.2 H 1.202 (ll lines of a multiple-line command in the same history).15 F(entry)184 -228 Q 5(.T)-.65 G(his allo)-5 E -(ws easy re-editing of multi-line commands.)-.25 E F1(compat31)144 240 Q -F0 .419(If set,)184 252 R F1(bash)2.919 E F0 .419(changes its beha)2.919 -F .419(vior to that of v)-.2 F .42(ersion 3.1 with respect to quoted ar) --.15 F(guments)-.18 E .462(to the)184 264 R F1([[)2.962 E F0 .462 -(conditional command')2.962 F(s)-.55 E F1(=~)2.962 E F0 .462 +524.4 Q 5(.T)-.65 G(his allo)-5 E +(ws easy re-editing of multi-line commands.)-.25 E F1(compat31)144 536.4 +Q F0 .419(If set,)184 548.4 R F1(bash)2.919 E F0 .419(changes its beha) +2.919 F .419(vior to that of v)-.2 F .42 +(ersion 3.1 with respect to quoted ar)-.15 F(guments)-.18 E .462(to the) +184 560.4 R F1([[)2.962 E F0 .462(conditional command')2.962 F(s)-.55 E +F1(=~)2.962 E F0 .462 (operator and locale-speci\214c string comparison when)2.962 F .71 -(using the)184 276 R F1([[)3.21 E F0 .71(conditional command')3.21 F(s) --.55 E F1(<)3.21 E F0(and)3.21 E F1(>)3.21 E F0 3.21(operators. Bash) +(using the)184 572.4 R F1([[)3.21 E F0 .71(conditional command')3.21 F +(s)-.55 E F1(<)3.21 E F0(and)3.21 E F1(>)3.21 E F0 3.21(operators. Bash) 3.21 F -.15(ve)3.21 G .71(rsions prior to bash-4.1).15 F .821 -(use ASCII collation and)184 288 R/F4 10/Times-Italic@0 SF(str)3.321 E -(cmp)-.37 E F0 .821(\(3\); bash-4.1 and later use the current locale') -.19 F 3.32(sc)-.55 G(ollation)-3.32 E(sequence and)184 300 Q F4(str)2.5 -E(coll)-.37 E F0(\(3\).).51 E F1(compat32)144 312 Q F0 1.409(If set,)184 -324 R F1(bash)3.909 E F0 1.409(changes its beha)3.909 F 1.409 -(vior to that of v)-.2 F 1.41 -(ersion 3.2 with respect to locale-speci\214c)-.15 F .423 -(string comparison when using the)184 336 R F1([[)2.922 E F0 .422 +(use ASCII collation and)184 584.4 R F2(str)3.321 E(cmp)-.37 E F0 .821 +(\(3\); bash-4.1 and later use the current locale').19 F 3.32(sc)-.55 G +(ollation)-3.32 E(sequence and)184 596.4 Q F2(str)2.5 E(coll)-.37 E F0 +(\(3\).).51 E F1(compat32)144 608.4 Q F0 1.409(If set,)184 620.4 R F1 +(bash)3.909 E F0 1.409(changes its beha)3.909 F 1.409(vior to that of v) +-.2 F 1.41(ersion 3.2 with respect to locale-speci\214c)-.15 F .423 +(string comparison when using the)184 632.4 R F1([[)2.922 E F0 .422 (conditional command')2.922 F(s)-.55 E F1(<)2.922 E F0(and)2.922 E F1(>) -2.922 E F0 .422(operators \(see pre-)2.922 F(vious item\).)184 348 Q F1 -(compat40)144 360 Q F0 1.409(If set,)184 372 R F1(bash)3.909 E F0 1.409 -(changes its beha)3.909 F 1.409(vior to that of v)-.2 F 1.41 +2.922 E F0 .422(operators \(see pre-)2.922 F(vious item\).)184 644.4 Q +F1(compat40)144 656.4 Q F0 1.409(If set,)184 668.4 R F1(bash)3.909 E F0 +1.409(changes its beha)3.909 F 1.409(vior to that of v)-.2 F 1.41 (ersion 4.0 with respect to locale-speci\214c)-.15 F 2.008 -(string comparison when using the)184 384 R F1([[)4.508 E F0 2.007 +(string comparison when using the)184 680.4 R F1([[)4.508 E F0 2.007 (conditional command')4.508 F(s)-.55 E F1(<)4.507 E F0(and)4.507 E F1(>) -4.507 E F0 2.007(operators \(see)4.507 F .769(description of)184 396 R +4.507 E F0 2.007(operators \(see)4.507 F .769(description of)184 692.4 R F1(compat31)3.269 E F0 3.269(\)a)C .769(nd the ef)-3.269 F .769 (fect of interrupting a command list.)-.25 F .77(Bash v)5.77 F(ersions) -.15 E .087(4.0 and later interrupt the list as if the shell recei)184 -408 R -.15(ve)-.25 G 2.586(dt).15 G .086(he interrupt; pre)-2.586 F .086 -(vious v)-.25 F .086(ersions con-)-.15 F(tinue with the ne)184 420 Q -(xt command in the list.)-.15 E F1(compat41)144 432 Q F0 1.443(If set,) -184 444 R F1(bash)3.943 E F0 3.943(,w)C 1.444 +704.4 R -.15(ve)-.25 G 2.586(dt).15 G .086(he interrupt; pre)-2.586 F +.086(vious v)-.25 F .086(ersions con-)-.15 F(tinue with the ne)184 716.4 +Q(xt command in the list.)-.15 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E +-.15(ve)-.15 G(mber 24).15 E(67)185.545 E 0 Cg EP +%%Page: 68 68 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(compat41)144 84 Q F0 1.443(If set,)184 96 R +F1(bash)3.943 E F0 3.943(,w)C 1.444 (hen in posix mode, treats a single quote in a double-quoted parameter) --3.943 F -.15(ex)184 456 S .959(pansion as a special character).15 F +-3.943 F -.15(ex)184 108 S .959(pansion as a special character).15 F 5.959(.T)-.55 G .958(he single quotes must match \(an e)-5.959 F -.15 (ve)-.25 G 3.458(nn).15 G .958(umber\) and)-3.458 F .59 -(the characters between the single quotes are considered quoted.)184 468 +(the characters between the single quotes are considered quoted.)184 120 R .59(This is the beha)5.59 F .59(vior of)-.2 F .59 -(posix mode through v)184 480 R .589(ersion 4.1.)-.15 F .589(The def) +(posix mode through v)184 132 R .589(ersion 4.1.)-.15 F .589(The def) 5.589 F .589(ault bash beha)-.1 F .589(vior remains as in pre)-.2 F .589 -(vious v)-.25 F(er)-.15 E(-)-.2 E(sions.)184 492 Q F1 -(complete_fullquote)144 504 Q F0 .653(If set,)184 516 R F1(bash)3.153 E +(vious v)-.25 F(er)-.15 E(-)-.2 E(sions.)184 144 Q F1 +(complete_fullquote)144 156 Q F0 .653(If set,)184 168 R F1(bash)3.153 E F0 .653(quotes all shell metacharacters in \214lenames and directory na\ -mes when per)3.153 F(-)-.2 E 1.525(forming completion.)184 528 R 1.524 +mes when per)3.153 F(-)-.2 E 1.525(forming completion.)184 180 R 1.524 (If not set,)6.525 F F1(bash)4.024 E F0(remo)4.024 E -.15(ve)-.15 G 4.024(sm).15 G 1.524(etacharacters such as the dollar sign)-4.024 F 2.667(from the set of characters that will be quoted in completed \214l\ -enames when these)184 540 R .029(metacharacters appear in shell v)184 -552 R .028(ariable references in w)-.25 F .028(ords to be completed.)-.1 -F .028(This means)5.028 F 1.072(that dollar signs in v)184 564 R 1.073 +enames when these)184 192 R .029(metacharacters appear in shell v)184 +204 R .028(ariable references in w)-.25 F .028(ords to be completed.)-.1 +F .028(This means)5.028 F 1.072(that dollar signs in v)184 216 R 1.073 (ariable names that e)-.25 F 1.073 (xpand to directories will not be quoted; ho)-.15 F(w-)-.25 E -2.15 -.25 -(ev e)184 576 T 1.923 -.4(r, a).25 H 1.423 -.15(ny d).4 H 1.123 +(ev e)184 228 T 1.923 -.4(r, a).25 H 1.423 -.15(ny d).4 H 1.123 (ollar signs appearing in \214lenames will not be quoted, either).15 F 6.123(.T)-.55 G 1.122(his is acti)-6.123 F -.15(ve)-.25 G .59 (only when bash is using backslashes to quote completed \214lenames.)184 -588 R .59(This v)5.59 F .59(ariable is set)-.25 F(by def)184 600 Q +240 R .59(This v)5.59 F .59(ariable is set)-.25 F(by def)184 252 Q (ault, which is the def)-.1 E(ault bash beha)-.1 E(vior in v)-.2 E -(ersions through 4.2.)-.15 E F1(dir)144 612 Q(expand)-.18 E F0 .487 -(If set,)184 624 R F1(bash)2.987 E F0 .486 +(ersions through 4.2.)-.15 E F1(dir)144 264 Q(expand)-.18 E F0 .487 +(If set,)184 276 R F1(bash)2.987 E F0 .486 (replaces directory names with the results of w)2.986 F .486(ord e)-.1 F .486(xpansion when perform-)-.15 F .179(ing \214lename completion.)184 -636 R .179(This changes the contents of the readline editing b)5.179 F +288 R .179(This changes the contents of the readline editing b)5.179 F (uf)-.2 E(fer)-.25 E 5.18(.I)-.55 G 2.68(fn)-5.18 G(ot)-2.68 E(set,)184 -648 Q F1(bash)2.5 E F0(attempts to preserv)2.5 E 2.5(ew)-.15 G -(hat the user typed.)-2.5 E F1(dirspell)144 660 Q F0 .859(If set,)7.77 F +300 Q F1(bash)2.5 E F0(attempts to preserv)2.5 E 2.5(ew)-.15 G +(hat the user typed.)-2.5 E F1(dirspell)144 312 Q F0 .859(If set,)7.77 F F1(bash)3.359 E F0 .858 (attempts spelling correction on directory names during w)3.359 F .858 (ord completion if)-.1 F -(the directory name initially supplied does not e)184 672 Q(xist.)-.15 E -F1(dotglob)144 684 Q F0 .165(If set,)7.77 F F1(bash)2.665 E F0 .165 +(the directory name initially supplied does not e)184 324 Q(xist.)-.15 E +F1(dotglob)144 336 Q F0 .165(If set,)7.77 F F1(bash)2.665 E F0 .165 (includes \214lenames be)2.665 F .165(ginning with a `.)-.15 F 2.665('i) -.7 G 2.665(nt)-2.665 G .165(he results of pathname e)-2.665 F -(xpansion.)-.15 E F1(execfail)144 696 Q F0 1.387 +(xpansion.)-.15 E F1(execfail)144 348 Q F0 1.387 (If set, a non-interacti)7.79 F 1.687 -.15(ve s)-.25 H 1.386 (hell will not e).15 F 1.386(xit if it cannot e)-.15 F -.15(xe)-.15 G -1.386(cute the \214le speci\214ed as an).15 F(ar)184 708 Q +1.386(cute the \214le speci\214ed as an).15 F(ar)184 360 Q (gument to the)-.18 E F1(exec)2.5 E F0 -.2(bu)2.5 G(iltin command.).2 E (An interacti)5 E .3 -.15(ve s)-.25 H(hell does not e).15 E(xit if)-.15 -E F1(exec)2.5 E F0 -.1(fa)2.5 G(ils.).1 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(67)198.165 E 0 Cg EP -%%Page: 68 68 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(expand_aliases)144 84 Q F0 .716 -(If set, aliases are e)184 96 R .717(xpanded as described abo)-.15 F -1.017 -.15(ve u)-.15 H(nder).15 E/F2 9/Times-Bold@0 SF(ALIASES)3.217 E +E F1(exec)2.5 E F0 -.1(fa)2.5 G(ils.).1 E F1(expand_aliases)144 372 Q F0 +.716(If set, aliases are e)184 384 R .717(xpanded as described abo)-.15 +F 1.017 -.15(ve u)-.15 H(nder).15 E/F2 9/Times-Bold@0 SF(ALIASES)3.217 E /F3 9/Times-Roman@0 SF(.)A F0 .717(This option is enabled)5.217 F -(by def)184 108 Q(ault for interacti)-.1 E .3 -.15(ve s)-.25 H(hells.) -.15 E F1(extdeb)144 120 Q(ug)-.2 E F0(If set, beha)184 132 Q +(by def)184 396 Q(ault for interacti)-.1 E .3 -.15(ve s)-.25 H(hells.) +.15 E F1(extdeb)144 408 Q(ug)-.2 E F0(If set, beha)184 420 Q (vior intended for use by deb)-.2 E(uggers is enabled:)-.2 E F1(1.)184 -144 Q F0(The)28.5 E F14.251 E F0 1.751(option to the)4.251 F F1 +432 Q F0(The)28.5 E F14.251 E F0 1.751(option to the)4.251 F F1 (declar)4.251 E(e)-.18 E F0 -.2(bu)4.251 G 1.751 (iltin displays the source \214le name and line).2 F -(number corresponding to each function name supplied as an ar)220 156 Q -(gument.)-.18 E F1(2.)184 168 Q F0 1.667(If the command run by the)28.5 +(number corresponding to each function name supplied as an ar)220 444 Q +(gument.)-.18 E F1(2.)184 456 Q F0 1.667(If the command run by the)28.5 F F1(DEB)4.167 E(UG)-.1 E F0 1.667(trap returns a non-zero v)4.167 F -1.667(alue, the ne)-.25 F(xt)-.15 E(command is skipped and not e)220 180 -Q -.15(xe)-.15 G(cuted.).15 E F1(3.)184 192 Q F0 .841 +1.667(alue, the ne)-.25 F(xt)-.15 E(command is skipped and not e)220 468 +Q -.15(xe)-.15 G(cuted.).15 E F1(3.)184 480 Q F0 .841 (If the command run by the)28.5 F F1(DEB)3.341 E(UG)-.1 E F0 .841 (trap returns a v)3.341 F .84(alue of 2, and the shell is)-.25 F -.15 -(exe)220 204 S .488 +(exe)220 492 S .488 (cuting in a subroutine \(a shell function or a shell script e).15 F -.15(xe)-.15 G .488(cuted by the).15 F F1(.)2.988 E F0(or)2.988 E F1 -(sour)220 216 Q(ce)-.18 E F0 -.2(bu)2.5 G(iltins\), a call to).2 E F1 --.18(re)2.5 G(tur).18 E(n)-.15 E F0(is simulated.)2.5 E F1(4.)184 228 Q +(sour)220 504 Q(ce)-.18 E F0 -.2(bu)2.5 G(iltins\), a call to).2 E F1 +-.18(re)2.5 G(tur).18 E(n)-.15 E F0(is simulated.)2.5 E F1(4.)184 516 Q F2 -.27(BA)28.5 G(SH_ARGC).27 E F0(and)3.154 E F2 -.27(BA)3.404 G (SH_ARGV).27 E F0 .904(are updated as described in their descriptions) -3.154 F(abo)220 240 Q -.15(ve)-.15 G(.).15 E F1(5.)184 252 Q F0 1.359 +3.154 F(abo)220 528 Q -.15(ve)-.15 G(.).15 E F1(5.)184 540 Q F0 1.359 (Function tracing is enabled:)28.5 F 1.359 (command substitution, shell functions, and sub-)6.359 F(shells in)220 -264 Q -.2(vo)-.4 G -.1(ke).2 G 2.5(dw).1 G(ith)-2.5 E F1(\()2.5 E/F4 10 +552 Q -.2(vo)-.4 G -.1(ke).2 G 2.5(dw).1 G(ith)-2.5 E F1(\()2.5 E/F4 10 /Times-Italic@0 SF(command)2.5 E F1(\))2.5 E F0(inherit the)2.5 E F1 (DEB)2.5 E(UG)-.1 E F0(and)2.5 E F1(RETURN)2.5 E F0(traps.)2.5 E F1(6.) -184 276 Q F0 .805(Error tracing is enabled:)28.5 F .804 -(command substitution, shell functions, and subshells)5.805 F(in)220 288 +184 564 Q F0 .805(Error tracing is enabled:)28.5 F .804 +(command substitution, shell functions, and subshells)5.805 F(in)220 576 Q -.2(vo)-.4 G -.1(ke).2 G 2.5(dw).1 G(ith)-2.5 E F1(\()2.5 E F4 (command)2.5 E F1(\))2.5 E F0(inherit the)2.5 E F1(ERR)2.5 E F0(trap.) -2.5 E F1(extglob)144 300 Q F0 .4(If set, the e)8.89 F .4 +2.5 E F1(extglob)144 588 Q F0 .4(If set, the e)8.89 F .4 (xtended pattern matching features described abo)-.15 F .7 -.15(ve u) --.15 H(nder).15 E F1 -.1(Pa)2.9 G .4(thname Expan-).1 F(sion)184 312 Q -F0(are enabled.)2.5 E F1(extquote)144 324 Q F0 2.473(If set,)184 336 R +-.15 H(nder).15 E F1 -.1(Pa)2.9 G .4(thname Expan-).1 F(sion)184 600 Q +F0(are enabled.)2.5 E F1(extquote)144 612 Q F0 2.473(If set,)184 624 R F1($)4.973 E F0<08>A F4(string)A F0 4.973<0861>C(nd)-4.973 E F1($)4.973 E F0(")A F4(string)A F0 4.973("q)C 2.473(uoting is performed within) -4.973 F F1(${)4.973 E F4(par)A(ameter)-.15 E F1(})A F0 -.15(ex)4.973 G -(pansions).15 E(enclosed in double quotes.)184 348 Q -(This option is enabled by def)5 E(ault.)-.1 E F1(failglob)144 360 Q F0 +(pansions).15 E(enclosed in double quotes.)184 636 Q +(This option is enabled by def)5 E(ault.)-.1 E F1(failglob)144 648 Q F0 1.424(If set, patterns which f)7.77 F 1.425 (ail to match \214lenames during pathname e)-.1 F 1.425 -(xpansion result in an)-.15 F -.15(ex)184 372 S(pansion error).15 E(.) --.55 E F1 -.25(fo)144 384 S -.18(rc).25 G(e_\214gnor).18 E(e)-.18 E F0 -.937(If set, the suf)184 396 R<8c78>-.25 E .936(es speci\214ed by the) +(xpansion result in an)-.15 F -.15(ex)184 660 S(pansion error).15 E(.) +-.55 E F1 -.25(fo)144 672 S -.18(rc).25 G(e_\214gnor).18 E(e)-.18 E F0 +.937(If set, the suf)184 684 R<8c78>-.25 E .936(es speci\214ed by the) -.15 F F2(FIGNORE)3.436 E F0 .936(shell v)3.186 F .936(ariable cause w) --.25 F .936(ords to be ignored)-.1 F .32(when performing w)184 408 R .32 +-.25 F .936(ords to be ignored)-.1 F .32(when performing w)184 696 R .32 (ord completion e)-.1 F -.15(ve)-.25 G 2.82(ni).15 G 2.82(ft)-2.82 G .32 (he ignored w)-2.82 F .32(ords are the only possible com-)-.1 F 2.948 -(pletions. See)184 420 R F2 .448(SHELL V)2.948 F(ARIABLES)-1.215 E F0 +(pletions. See)184 708 R F2 .448(SHELL V)2.948 F(ARIABLES)-1.215 E F0 (abo)2.698 E .748 -.15(ve f)-.15 H .448(or a description of).15 F F2 (FIGNORE)2.947 E F3(.)A F0 .447(This option is)4.947 F(enabled by def) -184 432 Q(ault.)-.1 E F1(globasciiranges)144 444 Q F0 .805 -(If set, range e)184 456 R .806 -(xpressions used in pattern matching \(see)-.15 F F2 -.09(Pa)3.306 G -(tter).09 E 3.056(nM)-.135 G(atching)-3.056 E F0(abo)3.056 E -.15(ve) --.15 G 3.306(\)b).15 G(eha)-3.306 E -.15(ve)-.2 G 2.089 -(as if in the traditional C locale when performing comparisons.)184 468 -R 2.089(That is, the current)7.089 F(locale')184 480 Q 2.613(sc)-.55 G +184 720 Q(ault.)-.1 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve) +-.15 G(mber 24).15 E(68)185.545 E 0 Cg EP +%%Page: 69 69 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(globasciiranges)144 84 Q F0 .805 +(If set, range e)184 96 R .806 +(xpressions used in pattern matching \(see)-.15 F/F2 9/Times-Bold@0 SF +-.09(Pa)3.306 G(tter).09 E 3.056(nM)-.135 G(atching)-3.056 E F0(abo) +3.056 E -.15(ve)-.15 G 3.306(\)b).15 G(eha)-3.306 E -.15(ve)-.2 G 2.089 +(as if in the traditional C locale when performing comparisons.)184 108 +R 2.089(That is, the current)7.089 F(locale')184 120 Q 2.613(sc)-.55 G .113(ollating sequence is not tak)-2.613 F .113(en into account, so)-.1 F F1(b)2.613 E F0 .114(will not collate between)2.613 F F1(A)2.614 E F0 -(and)2.614 E F1(B)184 492 Q F0 2.5(,a)C(nd upper)-2.5 E(-case and lo)-.2 +(and)2.614 E F1(B)184 132 Q F0 2.5(,a)C(nd upper)-2.5 E(-case and lo)-.2 E(wer)-.25 E(-case ASCII characters will collate together)-.2 E(.)-.55 E -F1(globstar)144 504 Q F0 .519(If set, the pattern)5 F F1(**)3.019 E F0 +F1(globstar)144 144 Q F0 .519(If set, the pattern)5 F F1(**)3.019 E F0 .519(used in a pathname e)3.019 F .519(xpansion conte)-.15 F .518 (xt will match all \214les and zero)-.15 F .431 -(or more directories and subdirectories.)184 516 R .431 +(or more directories and subdirectories.)184 156 R .431 (If the pattern is follo)5.431 F .432(wed by a)-.25 F F1(/)2.932 E F0 2.932(,o)C .432(nly directories)-2.932 F(and subdirectories match.)184 -528 Q F1(gnu_errfmt)144 540 Q F0(If set, shell error messages are writt\ -en in the standard GNU error message format.)184 552 Q F1(histappend)144 -564 Q F0 .676 +168 Q F1(gnu_errfmt)144 180 Q F0(If set, shell error messages are writt\ +en in the standard GNU error message format.)184 192 Q F1(histappend)144 +204 Q F0 .676 (If set, the history list is appended to the \214le named by the v)184 -576 R .676(alue of the)-.25 F F2(HISTFILE)3.176 E F0 -.25(va)2.926 G -(ri-).25 E(able when the shell e)184 588 Q(xits, rather than o)-.15 E --.15(ve)-.15 G(rwriting the \214le.).15 E F1(histr)144 600 Q(eedit)-.18 -E F0 .575(If set, and)184 612 R F1 -.18(re)3.075 G(adline).18 E F0 .575 +216 R .676(alue of the)-.25 F F2(HISTFILE)3.176 E F0 -.25(va)2.926 G +(ri-).25 E(able when the shell e)184 228 Q(xits, rather than o)-.15 E +-.15(ve)-.15 G(rwriting the \214le.).15 E F1(histr)144 240 Q(eedit)-.18 +E F0 .575(If set, and)184 252 R F1 -.18(re)3.075 G(adline).18 E F0 .575 (is being used, a user is gi)3.075 F -.15(ve)-.25 G 3.075(nt).15 G .576 (he opportunity to re-edit a f)-3.075 F .576(ailed his-)-.1 F -(tory substitution.)184 624 Q F1(histv)144 636 Q(erify)-.1 E F0 .403 -(If set, and)184 648 R F1 -.18(re)2.903 G(adline).18 E F0 .403 +(tory substitution.)184 264 Q F1(histv)144 276 Q(erify)-.1 E F0 .403 +(If set, and)184 288 R F1 -.18(re)2.903 G(adline).18 E F0 .403 (is being used, the results of history substitution are not immediately) -2.903 F .661(passed to the shell parser)184 660 R 5.661(.I)-.55 G .662 +2.903 F .661(passed to the shell parser)184 300 R 5.661(.I)-.55 G .662 (nstead, the resulting line is loaded into the)-5.661 F F1 -.18(re)3.162 -G(adline).18 E F0(editing)3.162 E -.2(bu)184 672 S -.25(ff).2 G(er).25 E +G(adline).18 E F0(editing)3.162 E -.2(bu)184 312 S -.25(ff).2 G(er).25 E 2.5(,a)-.4 G(llo)-2.5 E(wing further modi\214cation.)-.25 E F1 -(hostcomplete)144 684 Q F0 1.182(If set, and)184 696 R F1 -.18(re)3.682 +(hostcomplete)144 324 Q F0 1.182(If set, and)184 336 R F1 -.18(re)3.682 G(adline).18 E F0 1.182(is being used,)3.682 F F1(bash)3.682 E F0 1.181 (will attempt to perform hostname completion)3.681 F 1.38(when a w)184 -708 R 1.38(ord containing a)-.1 F F1(@)3.881 E F0 1.381 +348 R 1.38(ord containing a)-.1 F F1(@)3.881 E F0 1.381 (is being completed \(see)3.881 F F1(Completing)3.881 E F0(under)3.881 E -F2(READLINE)3.881 E F0(abo)184 720 Q -.15(ve)-.15 G 2.5(\). This).15 F -(is enabled by def)2.5 E(ault.)-.1 E(GNU Bash 4.2)72 768 Q(2012 July 14) -149.005 E(68)198.165 E 0 Cg EP -%%Page: 69 69 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF(huponexit)144 84 Q F0(If set,)184 96 Q F1 -(bash)2.5 E F0(will send)2.5 E/F2 9/Times-Bold@0 SF(SIGHUP)2.5 E F0 +F2(READLINE)3.881 E F0(abo)184 360 Q -.15(ve)-.15 G 2.5(\). This).15 F +(is enabled by def)2.5 E(ault.)-.1 E F1(huponexit)144 372 Q F0(If set,) +184 384 Q F1(bash)2.5 E F0(will send)2.5 E F2(SIGHUP)2.5 E F0 (to all jobs when an interacti)2.25 E .3 -.15(ve l)-.25 H(ogin shell e) -.15 E(xits.)-.15 E F1(interacti)144 108 Q -.1(ve)-.1 G(_comments).1 E F0 -.33(If set, allo)184 120 R 2.83(waw)-.25 G .33(ord be)-2.93 F .33 +.15 E(xits.)-.15 E F1(interacti)144 396 Q -.1(ve)-.1 G(_comments).1 E F0 +.33(If set, allo)184 408 R 2.83(waw)-.25 G .33(ord be)-2.93 F .33 (ginning with)-.15 F F1(#)2.83 E F0 .33(to cause that w)2.83 F .33 (ord and all remaining characters on)-.1 F .967 -(that line to be ignored in an interacti)184 132 R 1.267 -.15(ve s)-.25 +(that line to be ignored in an interacti)184 420 R 1.267 -.15(ve s)-.25 H .967(hell \(see).15 F F2(COMMENTS)3.467 E F0(abo)3.217 E -.15(ve)-.15 -G 3.467(\). This).15 F .968(option is)3.468 F(enabled by def)184 144 Q -(ault.)-.1 E F1(lastpipe)144 156 Q F0 1.212 +G 3.467(\). This).15 F .968(option is)3.468 F(enabled by def)184 432 Q +(ault.)-.1 E F1(lastpipe)144 444 Q F0 1.212 (If set, and job control is not acti)6.66 F -.15(ve)-.25 G 3.712(,t).15 G 1.212(he shell runs the last command of a pipeline not)-3.712 F -.15 -(exe)184 168 S(cuted in the background in the current shell en).15 E -(vironment.)-.4 E F1(lithist)144 180 Q F0 .654(If set, and the)15.55 F +(exe)184 456 S(cuted in the background in the current shell en).15 E +(vironment.)-.4 E F1(lithist)144 468 Q F0 .654(If set, and the)15.55 F F1(cmdhist)3.154 E F0 .654 (option is enabled, multi-line commands are sa)3.154 F -.15(ve)-.2 G 3.155(dt).15 G 3.155(ot)-3.155 G .655(he history)-3.155 F -(with embedded ne)184 192 Q +(with embedded ne)184 480 Q (wlines rather than using semicolon separators where possible.)-.25 E F1 -(login_shell)144 204 Q F0 .486 +(login_shell)144 492 Q F0 .486 (The shell sets this option if it is started as a login shell \(see)184 -216 R F2(INV)2.986 E(OCA)-.405 E(TION)-.855 E F0(abo)2.736 E -.15(ve) --.15 G 2.986(\). The).15 F -.25(va)184 228 S(lue may not be changed.).25 -E F1(mailwar)144 240 Q(n)-.15 E F0 .814(If set, and a \214le that)184 -252 R F1(bash)3.314 E F0 .815 +504 R F2(INV)2.986 E(OCA)-.405 E(TION)-.855 E F0(abo)2.736 E -.15(ve) +-.15 G 2.986(\). The).15 F -.25(va)184 516 S(lue may not be changed.).25 +E F1(mailwar)144 528 Q(n)-.15 E F0 .814(If set, and a \214le that)184 +540 R F1(bash)3.314 E F0 .815 (is checking for mail has been accessed since the last time it)3.314 F --.1(wa)184 264 S 2.5(sc).1 G(heck)-2.5 E(ed, the message `)-.1 E +-.1(wa)184 552 S 2.5(sc).1 G(heck)-2.5 E(ed, the message `)-.1 E (`The mail in)-.74 E/F3 10/Times-Italic@0 SF(mail\214le)2.5 E F0 (has been read')2.5 E 2.5('i)-.74 G 2.5(sd)-2.5 G(isplayed.)-2.5 E F1 -(no_empty_cmd_completion)144 276 Q F0 .325(If set, and)184 288 R F1 -.18 +(no_empty_cmd_completion)144 564 Q F0 .325(If set, and)184 576 R F1 -.18 (re)2.825 G(adline).18 E F0 .325(is being used,)2.825 F F1(bash)2.824 E F0 .324(will not attempt to search the)2.824 F F2 -.666(PA)2.824 G(TH) -.189 E F0 .324(for possible)2.574 F -(completions when completion is attempted on an empty line.)184 300 Q F1 -(nocaseglob)144 312 Q F0 .436(If set,)184 324 R F1(bash)2.936 E F0 .436 +(completions when completion is attempted on an empty line.)184 588 Q F1 +(nocaseglob)144 600 Q F0 .436(If set,)184 612 R F1(bash)2.936 E F0 .436 (matches \214lenames in a case\255insensiti)2.936 F .737 -.15(ve f)-.25 -H .437(ashion when performing pathname).05 F -.15(ex)184 336 S +H .437(ashion when performing pathname).05 F -.15(ex)184 624 S (pansion \(see).15 E F1 -.1(Pa)2.5 G(thname Expansion).1 E F0(abo)2.5 E --.15(ve)-.15 G(\).).15 E F1(nocasematch)144 348 Q F0 1.194(If set,)184 -360 R F1(bash)3.694 E F0 1.194(matches patterns in a case\255insensiti) +-.15(ve)-.15 G(\).).15 E F1(nocasematch)144 636 Q F0 1.194(If set,)184 +648 R F1(bash)3.694 E F0 1.194(matches patterns in a case\255insensiti) 3.694 F 1.493 -.15(ve f)-.25 H 1.193(ashion when performing matching).05 -F(while e)184 372 Q -.15(xe)-.15 G(cuting).15 E F1(case)2.5 E F0(or)2.5 -E F1([[)2.5 E F0(conditional commands.)2.5 E F1(nullglob)144 384 Q F0 -.854(If set,)184 396 R F1(bash)3.354 E F0(allo)3.354 E .855 +F(while e)184 660 Q -.15(xe)-.15 G(cuting).15 E F1(case)2.5 E F0(or)2.5 +E F1([[)2.5 E F0(conditional commands.)2.5 E F1(nullglob)144 672 Q F0 +.854(If set,)184 684 R F1(bash)3.354 E F0(allo)3.354 E .855 (ws patterns which match no \214les \(see)-.25 F F1 -.1(Pa)3.355 G .855 (thname Expansion).1 F F0(abo)3.355 E -.15(ve)-.15 G 3.355(\)t).15 G(o) --3.355 E -.15(ex)184 408 S(pand to a null string, rather than themselv) -.15 E(es.)-.15 E F1(pr)144 420 Q(ogcomp)-.18 E F0 .677 -(If set, the programmable completion f)184 432 R .677(acilities \(see) --.1 F F1(Pr)3.176 E .676(ogrammable Completion)-.18 F F0(abo)3.176 E --.15(ve)-.15 G(\)).15 E(are enabled.)184 444 Q -(This option is enabled by def)5 E(ault.)-.1 E F1(pr)144 456 Q(omptv) --.18 E(ars)-.1 E F0 1.447(If set, prompt strings under)184 468 R 1.448 +-3.355 E -.15(ex)184 696 S(pand to a null string, rather than themselv) +.15 E(es.)-.15 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G +(mber 24).15 E(69)185.545 E 0 Cg EP +%%Page: 70 70 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E/F1 10/Times-Bold@0 SF(pr)144 84 Q(ogcomp)-.18 E F0 .677 +(If set, the programmable completion f)184 96 R .677(acilities \(see)-.1 +F F1(Pr)3.176 E .676(ogrammable Completion)-.18 F F0(abo)3.176 E -.15 +(ve)-.15 G(\)).15 E(are enabled.)184 108 Q +(This option is enabled by def)5 E(ault.)-.1 E F1(pr)144 120 Q(omptv) +-.18 E(ars)-.1 E F0 1.447(If set, prompt strings under)184 132 R 1.448 (go parameter e)-.18 F 1.448(xpansion, command substitution, arithmetic) --.15 F -.15(ex)184 480 S .171(pansion, and quote remo).15 F -.25(va)-.15 +-.15 F -.15(ex)184 144 S .171(pansion, and quote remo).15 F -.25(va)-.15 G 2.67(la).25 G .17(fter being e)-2.67 F .17(xpanded as described in) --.15 F F2(PR)2.67 E(OMPTING)-.27 E F0(abo)2.42 E -.15(ve)-.15 G(.).15 E -(This option is enabled by def)184 492 Q(ault.)-.1 E F1 -.18(re)144 504 -S(stricted_shell).18 E F0 1.069 +-.15 F/F2 9/Times-Bold@0 SF(PR)2.67 E(OMPTING)-.27 E F0(abo)2.42 E -.15 +(ve)-.15 G(.).15 E(This option is enabled by def)184 156 Q(ault.)-.1 E +F1 -.18(re)144 168 S(stricted_shell).18 E F0 1.069 (The shell sets this option if it is started in restricted mode \(see) -184 516 R F2 1.069(RESTRICTED SHELL)3.569 F F0(belo)184 528 Q 4.178 +184 180 R F2 1.069(RESTRICTED SHELL)3.569 F F0(belo)184 192 Q 4.178 (w\). The)-.25 F -.25(va)4.178 G 1.678(lue may not be changed.).25 F 1.678(This is not reset when the startup \214les are)6.678 F -.15(exe) -184 540 S(cuted, allo).15 E(wing the startup \214les to disco)-.25 E +184 204 S(cuted, allo).15 E(wing the startup \214les to disco)-.25 E -.15(ve)-.15 G 2.5(rw).15 G(hether or not a shell is restricted.)-2.5 E -F1(shift_v)144 552 Q(erbose)-.1 E F0 .501(If set, the)184 564 R F1 +F1(shift_v)144 216 Q(erbose)-.1 E F0 .501(If set, the)184 228 R F1 (shift)3.001 E F0 -.2(bu)3.001 G .501 (iltin prints an error message when the shift count e).2 F .502 -(xceeds the number)-.15 F(of positional parameters.)184 576 Q F1(sour) -144 588 Q(cepath)-.18 E F0 .771(If set, the)184 600 R F1(sour)3.271 E +(xceeds the number)-.15 F(of positional parameters.)184 240 Q F1(sour) +144 252 Q(cepath)-.18 E F0 .771(If set, the)184 264 R F1(sour)3.271 E (ce)-.18 E F0(\()3.271 E F1(.)A F0 3.271(\)b)C .771(uiltin uses the v) -3.471 F .771(alue of)-.25 F F2 -.666(PA)3.27 G(TH)-.189 E F0 .77 (to \214nd the directory containing the)3.02 F(\214le supplied as an ar) -184 612 Q 2.5(gument. This)-.18 F(option is enabled by def)2.5 E(ault.) --.1 E F1(xpg_echo)144 624 Q F0(If set, the)184 636 Q F1(echo)2.5 E F0 +184 276 Q 2.5(gument. This)-.18 F(option is enabled by def)2.5 E(ault.) +-.1 E F1(xpg_echo)144 288 Q F0(If set, the)184 300 Q F1(echo)2.5 E F0 -.2(bu)2.5 G(iltin e).2 E(xpands backslash-escape sequences by def)-.15 -E(ault.)-.1 E F1(suspend)108 652.8 Q F0([)2.5 E F1A F0(])A 1.001 -(Suspend the e)144 664.8 R -.15(xe)-.15 G 1.001 +E(ault.)-.1 E F1(suspend)108 316.8 Q F0([)2.5 E F1A F0(])A 1.001 +(Suspend the e)144 328.8 R -.15(xe)-.15 G 1.001 (cution of this shell until it recei).15 F -.15(ve)-.25 G 3.501(sa).15 G F2(SIGCONT)A F0 3.502(signal. A)3.252 F 1.002(login shell cannot be) -3.502 F .023(suspended; the)144 676.8 R F12.523 E F0 .023 +3.502 F .023(suspended; the)144 340.8 R F12.523 E F0 .023 (option can be used to o)2.523 F -.15(ve)-.15 G .022 (rride this and force the suspension.).15 F .022(The return status is) -5.022 F 2.5(0u)144 688.8 S(nless the shell is a login shell and)-2.5 E +5.022 F 2.5(0u)144 352.8 S(nless the shell is a login shell and)-2.5 E F12.5 E F0(is not supplied, or if job control is not enabled.)2.5 -E F1(test)108 705.6 Q F3 -.2(ex)2.5 G(pr).2 E F1([)108 717.6 Q F3 -.2 -(ex)2.5 G(pr).2 E F1(])2.5 E F0 .877 +E F1(test)108 369.6 Q/F3 10/Times-Italic@0 SF -.2(ex)2.5 G(pr).2 E F1([) +108 381.6 Q F3 -.2(ex)2.5 G(pr).2 E F1(])2.5 E F0 .877 (Return a status of 0 \(true\) or 1 \(f)6.77 F .878 (alse\) depending on the e)-.1 F -.25(va)-.25 G .878 -(luation of the conditional e).25 F(xpression)-.15 E F3 -.2(ex)144 729.6 +(luation of the conditional e).25 F(xpression)-.15 E F3 -.2(ex)144 393.6 S(pr).2 E F0 5.53(.E).73 G .53 (ach operator and operand must be a separate ar)-5.53 F 3.03 -(gument. Expressions)-.18 F .53(are composed of the)3.03 F(GNU Bash 4.2) -72 768 Q(2012 July 14)149.005 E(69)198.165 E 0 Cg EP -%%Page: 70 70 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E 3.079(primaries described abo)144 84 R 3.379 -.15(ve u)-.15 H -(nder).15 E/F1 9/Times-Bold@0 SF(CONDITION)5.579 E 3.079(AL EXPRESSIONS) --.18 F/F2 9/Times-Roman@0 SF(.)A/F3 10/Times-Bold@0 SF(test)7.579 E F0 -3.08(does not accept an)5.58 F(y)-.15 E -(options, nor does it accept and ignore an ar)144 96 Q(gument of)-.18 E -F32.5 E F0(as signifying the end of options.)2.5 E .786 -(Expressions may be combined using the follo)144 114 R .785 +(gument. Expressions)-.18 F .53(are composed of the)3.03 F 3.079 +(primaries described abo)144 405.6 R 3.379 -.15(ve u)-.15 H(nder).15 E +F2(CONDITION)5.579 E 3.079(AL EXPRESSIONS)-.18 F/F4 9/Times-Roman@0 SF +(.)A F1(test)7.579 E F0 3.08(does not accept an)5.58 F(y)-.15 E +(options, nor does it accept and ignore an ar)144 417.6 Q(gument of)-.18 +E F12.5 E F0(as signifying the end of options.)2.5 E .786 +(Expressions may be combined using the follo)144 435.6 R .785 (wing operators, listed in decreasing order of prece-)-.25 F 3.411 -(dence. The)144 126 R -.25(eva)3.411 G .911 +(dence. The)144 447.6 R -.25(eva)3.411 G .911 (luation depends on the number of ar).25 F .912(guments; see belo)-.18 F 4.712 -.65(w. O)-.25 H .912(perator precedence is).65 F -(used when there are \214v)144 138 Q 2.5(eo)-.15 G 2.5(rm)-2.5 G(ore ar) --2.5 E(guments.)-.18 E F3(!)144 150 Q/F4 10/Times-Italic@0 SF -.2(ex)2.5 -G(pr).2 E F0 -.35(Tr)12.6 G(ue if).35 E F4 -.2(ex)2.5 G(pr).2 E F0(is f) -3.23 E(alse.)-.1 E F3(\()144 162 Q F4 -.2(ex)2.5 G(pr).2 E F3(\))2.5 E -F0 .26(Returns the v)6.77 F .26(alue of)-.25 F F4 -.2(ex)2.76 G(pr).2 E -F0 5.26(.T)C .26(his may be used to o)-5.26 F -.15(ve)-.15 G .26 -(rride the normal precedence of opera-).15 F(tors.)180 174 Q F4 -.2(ex) -144 186 S(pr1).2 E F02.5 E F3(a)A F4 -.2(ex)2.5 G(pr2).2 E F0 -.35 -(Tr)180 198 S(ue if both).35 E F4 -.2(ex)2.5 G(pr1).2 E F0(and)2.5 E F4 --.2(ex)2.5 G(pr2).2 E F0(are true.)2.52 E F4 -.2(ex)144 210 S(pr1).2 E -F02.5 E F3(o)A F4 -.2(ex)2.5 G(pr2).2 E F0 -.35(Tr)180 222 S -(ue if either).35 E F4 -.2(ex)2.5 G(pr1).2 E F0(or)2.5 E F4 -.2(ex)2.5 G -(pr2).2 E F0(is true.)2.52 E F3(test)144 238.8 Q F0(and)2.5 E F3([)2.5 E -F0 -.25(eva)2.5 G(luate conditional e).25 E +(used when there are \214v)144 459.6 Q 2.5(eo)-.15 G 2.5(rm)-2.5 G +(ore ar)-2.5 E(guments.)-.18 E F1(!)144 471.6 Q F3 -.2(ex)2.5 G(pr).2 E +F0 -.35(Tr)12.6 G(ue if).35 E F3 -.2(ex)2.5 G(pr).2 E F0(is f)3.23 E +(alse.)-.1 E F1(\()144 483.6 Q F3 -.2(ex)2.5 G(pr).2 E F1(\))2.5 E F0 +.26(Returns the v)6.77 F .26(alue of)-.25 F F3 -.2(ex)2.76 G(pr).2 E F0 +5.26(.T)C .26(his may be used to o)-5.26 F -.15(ve)-.15 G .26 +(rride the normal precedence of opera-).15 F(tors.)180 495.6 Q F3 -.2 +(ex)144 507.6 S(pr1).2 E F02.5 E F1(a)A F3 -.2(ex)2.5 G(pr2).2 E F0 +-.35(Tr)180 519.6 S(ue if both).35 E F3 -.2(ex)2.5 G(pr1).2 E F0(and)2.5 +E F3 -.2(ex)2.5 G(pr2).2 E F0(are true.)2.52 E F3 -.2(ex)144 531.6 S +(pr1).2 E F02.5 E F1(o)A F3 -.2(ex)2.5 G(pr2).2 E F0 -.35(Tr)180 +543.6 S(ue if either).35 E F3 -.2(ex)2.5 G(pr1).2 E F0(or)2.5 E F3 -.2 +(ex)2.5 G(pr2).2 E F0(is true.)2.52 E F1(test)144 560.4 Q F0(and)2.5 E +F1([)2.5 E F0 -.25(eva)2.5 G(luate conditional e).25 E (xpressions using a set of rules based on the number of ar)-.15 E -(guments.)-.18 E 2.5(0a)144 256.8 S -.18(rg)-2.5 G(uments).18 E(The e) -180 268.8 Q(xpression is f)-.15 E(alse.)-.1 E 2.5(1a)144 280.8 S -.18 -(rg)-2.5 G(ument).18 E(The e)180 292.8 Q +(guments.)-.18 E 2.5(0a)144 578.4 S -.18(rg)-2.5 G(uments).18 E(The e) +180 590.4 Q(xpression is f)-.15 E(alse.)-.1 E 2.5(1a)144 602.4 S -.18 +(rg)-2.5 G(ument).18 E(The e)180 614.4 Q (xpression is true if and only if the ar)-.15 E(gument is not null.)-.18 -E 2.5(2a)144 304.8 S -.18(rg)-2.5 G(uments).18 E .37(If the \214rst ar) -180 316.8 R .37(gument is)-.18 F F3(!)2.87 E F0 2.87(,t)C .37(he e)-2.87 +E 2.5(2a)144 626.4 S -.18(rg)-2.5 G(uments).18 E .37(If the \214rst ar) +180 638.4 R .37(gument is)-.18 F F1(!)2.87 E F0 2.87(,t)C .37(he e)-2.87 F .37(xpression is true if and only if the second ar)-.15 F .37 -(gument is null.)-.18 F .38(If the \214rst ar)180 328.8 R .38 +(gument is null.)-.18 F .38(If the \214rst ar)180 650.4 R .38 (gument is one of the unary conditional operators listed abo)-.18 F .679 --.15(ve u)-.15 H(nder).15 E F1(CONDI-)2.879 E(TION)180 340.8 Q .552 -(AL EXPRESSIONS)-.18 F F2(,)A F0 .552(the e)2.802 F .552 +-.15(ve u)-.15 H(nder).15 E F2(CONDI-)2.879 E(TION)180 662.4 Q .552 +(AL EXPRESSIONS)-.18 F F4(,)A F0 .552(the e)2.802 F .552 (xpression is true if the unary test is true.)-.15 F .552 -(If the \214rst ar)5.552 F(gu-)-.18 E(ment is not a v)180 352.8 Q +(If the \214rst ar)5.552 F(gu-)-.18 E(ment is not a v)180 674.4 Q (alid unary conditional operator)-.25 E 2.5(,t)-.4 G(he e)-2.5 E -(xpression is f)-.15 E(alse.)-.1 E 2.5(3a)144 364.8 S -.18(rg)-2.5 G -(uments).18 E .236(The follo)180 376.8 R .236 +(xpression is f)-.15 E(alse.)-.1 E 2.5(3a)144 686.4 S -.18(rg)-2.5 G +(uments).18 E .236(The follo)180 698.4 R .236 (wing conditions are applied in the order listed.)-.25 F .236 (If the second ar)5.236 F .236(gument is one of)-.18 F .855 -(the binary conditional operators listed abo)180 388.8 R 1.155 -.15 -(ve u)-.15 H(nder).15 E F1(CONDITION)3.355 E .855(AL EXPRESSIONS)-.18 F -F2(,)A F0(the)3.105 E .579(result of the e)180 400.8 R .578(xpression i\ +(the binary conditional operators listed abo)180 710.4 R 1.155 -.15 +(ve u)-.15 H(nder).15 E F2(CONDITION)3.355 E .855(AL EXPRESSIONS)-.18 F +F4(,)A F0(the)3.105 E .579(result of the e)180 722.4 R .578(xpression i\ s the result of the binary test using the \214rst and third ar)-.15 F -(guments)-.18 E 1.332(as operands.)180 412.8 R(The)6.332 E F33.832 -E F0(and)3.832 E F33.832 E F0 1.333 +(guments)-.18 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15(ve)-.15 G +(mber 24).15 E(70)185.545 E 0 Cg EP +%%Page: 71 71 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E 1.332(as operands.)180 84 R(The)6.332 E/F1 10/Times-Bold@0 SF +3.832 E F0(and)3.832 E F13.832 E F0 1.333 (operators are considered binary operators when there are)3.832 F .558 -(three ar)180 424.8 R 3.058(guments. If)-.18 F .558(the \214rst ar)3.058 -F .558(gument is)-.18 F F3(!)3.058 E F0 3.058(,t)C .558(he v)-3.058 F -.558(alue is the ne)-.25 F -.05(ga)-.15 G .558(tion of the tw).05 F -(o-ar)-.1 E(gument)-.18 E .52(test using the second and third ar)180 -436.8 R 3.021(guments. If)-.18 F .521(the \214rst ar)3.021 F .521 -(gument is e)-.18 F(xactly)-.15 E F3(\()3.021 E F0 .521(and the third) -3.021 F(ar)180 448.8 Q .485(gument is e)-.18 F(xactly)-.15 E F3(\))2.985 -E F0 2.985(,t)C .485(he result is the one-ar)-2.985 F .485 -(gument test of the second ar)-.18 F 2.985(gument. Other)-.18 F(-)-.2 E -(wise, the e)180 460.8 Q(xpression is f)-.15 E(alse.)-.1 E 2.5(4a)144 -472.8 S -.18(rg)-2.5 G(uments).18 E .384(If the \214rst ar)180 484.8 R -.384(gument is)-.18 F F3(!)2.884 E F0 2.885(,t)C .385 -(he result is the ne)-2.885 F -.05(ga)-.15 G .385(tion of the three-ar) -.05 F .385(gument e)-.18 F .385(xpression com-)-.15 F 1.648 -(posed of the remaining ar)180 496.8 R 4.147(guments. Otherwise,)-.18 F -1.647(the e)4.147 F 1.647(xpression is parsed and e)-.15 F -.25(va)-.25 -G(luated).25 E(according to precedence using the rules listed abo)180 -508.8 Q -.15(ve)-.15 G(.).15 E 2.5(5o)144 520.8 S 2.5(rm)-2.5 G(ore ar) --2.5 E(guments)-.18 E 1.635(The e)180 532.8 R 1.635 -(xpression is parsed and e)-.15 F -.25(va)-.25 G 1.635 -(luated according to precedence using the rules listed).25 F(abo)180 -544.8 Q -.15(ve)-.15 G(.).15 E(When used with)144 562.8 Q F3(test)2.5 E -F0(or)2.5 E F3([)2.5 E F0 2.5(,t)C(he)-2.5 E F3(<)2.5 E F0(and)2.5 E F3 -(>)2.5 E F0(operators sort le)2.5 E -(xicographically using ASCII ordering.)-.15 E F3(times)108 579.6 Q F0 +(three ar)180 96 R 3.058(guments. If)-.18 F .558(the \214rst ar)3.058 F +.558(gument is)-.18 F F1(!)3.058 E F0 3.058(,t)C .558(he v)-3.058 F .558 +(alue is the ne)-.25 F -.05(ga)-.15 G .558(tion of the tw).05 F(o-ar)-.1 +E(gument)-.18 E .52(test using the second and third ar)180 108 R 3.021 +(guments. If)-.18 F .521(the \214rst ar)3.021 F .521(gument is e)-.18 F +(xactly)-.15 E F1(\()3.021 E F0 .521(and the third)3.021 F(ar)180 120 Q +.485(gument is e)-.18 F(xactly)-.15 E F1(\))2.985 E F0 2.985(,t)C .485 +(he result is the one-ar)-2.985 F .485(gument test of the second ar)-.18 +F 2.985(gument. Other)-.18 F(-)-.2 E(wise, the e)180 132 Q +(xpression is f)-.15 E(alse.)-.1 E 2.5(4a)144 144 S -.18(rg)-2.5 G +(uments).18 E .384(If the \214rst ar)180 156 R .384(gument is)-.18 F F1 +(!)2.884 E F0 2.885(,t)C .385(he result is the ne)-2.885 F -.05(ga)-.15 +G .385(tion of the three-ar).05 F .385(gument e)-.18 F .385 +(xpression com-)-.15 F 1.648(posed of the remaining ar)180 168 R 4.147 +(guments. Otherwise,)-.18 F 1.647(the e)4.147 F 1.647 +(xpression is parsed and e)-.15 F -.25(va)-.25 G(luated).25 E +(according to precedence using the rules listed abo)180 180 Q -.15(ve) +-.15 G(.).15 E 2.5(5o)144 192 S 2.5(rm)-2.5 G(ore ar)-2.5 E(guments)-.18 +E 1.635(The e)180 204 R 1.635(xpression is parsed and e)-.15 F -.25(va) +-.25 G 1.635(luated according to precedence using the rules listed).25 F +(abo)180 216 Q -.15(ve)-.15 G(.).15 E(When used with)144 234 Q F1(test) +2.5 E F0(or)2.5 E F1([)2.5 E F0 2.5(,t)C(he)-2.5 E F1(<)2.5 E F0(and)2.5 +E F1(>)2.5 E F0(operators sort le)2.5 E +(xicographically using ASCII ordering.)-.15 E F1(times)108 250.8 Q F0 1.229(Print the accumulated user and system times for the shell and for\ - processes run from the shell.)13.23 F(The return status is 0.)144 591.6 -Q F3(trap)108 608.4 Q F0([)2.5 E F3(\255lp)A F0 2.5(][)C([)-2.5 E F4(ar) -A(g)-.37 E F0(])A F4(sigspec)2.5 E F0(...])2.5 E .702(The command)144 -620.4 R F4(ar)3.532 E(g)-.37 E F0 .702(is to be read and e)3.422 F -.15 -(xe)-.15 G .702(cuted when the shell recei).15 F -.15(ve)-.25 G 3.203 -(ss).15 G(ignal\(s\))-3.203 E F4(sigspec)3.203 E F0 5.703(.I).31 G(f) --5.703 E F4(ar)3.533 E(g)-.37 E F0(is)3.423 E .609 -(absent \(and there is a single)144 632.4 R F4(sigspec)3.108 E F0 3.108 -(\)o)C(r)-3.108 E F33.108 E F0 3.108(,e)C .608 + processes run from the shell.)13.23 F(The return status is 0.)144 262.8 +Q F1(trap)108 279.6 Q F0([)2.5 E F1(\255lp)A F0 2.5(][)C([)-2.5 E/F2 10 +/Times-Italic@0 SF(ar)A(g)-.37 E F0(])A F2(sigspec)2.5 E F0(...])2.5 E +.702(The command)144 291.6 R F2(ar)3.532 E(g)-.37 E F0 .702 +(is to be read and e)3.422 F -.15(xe)-.15 G .702 +(cuted when the shell recei).15 F -.15(ve)-.25 G 3.203(ss).15 G +(ignal\(s\))-3.203 E F2(sigspec)3.203 E F0 5.703(.I).31 G(f)-5.703 E F2 +(ar)3.533 E(g)-.37 E F0(is)3.423 E .609(absent \(and there is a single) +144 303.6 R F2(sigspec)3.108 E F0 3.108(\)o)C(r)-3.108 E F13.108 E +F0 3.108(,e)C .608 (ach speci\214ed signal is reset to its original disposition)-3.108 F -.658(\(the v)144 644.4 R .658(alue it had upon entrance to the shell\).) --.25 F(If)5.658 E F4(ar)3.488 E(g)-.37 E F0 .659 -(is the null string the signal speci\214ed by each)3.378 F F4(sigspec) -144.34 656.4 Q F0 .581 +.658(\(the v)144 315.6 R .658(alue it had upon entrance to the shell\).) +-.25 F(If)5.658 E F2(ar)3.488 E(g)-.37 E F0 .659 +(is the null string the signal speci\214ed by each)3.378 F F2(sigspec) +144.34 327.6 Q F0 .581 (is ignored by the shell and by the commands it in)3.391 F -.2(vo)-.4 G --.1(ke).2 G 3.08(s. If).1 F F4(ar)3.41 E(g)-.37 E F0 .58 -(is not present and)3.3 F F33.08 E F0(has)3.08 E 1.214 -(been supplied, then the trap commands associated with each)144 668.4 R -F4(sigspec)4.054 E F0 1.215(are displayed.)4.024 F 1.215(If no ar)6.215 -F(gu-)-.18 E .86(ments are supplied or if only)144 680.4 R F33.36 -E F0 .86(is gi)3.36 F -.15(ve)-.25 G(n,).15 E F3(trap)3.36 E F0 .86 +-.1(ke).2 G 3.08(s. If).1 F F2(ar)3.41 E(g)-.37 E F0 .58 +(is not present and)3.3 F F13.08 E F0(has)3.08 E 1.214 +(been supplied, then the trap commands associated with each)144 339.6 R +F2(sigspec)4.054 E F0 1.215(are displayed.)4.024 F 1.215(If no ar)6.215 +F(gu-)-.18 E .86(ments are supplied or if only)144 351.6 R F13.36 +E F0 .86(is gi)3.36 F -.15(ve)-.25 G(n,).15 E F1(trap)3.36 E F0 .86 (prints the list of commands associated with each)3.36 F 2.83 -(signal. The)144 692.4 R F32.83 E F0 .33(option causes the shell \ +(signal. The)144 363.6 R F12.83 E F0 .33(option causes the shell \ to print a list of signal names and their corresponding num-)2.83 F -4.311(bers. Each)144 704.4 R F4(sigspec)4.651 E F0 1.811 -(is either a signal name de\214ned in <)4.621 F F4(signal.h)A F0 1.81 +4.311(bers. Each)144 375.6 R F2(sigspec)4.651 E F0 1.811 +(is either a signal name de\214ned in <)4.621 F F2(signal.h)A F0 1.81 (>, or a signal number)B 6.81(.S)-.55 G(ignal)-6.81 E -(names are case insensiti)144 716.4 Q .3 -.15(ve a)-.25 H(nd the).15 E -F1(SIG)2.5 E F0(pre\214x is optional.)2.25 E(GNU Bash 4.2)72 768 Q -(2012 July 14)149.005 E(70)198.165 E 0 Cg EP -%%Page: 71 71 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E 1.648(If a)144 84 R/F1 10/Times-Italic@0 SF(sigspec)4.488 E F0 -(is)4.458 E/F2 9/Times-Bold@0 SF(EXIT)4.148 E F0 1.648 -(\(0\) the command)3.898 F F1(ar)4.479 E(g)-.37 E F0 1.649(is e)4.369 F --.15(xe)-.15 G 1.649(cuted on e).15 F 1.649(xit from the shell.)-.15 F -1.649(If a)6.649 F F1(sigspec)4.489 E F0(is)4.459 E F2(DEB)144 96 Q(UG) --.09 E/F3 9/Times-Roman@0 SF(,)A F0 1.168(the command)3.418 F F1(ar) -3.998 E(g)-.37 E F0 1.168(is e)3.888 F -.15(xe)-.15 G 1.167 -(cuted before e).15 F -.15(ve)-.25 G(ry).15 E F1 1.167(simple command) -3.667 F F0(,)A F1(for)3.667 E F0(command,)3.667 E F1(case)3.667 E F0 -(com-)3.667 E(mand,)144 108 Q F1(select)2.646 E F0 .146(command, e)2.646 -F -.15(ve)-.25 G .146(ry arithmetic).15 F F1(for)2.646 E F0 .147 +(names are case insensiti)144 387.6 Q .3 -.15(ve a)-.25 H(nd the).15 E +/F3 9/Times-Bold@0 SF(SIG)2.5 E F0(pre\214x is optional.)2.25 E 1.648 +(If a)144 405.6 R F2(sigspec)4.488 E F0(is)4.458 E F3(EXIT)4.148 E F0 +1.648(\(0\) the command)3.898 F F2(ar)4.479 E(g)-.37 E F0 1.649(is e) +4.369 F -.15(xe)-.15 G 1.649(cuted on e).15 F 1.649(xit from the shell.) +-.15 F 1.649(If a)6.649 F F2(sigspec)4.489 E F0(is)4.459 E F3(DEB)144 +417.6 Q(UG)-.09 E/F4 9/Times-Roman@0 SF(,)A F0 1.168(the command)3.418 F +F2(ar)3.998 E(g)-.37 E F0 1.168(is e)3.888 F -.15(xe)-.15 G 1.167 +(cuted before e).15 F -.15(ve)-.25 G(ry).15 E F2 1.167(simple command) +3.667 F F0(,)A F2(for)3.667 E F0(command,)3.667 E F2(case)3.667 E F0 +(com-)3.667 E(mand,)144 429.6 Q F2(select)2.646 E F0 .146(command, e) +2.646 F -.15(ve)-.25 G .146(ry arithmetic).15 F F2(for)2.646 E F0 .147 (command, and before the \214rst command e)2.646 F -.15(xe)-.15 G .147 -(cutes in a).15 F .146(shell function \(see)144 120 R F2 .146 +(cutes in a).15 F .146(shell function \(see)144 441.6 R F3 .146 (SHELL GRAMMAR)2.646 F F0(abo)2.396 E -.15(ve)-.15 G 2.646(\). Refer).15 -F .146(to the description of the)2.646 F/F4 10/Times-Bold@0 SF(extdeb) -2.645 E(ug)-.2 E F0 .145(option to)2.645 F(the)144 132 Q F4(shopt)3.2 E -F0 -.2(bu)3.2 G .7(iltin for details of its ef).2 F .7(fect on the)-.25 -F F4(DEB)3.2 E(UG)-.1 E F0 3.2(trap. If)3.2 F(a)3.2 E F1(sigspec)3.54 E -F0(is)3.51 E F2(RETURN)3.2 E F3(,)A F0 .701(the com-)2.951 F(mand)144 -144 Q F1(ar)3.474 E(g)-.37 E F0 .644(is e)3.364 F -.15(xe)-.15 G .643 +F .146(to the description of the)2.646 F F1(extdeb)2.645 E(ug)-.2 E F0 +.145(option to)2.645 F(the)144 453.6 Q F1(shopt)3.2 E F0 -.2(bu)3.2 G .7 +(iltin for details of its ef).2 F .7(fect on the)-.25 F F1(DEB)3.2 E(UG) +-.1 E F0 3.2(trap. If)3.2 F(a)3.2 E F2(sigspec)3.54 E F0(is)3.51 E F3 +(RETURN)3.2 E F4(,)A F0 .701(the com-)2.951 F(mand)144 465.6 Q F2(ar) +3.474 E(g)-.37 E F0 .644(is e)3.364 F -.15(xe)-.15 G .643 (cuted each time a shell function or a script e).15 F -.15(xe)-.15 G -.643(cuted with the).15 F F4(.)3.143 E F0(or)3.143 E F4(sour)3.143 E(ce) --.18 E F0 -.2(bu)3.143 G(iltins).2 E(\214nishes e)144 156 Q -.15(xe)-.15 -G(cuting.).15 E .928(If a)144 174 R F1(sigspec)3.768 E F0(is)3.738 E F2 -(ERR)3.429 E F3(,)A F0 .929(the command)3.179 F F1(ar)3.759 E(g)-.37 E -F0 .929(is e)3.649 F -.15(xe)-.15 G .929(cuted whene).15 F -.15(ve)-.25 -G 3.429(ras).15 G .929(imple command has a non\255zero)-3.429 F -.15(ex) -144 186 S 1.009(it status, subject to the follo).15 F 1.009 -(wing conditions.)-.25 F(The)6.009 E F2(ERR)3.509 E F0 1.009 +.643(cuted with the).15 F F1(.)3.143 E F0(or)3.143 E F1(sour)3.143 E(ce) +-.18 E F0 -.2(bu)3.143 G(iltins).2 E(\214nishes e)144 477.6 Q -.15(xe) +-.15 G(cuting.).15 E .928(If a)144 495.6 R F2(sigspec)3.768 E F0(is) +3.738 E F3(ERR)3.429 E F4(,)A F0 .929(the command)3.179 F F2(ar)3.759 E +(g)-.37 E F0 .929(is e)3.649 F -.15(xe)-.15 G .929(cuted whene).15 F +-.15(ve)-.25 G 3.429(ras).15 G .929(imple command has a non\255zero) +-3.429 F -.15(ex)144 507.6 S 1.009(it status, subject to the follo).15 F +1.009(wing conditions.)-.25 F(The)6.009 E F3(ERR)3.509 E F0 1.009 (trap is not e)3.259 F -.15(xe)-.15 G 1.008(cuted if the f).15 F 1.008 (ailed com-)-.1 F .324 -(mand is part of the command list immediately follo)144 198 R .324 -(wing a)-.25 F F4(while)2.824 E F0(or)2.824 E F4(until)2.824 E F0 -.1 +(mand is part of the command list immediately follo)144 519.6 R .324 +(wing a)-.25 F F1(while)2.824 E F0(or)2.824 E F1(until)2.824 E F0 -.1 (ke)2.824 G(yw)-.05 E .324(ord, part of the test)-.1 F .151(in an)144 -210 R F1(if)2.661 E F0 .151(statement, part of a command e)4.611 F -.15 -(xe)-.15 G .151(cuted in a).15 F F4(&&)2.651 E F0(or)2.651 E F4(||)2.651 -E F0 .151(list, or if the command')2.651 F 2.651(sr)-.55 G .151(eturn v) --2.651 F(alue)-.25 E(is being in)144 222 Q -.15(ve)-.4 G(rted via).15 E -F4(!)2.5 E F0 5(.T)C(hese are the same conditions obe)-5 E(yed by the) --.15 E F4(err)2.5 E(exit)-.18 E F0(option.)2.5 E 1.095 +531.6 R F2(if)2.661 E F0 .151(statement, part of a command e)4.611 F +-.15(xe)-.15 G .151(cuted in a).15 F F1(&&)2.651 E F0(or)2.651 E F1(||) +2.651 E F0 .151(list, or if the command')2.651 F 2.651(sr)-.55 G .151 +(eturn v)-2.651 F(alue)-.25 E(is being in)144 543.6 Q -.15(ve)-.4 G +(rted via).15 E F1(!)2.5 E F0 5(.T)C(hese are the same conditions obe)-5 +E(yed by the)-.15 E F1(err)2.5 E(exit)-.18 E F0(option.)2.5 E 1.095 (Signals ignored upon entry to the shell cannot be trapped or reset.)144 -240 R -.35(Tr)6.095 G 1.095(apped signals that are not).35 F .662 -(being ignored are reset to their original v)144 252 R .662 +561.6 R -.35(Tr)6.095 G 1.095(apped signals that are not).35 F .662 +(being ignored are reset to their original v)144 573.6 R .662 (alues in a subshell or subshell en)-.25 F .661(vironment when one is) --.4 F 2.5(created. The)144 264 R(return status is f)2.5 E(alse if an)-.1 -E(y)-.15 E F1(sigspec)2.84 E F0(is in)2.81 E -.25(va)-.4 G -(lid; otherwise).25 E F4(trap)2.5 E F0(returns true.)2.5 E F4(type)108 -280.8 Q F0([)2.5 E F4(\255aftpP)A F0(])A F1(name)2.5 E F0([)2.5 E F1 -(name)A F0(...])2.5 E -.4(Wi)144 292.8 S .173 -(th no options, indicate ho).4 F 2.673(we)-.25 G(ach)-2.673 E F1(name) +-.4 F 2.5(created. The)144 585.6 R(return status is f)2.5 E(alse if an) +-.1 E(y)-.15 E F2(sigspec)2.84 E F0(is in)2.81 E -.25(va)-.4 G +(lid; otherwise).25 E F1(trap)2.5 E F0(returns true.)2.5 E F1(type)108 +602.4 Q F0([)2.5 E F1(\255aftpP)A F0(])A F2(name)2.5 E F0([)2.5 E F2 +(name)A F0(...])2.5 E -.4(Wi)144 614.4 S .173 +(th no options, indicate ho).4 F 2.673(we)-.25 G(ach)-2.673 E F2(name) 3.033 E F0 -.1(wo)2.853 G .174 (uld be interpreted if used as a command name.).1 F .174(If the)5.174 F -F4144 304.8 Q F0 .843(option is used,)3.343 F F4(type)3.343 E F0 -.843(prints a string which is one of)3.343 F F1(alias)3.343 E F0(,).27 E -F1 -.1(ke)3.343 G(ywor)-.2 E(d)-.37 E F0(,).77 E F1(function)3.343 E F0 -(,).24 E F1 -.2(bu)3.342 G(iltin).2 E F0 3.342(,o).24 G(r)-3.342 E F1 -(\214le)5.252 E F0(if)3.522 E F1(name)144.36 316.8 Q F0 .086 +F1144 626.4 Q F0 .843(option is used,)3.343 F F1(type)3.343 E F0 +.843(prints a string which is one of)3.343 F F2(alias)3.343 E F0(,).27 E +F2 -.1(ke)3.343 G(ywor)-.2 E(d)-.37 E F0(,).77 E F2(function)3.343 E F0 +(,).24 E F2 -.2(bu)3.342 G(iltin).2 E F0 3.342(,o).24 G(r)-3.342 E F2 +(\214le)5.252 E F0(if)3.522 E F2(name)144.36 638.4 Q F0 .086 (is an alias, shell reserv)2.766 F .086(ed w)-.15 F .086 (ord, function, b)-.1 F .087(uiltin, or disk \214le, respecti)-.2 F -.15 -(ve)-.25 G(ly).15 E 5.087(.I)-.65 G 2.587(ft)-5.087 G(he)-2.587 E F1 +(ve)-.25 G(ly).15 E 5.087(.I)-.65 G 2.587(ft)-5.087 G(he)-2.587 E F2 (name)2.947 E F0 .087(is not)2.767 F .119 -(found, then nothing is printed, and an e)144 328.8 R .118 +(found, then nothing is printed, and an e)144 650.4 R .118 (xit status of f)-.15 F .118(alse is returned.)-.1 F .118(If the)5.118 F -F42.618 E F0 .118(option is used,)2.618 F F4(type)2.618 E F0 .855 -(either returns the name of the disk \214le that w)144 340.8 R .855 -(ould be e)-.1 F -.15(xe)-.15 G .855(cuted if).15 F F1(name)3.715 E F0 +F12.618 E F0 .118(option is used,)2.618 F F1(type)2.618 E F0 .855 +(either returns the name of the disk \214le that w)144 662.4 R .855 +(ould be e)-.1 F -.15(xe)-.15 G .855(cuted if).15 F F2(name)3.715 E F0 .855(were speci\214ed as a com-)3.535 F .641(mand name, or nothing if) -144 352.8 R/F5 10/Courier@0 SF .641(type -t name)3.141 F F0 -.1(wo)3.141 -G .641(uld not return).1 F F1(\214le)3.14 E F0 5.64(.T).18 G(he)-5.64 E -F43.14 E F0 .64(option forces a)3.14 F F2 -.666(PA)3.14 G(TH)-.189 -E F0 .112(search for each)144 364.8 R F1(name)2.612 E F0 2.612(,e)C -.15 +144 674.4 R/F5 10/Courier@0 SF .641(type -t name)3.141 F F0 -.1(wo)3.141 +G .641(uld not return).1 F F2(\214le)3.14 E F0 5.64(.T).18 G(he)-5.64 E +F13.14 E F0 .64(option forces a)3.14 F F3 -.666(PA)3.14 G(TH)-.189 +E F0 .112(search for each)144 686.4 R F2(name)2.612 E F0 2.612(,e)C -.15 (ve)-2.862 G 2.613(ni).15 G(f)-2.613 E F5 .113(type -t name)2.613 F F0 --.1(wo)2.613 G .113(uld not return).1 F F1(\214le)2.613 E F0 5.113(.I) -.18 G 2.613(fac)-5.113 G .113(ommand is hashed,)-2.613 F F42.613 E -F0(and)144 376.8 Q F43.231 E F0 .731(print the hashed v)3.231 F +-.1(wo)2.613 G .113(uld not return).1 F F2(\214le)2.613 E F0 5.113(.I) +.18 G 2.613(fac)-5.113 G .113(ommand is hashed,)-2.613 F F12.613 E +F0(and)144 698.4 Q F13.231 E F0 .731(print the hashed v)3.231 F .73(alue, which is not necessarily the \214le that appears \214rst in) --.25 F F2 -.666(PA)3.23 G(TH)-.189 E F3(.)A F0 .73(If the)5.23 F F4 -144 388.8 Q F0 1.748(option is used,)4.248 F F4(type)4.248 E F0 +-.25 F F3 -.666(PA)3.23 G(TH)-.189 E F4(.)A F0 .73(If the)5.23 F F1 +144 710.4 Q F0 1.748(option is used,)4.248 F F1(type)4.248 E F0 1.748(prints all of the places that contain an e)4.248 F -.15(xe)-.15 G -1.748(cutable named).15 F F1(name)4.249 E F0 6.749(.T).18 G(his)-6.749 E -.744(includes aliases and functions, if and only if the)144 400.8 R F4 +1.748(cutable named).15 F F2(name)4.249 E F0 6.749(.T).18 G(his)-6.749 E +.744(includes aliases and functions, if and only if the)144 722.4 R F1 3.244 E F0 .744(option is not also used.)3.244 F .743 -(The table of hashed)5.744 F 1.223(commands is not consulted when using) -144 412.8 R F43.723 E F0 6.223(.T)C(he)-6.223 E F43.723 E F0 -1.223(option suppresses shell function lookup, as)3.723 F .326(with the) -144 424.8 R F4(command)2.826 E F0 -.2(bu)2.826 G(iltin.).2 E F4(type) -5.326 E F0 .326(returns true if all of the ar)2.826 F .325 +(The table of hashed)5.744 F(GNU Bash 4.2)72 768 Q(2012 No)136.385 E +-.15(ve)-.15 G(mber 24).15 E(71)185.545 E 0 Cg EP +%%Page: 72 72 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E 1.223(commands is not consulted when using)144 84 R/F1 10 +/Times-Bold@0 SF3.723 E F0 6.223(.T)C(he)-6.223 E F13.723 E +F0 1.223(option suppresses shell function lookup, as)3.723 F .326 +(with the)144 96 R F1(command)2.826 E F0 -.2(bu)2.826 G(iltin.).2 E F1 +(type)5.326 E F0 .326(returns true if all of the ar)2.826 F .325 (guments are found, f)-.18 F .325(alse if an)-.1 F 2.825(ya)-.15 G .325 -(re not)-2.825 F(found.)144 436.8 Q F4(ulimit)108 453.6 Q F0([)2.5 E F4 -(\255HST)A(abcde\214lmnpqrstuvx)-.92 E F0([)2.5 E F1(limit)A F0(]])A -(Pro)144 465.6 Q .243(vides control o)-.15 F -.15(ve)-.15 G 2.743(rt).15 -G .243(he resources a)-2.743 F -.25(va)-.2 G .244 +(re not)-2.825 F(found.)144 108 Q F1(ulimit)108 124.8 Q F0([)2.5 E F1 +(\255HST)A(abcde\214lmnpqrstuvx)-.92 E F0([)2.5 E/F2 10/Times-Italic@0 +SF(limit)A F0(]])A(Pro)144 136.8 Q .243(vides control o)-.15 F -.15(ve) +-.15 G 2.743(rt).15 G .243(he resources a)-2.743 F -.25(va)-.2 G .244 (ilable to the shell and to processes started by it, on systems).25 F -.944(that allo)144 477.6 R 3.444(ws)-.25 G .944(uch control.)-3.444 F -(The)5.944 E F43.444 E F0(and)3.444 E F43.444 E F0 .943 +.944(that allo)144 148.8 R 3.444(ws)-.25 G .944(uch control.)-3.444 F +(The)5.944 E F13.444 E F0(and)3.444 E F13.444 E F0 .943 (options specify that the hard or soft limit is set for the)3.444 F(gi) -144 489.6 Q -.15(ve)-.25 G 2.708(nr).15 G 2.708(esource. A)-2.708 F .208 +144 160.8 Q -.15(ve)-.25 G 2.708(nr).15 G 2.708(esource. A)-2.708 F .208 (hard limit cannot be increased by a non-root user once it is set; a so\ -ft limit may)2.708 F .426(be increased up to the v)144 501.6 R .426 -(alue of the hard limit.)-.25 F .425(If neither)5.426 F F42.925 E -F0(nor)2.925 E F42.925 E F0 .425 +ft limit may)2.708 F .426(be increased up to the v)144 172.8 R .426 +(alue of the hard limit.)-.25 F .425(If neither)5.426 F F12.925 E +F0(nor)2.925 E F12.925 E F0 .425 (is speci\214ed, both the soft and)2.925 F .139(hard limits are set.)144 -513.6 R .139(The v)5.139 F .139(alue of)-.25 F F1(limit)2.729 E F0 .139 +184.8 R .139(The v)5.139 F .139(alue of)-.25 F F2(limit)2.729 E F0 .139 (can be a number in the unit speci\214ed for the resource or one)3.319 F -.742(of the special v)144 525.6 R(alues)-.25 E F4(hard)3.242 E F0(,)A F4 -(soft)3.241 E F0 3.241(,o)C(r)-3.241 E F4(unlimited)3.241 E F0 3.241(,w) +.742(of the special v)144 196.8 R(alues)-.25 E F1(hard)3.242 E F0(,)A F1 +(soft)3.241 E F0 3.241(,o)C(r)-3.241 E F1(unlimited)3.241 E F0 3.241(,w) C .741(hich stand for the current hard limit, the current)-3.241 F .78 -(soft limit, and no limit, respecti)144 537.6 R -.15(ve)-.25 G(ly).15 E -5.78(.I)-.65 G(f)-5.78 E F1(limit)3.37 E F0 .78 +(soft limit, and no limit, respecti)144 208.8 R -.15(ve)-.25 G(ly).15 E +5.78(.I)-.65 G(f)-5.78 E F2(limit)3.37 E F0 .78 (is omitted, the current v)3.96 F .78(alue of the soft limit of the)-.25 -F .499(resource is printed, unless the)144 549.6 R F42.999 E F0 +F .499(resource is printed, unless the)144 220.8 R F12.999 E F0 .499(option is gi)2.999 F -.15(ve)-.25 G 2.999(n. When).15 F .498 (more than one resource is speci\214ed, the)2.999 F -(limit name and unit are printed before the v)144 561.6 Q 2.5 -(alue. Other)-.25 F(options are interpreted as follo)2.5 E(ws:)-.25 E F4 -144 573.6 Q F0(All current limits are reported)25.3 E F4144 -585.6 Q F0(The maximum sock)24.74 E(et b)-.1 E(uf)-.2 E(fer size)-.25 E -F4144 597.6 Q F0(The maximum size of core \214les created)25.86 E -F4144 609.6 Q F0(The maximum size of a process')24.74 E 2.5(sd) --.55 G(ata se)-2.5 E(gment)-.15 E F4144 621.6 Q F0 -(The maximum scheduling priority \("nice"\))25.86 E F4144 633.6 Q +(limit name and unit are printed before the v)144 232.8 Q 2.5 +(alue. Other)-.25 F(options are interpreted as follo)2.5 E(ws:)-.25 E F1 +144 244.8 Q F0(All current limits are reported)25.3 E F1144 +256.8 Q F0(The maximum sock)24.74 E(et b)-.1 E(uf)-.2 E(fer size)-.25 E +F1144 268.8 Q F0(The maximum size of core \214les created)25.86 E +F1144 280.8 Q F0(The maximum size of a process')24.74 E 2.5(sd) +-.55 G(ata se)-2.5 E(gment)-.15 E F1144 292.8 Q F0 +(The maximum scheduling priority \("nice"\))25.86 E F1144 304.8 Q F0(The maximum size of \214les written by the shell and its children) -26.97 E F4144 645.6 Q F0(The maximum number of pending signals) -27.52 E F4144 657.6 Q F0(The maximum size that may be lock)27.52 E -(ed into memory)-.1 E F4144 669.6 Q F0 +26.97 E F1144 316.8 Q F0(The maximum number of pending signals) +27.52 E F1144 328.8 Q F0(The maximum size that may be lock)27.52 E +(ed into memory)-.1 E F1144 340.8 Q F0 (The maximum resident set size \(man)21.97 E 2.5(ys)-.15 G -(ystems do not honor this limit\))-2.5 E F4144 681.6 Q F0 .791(Th\ +(ystems do not honor this limit\))-2.5 E F1144 352.8 Q F0 .791(Th\ e maximum number of open \214le descriptors \(most systems do not allo) 24.74 F 3.291(wt)-.25 G .791(his v)-3.291 F .791(alue to)-.25 F -(be set\))180 693.6 Q F4144 705.6 Q F0 -(The pipe size in 512-byte blocks \(this may not be set\))24.74 E F4 -144 717.6 Q F0 -(The maximum number of bytes in POSIX message queues)24.74 E -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(71)198.165 E 0 Cg EP -%%Page: 72 72 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E/F1 10/Times-Bold@0 SF144 84 Q F0 -(The maximum real-time scheduling priority)25.86 E F1144 96 Q F0 -(The maximum stack size)26.41 E F1144 108 Q F0 -(The maximum amount of cpu time in seconds)26.97 E F1144 120 Q F0 -(The maximum number of processes a)24.74 E -.25(va)-.2 G -(ilable to a single user).25 E F1144 132 Q F0 .47 +(be set\))180 364.8 Q F1144 376.8 Q F0 +(The pipe size in 512-byte blocks \(this may not be set\))24.74 E F1 +144 388.8 Q F0 +(The maximum number of bytes in POSIX message queues)24.74 E F1144 +400.8 Q F0(The maximum real-time scheduling priority)25.86 E F1144 +412.8 Q F0(The maximum stack size)26.41 E F1144 424.8 Q F0 +(The maximum amount of cpu time in seconds)26.97 E F1144 436.8 Q +F0(The maximum number of processes a)24.74 E -.25(va)-.2 G +(ilable to a single user).25 E F1144 448.8 Q F0 .47 (The maximum amount of virtual memory a)25.3 F -.25(va)-.2 G .47 -(ilable to the shell and, on some systems, to).25 F(its children)180 144 -Q F1144 156 Q F0(The maximum number of \214le locks)25.3 E F1 -144 168 Q F0(The maximum number of threads)23.63 E(If)144 184.8 Q -/F2 10/Times-Italic@0 SF(limit)3.058 E F0 .468(is gi)3.648 F -.15(ve) --.25 G .468(n, and the).15 F F12.968 E F0 .468 -(option is not used,)2.968 F F2(limit)2.968 E F0 .468(is the ne)2.968 F -2.968(wv)-.25 G .468(alue of the speci\214ed resource.)-3.218 F(If)5.468 -E .045(no option is gi)144 196.8 R -.15(ve)-.25 G .045(n, then).15 F F1 -2.545 E F0 .045(is assumed.)2.545 F -1.11(Va)5.045 G .045 +(ilable to the shell and, on some systems, to).25 F(its children)180 +460.8 Q F1144 472.8 Q F0(The maximum number of \214le locks)25.3 E +F1144 484.8 Q F0(The maximum number of threads)23.63 E(If)144 +501.6 Q F2(limit)3.058 E F0 .468(is gi)3.648 F -.15(ve)-.25 G .468 +(n, and the).15 F F12.968 E F0 .468(option is not used,)2.968 F F2 +(limit)2.968 E F0 .468(is the ne)2.968 F 2.968(wv)-.25 G .468 +(alue of the speci\214ed resource.)-3.218 F(If)5.468 E .045 +(no option is gi)144 513.6 R -.15(ve)-.25 G .045(n, then).15 F F1 +2.545 E F0 .045(is assumed.)2.545 F -1.11(Va)5.045 G .045 (lues are in 1024-byte increments, e)1.11 F .044(xcept for)-.15 F F1 2.544 E F0 2.544(,w)C .044(hich is)-2.544 F .402(in seconds;)144 -208.8 R F12.902 E F0 2.902(,w)C .402 +525.6 R F12.902 E F0 2.902(,w)C .402 (hich is in units of 512-byte blocks; and)-2.902 F F12.902 E F0(,) A F12.902 E F0(,)A F12.902 E F0 2.902(,a)C(nd)-2.902 E F1 2.903 E F0 2.903(,w)C .403(hich are unscaled)-2.903 F -.25(va)144 -220.8 S 3.083(lues. The).25 F .583(return status is 0 unless an in)3.083 +537.6 S 3.083(lues. The).25 F .583(return status is 0 unless an in)3.083 F -.25(va)-.4 G .583(lid option or ar).25 F .583 (gument is supplied, or an error occurs)-.18 F(while setting a ne)144 -232.8 Q 2.5(wl)-.25 G(imit.)-2.5 E F1(umask)108 249.6 Q F0([)2.5 E F1 +549.6 Q 2.5(wl)-.25 G(imit.)-2.5 E F1(umask)108 566.4 Q F0([)2.5 E F1 A F0 2.5(][)C F1-2.5 E F0 2.5(][)C F2(mode)-2.5 E F0(])A .2 -(The user \214le-creation mask is set to)144 261.6 R F2(mode)2.7 E F0 +(The user \214le-creation mask is set to)144 578.4 R F2(mode)2.7 E F0 5.2(.I).18 G(f)-5.2 E F2(mode)3.08 E F0(be)2.88 E .2 (gins with a digit, it is interpreted as an octal)-.15 F .066(number; o\ therwise it is interpreted as a symbolic mode mask similar to that acce\ -pted by)144 273.6 R F2 -.15(ch)2.566 G(mod).15 E F0(\(1\).).77 E(If)144 -285.6 Q F2(mode)3.262 E F0 .382(is omitted, the current v)3.062 F .382 +pted by)144 590.4 R F2 -.15(ch)2.566 G(mod).15 E F0(\(1\).).77 E(If)144 +602.4 Q F2(mode)3.262 E F0 .382(is omitted, the current v)3.062 F .382 (alue of the mask is printed.)-.25 F(The)5.382 E F12.882 E F0 .382 (option causes the mask to be)2.882 F .547 -(printed in symbolic form; the def)144 297.6 R .547 +(printed in symbolic form; the def)144 614.4 R .547 (ault output is an octal number)-.1 F 5.547(.I)-.55 G 3.047(ft)-5.547 G (he)-3.047 E F13.047 E F0 .547(option is supplied, and)3.047 F F2 -(mode)144.38 309.6 Q F0 .551 +(mode)144.38 626.4 Q F0 .551 (is omitted, the output is in a form that may be reused as input.)3.231 -F .552(The return status is 0 if the)5.552 F(mode w)144 321.6 Q +F .552(The return status is 0 if the)5.552 F(mode w)144 638.4 Q (as successfully changed or if no)-.1 E F2(mode)2.5 E F0(ar)2.5 E (gument w)-.18 E(as supplied, and f)-.1 E(alse otherwise.)-.1 E F1 -(unalias)108 338.4 Q F0<5bad>2.5 E F1(a)A F0 2.5(][)C F2(name)-2.5 E F0 -(...])2.5 E(Remo)144 350.4 Q 1.955 -.15(ve e)-.15 H(ach).15 E F2(name) +(unalias)108 655.2 Q F0<5bad>2.5 E F1(a)A F0 2.5(][)C F2(name)-2.5 E F0 +(...])2.5 E(Remo)144 667.2 Q 1.955 -.15(ve e)-.15 H(ach).15 E F2(name) 4.155 E F0 1.655(from the list of de\214ned aliases.)4.155 F(If)6.655 E F14.155 E F0 1.655(is supplied, all alias de\214nitions are)4.155 -F(remo)144 362.4 Q -.15(ve)-.15 G 2.5(d. The).15 F(return v)2.5 E +F(remo)144 679.2 Q -.15(ve)-.15 G 2.5(d. The).15 F(return v)2.5 E (alue is true unless a supplied)-.25 E F2(name)2.86 E F0 -(is not a de\214ned alias.)2.68 E F1(unset)108 379.2 Q F0<5bad>2.5 E F1 +(is not a de\214ned alias.)2.68 E F1(unset)108 696 Q F0<5bad>2.5 E F1 (fv)A F0 2.5(][)C-2.5 E F1(n)A F0 2.5(][)C F2(name)-2.5 E F0(...]) -2.5 E -.15(Fo)144 391.2 S 3.827(re).15 G(ach)-3.827 E F2(name)3.827 E F0 +2.5 E -.15(Fo)144 708 S 3.827(re).15 G(ach)-3.827 E F2(name)3.827 E F0 3.827(,r).18 G(emo)-3.827 E 1.627 -.15(ve t)-.15 H 1.327 (he corresponding v).15 F 1.327(ariable or function.)-.25 F 1.327 (If the)6.327 F F13.828 E F0 1.328(option is gi)3.828 F -.15(ve) --.25 G 1.328(n, each).15 F F2(name)144.36 403.2 Q F0 1.551 +-.25 G 1.328(n, each).15 F F2(name)144.36 720 Q F0 1.551 (refers to a shell v)4.231 F 1.551(ariable, and that v)-.25 F 1.551 (ariable is remo)-.25 F -.15(ve)-.15 G 4.05(d. Read-only).15 F -.25(va) -4.05 G 1.55(riables may not be).25 F 4.641(unset. If)144 415.2 R F1 -4.641 E F0 2.141(is speci\214ed, each)4.641 F F2(name)5.001 E F0 -2.141(refers to a shell function, and the function de\214nition is)4.821 -F(remo)144 427.2 Q -.15(ve)-.15 G 2.538(d. If).15 F(the)2.537 E F1 -2.537 E F0 .037(option is supplied, and)2.537 F F2(name)2.537 E F0 .037 -(is a v)2.537 F .037(ariable with the)-.25 F F2(namer)2.537 E(ef)-.37 E -F0(attrib)2.537 E(ute,)-.2 E F2(name)2.537 E F0(will)2.537 E .492 -(be unset rather than the v)144 439.2 R .492(ariable it references.)-.25 -F F15.492 E F0 .492(has no ef)2.992 F .492(fect if the)-.25 F F1 +4.05 G 1.55(riables may not be).25 F(GNU Bash 4.2)72 768 Q(2012 No) +136.385 E -.15(ve)-.15 G(mber 24).15 E(72)185.545 E 0 Cg EP +%%Page: 73 73 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) +-.35 E 4.641(unset. If)144 84 R/F1 10/Times-Bold@0 SF4.641 E F0 +2.141(is speci\214ed, each)4.641 F/F2 10/Times-Italic@0 SF(name)5.001 E +F0 2.141(refers to a shell function, and the function de\214nition is) +4.821 F(remo)144 96 Q -.15(ve)-.15 G 2.538(d. If).15 F(the)2.537 E F1 +2.537 E F0 .037(option is supplied, and)2.537 F F2(name)2.537 E F0 +.037(is a v)2.537 F .037(ariable with the)-.25 F F2(namer)2.537 E(ef) +-.37 E F0(attrib)2.537 E(ute,)-.2 E F2(name)2.537 E F0(will)2.537 E .492 +(be unset rather than the v)144 108 R .492(ariable it references.)-.25 F +F15.492 E F0 .492(has no ef)2.992 F .492(fect if the)-.25 F F1 2.992 E F0 .492(option is supplied.)2.992 F .493(If no)5.493 F -.221(options are supplied, each)144 451.2 R F2(name)2.721 E F0 .221 +.221(options are supplied, each)144 120 R F2(name)2.721 E F0 .221 (refers to a v)2.721 F .22(ariable; if there is no v)-.25 F .22 (ariable by that name, an)-.25 F 2.72(yf)-.15 G(unc-)-2.72 E 1.188 -(tion with that name is unset.)144 463.2 R 1.189(Each unset v)6.189 F +(tion with that name is unset.)144 132 R 1.189(Each unset v)6.189 F 1.189(ariable or function is remo)-.25 F -.15(ve)-.15 G 3.689(df).15 G 1.189(rom the en)-3.689 F(vironment)-.4 E 3.206 -(passed to subsequent commands.)144 475.2 R 3.206(If an)8.206 F 5.706 -(yo)-.15 G(f)-5.706 E/F3 9/Times-Bold@0 SF(COMP_W)5.706 E(ORDBREAKS)-.09 -E/F4 9/Times-Roman@0 SF(,)A F3(RANDOM)5.455 E F4(,)A F3(SECONDS)5.455 E -F4(,)A F3(LINENO)144 487.2 Q F4(,)A F3(HISTCMD)4.347 E F4(,)A F3(FUNCN) +(passed to subsequent commands.)144 144 R 3.206(If an)8.206 F 5.706(yo) +-.15 G(f)-5.706 E/F3 9/Times-Bold@0 SF(COMP_W)5.706 E(ORDBREAKS)-.09 E +/F4 9/Times-Roman@0 SF(,)A F3(RANDOM)5.455 E F4(,)A F3(SECONDS)5.455 E +F4(,)A F3(LINENO)144 156 Q F4(,)A F3(HISTCMD)4.347 E F4(,)A F3(FUNCN) 4.347 E(AME)-.18 E F4(,)A F3(GR)4.347 E(OUPS)-.27 E F4(,)A F0(or)4.348 E F3(DIRST)4.598 E -.495(AC)-.81 G(K).495 E F0 2.098(are unset, the)4.348 -F 4.598(yl)-.15 G 2.098(ose their special)-4.598 F(properties, e)144 -499.2 Q -.15(ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 G(he)-2.5 E 2.5(ya)-.15 -G(re subsequently reset.)-2.5 E(The e)5 E(xit status is true unless a) --.15 E F2(name)2.86 E F0(is readonly)2.68 E(.)-.65 E F1(wait)108 516 Q -F0([)2.5 E F2 2.5(n.)C(..)-2.5 E F0(])A -.8(Wa)144 528 S .288 +F 4.598(yl)-.15 G 2.098(ose their special)-4.598 F(properties, e)144 168 +Q -.15(ve)-.25 G 2.5(ni).15 G 2.5(ft)-2.5 G(he)-2.5 E 2.5(ya)-.15 G +(re subsequently reset.)-2.5 E(The e)5 E(xit status is true unless a) +-.15 E F2(name)2.86 E F0(is readonly)2.68 E(.)-.65 E F1(wait)108 184.8 Q +F0([)2.5 E F1(\255-n)A F0 2.5(][)C F2 2.5(n.)-2.5 G(..)-2.5 E F0(])A -.8 +(Wa)144 196.8 S .288 (it for each speci\214ed process and return its termination status.).8 F (Each)5.288 E F2(n)3.148 E F0 .287(may be a process ID or a)3.028 F .722 -(job speci\214cation; if a job spec is gi)144 540 R -.15(ve)-.25 G .722 -(n, all processes in that job').15 F 3.222(sp)-.55 G .722(ipeline are w) --3.222 F .722(aited for)-.1 F 5.722(.I)-.55 G(f)-5.722 E F2(n)3.583 E F0 -(is)3.463 E 1.266(not gi)144 552 R -.15(ve)-.25 G 1.266 -(n, all currently acti).15 F 1.566 -.15(ve c)-.25 H 1.265 -(hild processes are w).15 F 1.265(aited for)-.1 F 3.765(,a)-.4 G 1.265 -(nd the return status is zero.)-3.765 F(If)6.265 E F2(n)4.125 E F0 .456 -(speci\214es a non-e)144 564 R .457 -(xistent process or job, the return status is 127.)-.15 F .457 -(Otherwise, the return status is the)5.457 F -.15(ex)144 576 S -(it status of the last process or job w).15 E(aited for)-.1 E(.)-.55 E -/F5 10.95/Times-Bold@0 SF(RESTRICTED SHELL)72 592.8 Q F0(If)108 604.8 Q -F1(bash)4.397 E F0 1.897(is started with the name)4.397 F F1(rbash)4.397 -E F0 4.397(,o)C 4.397(rt)-4.397 G(he)-4.397 E F14.397 E F0 1.896 -(option is supplied at in)4.397 F -.2(vo)-.4 G 1.896 -(cation, the shell becomes).2 F 3.445(restricted. A)108 616.8 R .945 -(restricted shell is used to set up an en)3.445 F .946 -(vironment more controlled than the standard shell.)-.4 F(It)5.946 E -(beha)108 628.8 Q -.15(ve)-.2 G 2.5(si).15 G(dentically to)-2.5 E F1 +(job speci\214cation; if a job spec is gi)144 208.8 R -.15(ve)-.25 G +.722(n, all processes in that job').15 F 3.222(sp)-.55 G .722 +(ipeline are w)-3.222 F .722(aited for)-.1 F 5.722(.I)-.55 G(f)-5.722 E +F2(n)3.583 E F0(is)3.463 E .876(not gi)144 220.8 R -.15(ve)-.25 G .876 +(n, all currently acti).15 F 1.176 -.15(ve c)-.25 H .876 +(hild processes are w).15 F .876(aited for)-.1 F 3.376(,a)-.4 G .876 +(nd the return status is zero.)-3.376 F .875(If the)5.875 F F1(\255-n) +144 232.8 Q F0 .176(option is supplied,)2.676 F F1(wait)2.676 E F0 -.1 +(wa)2.676 G .176(its for an).1 F 2.677(yj)-.15 G .177 +(ob to terminate and returns its e)-2.677 F .177(xit status.)-.15 F(If) +5.177 E F2(n)3.037 E F0(speci\214es)2.917 E 2.596(an)144 244.8 S(on-e) +-2.596 E .096(xistent process or job, the return status is 127.)-.15 F +.095(Otherwise, the return status is the e)5.095 F .095(xit status)-.15 +F(of the last process or job w)144 256.8 Q(aited for)-.1 E(.)-.55 E/F5 +10.95/Times-Bold@0 SF(RESTRICTED SHELL)72 273.6 Q F0(If)108 285.6 Q F1 +(bash)4.396 E F0 1.896(is started with the name)4.396 F F1(rbash)4.397 E +F0 4.397(,o)C 4.397(rt)-4.397 G(he)-4.397 E F14.397 E F0 1.897 +(option is supplied at in)4.397 F -.2(vo)-.4 G 1.897 +(cation, the shell becomes).2 F 3.446(restricted. A)108 297.6 R .945 +(restricted shell is used to set up an en)3.446 F .945 +(vironment more controlled than the standard shell.)-.4 F(It)5.945 E +(beha)108 309.6 Q -.15(ve)-.2 G 2.5(si).15 G(dentically to)-2.5 E F1 (bash)2.5 E F0(with the e)2.5 E(xception that the follo)-.15 E (wing are disallo)-.25 E(wed or not performed:)-.25 E 32.5<8363>108 -645.6 S(hanging directories with)-32.5 E F1(cd)2.5 E F0 32.5<8373>108 -662.4 S(etting or unsetting the v)-32.5 E(alues of)-.25 E F3(SHELL)2.5 E +326.4 S(hanging directories with)-32.5 E F1(cd)2.5 E F0 32.5<8373>108 +343.2 S(etting or unsetting the v)-32.5 E(alues of)-.25 E F3(SHELL)2.5 E F4(,)A F3 -.666(PA)2.25 G(TH)-.189 E F4(,)A F3(ENV)2.25 E F4(,)A F0(or) -2.25 E F3 -.27(BA)2.5 G(SH_ENV).27 E F0 32.5<8373>108 679.2 S +2.25 E F3 -.27(BA)2.5 G(SH_ENV).27 E F0 32.5<8373>108 360 S (pecifying command names containing)-32.5 E F1(/)2.5 E F0 32.5<8373>108 -696 S(pecifying a \214lename containing a)-32.5 E F1(/)2.5 E F0 +376.8 S(pecifying a \214lename containing a)-32.5 E F1(/)2.5 E F0 (as an ar)2.5 E(gument to the)-.18 E F1(.)2.5 E F0 -.2(bu)5 G -(iltin command).2 E 32.5<8373>108 712.8 S .45 +(iltin command).2 E 32.5<8373>108 393.6 S .449 (pecifying a \214lename containing a slash as an ar)-32.5 F .449 -(gument to the)-.18 F F12.949 E F0 .449(option to the)2.949 F F1 -(hash)2.949 E F0 -.2(bu)2.949 G .449(iltin com-).2 F(mand)144 724.8 Q -(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E(72)198.165 E 0 Cg EP -%%Page: 73 73 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E 32.5<8369>108 84 S -(mporting function de\214nitions from the shell en)-32.5 E -(vironment at startup)-.4 E 32.5<8370>108 100.8 S(arsing the v)-32.5 E -(alue of)-.25 E/F1 9/Times-Bold@0 SF(SHELLOPTS)2.5 E F0 -(from the shell en)2.25 E(vironment at startup)-.4 E 32.5<8372>108 117.6 -S(edirecting output using the >, >|, <>, >&, &>, and >> redirection ope\ -rators)-32.5 E 32.5<8375>108 134.4 S(sing the)-32.5 E/F2 10/Times-Bold@0 -SF(exec)2.5 E F0 -.2(bu)2.5 G +(gument to the)-.18 F F12.95 E F0 .45(option to the)2.95 F F1 +(hash)2.95 E F0 -.2(bu)2.95 G .45(iltin com-).2 F(mand)144 405.6 Q 32.5 +<8369>108 422.4 S(mporting function de\214nitions from the shell en) +-32.5 E(vironment at startup)-.4 E 32.5<8370>108 439.2 S(arsing the v) +-32.5 E(alue of)-.25 E F3(SHELLOPTS)2.5 E F0(from the shell en)2.25 E +(vironment at startup)-.4 E 32.5<8372>108 456 S(edirecting output using\ + the >, >|, <>, >&, &>, and >> redirection operators)-32.5 E 32.5<8375> +108 472.8 S(sing the)-32.5 E F1(exec)2.5 E F0 -.2(bu)2.5 G (iltin command to replace the shell with another command).2 E 32.5<8361> -108 151.2 S(dding or deleting b)-32.5 E(uiltin commands with the)-.2 E -F22.5 E F0(and)2.5 E F22.5 E F0(options to the)2.5 E F2 -(enable)2.5 E F0 -.2(bu)2.5 G(iltin command).2 E 32.5<8375>108 168 S -(sing the)-32.5 E F2(enable)2.5 E F0 -.2(bu)2.5 G +108 489.6 S(dding or deleting b)-32.5 E(uiltin commands with the)-.2 E +F12.5 E F0(and)2.5 E F12.5 E F0(options to the)2.5 E F1 +(enable)2.5 E F0 -.2(bu)2.5 G(iltin command).2 E 32.5<8375>108 506.4 S +(sing the)-32.5 E F1(enable)2.5 E F0 -.2(bu)2.5 G (iltin command to enable disabled shell b).2 E(uiltins)-.2 E 32.5<8373> -108 184.8 S(pecifying the)-32.5 E F22.5 E F0(option to the)2.5 E -F2(command)2.5 E F0 -.2(bu)2.5 G(iltin command).2 E 32.5<8374>108 201.6 -S(urning of)-32.5 E 2.5(fr)-.25 G(estricted mode with)-2.5 E F2(set +r) -2.5 E F0(or)2.5 E F2(set +o r)2.5 E(estricted)-.18 E F0(.)A -(These restrictions are enforced after an)108 218.4 Q 2.5(ys)-.15 G +108 523.2 S(pecifying the)-32.5 E F12.5 E F0(option to the)2.5 E +F1(command)2.5 E F0 -.2(bu)2.5 G(iltin command).2 E 32.5<8374>108 540 S +(urning of)-32.5 E 2.5(fr)-.25 G(estricted mode with)-2.5 E F1(set +r) +2.5 E F0(or)2.5 E F1(set +o r)2.5 E(estricted)-.18 E F0(.)A +(These restrictions are enforced after an)108 556.8 Q 2.5(ys)-.15 G (tartup \214les are read.)-2.5 E 1.566 -(When a command that is found to be a shell script is e)108 235.2 R -.15 -(xe)-.15 G 1.567(cuted \(see).15 F F1 1.567(COMMAND EXECUTION)4.067 F F0 -(abo)3.817 E -.15(ve)-.15 G(\),).15 E F2(rbash)108 247.2 Q F0(turns of) +(When a command that is found to be a shell script is e)108 573.6 R -.15 +(xe)-.15 G 1.566(cuted \(see).15 F F3 1.566(COMMAND EXECUTION)4.066 F F0 +(abo)3.816 E -.15(ve)-.15 G(\),).15 E F1(rbash)108 585.6 Q F0(turns of) 2.5 E 2.5(fa)-.25 G .3 -.15(ny r)-2.5 H(estrictions in the shell spa).15 -E(wned to e)-.15 E -.15(xe)-.15 G(cute the script.).15 E/F3 10.95 -/Times-Bold@0 SF(SEE ALSO)72 264 Q/F4 10/Times-Italic@0 SF(Bash Refer) -108 276 Q(ence Manual)-.37 E F0 2.5(,B)C(rian F)-2.5 E(ox and Chet Rame) --.15 E(y)-.15 E F4(The Gnu Readline Libr)108 288 Q(ary)-.15 E F0 2.5(,B) -C(rian F)-2.5 E(ox and Chet Rame)-.15 E(y)-.15 E F4 -(The Gnu History Libr)108 300 Q(ary)-.15 E F0 2.5(,B)C(rian F)-2.5 E -(ox and Chet Rame)-.15 E(y)-.15 E F4 -.8(Po)108 312 S(rtable Oper).8 E -(ating System Interface \(POSIX\) P)-.15 E(art 2: Shell and Utilities) --.8 E F0 2.5(,I)C(EEE)-2.5 E F4(sh)108 324 Q F0(\(1\),)A F4(ksh)2.5 E F0 -(\(1\),)A F4(csh)2.5 E F0(\(1\))A F4(emacs)108 336 Q F0(\(1\),)A F4(vi) -2.5 E F0(\(1\))A F4 -.37(re)108 348 S(adline).37 E F0(\(3\))A F3(FILES) -72 364.8 Q F4(/bin/bash)109.666 376.8 Q F0(The)144 388.8 Q F2(bash)2.5 E -F0 -.15(exe)2.5 G(cutable).15 E F4(/etc/pr)109.666 400.8 Q(o\214le)-.45 -E F0(The systemwide initialization \214le, e)144 412.8 Q -.15(xe)-.15 G -(cuted for login shells).15 E F4(~/.bash_pr)109.666 424.8 Q(o\214le)-.45 -E F0(The personal initialization \214le, e)144 436.8 Q -.15(xe)-.15 G -(cuted for login shells).15 E F4(~/.bashr)109.666 448.8 Q(c)-.37 E F0 -(The indi)144 460.8 Q(vidual per)-.25 E(-interacti)-.2 E -.15(ve)-.25 G -(-shell startup \214le).15 E F4(~/.bash_lo)109.666 472.8 Q(gout)-.1 E F0 -(The indi)144 484.8 Q(vidual login shell cleanup \214le, e)-.25 E -.15 -(xe)-.15 G(cuted when a login shell e).15 E(xits)-.15 E F4(~/.inputr) -109.666 496.8 Q(c)-.37 E F0(Indi)144 508.8 Q(vidual)-.25 E F4 -.37(re) -2.5 G(adline).37 E F0(initialization \214le)2.5 E F3 -.548(AU)72 525.6 S -(THORS).548 E F0(Brian F)108 537.6 Q(ox, Free Softw)-.15 E(are F)-.1 E -(oundation)-.15 E(bfox@gnu.or)108 549.6 Q(g)-.18 E(Chet Rame)108 566.4 Q -1.3 -.65(y, C)-.15 H(ase W).65 E(estern Reserv)-.8 E 2.5(eU)-.15 G(ni) --2.5 E -.15(ve)-.25 G(rsity).15 E(chet.rame)108 578.4 Q(y@case.edu)-.15 -E F3 -.11(BU)72 595.2 S 2.738(GR).11 G(EPOR)-2.738 E(TS)-.438 E F0 .568 -(If you \214nd a b)108 607.2 R .568(ug in)-.2 F F2(bash,)3.068 E F0 .568 -(you should report it.)3.068 F .568(But \214rst, you should mak)5.568 F -3.068(es)-.1 G .568(ure that it really is a b)-3.068 F .567(ug, and)-.2 -F 5.625(that it appears in the latest v)108 619.2 R 5.625(ersion of)-.15 -F F2(bash)8.125 E F0 10.625(.T)C 5.625(he latest v)-10.625 F 5.626 -(ersion is al)-.15 F -.1(wa)-.1 G 5.626(ys a).1 F -.25(va)-.2 G 5.626 -(ilable from).25 F F4(ftp://ftp.gnu.or)108 631.2 Q(g/pub/gnu/bash/)-.37 -E F0(.)A .411(Once you ha)108 648 R .711 -.15(ve d)-.2 H .411 -(etermined that a b).15 F .411(ug actually e)-.2 F .411(xists, use the) --.15 F F4(bashb)3.18 E(ug)-.2 E F0 .41(command to submit a b)3.13 F .41 -(ug report.)-.2 F(If)5.41 E .594(you ha)108 660 R .894 -.15(ve a \214) --.2 H .595(x, you are encouraged to mail that as well!).15 F .595 -(Suggestions and `philosophical' b)5.595 F .595(ug reports may)-.2 F -(be mailed to)108 672 Q F4 -.2(bu)2.5 G(g-bash@gnu.or).2 E(g)-.37 E F0 -(or posted to the Usenet ne)2.5 E(wsgroup)-.25 E F2(gnu.bash.b)2.5 E(ug) --.2 E F0(.)A(ALL b)108 688.8 Q(ug reports should include:)-.2 E(The v) -108 705.6 Q(ersion number of)-.15 E F2(bash)2.5 E F0(GNU Bash 4.2)72 768 -Q(2012 July 14)149.005 E(73)198.165 E 0 Cg EP +E(wned to e)-.15 E -.15(xe)-.15 G(cute the script.).15 E F5(SEE ALSO)72 +602.4 Q F2(Bash Refer)108 614.4 Q(ence Manual)-.37 E F0 2.5(,B)C(rian F) +-2.5 E(ox and Chet Rame)-.15 E(y)-.15 E F2(The Gnu Readline Libr)108 +626.4 Q(ary)-.15 E F0 2.5(,B)C(rian F)-2.5 E(ox and Chet Rame)-.15 E(y) +-.15 E F2(The Gnu History Libr)108 638.4 Q(ary)-.15 E F0 2.5(,B)C +(rian F)-2.5 E(ox and Chet Rame)-.15 E(y)-.15 E F2 -.8(Po)108 650.4 S +(rtable Oper).8 E(ating System Interface \(POSIX\) P)-.15 E +(art 2: Shell and Utilities)-.8 E F0 2.5(,I)C(EEE)-2.5 E F2(sh)108 662.4 +Q F0(\(1\),)A F2(ksh)2.5 E F0(\(1\),)A F2(csh)2.5 E F0(\(1\))A F2(emacs) +108 674.4 Q F0(\(1\),)A F2(vi)2.5 E F0(\(1\))A F2 -.37(re)108 686.4 S +(adline).37 E F0(\(3\))A F5(FILES)72 703.2 Q F0(GNU Bash 4.2)72 768 Q +(2012 No)136.385 E -.15(ve)-.15 G(mber 24).15 E(73)185.545 E 0 Cg EP %%Page: 74 74 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.35(BA)72 48 S 389.54(SH\(1\) B).35 F(ASH\(1\)) --.35 E(The hardw)108 84 Q(are and operating system)-.1 E -(The compiler used to compile)108 96 Q 2.5(Ad)108 108 S -(escription of the b)-2.5 E(ug beha)-.2 E(viour)-.2 E 2.5(As)108 120 S -(hort script or `recipe' which e)-2.5 E -.15(xe)-.15 G(rcises the b).15 -E(ug)-.2 E/F1 10/Times-Italic@0 SF(bashb)108.27 136.8 Q(ug)-.2 E F0 +-.35 E/F1 10/Times-Italic@0 SF(/bin/bash)109.666 84 Q F0(The)144 96 Q/F2 +10/Times-Bold@0 SF(bash)2.5 E F0 -.15(exe)2.5 G(cutable).15 E F1 +(/etc/pr)109.666 108 Q(o\214le)-.45 E F0 +(The systemwide initialization \214le, e)144 120 Q -.15(xe)-.15 G +(cuted for login shells).15 E F1(~/.bash_pr)109.666 132 Q(o\214le)-.45 E +F0(The personal initialization \214le, e)144 144 Q -.15(xe)-.15 G +(cuted for login shells).15 E F1(~/.bashr)109.666 156 Q(c)-.37 E F0 +(The indi)144 168 Q(vidual per)-.25 E(-interacti)-.2 E -.15(ve)-.25 G +(-shell startup \214le).15 E F1(~/.bash_lo)109.666 180 Q(gout)-.1 E F0 +(The indi)144 192 Q(vidual login shell cleanup \214le, e)-.25 E -.15(xe) +-.15 G(cuted when a login shell e).15 E(xits)-.15 E F1(~/.inputr)109.666 +204 Q(c)-.37 E F0(Indi)144 216 Q(vidual)-.25 E F1 -.37(re)2.5 G(adline) +.37 E F0(initialization \214le)2.5 E/F3 10.95/Times-Bold@0 SF -.548(AU) +72 232.8 S(THORS).548 E F0(Brian F)108 244.8 Q(ox, Free Softw)-.15 E +(are F)-.1 E(oundation)-.15 E(bfox@gnu.or)108 256.8 Q(g)-.18 E +(Chet Rame)108 273.6 Q 1.3 -.65(y, C)-.15 H(ase W).65 E(estern Reserv) +-.8 E 2.5(eU)-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E(chet.rame)108 +285.6 Q(y@case.edu)-.15 E F3 -.11(BU)72 302.4 S 2.738(GR).11 G(EPOR) +-2.738 E(TS)-.438 E F0 .567(If you \214nd a b)108 314.4 R .568(ug in)-.2 +F F2(bash,)3.068 E F0 .568(you should report it.)3.068 F .568 +(But \214rst, you should mak)5.568 F 3.068(es)-.1 G .568 +(ure that it really is a b)-3.068 F .568(ug, and)-.2 F 5.626 +(that it appears in the latest v)108 326.4 R 5.625(ersion of)-.15 F F2 +(bash)8.125 E F0 10.625(.T)C 5.625(he latest v)-10.625 F 5.625 +(ersion is al)-.15 F -.1(wa)-.1 G 5.625(ys a).1 F -.25(va)-.2 G 5.625 +(ilable from).25 F F1(ftp://ftp.gnu.or)108 338.4 Q(g/pub/gnu/bash/)-.37 +E F0(.)A .41(Once you ha)108 355.2 R .71 -.15(ve d)-.2 H .41 +(etermined that a b).15 F .41(ug actually e)-.2 F .411(xists, use the) +-.15 F F1(bashb)3.181 E(ug)-.2 E F0 .411(command to submit a b)3.131 F +.411(ug report.)-.2 F(If)5.411 E .595(you ha)108 367.2 R .895 -.15 +(ve a \214)-.2 H .595(x, you are encouraged to mail that as well!).15 F +.594(Suggestions and `philosophical' b)5.595 F .594(ug reports may)-.2 F +(be mailed to)108 379.2 Q F1 -.2(bu)2.5 G(g-bash@gnu.or).2 E(g)-.37 E F0 +(or posted to the Usenet ne)2.5 E(wsgroup)-.25 E F2(gnu.bash.b)2.5 E(ug) +-.2 E F0(.)A(ALL b)108 396 Q(ug reports should include:)-.2 E(The v)108 +412.8 Q(ersion number of)-.15 E F2(bash)2.5 E F0(The hardw)108 424.8 Q +(are and operating system)-.1 E(The compiler used to compile)108 436.8 Q +2.5(Ad)108 448.8 S(escription of the b)-2.5 E(ug beha)-.2 E(viour)-.2 E +2.5(As)108 460.8 S(hort script or `recipe' which e)-2.5 E -.15(xe)-.15 G +(rcises the b).15 E(ug)-.2 E F1(bashb)108.27 477.6 Q(ug)-.2 E F0 (inserts the \214rst three items automatically into the template it pro) 2.72 E(vides for \214ling a b)-.15 E(ug report.)-.2 E(Comments and b)108 -153.6 Q(ug reports concerning this manual page should be directed to)-.2 +494.4 Q(ug reports concerning this manual page should be directed to)-.2 E F1 -.15(ch)2.5 G(et.r).15 E(ame)-.15 E(y@case)-.3 E(.edu)-.15 E F0(.) -.25 E/F2 10.95/Times-Bold@0 SF -.11(BU)72 170.4 S(GS).11 E F0(It')108 -182.4 Q 2.5(st)-.55 G(oo big and too slo)-2.5 E -.65(w.)-.25 G 1.869 -(There are some subtle dif)108 199.2 R 1.869(ferences between)-.25 F/F3 -10/Times-Bold@0 SF(bash)4.369 E F0 1.869(and traditional v)4.369 F 1.869 -(ersions of)-.15 F F3(sh)4.368 E F0 4.368(,m)C 1.868 -(ostly because of the)-4.368 F/F4 9/Times-Bold@0 SF(POSIX)108 211.2 Q F0 -(speci\214cation.)2.25 E(Aliases are confusing in some uses.)108 228 Q -(Shell b)108 244.8 Q +.25 E F3 -.11(BU)72 511.2 S(GS).11 E F0(It')108 523.2 Q 2.5(st)-.55 G +(oo big and too slo)-2.5 E -.65(w.)-.25 G 1.868 +(There are some subtle dif)108 540 R 1.868(ferences between)-.25 F F2 +(bash)4.369 E F0 1.869(and traditional v)4.369 F 1.869(ersions of)-.15 F +F2(sh)4.369 E F0 4.369(,m)C 1.869(ostly because of the)-4.369 F/F4 9 +/Times-Bold@0 SF(POSIX)108 552 Q F0(speci\214cation.)2.25 E +(Aliases are confusing in some uses.)108 568.8 Q(Shell b)108 585.6 Q (uiltin commands and functions are not stoppable/restartable.)-.2 E 1.315(Compound commands and command sequences of the form `a ; b ; c' a\ -re not handled gracefully when)108 261.6 R .39 -(process suspension is attempted.)108 273.6 R .389 -(When a process is stopped, the shell immediately e)5.39 F -.15(xe)-.15 -G .389(cutes the ne).15 F .389(xt com-)-.15 F .192 -(mand in the sequence.)108 285.6 R .192(It suf)5.192 F .192(\214ces to \ -place the sequence of commands between parentheses to force it into a) --.25 F(subshell, which may be stopped as a unit.)108 297.6 Q(Array v)108 -314.4 Q(ariables may not \(yet\) be e)-.25 E(xported.)-.15 E -(There may be only one acti)108 331.2 Q .3 -.15(ve c)-.25 H -(oprocess at a time.).15 E(GNU Bash 4.2)72 768 Q(2012 July 14)149.005 E -(74)198.165 E 0 Cg EP +re not handled gracefully when)108 602.4 R .389 +(process suspension is attempted.)108 614.4 R .389 +(When a process is stopped, the shell immediately e)5.389 F -.15(xe)-.15 +G .39(cutes the ne).15 F .39(xt com-)-.15 F .193(mand in the sequence.) +108 626.4 R .192(It suf)5.193 F .192(\214ces to place the sequence of c\ +ommands between parentheses to force it into a)-.25 F +(subshell, which may be stopped as a unit.)108 638.4 Q(Array v)108 655.2 +Q(ariables may not \(yet\) be e)-.25 E(xported.)-.15 E +(There may be only one acti)108 672 Q .3 -.15(ve c)-.25 H +(oprocess at a time.).15 E(GNU Bash 4.2)72 768 Q(2012 No)136.385 E -.15 +(ve)-.15 G(mber 24).15 E(74)185.545 E 0 Cg EP %%Trailer end %%EOF diff --git a/doc/bashref.texi b/doc/bashref.texi index 1d3ea1f2a..0b0ee013c 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -1197,6 +1197,8 @@ available as the value of the variable @env{NAME}_PID. The @code{wait} builtin command may be used to wait for the coprocess to terminate. +Since the coprocess is created as an asynchronous command, +the @code{coproc} command always returns success. The return status of a coprocess is the exit status of @var{command}. @node GNU Parallel @@ -4174,10 +4176,13 @@ Causes @code{printf} to output the corresponding @var{argument} in a format that can be reused as shell input. @item %(@var{datefmt})T Causes @code{printf} to output the date-time string resulting from using -@var{datefmt} as a format string for @code{strftime}(3). The corresponding -@var{argument} is an integer representing the number of seconds since the -epoch. Two special argument values may be used: -1 represents the current +@var{datefmt} as a format string for @code{strftime}(3). +The corresponding @var{argument} is an integer representing the number of +seconds since the epoch. +Two special argument values may be used: -1 represents the current time, and -2 represents the time the shell was invoked. +If no argument is specified, conversion behaves as if -1 had been given. +This is an exception to the usual @code{printf} behavior. @end table @noindent @@ -4269,12 +4274,15 @@ not echoed. @item -t @var{timeout} Cause @code{read} to time out and return failure if a complete line of -input is not read within @var{timeout} seconds. +input (or a specified number of characters) +is not read within @var{timeout} seconds. @var{timeout} may be a decimal number with a fractional portion following the decimal point. This option is only effective if @code{read} is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. +If @code{read} times out, @code{read} saves any partial input read into +the specified variable @var{name}. If @var{timeout} is 0, @code{read} returns immediately, without trying to read and data. The exit status is 0 if input is available on the specified file descriptor, non-zero otherwise. diff --git a/doc/bashref.texi~ b/doc/bashref.texi~ new file mode 100644 index 000000000..0dc862120 --- /dev/null +++ b/doc/bashref.texi~ @@ -0,0 +1,8627 @@ +\input texinfo.tex @c -*- texinfo -*- +@c %**start of header +@setfilename bashref.info +@settitle Bash Reference Manual + +@include version.texi +@c %**end of header + +@copying +This text is a brief description of the features that are present in +the Bash shell (version @value{VERSION}, @value{UPDATED}). + +This is Edition @value{EDITION}, last updated @value{UPDATED}, +of @cite{The GNU Bash Reference Manual}, +for @code{Bash}, Version @value{VERSION}. + +Copyright @copyright{} 1988--2012 Free Software Foundation, Inc. + +@quotation +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +A copy of the license is included in the section entitled +``GNU Free Documentation License''. +@end quotation +@end copying + +@defcodeindex bt +@defcodeindex rw +@set BashFeatures + +@dircategory Basics +@direntry +* Bash: (bash). The GNU Bourne-Again SHell. +@end direntry + +@finalout + +@titlepage +@title Bash Reference Manual +@subtitle Reference Documentation for Bash +@subtitle Edition @value{EDITION}, for @code{Bash} Version @value{VERSION}. +@subtitle @value{UPDATED-MONTH} +@author Chet Ramey, Case Western Reserve University +@author Brian Fox, Free Software Foundation + +@page +@vskip 0pt plus 1filll +@insertcopying + +@end titlepage + +@contents + +@ifnottex +@node Top, Introduction, (dir), (dir) +@top Bash Features + +This text is a brief description of the features that are present in +the Bash shell (version @value{VERSION}, @value{UPDATED}). +The Bash home page is @url{http://www.gnu.org/software/bash/}. + +This is Edition @value{EDITION}, last updated @value{UPDATED}, +of @cite{The GNU Bash Reference Manual}, +for @code{Bash}, Version @value{VERSION}. + +Bash contains features that appear in other popular shells, and some +features that only appear in Bash. Some of the shells that Bash has +borrowed concepts from are the Bourne Shell (@file{sh}), the Korn Shell +(@file{ksh}), and the C-shell (@file{csh} and its successor, +@file{tcsh}). The following menu breaks the features up into +categories, noting which features were inspired by other shells and +which are specific to Bash. + +This manual is meant as a brief introduction to features found in +Bash. The Bash manual page should be used as the definitive +reference on shell behavior. + +@menu +* Introduction:: An introduction to the shell. +* Definitions:: Some definitions used in the rest of this + manual. +* Basic Shell Features:: The shell "building blocks". +* Shell Builtin Commands:: Commands that are a part of the shell. +* Shell Variables:: Variables used or set by Bash. +* Bash Features:: Features found only in Bash. +* Job Control:: What job control is and how Bash allows you + to use it. +* Command Line Editing:: Chapter describing the command line + editing features. +* Using History Interactively:: Command History Expansion +* Installing Bash:: How to build and install Bash on your system. +* Reporting Bugs:: How to report bugs in Bash. +* Major Differences From The Bourne Shell:: A terse list of the differences + between Bash and historical + versions of /bin/sh. +* GNU Free Documentation License:: Copying and sharing this documentation. +* Indexes:: Various indexes for this manual. +@end menu +@end ifnottex + +@node Introduction +@chapter Introduction +@menu +* What is Bash?:: A short description of Bash. +* What is a shell?:: A brief introduction to shells. +@end menu + +@node What is Bash? +@section What is Bash? + +Bash is the shell, or command language interpreter, +for the @sc{gnu} operating system. +The name is an acronym for the @samp{Bourne-Again SHell}, +a pun on Stephen Bourne, the author of the direct ancestor of +the current Unix shell @code{sh}, +which appeared in the Seventh Edition Bell Labs Research version +of Unix. + +Bash is largely compatible with @code{sh} and incorporates useful +features from the Korn shell @code{ksh} and the C shell @code{csh}. +It is intended to be a conformant implementation of the @sc{ieee} +@sc{posix} Shell and Tools portion of the @sc{ieee} @sc{posix} +specification (@sc{ieee} Standard 1003.1). +It offers functional improvements over @code{sh} for both interactive and +programming use. + +While the @sc{gnu} operating system provides other shells, including +a version of @code{csh}, Bash is the default shell. +Like other @sc{gnu} software, Bash is quite portable. It currently runs +on nearly every version of Unix and a few other operating systems @minus{} +independently-supported ports exist for @sc{ms-dos}, @sc{os/2}, +and Windows platforms. + +@node What is a shell? +@section What is a shell? + +At its base, a shell is simply a macro processor that executes +commands. The term macro processor means functionality where text +and symbols are expanded to create larger expressions. + +A Unix shell is both a command interpreter and a programming +language. As a command interpreter, the shell provides the user +interface to the rich set of @sc{gnu} utilities. The programming +language features allow these utilities to be combined. +Files containing commands can be created, and become +commands themselves. These new commands have the same status as +system commands in directories such as @file{/bin}, allowing users +or groups to establish custom environments to automate their common +tasks. + +Shells may be used interactively or non-interactively. In +interactive mode, they accept input typed from the keyboard. +When executing non-interactively, shells execute commands read +from a file. + +A shell allows execution of @sc{gnu} commands, both synchronously and +asynchronously. +The shell waits for synchronous commands to complete before accepting +more input; asynchronous commands continue to execute in parallel +with the shell while it reads and executes additional commands. +The @dfn{redirection} constructs permit +fine-grained control of the input and output of those commands. +Moreover, the shell allows control over the contents of commands' +environments. + +Shells also provide a small set of built-in +commands (@dfn{builtins}) implementing functionality impossible +or inconvenient to obtain via separate utilities. +For example, @code{cd}, @code{break}, @code{continue}, and +@code{exec} cannot be implemented outside of the shell because +they directly manipulate the shell itself. +The @code{history}, @code{getopts}, @code{kill}, or @code{pwd} +builtins, among others, could be implemented in separate utilities, +but they are more convenient to use as builtin commands. +All of the shell builtins are described in +subsequent sections. + +While executing commands is essential, most of the power (and +complexity) of shells is due to their embedded programming +languages. Like any high-level language, the shell provides +variables, flow control constructs, quoting, and functions. + +Shells offer features geared specifically for +interactive use rather than to augment the programming language. +These interactive features include job control, command line +editing, command history and aliases. Each of these features is +described in this manual. + +@node Definitions +@chapter Definitions +These definitions are used throughout the remainder of this manual. + +@table @code + +@item POSIX +@cindex POSIX +A family of open system standards based on Unix. Bash +is primarily concerned with the Shell and Utilities portion of the +@sc{posix} 1003.1 standard. + +@item blank +A space or tab character. + +@item builtin +@cindex builtin +A command that is implemented internally by the shell itself, rather +than by an executable program somewhere in the file system. + +@item control operator +@cindex control operator +A @code{token} that performs a control function. It is a @code{newline} +or one of the following: +@samp{||}, @samp{&&}, @samp{&}, @samp{;}, @samp{;;}, +@samp{|}, @samp{|&}, @samp{(}, or @samp{)}. + +@item exit status +@cindex exit status +The value returned by a command to its caller. The value is restricted +to eight bits, so the maximum value is 255. + +@item field +@cindex field +A unit of text that is the result of one of the shell expansions. After +expansion, when executing a command, the resulting fields are used as +the command name and arguments. + +@item filename +@cindex filename +A string of characters used to identify a file. + +@item job +@cindex job +A set of processes comprising a pipeline, and any processes descended +from it, that are all in the same process group. + +@item job control +@cindex job control +A mechanism by which users can selectively stop (suspend) and restart +(resume) execution of processes. + +@item metacharacter +@cindex metacharacter +A character that, when unquoted, separates words. A metacharacter is +a @code{blank} or one of the following characters: +@samp{|}, @samp{&}, @samp{;}, @samp{(}, @samp{)}, @samp{<}, or +@samp{>}. + +@item name +@cindex name +@cindex identifier +A @code{word} consisting solely of letters, numbers, and underscores, +and beginning with a letter or underscore. @code{Name}s are used as +shell variable and function names. +Also referred to as an @code{identifier}. + +@item operator +@cindex operator, shell +A @code{control operator} or a @code{redirection operator}. +@xref{Redirections}, for a list of redirection operators. +Operators contain at least one unquoted @code{metacharacter}. + +@item process group +@cindex process group +A collection of related processes each having the same process +group @sc{id}. + +@item process group ID +@cindex process group ID +A unique identifier that represents a @code{process group} +during its lifetime. + +@item reserved word +@cindex reserved word +A @code{word} that has a special meaning to the shell. Most reserved +words introduce shell flow control constructs, such as @code{for} and +@code{while}. + +@item return status +@cindex return status +A synonym for @code{exit status}. + +@item signal +@cindex signal +A mechanism by which a process may be notified by the kernel +of an event occurring in the system. + +@item special builtin +@cindex special builtin +A shell builtin command that has been classified as special by the +@sc{posix} standard. + +@item token +@cindex token +A sequence of characters considered a single unit by the shell. +It is either a @code{word} or an @code{operator}. + +@item word +@cindex word +A sequence of characters treated as a unit by the shell. +Words may not include unquoted @code{metacharacters}. +@end table + +@node Basic Shell Features +@chapter Basic Shell Features +@cindex Bourne shell + +Bash is an acronym for @samp{Bourne-Again SHell}. +The Bourne shell is +the traditional Unix shell originally written by Stephen Bourne. +All of the Bourne shell builtin commands are available in Bash, +The rules for evaluation and quoting are taken from the @sc{posix} +specification for the `standard' Unix shell. + +This chapter briefly summarizes the shell's `building blocks': +commands, control structures, shell functions, shell @i{parameters}, +shell expansions, +@i{redirections}, which are a way to direct input and output from +and to named files, and how the shell executes commands. + +@menu +* Shell Syntax:: What your input means to the shell. +* Shell Commands:: The types of commands you can use. +* Shell Functions:: Grouping commands by name. +* Shell Parameters:: How the shell stores values. +* Shell Expansions:: How Bash expands parameters and the various + expansions available. +* Redirections:: A way to control where input and output go. +* Executing Commands:: What happens when you run a command. +* Shell Scripts:: Executing files of shell commands. +@end menu + +@node Shell Syntax +@section Shell Syntax +@menu +* Shell Operation:: The basic operation of the shell. +* Quoting:: How to remove the special meaning from characters. +* Comments:: How to specify comments. +@end menu + +When the shell reads input, it proceeds through a +sequence of operations. If the input indicates the beginning of a +comment, the shell ignores the comment symbol (@samp{#}), and the rest +of that line. + +Otherwise, roughly speaking, the shell reads its input and +divides the input into words and operators, employing the quoting rules +to select which meanings to assign various words and characters. + +The shell then parses these tokens into commands and other constructs, +removes the special meaning of certain words or characters, expands +others, redirects input and output as needed, executes the specified +command, waits for the command's exit status, and makes that exit status +available for further inspection or processing. + +@node Shell Operation +@subsection Shell Operation + +The following is a brief description of the shell's operation when it +reads and executes a command. Basically, the shell does the +following: + +@enumerate +@item +Reads its input from a file (@pxref{Shell Scripts}), from a string +supplied as an argument to the @option{-c} invocation option +(@pxref{Invoking Bash}), or from the user's terminal. + +@item +Breaks the input into words and operators, obeying the quoting rules +described in @ref{Quoting}. These tokens are separated by +@code{metacharacters}. Alias expansion is performed by this step +(@pxref{Aliases}). + +@item +Parses the tokens into simple and compound commands +(@pxref{Shell Commands}). + +@item +Performs the various shell expansions (@pxref{Shell Expansions}), breaking +the expanded tokens into lists of filenames (@pxref{Filename Expansion}) +and commands and arguments. + +@item +Performs any necessary redirections (@pxref{Redirections}) and removes +the redirection operators and their operands from the argument list. + +@item +Executes the command (@pxref{Executing Commands}). + +@item +Optionally waits for the command to complete and collects its exit +status (@pxref{Exit Status}). + +@end enumerate + +@node Quoting +@subsection Quoting +@cindex quoting +@menu +* Escape Character:: How to remove the special meaning from a single + character. +* Single Quotes:: How to inhibit all interpretation of a sequence + of characters. +* Double Quotes:: How to suppress most of the interpretation of a + sequence of characters. +* ANSI-C Quoting:: How to expand ANSI-C sequences in quoted strings. +* Locale Translation:: How to translate strings into different languages. +@end menu + +Quoting is used to remove the special meaning of certain +characters or words to the shell. Quoting can be used to +disable special treatment for special characters, to prevent +reserved words from being recognized as such, and to prevent +parameter expansion. + +Each of the shell metacharacters (@pxref{Definitions}) +has special meaning to the shell and must be quoted if it is to +represent itself. +When the command history expansion facilities are being used +(@pxref{History Interaction}), the +@var{history expansion} character, usually @samp{!}, must be quoted +to prevent history expansion. @xref{Bash History Facilities}, for +more details concerning history expansion. + +There are three quoting mechanisms: the +@var{escape character}, single quotes, and double quotes. + +@node Escape Character +@subsubsection Escape Character +A non-quoted backslash @samp{\} is the Bash escape character. +It preserves the literal value of the next character that follows, +with the exception of @code{newline}. If a @code{\newline} pair +appears, and the backslash itself is not quoted, the @code{\newline} +is treated as a line continuation (that is, it is removed from +the input stream and effectively ignored). + +@node Single Quotes +@subsubsection Single Quotes + +Enclosing characters in single quotes (@samp{'}) preserves the literal value +of each character within the quotes. A single quote may not occur +between single quotes, even when preceded by a backslash. + +@node Double Quotes +@subsubsection Double Quotes + +Enclosing characters in double quotes (@samp{"}) preserves the literal value +of all characters within the quotes, with the exception of +@samp{$}, @samp{`}, @samp{\}, +and, when history expansion is enabled, @samp{!}. +The characters @samp{$} and @samp{`} +retain their special meaning within double quotes (@pxref{Shell Expansions}). +The backslash retains its special meaning only when followed by one of +the following characters: +@samp{$}, @samp{`}, @samp{"}, @samp{\}, or @code{newline}. +Within double quotes, backslashes that are followed by one of these +characters are removed. Backslashes preceding characters without a +special meaning are left unmodified. +A double quote may be quoted within double quotes by preceding it with +a backslash. +If enabled, history expansion will be performed unless an @samp{!} +appearing in double quotes is escaped using a backslash. +The backslash preceding the @samp{!} is not removed. + +The special parameters @samp{*} and @samp{@@} have special meaning +when in double quotes (@pxref{Shell Parameter Expansion}). + +@node ANSI-C Quoting +@subsubsection ANSI-C Quoting +@cindex quoting, ANSI + +Words of the form @code{$'@var{string}'} are treated specially. The +word expands to @var{string}, with backslash-escaped characters replaced +as specified by the ANSI C standard. Backslash escape sequences, if +present, are decoded as follows: + +@table @code +@item \a +alert (bell) +@item \b +backspace +@item \e +@itemx \E +an escape character (not ANSI C) +@item \f +form feed +@item \n +newline +@item \r +carriage return +@item \t +horizontal tab +@item \v +vertical tab +@item \\ +backslash +@item \' +single quote +@item \" +double quote +@item \@var{nnn} +the eight-bit character whose value is the octal value @var{nnn} +(one to three digits) +@item \x@var{HH} +the eight-bit character whose value is the hexadecimal value @var{HH} +(one or two hex digits) +@item \u@var{HHHH} +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +@var{HHHH} (one to four hex digits) +@item \U@var{HHHHHHHH} +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +@var{HHHHHHHH} (one to eight hex digits) +@item \c@var{x} +a control-@var{x} character +@end table + +@noindent +The expanded result is single-quoted, as if the dollar sign had not +been present. + +@node Locale Translation +@subsubsection Locale-Specific Translation +@cindex localization +@cindex internationalization +@cindex native languages +@cindex translation, native languages + +A double-quoted string preceded by a dollar sign (@samp{$}) will cause +the string to be translated according to the current locale. +If the current locale is @code{C} or @code{POSIX}, the dollar sign +is ignored. +If the string is translated and replaced, the replacement is +double-quoted. + +@vindex LC_MESSAGES +@vindex TEXTDOMAIN +@vindex TEXTDOMAINDIR +Some systems use the message catalog selected by the @env{LC_MESSAGES} +shell variable. Others create the name of the message catalog from the +value of the @env{TEXTDOMAIN} shell variable, possibly adding a +suffix of @samp{.mo}. If you use the @env{TEXTDOMAIN} variable, you +may need to set the @env{TEXTDOMAINDIR} variable to the location of +the message catalog files. Still others use both variables in this +fashion: +@env{TEXTDOMAINDIR}/@env{LC_MESSAGES}/LC_MESSAGES/@env{TEXTDOMAIN}.mo. + +@node Comments +@subsection Comments +@cindex comments, shell + +In a non-interactive shell, or an interactive shell in which the +@code{interactive_comments} option to the @code{shopt} +builtin is enabled (@pxref{The Shopt Builtin}), +a word beginning with @samp{#} +causes that word and all remaining characters on that line to +be ignored. An interactive shell without the @code{interactive_comments} +option enabled does not allow comments. The @code{interactive_comments} +option is on by default in interactive shells. +@xref{Interactive Shells}, for a description of what makes +a shell interactive. + +@node Shell Commands +@section Shell Commands +@cindex commands, shell + +A simple shell command such as @code{echo a b c} consists of the command +itself followed by arguments, separated by spaces. + +More complex shell commands are composed of simple commands arranged together +in a variety of ways: in a pipeline in which the output of one command +becomes the input of a second, in a loop or conditional construct, or in +some other grouping. + +@menu +* Simple Commands:: The most common type of command. +* Pipelines:: Connecting the input and output of several + commands. +* Lists:: How to execute commands sequentially. +* Compound Commands:: Shell commands for control flow. +* Coprocesses:: Two-way communication between commands. +* GNU Parallel:: Running commands in parallel. +@end menu + +@node Simple Commands +@subsection Simple Commands +@cindex commands, simple + +A simple command is the kind of command encountered most often. +It's just a sequence of words separated by @code{blank}s, terminated +by one of the shell's control operators (@pxref{Definitions}). The +first word generally specifies a command to be executed, with the +rest of the words being that command's arguments. + +The return status (@pxref{Exit Status}) of a simple command is +its exit status as provided +by the @sc{posix} 1003.1 @code{waitpid} function, or 128+@var{n} if +the command was terminated by signal @var{n}. + +@node Pipelines +@subsection Pipelines +@cindex pipeline +@cindex commands, pipelines + +A @code{pipeline} is a sequence of simple commands separated by one of +the control operators @samp{|} or @samp{|&}. + +@rwindex time +@rwindex ! +@cindex command timing +The format for a pipeline is +@example +[time [-p]] [!] @var{command1} [ | or |& @var{command2} ] @dots{} +@end example + +@noindent +The output of each command in the pipeline is connected via a pipe +to the input of the next command. +That is, each command reads the previous command's output. This +connection is performed before any redirections specified by the +command. + +If @samp{|&} is used, @var{command1}'s standard output and standard error +are connected to +@var{command2}'s standard input through the pipe; +it is shorthand for @code{2>&1 |}. +This implicit redirection of the standard error is +performed after any redirections specified by the command. + +The reserved word @code{time} causes timing statistics +to be printed for the pipeline once it finishes. +The statistics currently consist of elapsed (wall-clock) time and +user and system time consumed by the command's execution. +The @option{-p} option changes the output format to that specified +by @sc{posix}. +When the shell is in @sc{posix} mode (@pxref{Bash POSIX Mode}), +it does not recognize @code{time} as a reserved word if the next +token begins with a @samp{-}. +The @env{TIMEFORMAT} variable may be set to a format string that +specifies how the timing information should be displayed. +@xref{Bash Variables}, for a description of the available formats. +The use of @code{time} as a reserved word permits the timing of +shell builtins, shell functions, and pipelines. An external +@code{time} command cannot time these easily. + +When the shell is in @sc{posix} mode (@pxref{Bash POSIX Mode}), @code{time} +may be followed by a newline. In this case, the shell displays the +total user and system time consumed by the shell and its children. +The @env{TIMEFORMAT} variable may be used to specify the format of +the time information. + +If the pipeline is not executed asynchronously (@pxref{Lists}), the +shell waits for all commands in the pipeline to complete. + +Each command in a pipeline is executed in its own subshell +(@pxref{Command Execution Environment}). The exit +status of a pipeline is the exit status of the last command in the +pipeline, unless the @code{pipefail} option is enabled +(@pxref{The Set Builtin}). +If @code{pipefail} is enabled, the pipeline's return status is the +value of the last (rightmost) command to exit with a non-zero status, +or zero if all commands exit successfully. +If the reserved word @samp{!} precedes the pipeline, the +exit status is the logical negation of the exit status as described +above. +The shell waits for all commands in the pipeline to terminate before +returning a value. + +@node Lists +@subsection Lists of Commands +@cindex commands, lists + +A @code{list} is a sequence of one or more pipelines separated by one +of the operators @samp{;}, @samp{&}, @samp{&&}, or @samp{||}, +and optionally terminated by one of @samp{;}, @samp{&}, or a +@code{newline}. + +Of these list operators, @samp{&&} and @samp{||} +have equal precedence, followed by @samp{;} and @samp{&}, +which have equal precedence. + +A sequence of one or more newlines may appear in a @code{list} +to delimit commands, equivalent to a semicolon. + +If a command is terminated by the control operator @samp{&}, +the shell executes the command asynchronously in a subshell. +This is known as executing the command in the @var{background}. +The shell does not wait for the command to finish, and the return +status is 0 (true). +When job control is not active (@pxref{Job Control}), +the standard input for asynchronous commands, in the absence of any +explicit redirections, is redirected from @code{/dev/null}. + +Commands separated by a @samp{;} are executed sequentially; the shell +waits for each command to terminate in turn. The return status is the +exit status of the last command executed. + +@sc{and} and @sc{or} lists are sequences of one or more pipelines +separated by the control operators @samp{&&} and @samp{||}, +respectively. @sc{and} and @sc{or} lists are executed with left +associativity. + +An @sc{and} list has the form +@example +@var{command1} && @var{command2} +@end example + +@noindent +@var{command2} is executed if, and only if, @var{command1} +returns an exit status of zero. + +An @sc{or} list has the form +@example +@var{command1} || @var{command2} +@end example + +@noindent +@var{command2} is executed if, and only if, @var{command1} +returns a non-zero exit status. + +The return status of +@sc{and} and @sc{or} lists is the exit status of the last command +executed in the list. + +@node Compound Commands +@subsection Compound Commands +@cindex commands, compound + +@menu +* Looping Constructs:: Shell commands for iterative action. +* Conditional Constructs:: Shell commands for conditional execution. +* Command Grouping:: Ways to group commands. +@end menu + +Compound commands are the shell programming constructs. +Each construct begins with a reserved word or control operator and is +terminated by a corresponding reserved word or operator. +Any redirections (@pxref{Redirections}) associated with a compound command +apply to all commands within that compound command unless explicitly overridden. + +In most cases a list of commands in a compound command's description may be +separated from the rest of the command by one or more newlines, and may be +followed by a newline in place of a semicolon. + +Bash provides looping constructs, conditional commands, and mechanisms +to group commands and execute them as a unit. + +@node Looping Constructs +@subsubsection Looping Constructs +@cindex commands, looping + +Bash supports the following looping constructs. + +Note that wherever a @samp{;} appears in the description of a +command's syntax, it may be replaced with one or more newlines. + +@table @code +@item until +@rwindex until +@rwindex do +@rwindex done +The syntax of the @code{until} command is: + +@example +until @var{test-commands}; do @var{consequent-commands}; done +@end example + +Execute @var{consequent-commands} as long as +@var{test-commands} has an exit status which is not zero. +The return status is the exit status of the last command executed +in @var{consequent-commands}, or zero if none was executed. + +@item while +@rwindex while +The syntax of the @code{while} command is: + +@example +while @var{test-commands}; do @var{consequent-commands}; done +@end example + +Execute @var{consequent-commands} as long as +@var{test-commands} has an exit status of zero. +The return status is the exit status of the last command executed +in @var{consequent-commands}, or zero if none was executed. + +@item for +@rwindex for +The syntax of the @code{for} command is: + +@example +for @var{name} [ [in [@var{words} @dots{}] ] ; ] do @var{commands}; done +@end example + +Expand @var{words}, and execute @var{commands} once for each member +in the resultant list, with @var{name} bound to the current member. +If @samp{in @var{words}} is not present, the @code{for} command +executes the @var{commands} once for each positional parameter that is +set, as if @samp{in "$@@"} had been specified +(@pxref{Special Parameters}). +The return status is the exit status of the last command that executes. +If there are no items in the expansion of @var{words}, no commands are +executed, and the return status is zero. + +An alternate form of the @code{for} command is also supported: + +@example +for (( @var{expr1} ; @var{expr2} ; @var{expr3} )) ; do @var{commands} ; done +@end example + +First, the arithmetic expression @var{expr1} is evaluated according +to the rules described below (@pxref{Shell Arithmetic}). +The arithmetic expression @var{expr2} is then evaluated repeatedly +until it evaluates to zero. +Each time @var{expr2} evaluates to a non-zero value, @var{commands} are +executed and the arithmetic expression @var{expr3} is evaluated. +If any expression is omitted, it behaves as if it evaluates to 1. +The return value is the exit status of the last command in @var{commands} +that is executed, or false if any of the expressions is invalid. +@end table + +The @code{break} and @code{continue} builtins (@pxref{Bourne Shell Builtins}) +may be used to control loop execution. + +@node Conditional Constructs +@subsubsection Conditional Constructs +@cindex commands, conditional + +@table @code +@item if +@rwindex if +@rwindex then +@rwindex else +@rwindex elif +@rwindex fi +The syntax of the @code{if} command is: + +@example +if @var{test-commands}; then + @var{consequent-commands}; +[elif @var{more-test-commands}; then + @var{more-consequents};] +[else @var{alternate-consequents};] +fi +@end example + +The @var{test-commands} list is executed, and if its return status is zero, +the @var{consequent-commands} list is executed. +If @var{test-commands} returns a non-zero status, each @code{elif} list +is executed in turn, and if its exit status is zero, +the corresponding @var{more-consequents} is executed and the +command completes. +If @samp{else @var{alternate-consequents}} is present, and +the final command in the final @code{if} or @code{elif} clause +has a non-zero exit status, then @var{alternate-consequents} is executed. +The return status is the exit status of the last command executed, or +zero if no condition tested true. + +@item case +@rwindex case +@rwindex in +@rwindex esac +The syntax of the @code{case} command is: + +@example +case @var{word} in [ [(] @var{pattern} [| @var{pattern}]@dots{}) @var{command-list} ;;]@dots{} esac +@end example + +@code{case} will selectively execute the @var{command-list} corresponding to +the first @var{pattern} that matches @var{word}. +If the shell option @code{nocasematch} +(see the description of @code{shopt} in @ref{The Shopt Builtin}) +is enabled, the match is performed without regard to the case +of alphabetic characters. +The @samp{|} is used to separate multiple patterns, and the @samp{)} +operator terminates a pattern list. +A list of patterns and an associated command-list is known +as a @var{clause}. + +Each clause must be terminated with @samp{;;}, @samp{;&}, or @samp{;;&}. +The @var{word} undergoes tilde expansion, parameter expansion, command +substitution, arithmetic expansion, and quote removal before matching is +attempted. Each @var{pattern} undergoes tilde expansion, parameter +expansion, command substitution, and arithmetic expansion. + +There may be an arbitrary number of @code{case} clauses, each terminated +by a @samp{;;}, @samp{;&}, or @samp{;;&}. +The first pattern that matches determines the +command-list that is executed. +It's a common idiom to use @samp{*} as the final pattern to define the +default case, since that pattern will always match. + +Here is an example using @code{case} in a script that could be used to +describe one interesting feature of an animal: + +@example +echo -n "Enter the name of an animal: " +read ANIMAL +echo -n "The $ANIMAL has " +case $ANIMAL in + horse | dog | cat) echo -n "four";; + man | kangaroo ) echo -n "two";; + *) echo -n "an unknown number of";; +esac +echo " legs." +@end example + +@noindent + +If the @samp{;;} operator is used, no subsequent matches are attempted after +the first pattern match. +Using @samp{;&} in place of @samp{;;} causes execution to continue with +the @var{command-list} associated with the next clause, if any. +Using @samp{;;&} in place of @samp{;;} causes the shell to test the patterns +in the next clause, if any, and execute any associated @var{command-list} +on a successful match. + +The return status is zero if no @var{pattern} is matched. Otherwise, the +return status is the exit status of the @var{command-list} executed. + +@item select +@rwindex select + +The @code{select} construct allows the easy generation of menus. +It has almost the same syntax as the @code{for} command: + +@example +select @var{name} [in @var{words} @dots{}]; do @var{commands}; done +@end example + +The list of words following @code{in} is expanded, generating a list +of items. The set of expanded words is printed on the standard +error output stream, each preceded by a number. If the +@samp{in @var{words}} is omitted, the positional parameters are printed, +as if @samp{in "$@@"} had been specified. +The @env{PS3} prompt is then displayed and a line is read from the +standard input. +If the line consists of a number corresponding to one of the displayed +words, then the value of @var{name} is set to that word. +If the line is empty, the words and prompt are displayed again. +If @code{EOF} is read, the @code{select} command completes. +Any other value read causes @var{name} to be set to null. +The line read is saved in the variable @env{REPLY}. + +The @var{commands} are executed after each selection until a +@code{break} command is executed, at which +point the @code{select} command completes. + +Here is an example that allows the user to pick a filename from the +current directory, and displays the name and index of the file +selected. + +@example +select fname in *; +do + echo you picked $fname \($REPLY\) + break; +done +@end example + +@item ((@dots{})) +@example +(( @var{expression} )) +@end example + +The arithmetic @var{expression} is evaluated according to the rules +described below (@pxref{Shell Arithmetic}). +If the value of the expression is non-zero, the return status is 0; +otherwise the return status is 1. This is exactly equivalent to +@example +let "@var{expression}" +@end example +@noindent +@xref{Bash Builtins}, for a full description of the @code{let} builtin. + +@item [[@dots{}]] +@rwindex [[ +@rwindex ]] +@example +[[ @var{expression} ]] +@end example + +Return a status of 0 or 1 depending on the evaluation of +the conditional expression @var{expression}. +Expressions are composed of the primaries described below in +@ref{Bash Conditional Expressions}. +Word splitting and filename expansion are not performed on the words +between the @code{[[} and @code{]]}; tilde expansion, parameter and +variable expansion, arithmetic expansion, command substitution, process +substitution, and quote removal are performed. +Conditional operators such as @samp{-f} must be unquoted to be recognized +as primaries. + +When used with @code{[[}, the @samp{<} and @samp{>} operators sort +lexicographically using the current locale. + +When the @samp{==} and @samp{!=} operators are used, the string to the +right of the operator is considered a pattern and matched according +to the rules described below in @ref{Pattern Matching}. +The @samp{=} operator is identical to @samp{==}. +If the shell option @code{nocasematch} +(see the description of @code{shopt} in @ref{The Shopt Builtin}) +is enabled, the match is performed without regard to the case +of alphabetic characters. +The return value is 0 if the string matches (@samp{==}) or does not +match (@samp{!=})the pattern, and 1 otherwise. +Any part of the pattern may be quoted to force the quoted portion +to be matched as a string. + +An additional binary operator, @samp{=~}, is available, with the same +precedence as @samp{==} and @samp{!=}. +When it is used, the string to the right of the operator is considered +an extended regular expression and matched accordingly (as in @i{regex}3)). +The return value is 0 if the string matches +the pattern, and 1 otherwise. +If the regular expression is syntactically incorrect, the conditional +expression's return value is 2. +If the shell option @code{nocasematch} +(see the description of @code{shopt} in @ref{The Shopt Builtin}) +is enabled, the match is performed without regard to the case +of alphabetic characters. +Any part of the pattern may be quoted to force the quoted portion +to be matched as a string. +Bracket expressions in regular expressions must be treated carefully, +since normal quoting characters lose their meanings between brackets. +If the pattern is stored in a shell variable, quoting the variable +expansion forces the entire pattern to be matched as a string. +Substrings matched by parenthesized subexpressions within the regular +expression are saved in the array variable @code{BASH_REMATCH}. +The element of @code{BASH_REMATCH} with index 0 is the portion of the string +matching the entire regular expression. +The element of @code{BASH_REMATCH} with index @var{n} is the portion of the +string matching the @var{n}th parenthesized subexpression. + +For example, the following will match a line +(stored in the shell variable @var{line}) +if there is a sequence of characters in the value consisting of +any number, including zero, of +space characters, zero or one instances of @samp{a}, then a @samp{b}: +@example +[[ $line =~ [[:space:]]*(a)?b ]] +@end example + +@noindent +That means values like @samp{aab} and @samp{ aaaaaab} will match, as +will a line containing a @samp{b} anywhere in its value. + +Storing the regular expression in a shell variable is often a useful +way to avoid problems with quoting characters that are special to the +shell. +It is sometimes difficult to specify a regular expression literally +without using quotes, or to keep track of the quoting used by regular +expressions while paying attention to the shell's quote removal. +Using a shell variable to store the pattern decreases these problems. +For example, the following is equivalent to the above: +@example +pattern='[[:space:]]*(a)?b' +[[ $line =~ $pattern ]] +@end example + +@noindent +If you want to match a character that's special to the regular expression +grammar, it has to be quoted to remove its special meaning. +This means that in the pattern @samp{xxx.txt}, the @samp{.} matches any +character in the string (its usual regular expression meaning), but in the +pattern @samp{"xxx.txt"} it can only match a literal @samp{.}. +Shell programmers should take special care with backslashes, since backslashes +are used both by the shell and regular expressions to remove the special +meaning from the following character. +The following two sets of commands are @emph{not} equivalent: +@example +pattern='\.' + +[[ . =~ $pattern ]] +[[ . =~ \. ]] + +[[ . =~ "$pattern" ]] +[[ . =~ '\.' ]] +@end example + +@noindent +The first two matches will succeed, but the second two will not, because +in the second two the backslash will be part of the pattern to be matched. +In the first two examples, the backslash removes the special meaning from +@samp{.}, so the literal @samp{.} matches. +If the string in the first examples were anything other than @samp{.}, say +@samp{a}, the pattern would not match, because the quoted @samp{.} in the +pattern loses its special meaning of matching any single character. + +Expressions may be combined using the following operators, listed +in decreasing order of precedence: + +@table @code +@item ( @var{expression} ) +Returns the value of @var{expression}. +This may be used to override the normal precedence of operators. + +@item ! @var{expression} +True if @var{expression} is false. + +@item @var{expression1} && @var{expression2} +True if both @var{expression1} and @var{expression2} are true. + +@item @var{expression1} || @var{expression2} +True if either @var{expression1} or @var{expression2} is true. +@end table + +@noindent +The @code{&&} and @code{||} operators do not evaluate @var{expression2} if the +value of @var{expression1} is sufficient to determine the return +value of the entire conditional expression. +@end table + +@node Command Grouping +@subsubsection Grouping Commands +@cindex commands, grouping + +Bash provides two ways to group a list of commands to be executed +as a unit. When commands are grouped, redirections may be applied +to the entire command list. For example, the output of all the +commands in the list may be redirected to a single stream. + +@table @code +@item () +@example +( @var{list} ) +@end example + +Placing a list of commands between parentheses causes a subshell +environment to be created (@pxref{Command Execution Environment}), and each +of the commands in @var{list} to be executed in that subshell. Since the +@var{list} is executed in a subshell, variable assignments do not remain in +effect after the subshell completes. + +@item @{@} +@rwindex @{ +@rwindex @} +@example +@{ @var{list}; @} +@end example + +Placing a list of commands between curly braces causes the list to +be executed in the current shell context. No subshell is created. +The semicolon (or newline) following @var{list} is required. +@end table + +In addition to the creation of a subshell, there is a subtle difference +between these two constructs due to historical reasons. The braces +are @code{reserved words}, so they must be separated from the @var{list} +by @code{blank}s or other shell metacharacters. +The parentheses are @code{operators}, and are +recognized as separate tokens by the shell even if they are not separated +from the @var{list} by whitespace. + +The exit status of both of these constructs is the exit status of +@var{list}. + +@node Coprocesses +@subsection Coprocesses +@cindex coprocess + +A @code{coprocess} is a shell command preceded by the @code{coproc} +reserved word. +A coprocess is executed asynchronously in a subshell, as if the command +had been terminated with the @samp{&} control operator, with a two-way pipe +established between the executing shell and the coprocess. + +The format for a coprocess is: +@example +coproc [@var{NAME}] @var{command} [@var{redirections}] +@end example + +@noindent +This creates a coprocess named @var{NAME}. +If @var{NAME} is not supplied, the default name is @var{COPROC}. +@var{NAME} must not be supplied if @var{command} is a simple +command (@pxref{Simple Commands}); otherwise, it is interpreted as +the first word of the simple command. + +When the coprocess is executed, the shell creates an array variable +(@pxref{Arrays}) +named @env{NAME} in the context of the executing shell. +The standard output of @var{command} +is connected via a pipe to a file descriptor in the executing shell, +and that file descriptor is assigned to @env{NAME}[0]. +The standard input of @var{command} +is connected via a pipe to a file descriptor in the executing shell, +and that file descriptor is assigned to @env{NAME}[1]. +This pipe is established before any redirections specified by the +command (@pxref{Redirections}). +The file descriptors can be utilized as arguments to shell commands +and redirections using standard word expansions. +The file descriptors are not available in subshells. + +The process ID of the shell spawned to execute the coprocess is +available as the value of the variable @env{NAME}_PID. +The @code{wait} +builtin command may be used to wait for the coprocess to terminate. + +Since the coprocess is created as an asynchronous command, +the @code{coproc} command always returns success. +The return status of a coprocess is the exit status of @var{command}. + +@node GNU Parallel +@subsection GNU Parallel + +GNU Parallel, as its name suggests, can be used to build and run commands +in parallel. You may run the same command with different arguments, whether +they are filenames, usernames, hostnames, or lines read from files. + +For a complete description, refer to the GNU Parallel documentation. A few +examples should provide a brief introduction to its use. + +For example, it is easy to prefix each line in a text file with a specified +string: +@example +cat file | parallel -k echo prefix_string +@end example +@noindent +The @option{-k} option is required to preserve the lines' order. + +Similarly, you can append a specified string to each line in a text file: +@example +cat file | parallel -k echo @{@} append_string +@end example + +You can use Parallel to move files from the current directory when the +number of files is too large to process with one @code{mv} invocation: +@example +ls | parallel mv @{@} destdir +@end example + +As you can see, the @{@} is replaced with each line read from standard input. +This will run as many @code{mv} commands as there are files in the current +directory. You can emulate a parallel @code{xargs} by adding the @option{-X} +option: +@example +ls | parallel -X mv @{@} destdir +@end example + +GNU Parallel can replace certain common idioms that operate on lines read +from a file (in this case, filenames): +@example + for x in $(cat list); do + do-something1 $x config-$x + do-something2 < $x + done | process-output +@end example + +@noindent +with a more compact syntax reminiscent of lambdas: +@example +cat list | parallel "do-something1 @{@} config-@{@} ; do-something2 < @{@}" | process-output +@end example + +Parallel provides a built-in mechanism to remove filename extensions, which +lends itself to batch file transformations or renaming: +@example +ls *.gz | parallel -j+0 "zcat @{@} | bzip2 >@{.@}.bz2 && rm @{@}" +@end example +@noindent +This will recompress all files in the current directory with names ending +in .gz using bzip2, running one job per CPU (-j+0) in parallel. + +If a command generates output, you may want to preserve the input order in +the output. For instance, the following command +@example +@{ echo foss.org.my ; echo debian.org; echo freenetproject.org; @} | parallel traceroute +@end example +@noindent +will display as output the traceroute invocation that finishes first. Using +the @option{-k} option, as we saw above +@example +@{ echo foss.org.my ; echo debian.org; echo freenetproject.org; @} | parallel -k traceroute +@end example +@noindent +will ensure that the output of @code{traceroute foss.org.my} is displayed first. + +@node Shell Functions +@section Shell Functions +@cindex shell function +@cindex functions, shell + +Shell functions are a way to group commands for later execution +using a single name for the group. They are executed just like +a "regular" command. +When the name of a shell function is used as a simple command name, +the list of commands associated with that function name is executed. +Shell functions are executed in the current +shell context; no new process is created to interpret them. + +Functions are declared using this syntax: +@rwindex function +@example +@var{name} () @var{compound-command} [ @var{redirections} ] +@end example + +or + +@example +function @var{name} [()] @var{compound-command} [ @var{redirections} ] +@end example + +This defines a shell function named @var{name}. The reserved +word @code{function} is optional. +If the @code{function} reserved +word is supplied, the parentheses are optional. +The @var{body} of the function is the compound command +@var{compound-command} (@pxref{Compound Commands}). +That command is usually a @var{list} enclosed between @{ and @}, but +may be any compound command listed above. +@var{compound-command} is executed whenever @var{name} is specified as the +name of a command. +When the shell is in @sc{posix} mode (@pxref{Bash POSIX Mode}), +@var{name} may not be the same as one of the special builtins +(@pxref{Special Builtins}). +Any redirections (@pxref{Redirections}) associated with the shell function +are performed when the function is executed. + +A function definition may be deleted using the @option{-f} option to the +@code{unset} builtin (@pxref{Bourne Shell Builtins}). + +The exit status of a function definition is zero unless a syntax error +occurs or a readonly function with the same name already exists. +When executed, the exit status of a function is the exit status of the +last command executed in the body. + +Note that for historical reasons, in the most common usage the curly braces +that surround the body of the function must be separated from the body by +@code{blank}s or newlines. +This is because the braces are reserved words and are only recognized +as such when they are separated from the command list +by whitespace or another shell metacharacter. +Also, when using the braces, the @var{list} must be terminated by a semicolon, +a @samp{&}, or a newline. + +When a function is executed, the arguments to the +function become the positional parameters +during its execution (@pxref{Positional Parameters}). +The special parameter @samp{#} that expands to the number of +positional parameters is updated to reflect the change. +Special parameter @code{0} is unchanged. +The first element of the @env{FUNCNAME} variable is set to the +name of the function while the function is executing. + +All other aspects of the shell execution +environment are identical between a function and its caller +with these exceptions: +the @env{DEBUG} and @env{RETURN} traps +are not inherited unless the function has been given the +@code{trace} attribute using the @code{declare} builtin or +the @code{-o functrace} option has been enabled with +the @code{set} builtin, +(in which case all functions inherit the @env{DEBUG} and @env{RETURN} traps), +and the @env{ERR} trap is not inherited unless the @code{-o errtrace} +shell option has been enabled. +@xref{Bourne Shell Builtins}, for the description of the +@code{trap} builtin. + +The @env{FUNCNEST} variable, if set to a numeric value greater +than 0, defines a maximum function nesting level. Function +invocations that exceed the limit cause the entire command to +abort. + +If the builtin command @code{return} +is executed in a function, the function completes and +execution resumes with the next command after the function +call. +Any command associated with the @code{RETURN} trap is executed +before execution resumes. +When a function completes, the values of the +positional parameters and the special parameter @samp{#} +are restored to the values they had prior to the function's +execution. If a numeric argument is given to @code{return}, +that is the function's return status; otherwise the function's +return status is the exit status of the last command executed +before the @code{return}. + +Variables local to the function may be declared with the +@code{local} builtin. These variables are visible only to +the function and the commands it invokes. + +Function names and definitions may be listed with the +@option{-f} option to the @code{declare} (@code{typeset}) +builtin command (@pxref{Bash Builtins}). +The @option{-F} option to @code{declare} or @code{typeset} +will list the function names only +(and optionally the source file and line number, if the @code{extdebug} +shell option is enabled). +Functions may be exported so that subshells +automatically have them defined with the +@option{-f} option to the @code{export} builtin +(@pxref{Bourne Shell Builtins}). +Note that shell functions and variables with the same name may result +in multiple identically-named entries in the environment passed to the +shell's children. +Care should be taken in cases where this may cause a problem. + +Functions may be recursive. +The @code{FUNCNEST} variable may be used to limit the depth of the +function call stack and restrict the number of function invocations. +By default, no limit is placed on the number of recursive calls. + +@node Shell Parameters +@section Shell Parameters +@cindex parameters +@cindex variable, shell +@cindex shell variable + +@menu +* Positional Parameters:: The shell's command-line arguments. +* Special Parameters:: Parameters denoted by special characters. +@end menu + +A @var{parameter} is an entity that stores values. +It can be a @code{name}, a number, or one of the special characters +listed below. +A @var{variable} is a parameter denoted by a @code{name}. +A variable has a @var{value} and zero or more @var{attributes}. +Attributes are assigned using the @code{declare} builtin command +(see the description of the @code{declare} builtin in @ref{Bash Builtins}). + +A parameter is set if it has been assigned a value. The null string is +a valid value. Once a variable is set, it may be unset only by using +the @code{unset} builtin command. + +A variable may be assigned to by a statement of the form +@example +@var{name}=[@var{value}] +@end example +@noindent +If @var{value} +is not given, the variable is assigned the null string. All +@var{value}s undergo tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote +removal (detailed below). If the variable has its @code{integer} +attribute set, then @var{value} +is evaluated as an arithmetic expression even if the @code{$((@dots{}))} +expansion is not used (@pxref{Arithmetic Expansion}). +Word splitting is not performed, with the exception +of @code{"$@@"} as explained below. +Filename expansion is not performed. +Assignment statements may also appear as arguments to the +@code{alias}, +@code{declare}, @code{typeset}, @code{export}, @code{readonly}, +and @code{local} builtin commands. +When in @sc{posix} mode (@pxref{Bash POSIX Mode}), these builtins may appear +in a command after one or more instances of the @code{command} builtin +and retain these assignment statement properties. + +In the context where an assignment statement is assigning a value +to a shell variable or array index (@pxref{Arrays}), the @samp{+=} +operator can be used to +append to or add to the variable's previous value. +When @samp{+=} is applied to a variable for which the @var{integer} attribute +has been set, @var{value} is evaluated as an arithmetic expression and +added to the variable's current value, which is also evaluated. +When @samp{+=} is applied to an array variable using compound assignment +(@pxref{Arrays}), the +variable's value is not unset (as it is when using @samp{=}), and new +values are appended to the array beginning at one greater than the array's +maximum index (for indexed arrays), or added as additional key-value pairs +in an associative array. +When applied to a string-valued variable, @var{value} is expanded and +appended to the variable's value. + +A variable can be assigned the @var{nameref} attribute using the +@option{-n} option to the \fBdeclare\fP or \fBlocal\fP builtin commands +(@pxref{Bash Builtins}) +to create a @var{nameref}, or a reference to another variable. +This allows variables to be manipulated indirectly. +Whenever the nameref variable is referenced or assigned to, the operation +is actually performed on the variable specified by the nameref variable's +value. +A nameref is commonly used within shell functions to refer to a variable +whose name is passed as an argument to the function. +For instance, if a variable name is passed to a shell function as its first +argument, running +@example +declare -n ref=$1 +@end example +@noindent +inside the function creates a nameref variable @var{ref} whose value is +the variable name passed as the first argument. +References and assignments to @var{ref} are treated as references and +assignments to the variable whose name was passed as @code{$1}. + +If the control variable in a @code{for} loop has the nameref attribute, +the list of words can be a list of shell variables, and a name reference +will be established for each word in the list, in turn, when the loop is +executed. +Array variables cannot be given the @option{-n} attribute. +However, nameref variables can reference array variables and subscripted +array variables. +Namerefs can be unset using the @option{-n} option to the @code{unset} builtin +(@pxref{Bourne Shell Builtins}). +Otherwise, if @code{unset} is executed with the name of a nameref variable +as an argument, the variable referenced by the nameref variable will be unset. + +@node Positional Parameters +@subsection Positional Parameters +@cindex parameters, positional + +A @var{positional parameter} is a parameter denoted by one or more +digits, other than the single digit @code{0}. Positional parameters are +assigned from the shell's arguments when it is invoked, +and may be reassigned using the @code{set} builtin command. +Positional parameter @code{N} may be referenced as @code{$@{N@}}, or +as @code{$N} when @code{N} consists of a single digit. +Positional parameters may not be assigned to with assignment statements. +The @code{set} and @code{shift} builtins are used to set and +unset them (@pxref{Shell Builtin Commands}). +The positional parameters are +temporarily replaced when a shell function is executed +(@pxref{Shell Functions}). + +When a positional parameter consisting of more than a single +digit is expanded, it must be enclosed in braces. + +@node Special Parameters +@subsection Special Parameters +@cindex parameters, special + +The shell treats several parameters specially. These parameters may +only be referenced; assignment to them is not allowed. + +@vtable @code + +@item * +Expands to the positional parameters, starting from one. 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 @env{IFS} +special variable. That is, @code{"$*"} is equivalent +to @code{"$1@var{c}$2@var{c}@dots{}"}, where @var{c} +is the first character of the value of the @code{IFS} +variable. +If @env{IFS} is unset, the parameters are separated by spaces. +If @env{IFS} is null, the parameters are joined without intervening +separators. + + +@item @@ +Expands to the positional parameters, starting from one. When the +expansion occurs within double quotes, each parameter expands to a +separate word. That is, @code{"$@@"} is equivalent to +@code{"$1" "$2" @dots{}}. +If the double-quoted expansion occurs within a word, the expansion of +the first parameter is joined with the beginning part of the original +word, and the expansion of the last parameter is joined with the last +part of the original word. +When there are no positional parameters, @code{"$@@"} and +@code{$@@} +expand to nothing (i.e., they are removed). + +@item # +Expands to the number of positional parameters in decimal. + +@item ? +Expands to the exit status of the most recently executed foreground +pipeline. + +@item - +(A hyphen.) Expands to the current option flags as specified upon +invocation, by the @code{set} +builtin command, or those set by the shell itself +(such as the @option{-i} option). + +@item $ +Expands to the process @sc{id} of the shell. In a @code{()} subshell, it +expands to the process @sc{id} of the invoking shell, not the subshell. + +@item ! +Expands to the process @sc{id} of the most recently executed background +(asynchronous) command. + +@item 0 +Expands to the name of the shell or shell script. This is set at +shell initialization. If Bash is invoked with a file of commands +(@pxref{Shell Scripts}), @code{$0} is set to the name of that file. +If Bash is started with the @option{-c} option (@pxref{Invoking Bash}), +then @code{$0} is set to the first argument after the string to be +executed, if one is present. Otherwise, it is set +to the filename used to invoke Bash, as given by argument zero. + +@item _ +(An underscore.) +At shell startup, set to the absolute pathname used to invoke the +shell or shell script being executed as passed in the environment +or argument list. +Subsequently, expands to the last argument to the previous command, +after expansion. +Also set to the full pathname used to invoke each command executed +and placed in the environment exported to that command. +When checking mail, this parameter holds the name of the mail file. +@end vtable + +@node Shell Expansions +@section Shell Expansions +@cindex expansion + +Expansion is performed on the command line after it has been split into +@code{token}s. There are seven kinds of expansion performed: + +@itemize @bullet +@item brace expansion +@item tilde expansion +@item parameter and variable expansion +@item command substitution +@item arithmetic expansion +@item word splitting +@item filename expansion +@end itemize + +@menu +* Brace Expansion:: Expansion of expressions within braces. +* Tilde Expansion:: Expansion of the ~ character. +* Shell Parameter Expansion:: How Bash expands variables to their values. +* Command Substitution:: Using the output of a command as an argument. +* Arithmetic Expansion:: How to use arithmetic in shell expansions. +* Process Substitution:: A way to write and read to and from a + command. +* Word Splitting:: How the results of expansion are split into separate + arguments. +* Filename Expansion:: A shorthand for specifying filenames matching patterns. +* Quote Removal:: How and when quote characters are removed from + words. +@end menu + +The order of expansions is: brace expansion, tilde expansion, +parameter, variable, and arithmetic expansion and +command substitution +(done in a left-to-right fashion), word splitting, and filename +expansion. + +On systems that can support it, there is an additional expansion +available: @var{process substitution}. This is performed at the +same time as parameter, variable, and arithmetic expansion and +command substitution. + +Only brace expansion, word splitting, and filename expansion +can change the number of words of the expansion; other expansions +expand a single word to a single word. +The only exceptions to this are the expansions of +@code{"$@@"} (@pxref{Special Parameters}) and @code{"$@{@var{name}[@@]@}"} +(@pxref{Arrays}). + +After all expansions, @code{quote removal} (@pxref{Quote Removal}) +is performed. + +@node Brace Expansion +@subsection Brace Expansion +@cindex brace expansion +@cindex expansion, brace + +Brace expansion is a mechanism by which arbitrary strings may be generated. +This mechanism is similar to +@var{filename expansion} (@pxref{Filename Expansion}), +but the filenames generated need not exist. +Patterns to be brace expanded take the form of an optional @var{preamble}, +followed by either a series of comma-separated strings or a sequence expression +between a pair of braces, +followed by an optional @var{postscript}. +The preamble is prefixed to each string contained within the braces, and +the postscript is then appended to each resulting string, expanding left +to right. + +Brace expansions may be nested. +The results of each expanded string are not sorted; left to right order +is preserved. +For example, +@example +bash$ echo a@{d,c,b@}e +ade ace abe +@end example + +A sequence expression takes the form @code{@{@var{x}..@var{y}[..@var{incr}]@}}, +where @var{x} and @var{y} are either integers or single characters, +and @var{incr}, an optional increment, is an integer. +When integers are supplied, the expression expands to each number between +@var{x} and @var{y}, inclusive. +Supplied integers may be prefixed with @samp{0} to force each term to have the +same width. +When either @var{x} or @var{y} begins with a zero, the shell +attempts to force all generated terms to contain the same number of digits, +zero-padding where necessary. +When characters are supplied, the expression expands to each character +lexicographically between @var{x} and @var{y}, inclusive, +using the default C locale. +Note that both @var{x} and @var{y} must be of the same type. +When the increment is supplied, it is used as the difference between +each term. The default increment is 1 or -1 as appropriate. + +Brace expansion is performed before any other expansions, +and any characters special to other expansions are preserved +in the result. It is strictly textual. Bash +does not apply any syntactic interpretation to the context of the +expansion or the text between the braces. +To avoid conflicts with parameter expansion, the string @samp{$@{} +is not considered eligible for brace expansion. + +A correctly-formed brace expansion must contain unquoted opening +and closing braces, and at least one unquoted comma or a valid +sequence expression. +Any incorrectly formed brace expansion is left unchanged. + +A @{ or @samp{,} may be quoted with a backslash to prevent its +being considered part of a brace expression. +To avoid conflicts with parameter expansion, the string @samp{$@{} +is not considered eligible for brace expansion. + +This construct is typically used as shorthand when the common +prefix of the strings to be generated is longer than in the +above example: +@example +mkdir /usr/local/src/bash/@{old,new,dist,bugs@} +@end example +or +@example +chown root /usr/@{ucb/@{ex,edit@},lib/@{ex?.?*,how_ex@}@} +@end example + +@node Tilde Expansion +@subsection Tilde Expansion +@cindex tilde expansion +@cindex expansion, tilde + +If a word begins with an unquoted tilde character (@samp{~}), all of the +characters up to the first unquoted slash (or all characters, +if there is no unquoted slash) are considered a @var{tilde-prefix}. +If none of the characters in the tilde-prefix are quoted, the +characters in the tilde-prefix following the tilde are treated as a +possible @var{login name}. +If this login name is the null string, the tilde is replaced with the +value of the @env{HOME} shell variable. +If @env{HOME} is unset, the home directory of the user executing the +shell is substituted instead. +Otherwise, the tilde-prefix is replaced with the home directory +associated with the specified login name. + +If the tilde-prefix is @samp{~+}, the value of +the shell variable @env{PWD} replaces the tilde-prefix. +If the tilde-prefix is @samp{~-}, the value of the shell variable +@env{OLDPWD}, if it is set, is substituted. + +If the characters following the tilde in the tilde-prefix consist of a +number @var{N}, optionally prefixed by a @samp{+} or a @samp{-}, +the tilde-prefix is replaced with the +corresponding element from the directory stack, as it would be displayed +by the @code{dirs} builtin invoked with the characters following tilde +in the tilde-prefix as an argument (@pxref{The Directory Stack}). +If the tilde-prefix, sans the tilde, consists of a number without a +leading @samp{+} or @samp{-}, @samp{+} is assumed. + +If the login name is invalid, or the tilde expansion fails, the word is +left unchanged. + +Each variable assignment is checked for unquoted tilde-prefixes immediately +following a @samp{:} or the first @samp{=}. +In these cases, tilde expansion is also performed. +Consequently, one may use filenames with tildes in assignments to +@env{PATH}, @env{MAILPATH}, and @env{CDPATH}, +and the shell assigns the expanded value. + +The following table shows how Bash treats unquoted tilde-prefixes: + +@table @code +@item ~ +The value of @code{$HOME} +@item ~/foo +@file{$HOME/foo} + +@item ~fred/foo +The subdirectory @code{foo} of the home directory of the user +@code{fred} + +@item ~+/foo +@file{$PWD/foo} + +@item ~-/foo +@file{$@{OLDPWD-'~-'@}/foo} + +@item ~@var{N} +The string that would be displayed by @samp{dirs +@var{N}} + +@item ~+@var{N} +The string that would be displayed by @samp{dirs +@var{N}} + +@item ~-@var{N} +The string that would be displayed by @samp{dirs -@var{N}} +@end table + +@node Shell Parameter Expansion +@subsection Shell Parameter Expansion +@cindex parameter expansion +@cindex expansion, parameter + +The @samp{$} character introduces parameter expansion, +command substitution, or arithmetic expansion. The parameter name +or symbol to be expanded may be enclosed in braces, which +are optional but serve to protect the variable to be expanded from +characters immediately following it which could be +interpreted as part of the name. + +When braces are used, the matching ending brace is the first @samp{@}} +not escaped by a backslash or within a quoted string, and not within an +embedded arithmetic expansion, command substitution, or parameter +expansion. + +The basic form of parameter expansion is $@{@var{parameter}@}. +The value of @var{parameter} is substituted. +The @var{parameter} is a shell parameter as described above +(@pxref{Shell Parameters}) or an array reference (@pxref{Arrays}). +The braces are required when @var{parameter} +is a positional parameter with more than one digit, +or when @var{parameter} is followed by a character that is not to be +interpreted as part of its name. + +If the first character of @var{parameter} is an exclamation point (!), +it introduces a level of variable indirection. +Bash uses the value of the variable formed from the rest of +@var{parameter} as the name of the variable; this variable is then +expanded and that value is used in the rest of the substitution, rather +than the value of @var{parameter} itself. +This is known as @code{indirect expansion}. +The exceptions to this are the expansions of $@{!@var{prefix}*@} +and $@{!@var{name}[@@]@} +described below. +The exclamation point must immediately follow the left brace in order to +introduce indirection. + +In each of the cases below, @var{word} is subject to tilde expansion, +parameter expansion, command substitution, and arithmetic expansion. + +When not performing substring expansion, using the form described +below (e.g., @samp{:-}), Bash tests for a parameter that is unset or null. +Omitting the colon results in a test only for a parameter that is unset. +Put another way, if the colon is included, +the operator tests for both @var{parameter}'s existence and that its value +is not null; if the colon is omitted, the operator tests only for existence. + +@table @code + +@item $@{@var{parameter}:@minus{}@var{word}@} +If @var{parameter} is unset or null, the expansion of +@var{word} is substituted. Otherwise, the value of +@var{parameter} is substituted. + +@item $@{@var{parameter}:=@var{word}@} +If @var{parameter} +is unset or null, the expansion of @var{word} +is assigned to @var{parameter}. +The value of @var{parameter} is then substituted. +Positional parameters and special parameters may not be assigned to +in this way. + +@item $@{@var{parameter}:?@var{word}@} +If @var{parameter} +is null or unset, the expansion of @var{word} (or a message +to that effect if @var{word} +is not present) is written to the standard error and the shell, if it +is not interactive, exits. Otherwise, the value of @var{parameter} is +substituted. + +@item $@{@var{parameter}:+@var{word}@} +If @var{parameter} +is null or unset, nothing is substituted, otherwise the expansion of +@var{word} is substituted. + +@item $@{@var{parameter}:@var{offset}@} +@itemx $@{@var{parameter}:@var{offset}:@var{length}@} +This is referred to as Substring Expansion. +It expands to up to @var{length} characters of the value of @var{parameter} +starting at the character specified by @var{offset}. +If @var{parameter} is @samp{@@}, an indexed array subscripted by +@samp{@@} or @samp{*}, or an associative array name, the results differ as +described below. +If @var{length} is omitted, it expands to the substring of the value of +@var{parameter} starting at the character specified by @var{offset} +and extending to the end of the value. +@var{length} and @var{offset} are arithmetic expressions +(@pxref{Shell Arithmetic}). + +If @var{offset} evaluates to a number less than zero, the value +is used as an offset in characters +from the end of the value of @var{parameter}. +If @var{length} evaluates to a number less than zero, +it is interpreted as an offset in characters +from the end of the value of @var{parameter} rather than +a number of characters, and the expansion is the characters between +@var{offset} and that result. +Note that a negative offset must be separated from the colon by at least +one space to avoid being confused with the @samp{:-} expansion. + +Here are some examples illustrating substring expansion on parameters and +subscripted arrays: + +@verbatim +$ string=01234567890abcdefgh +$ echo ${string:7} +7890abcdefgh +$ echo ${string:7:0} + +$ echo ${string:7:2} +78 +$ echo ${string:7:-2} +7890abcdef +$ echo ${string: -7} +bcdefgh +$ echo ${string: -7:0} + +$ echo ${string: -7:2} +bc +$ echo ${string: -7:-2} +bcdef +$ set -- 01234567890abcdefgh +$ echo ${1:7} +7890abcdefgh +$ echo ${1:7:0} + +$ echo ${1:7:2} +78 +$ echo ${1:7:-2} +7890abcdef +$ echo ${1: -7} +bcdefgh +$ echo ${1: -7:0} + +$ echo ${1: -7:2} +bc +$ echo ${1: -7:-2} +bcdef +$ array[0]=01234567890abcdefgh +$ echo ${array[0]:7} +7890abcdefgh +$ echo ${array[0]:7:0} + +$ echo ${array[0]:7:2} +78 +$ echo ${array[0]:7:-2} +7890abcdef +$ echo ${array[0]: -7} +bcdefgh +$ echo ${array[0]: -7:0} + +$ echo ${array[0]: -7:2} +bc +$ echo ${array[0]: -7:-2} +bcdef +@end verbatim + +If @var{parameter} is @samp{@@}, the result is @var{length} positional +parameters beginning at @var{offset}. +A negative @var{offset} is taken relative to one greater than the greatest +positional parameter, so an offset of -1 evaluates to the last positional +parameter. +It is an expansion error if @var{length} evaluates to a number less than zero. + +The following examples illustrate substring expansion using positional +parameters: + +@verbatim +$ set -- 1 2 3 4 5 6 7 8 9 0 a b c d e f g h +$ echo ${@:7} +7 8 9 0 a b c d e f g h +$ echo ${@:7:0} + +$ echo ${@:7:2} +7 8 +$ echo ${@:7:-2} +bash: -2: substring expression < 0 +$ echo ${@: -7:2} +b c +$ echo ${@:0} +./bash 1 2 3 4 5 6 7 8 9 0 a b c d e f g h +$ echo ${@:0:2} +./bash 1 +$ echo ${@: -7:0} + +@end verbatim + +If @var{parameter} is an indexed array name subscripted +by @samp{@@} or @samp{*}, the result is the @var{length} +members of the array beginning with @code{$@{@var{parameter}[@var{offset}]@}}. +A negative @var{offset} is taken relative to one greater than the maximum +index of the specified array. +It is an expansion error if @var{length} evaluates to a number less than zero. + +These examples show how you can use substring expansion with indexed +arrays: + +@verbatim +$ array=(0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h) +$ echo ${array[@]:7} +7 8 9 0 a b c d e f g h +$ echo ${array[@]:7:2} +7 8 +$ echo ${array[@]: -7:2} +b c +$ echo ${array[@]: -7:-2} +bash: -2: substring expression < 0 +$ echo ${array[@]:0} +0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h +$ echo ${array[@]:0:2} +0 1 +$ echo ${array[@]: -7:0} + +@end verbatim + +Substring expansion applied to an associative array produces undefined +results. + +Substring indexing is zero-based unless the positional parameters +are used, in which case the indexing starts at 1 by default. +If @var{offset} is 0, and the positional parameters are used, @code{$@@} is +prefixed to the list. + +@item $@{!@var{prefix}*@} +@itemx $@{!@var{prefix}@@@} +Expands to the names of variables whose names begin with @var{prefix}, +separated by the first character of the @env{IFS} special variable. +When @samp{@@} is used and the expansion appears within double quotes, each +variable name expands to a separate word. + +@item $@{!@var{name}[@@]@} +@itemx $@{!@var{name}[*]@} +If @var{name} is an array variable, expands to the list of array indices +(keys) assigned in @var{name}. +If @var{name} is not an array, expands to 0 if @var{name} is set and null +otherwise. +When @samp{@@} is used and the expansion appears within double quotes, each +key expands to a separate word. + +@item $@{#@var{parameter}@} +The length in characters of the expanded value of @var{parameter} is +substituted. +If @var{parameter} is @samp{*} or @samp{@@}, the value substituted +is the number of positional parameters. +If @var{parameter} is an array name subscripted by @samp{*} or @samp{@@}, +the value substituted is the number of elements in the array. +If @var{parameter} +is an indexed array name subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +@var{parameter}, so negative indices count back from the end of the +array, and an index of -1 references the last element. + +@item $@{@var{parameter}#@var{word}@} +@itemx $@{@var{parameter}##@var{word}@} +The @var{word} +is expanded to produce a pattern just as in filename +expansion (@pxref{Filename Expansion}). If the pattern matches +the beginning of the expanded value of @var{parameter}, +then the result of the expansion is the expanded value of @var{parameter} +with the shortest matching pattern (the @samp{#} case) or the +longest matching pattern (the @samp{##} case) deleted. +If @var{parameter} is @samp{@@} or @samp{*}, +the pattern removal operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If @var{parameter} is an array variable subscripted with +@samp{@@} or @samp{*}, +the pattern removal operation is applied to each member of the +array in turn, and the expansion is the resultant list. + +@item $@{@var{parameter}%@var{word}@} +@itemx $@{@var{parameter}%%@var{word}@} +The @var{word} is expanded to produce a pattern just as in +filename expansion. +If the pattern matches a trailing portion of the expanded value of +@var{parameter}, then the result of the expansion is the value of +@var{parameter} with the shortest matching pattern (the @samp{%} case) +or the longest matching pattern (the @samp{%%} case) deleted. +If @var{parameter} is @samp{@@} or @samp{*}, +the pattern removal operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If @var{parameter} +is an array variable subscripted with @samp{@@} or @samp{*}, +the pattern removal operation is applied to each member of the +array in turn, and the expansion is the resultant list. + +@item $@{@var{parameter}/@var{pattern}/@var{string}@} + +The @var{pattern} is expanded to produce a pattern just as in +filename expansion. +@var{Parameter} is expanded and the longest match of @var{pattern} +against its value is replaced with @var{string}. +If @var{pattern} begins with @samp{/}, all matches of @var{pattern} are +replaced with @var{string}. Normally only the first match is replaced. +If @var{pattern} begins with @samp{#}, it must match at the beginning +of the expanded value of @var{parameter}. +If @var{pattern} begins with @samp{%}, it must match at the end +of the expanded value of @var{parameter}. +If @var{string} is null, matches of @var{pattern} are deleted +and the @code{/} following @var{pattern} may be omitted. +If @var{parameter} is @samp{@@} or @samp{*}, +the substitution operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If @var{parameter} +is an array variable subscripted with @samp{@@} or @samp{*}, +the substitution operation is applied to each member of the +array in turn, and the expansion is the resultant list. + +@item $@{@var{parameter}^@var{pattern}@} +@itemx $@{@var{parameter}^^@var{pattern}@} +@itemx $@{@var{parameter},@var{pattern}@} +@itemx $@{@var{parameter},,@var{pattern}@} +This expansion modifies the case of alphabetic characters in @var{parameter}. +The @var{pattern} is expanded to produce a pattern just as in +filename expansion. +Each character in the expanded value of @var{parameter} is tested against +@var{pattern}, and, if it matches the pattern, its case is converted. +The pattern should not attempt to match more than one character. +The @samp{^} operator converts lowercase letters matching @var{pattern} +to uppercase; the @samp{,} operator converts matching uppercase letters +to lowercase. +The @samp{^^} and @samp{,,} expansions convert each matched character in the +expanded value; the @samp{^} and @samp{,} expansions match and convert only +the first character in the expanded value. +If @var{pattern} is omitted, it is treated like a @samp{?}, which matches +every character. +If @var{parameter} is @samp{@@} or @samp{*}, +the case modification operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If @var{parameter} +is an array variable subscripted with @samp{@@} or @samp{*}, +the case modification operation is applied to each member of the +array in turn, and the expansion is the resultant list. +@end table + +@node Command Substitution +@subsection Command Substitution +@cindex command substitution + +Command substitution allows the output of a command to replace +the command itself. +Command substitution occurs when a command is enclosed as follows: +@example +$(@var{command}) +@end example +@noindent +or +@example +`@var{command}` +@end example + +@noindent +Bash performs the expansion by executing @var{command} and +replacing the command substitution with the standard output of the +command, with any trailing newlines deleted. +Embedded newlines are not deleted, but they may be removed during +word splitting. +The command substitution @code{$(cat @var{file})} can be +replaced by the equivalent but faster @code{$(< @var{file})}. + +When the old-style backquote form of substitution is used, +backslash retains its literal meaning except when followed by +@samp{$}, @samp{`}, or @samp{\}. +The first backquote not preceded by a backslash terminates the +command substitution. +When using the @code{$(@var{command})} form, all characters between +the parentheses make up the command; none are treated specially. + +Command substitutions may be nested. To nest when using the backquoted +form, escape the inner backquotes with backslashes. + +If the substitution appears within double quotes, word splitting and +filename expansion are not performed on the results. + +@node Arithmetic Expansion +@subsection Arithmetic Expansion +@cindex expansion, arithmetic +@cindex arithmetic expansion + +Arithmetic expansion allows the evaluation of an arithmetic expression +and the substitution of the result. The format for arithmetic expansion is: + +@example +$(( @var{expression} )) +@end example + +The expression is treated as if it were within double quotes, but +a double quote inside the parentheses is not treated specially. +All tokens in the expression undergo parameter expansion, command +substitution, and quote removal. +Arithmetic expansions may be nested. + +The evaluation is performed according to the rules listed below +(@pxref{Shell Arithmetic}). +If the expression is invalid, Bash prints a message indicating +failure to the standard error and no substitution occurs. + +@node Process Substitution +@subsection Process Substitution +@cindex process substitution + +Process substitution is supported on systems that support named +pipes (@sc{fifo}s) or the @file{/dev/fd} method of naming open files. +It takes the form of +@example +<(@var{list}) +@end example +@noindent +or +@example +>(@var{list}) +@end example +@noindent +The process @var{list} is run with its input or output connected to a +@sc{fifo} or some file in @file{/dev/fd}. The name of this file is +passed as an argument to the current command as the result of the +expansion. If the @code{>(@var{list})} form is used, writing to +the file will provide input for @var{list}. If the +@code{<(@var{list})} form is used, the file passed as an +argument should be read to obtain the output of @var{list}. +Note that no space may appear between the @code{<} or @code{>} +and the left parenthesis, otherwise the construct would be interpreted +as a redirection. + +When available, process substitution is performed simultaneously with +parameter and variable expansion, command substitution, and arithmetic +expansion. + +@node Word Splitting +@subsection Word Splitting +@cindex word splitting + +The shell scans the results of parameter expansion, command substitution, +and arithmetic expansion that did not occur within double quotes for +word splitting. + +The shell treats each character of @env{$IFS} as a delimiter, and splits +the results of the other expansions into words on these characters. +If @env{IFS} is unset, or its value is exactly @code{}, +the default, then sequences of +@code{ }, @code{}, and @code{} +at the beginning and end of the results of the previous +expansions are ignored, and any sequence of @env{IFS} +characters not at the beginning or end serves to delimit words. +If @env{IFS} has a value other than the default, then sequences of +the whitespace characters @code{space} and @code{tab} +are ignored at the beginning and end of the +word, as long as the whitespace character is in the +value of @env{IFS} (an @env{IFS} whitespace character). +Any character in @env{IFS} that is not @env{IFS} +whitespace, along with any adjacent @env{IFS} +whitespace characters, delimits a field. A sequence of @env{IFS} +whitespace characters is also treated as a delimiter. +If the value of @env{IFS} is null, no word splitting occurs. + +Explicit null arguments (@code{""} or @code{''}) are retained. +Unquoted implicit null arguments, resulting from the expansion of +parameters that have no values, are removed. +If a parameter with no value is expanded within double quotes, a +null argument results and is retained. + +Note that if no expansion occurs, no splitting +is performed. + +@node Filename Expansion +@subsection Filename Expansion +@menu +* Pattern Matching:: How the shell matches patterns. +@end menu +@cindex expansion, filename +@cindex expansion, pathname +@cindex filename expansion +@cindex pathname expansion + +After word splitting, unless the @option{-f} option has been set +(@pxref{The Set Builtin}), Bash scans each word for the characters +@samp{*}, @samp{?}, and @samp{[}. +If one of these characters appears, then the word is +regarded as a @var{pattern}, +and replaced with an alphabetically sorted list of +filenames matching the pattern (@pxref{Pattern Matching}). +If no matching filenames are found, +and the shell option @code{nullglob} is disabled, the word is left +unchanged. +If the @code{nullglob} option is set, and no matches are found, the word +is removed. +If the @code{failglob} shell option is set, and no matches are found, +an error message is printed and the command is not executed. +If the shell option @code{nocaseglob} is enabled, the match is performed +without regard to the case of alphabetic characters. + +When a pattern is used for filename expansion, the character @samp{.} +at the start of a filename or immediately following a slash +must be matched explicitly, unless the shell option @code{dotglob} is set. +When matching a filename, the slash character must always be +matched explicitly. +In other cases, the @samp{.} character is not treated specially. + +See the description of @code{shopt} in @ref{The Shopt Builtin}, +for a description of the @code{nocaseglob}, @code{nullglob}, +@code{failglob}, and @code{dotglob} options. + +The @env{GLOBIGNORE} +shell variable may be used to restrict the set of filenames matching a +pattern. If @env{GLOBIGNORE} +is set, each matching filename that also matches one of the patterns in +@env{GLOBIGNORE} is removed from the list of matches. The filenames +@file{.} and @file{..} +are always ignored when @env{GLOBIGNORE} +is set and not null. +However, setting @env{GLOBIGNORE} to a non-null value has the effect of +enabling the @code{dotglob} +shell option, so all other filenames beginning with a +@samp{.} will match. +To get the old behavior of ignoring filenames beginning with a +@samp{.}, make @samp{.*} one of the patterns in @env{GLOBIGNORE}. +The @code{dotglob} option is disabled when @env{GLOBIGNORE} +is unset. + +@node Pattern Matching +@subsubsection Pattern Matching +@cindex pattern matching +@cindex matching, pattern + +Any character that appears in a pattern, other than the special pattern +characters described below, matches itself. +The @sc{nul} character may not occur in a pattern. +A backslash escapes the following character; the +escaping backslash is discarded when matching. +The special pattern characters must be quoted if they are to be matched +literally. + +The special pattern characters have the following meanings: +@table @code +@item * +Matches any string, including the null string. +When the @code{globstar} shell option is enabled, and @samp{*} is used in +a filename expansion context, two adjacent @samp{*}s used as a single +pattern will match all files and zero or more directories and +subdirectories. +If followed by a @samp{/}, two adjacent @samp{*}s will match only +directories and subdirectories. +@item ? +Matches any single character. +@item [@dots{}] +Matches any one of the enclosed characters. A pair of characters +separated by a hyphen denotes a @var{range expression}; +any character that falls between those two characters, inclusive, +using the current locale's collating sequence and character set, +is matched. If the first character following the +@samp{[} is a @samp{!} or a @samp{^} +then any character not enclosed is matched. A @samp{@minus{}} +may be matched by including it as the first or last character +in the set. A @samp{]} may be matched by including it as the first +character in the set. +The sorting order of characters in range expressions is determined by +the current locale and the values of the +@env{LC_COLLATE} and @env{LC_ALL} shell variables, if set. + +For example, in the default C locale, @samp{[a-dx-z]} is equivalent to +@samp{[abcdxyz]}. Many locales sort characters in dictionary order, and in +these locales @samp{[a-dx-z]} is typically not equivalent to @samp{[abcdxyz]}; +it might be equivalent to @samp{[aBbCcDdxXyYz]}, for example. To obtain +the traditional interpretation of ranges in bracket expressions, you can +force the use of the C locale by setting the @env{LC_COLLATE} or +@env{LC_ALL} environment variable to the value @samp{C}, or enable the +@code{globasciiranges} shell option. + +Within @samp{[} and @samp{]}, @var{character classes} can be specified +using the syntax +@code{[:}@var{class}@code{:]}, where @var{class} is one of the +following classes defined in the @sc{posix} standard: +@example +alnum alpha ascii blank cntrl digit graph lower +print punct space upper word xdigit +@end example +@noindent +A character class matches any character belonging to that class. +The @code{word} character class matches letters, digits, and the character +@samp{_}. + +Within @samp{[} and @samp{]}, an @var{equivalence class} can be +specified using the syntax @code{[=}@var{c}@code{=]}, which +matches all characters with the same collation weight (as defined +by the current locale) as the character @var{c}. + +Within @samp{[} and @samp{]}, the syntax @code{[.}@var{symbol}@code{.]} +matches the collating symbol @var{symbol}. +@end table + +If the @code{extglob} shell option is enabled using the @code{shopt} +builtin, several extended pattern matching operators are recognized. +In the following description, a @var{pattern-list} is a list of one +or more patterns separated by a @samp{|}. +Composite patterns may be formed using one or more of the following +sub-patterns: + +@table @code +@item ?(@var{pattern-list}) +Matches zero or one occurrence of the given patterns. + +@item *(@var{pattern-list}) +Matches zero or more occurrences of the given patterns. + +@item +(@var{pattern-list}) +Matches one or more occurrences of the given patterns. + +@item @@(@var{pattern-list}) +Matches one of the given patterns. + +@item !(@var{pattern-list}) +Matches anything except one of the given patterns. +@end table + +@node Quote Removal +@subsection Quote Removal + +After the preceding expansions, all unquoted occurrences of the +characters @samp{\}, @samp{'}, and @samp{"} that did not +result from one of the above expansions are removed. + +@node Redirections +@section Redirections +@cindex redirection + +Before a command is executed, its input and output +may be @var{redirected} +using a special notation interpreted by the shell. +Redirection allows commands' file handles to be +duplicated, opened, closed, +made to refer to different files, +and can change the files the command reads from and writes to. +Redirection may also be used to modify file handles in the +current shell execution environment. The following redirection +operators may precede or appear anywhere within a +simple command or may follow a command. +Redirections are processed in the order they appear, from +left to right. + +Each redirection that may be preceded by a file descriptor number +may instead be preceded by a word of the form @{@var{varname}@}. +In this case, for each redirection operator except +>&- and <&-, the shell will allocate a file descriptor greater +than 10 and assign it to @{@var{varname}@}. If >&- or <&- is preceded +by @{@var{varname}@}, the value of @var{varname} defines the file +descriptor to close. + +In the following descriptions, if the file descriptor number is +omitted, and the first character of the redirection operator is +@samp{<}, the redirection refers to the standard input (file +descriptor 0). If the first character of the redirection operator +is @samp{>}, the redirection refers to the standard output (file +descriptor 1). + +The word following the redirection operator in the following +descriptions, unless otherwise noted, is subjected to brace expansion, +tilde expansion, parameter expansion, command substitution, arithmetic +expansion, quote removal, filename expansion, and word splitting. +If it expands to more than one word, Bash reports an error. + +Note that the order of redirections is significant. For example, +the command +@example +ls > @var{dirlist} 2>&1 +@end example +@noindent +directs both standard output (file descriptor 1) and standard error +(file descriptor 2) to the file @var{dirlist}, while the command +@example +ls 2>&1 > @var{dirlist} +@end example +@noindent +directs only the standard output to file @var{dirlist}, +because the standard error was made a copy of the standard output +before the standard output was redirected to @var{dirlist}. + +Bash handles several filenames specially when they are used in +redirections, as described in the following table: + +@table @code +@item /dev/fd/@var{fd} +If @var{fd} is a valid integer, file descriptor @var{fd} is duplicated. + +@item /dev/stdin +File descriptor 0 is duplicated. + +@item /dev/stdout +File descriptor 1 is duplicated. + +@item /dev/stderr +File descriptor 2 is duplicated. + +@item /dev/tcp/@var{host}/@var{port} +If @var{host} is a valid hostname or Internet address, and @var{port} +is an integer port number or service name, Bash attempts to open +the corresponding TCP socket. + +@item /dev/udp/@var{host}/@var{port} +If @var{host} is a valid hostname or Internet address, and @var{port} +is an integer port number or service name, Bash attempts to open +the corresponding UDP socket. +@end table + +A failure to open or create a file causes the redirection to fail. + +Redirections using file descriptors greater than 9 should be used with +care, as they may conflict with file descriptors the shell uses +internally. + +@subsection Redirecting Input +Redirection of input causes the file whose name results from +the expansion of @var{word} +to be opened for reading on file descriptor @code{n}, +or the standard input (file descriptor 0) if @code{n} +is not specified. + +The general format for redirecting input is: +@example +[@var{n}]<@var{word} +@end example + +@subsection Redirecting Output +Redirection of output causes the file whose name results from +the expansion of @var{word} +to be opened for writing on file descriptor @var{n}, +or the standard output (file descriptor 1) if @var{n} +is not specified. If the file does not exist it is created; +if it does exist it is truncated to zero size. + +The general format for redirecting output is: +@example +[@var{n}]>[|]@var{word} +@end example + +If the redirection operator is @samp{>}, and the @code{noclobber} +option to the @code{set} builtin has been enabled, the redirection +will fail if the file whose name results from the expansion of +@var{word} exists and is a regular file. +If the redirection operator is @samp{>|}, or the redirection operator is +@samp{>} and the @code{noclobber} option is not enabled, the redirection +is attempted even if the file named by @var{word} exists. + +@subsection Appending Redirected Output +Redirection of output in this fashion +causes the file whose name results from +the expansion of @var{word} +to be opened for appending on file descriptor @var{n}, +or the standard output (file descriptor 1) if @var{n} +is not specified. If the file does not exist it is created. + +The general format for appending output is: +@example +[@var{n}]>>@var{word} +@end example + +@subsection Redirecting Standard Output and Standard Error +This construct allows both the +standard output (file descriptor 1) and +the standard error output (file descriptor 2) +to be redirected to the file whose name is the +expansion of @var{word}. + +There are two formats for redirecting standard output and +standard error: +@example +&>@var{word} +@end example +@noindent +and +@example +>&@var{word} +@end example +@noindent +Of the two forms, the first is preferred. +This is semantically equivalent to +@example +>@var{word} 2>&1 +@end example +When using the second form, @var{word} may not expand to a number or +@samp{-}. If it does, other redirection operators apply +(see Duplicating File Descriptors below) for compatibility reasons. + +@subsection Appending Standard Output and Standard Error +This construct allows both the +standard output (file descriptor 1) and +the standard error output (file descriptor 2) +to be appended to the file whose name is the +expansion of @var{word}. + +The format for appending standard output and standard error is: +@example +&>>@var{word} +@end example +@noindent +This is semantically equivalent to +@example +>>@var{word} 2>&1 +@end example +(see Duplicating File Descriptors below). + +@subsection Here Documents +This type of redirection instructs the shell to read input from the +current source until a line containing only @var{word} +(with no trailing blanks) is seen. All of +the lines read up to that point are then used as the standard +input for a command. + +The format of here-documents is: +@example +<<[@minus{}]@var{word} + @var{here-document} +@var{delimiter} +@end example + +No parameter and variable expansion, command substitution, +arithmetic expansion, or filename expansion is performed on +@var{word}. If any characters in @var{word} are quoted, the +@var{delimiter} is the result of quote removal on @var{word}, +and the lines in the here-document are not expanded. +If @var{word} is unquoted, +all lines of the here-document are subjected to +parameter expansion, command substitution, and arithmetic expansion, +the character sequence @code{\newline} is ignored, and @samp{\} +must be used to quote the characters +@samp{\}, @samp{$}, and @samp{`}. + +If the redirection operator is @samp{<<-}, +then all leading tab characters are stripped from input lines and the +line containing @var{delimiter}. +This allows here-documents within shell scripts to be indented in a +natural fashion. + +@subsection Here Strings +A variant of here documents, the format is: +@example +<<< @var{word} +@end example + +The @var{word} undergoes +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote removal. +Pathname expansion and word splitting are not performed. +The result is supplied as a single string to the command on its +standard input. + +@subsection Duplicating File Descriptors +The redirection operator +@example +[@var{n}]<&@var{word} +@end example +@noindent +is used to duplicate input file descriptors. +If @var{word} +expands to one or more digits, the file descriptor denoted by @var{n} +is made to be a copy of that file descriptor. +If the digits in @var{word} do not specify a file descriptor open for +input, a redirection error occurs. +If @var{word} +evaluates to @samp{-}, file descriptor @var{n} is closed. +If @var{n} is not specified, the standard input (file descriptor 0) is used. + +The operator +@example +[@var{n}]>&@var{word} +@end example +@noindent +is used similarly to duplicate output file descriptors. If +@var{n} is not specified, the standard output (file descriptor 1) is used. +If the digits in @var{word} do not specify a file descriptor open for +output, a redirection error occurs. +If @var{word} +evaluates to @samp{-}, file descriptor @var{n} is closed. +As a special case, if @var{n} is omitted, and @var{word} does not +expand to one or more digits or @samp{-}, the standard output and standard +error are redirected as described previously. + +@subsection Moving File Descriptors +The redirection operator +@example +[@var{n}]<&@var{digit}- +@end example +@noindent +moves the file descriptor @var{digit} to file descriptor @var{n}, +or the standard input (file descriptor 0) if @var{n} is not specified. +@var{digit} is closed after being duplicated to @var{n}. + +Similarly, the redirection operator +@example +[@var{n}]>&@var{digit}- +@end example +@noindent +moves the file descriptor @var{digit} to file descriptor @var{n}, +or the standard output (file descriptor 1) if @var{n} is not specified. + +@subsection Opening File Descriptors for Reading and Writing +The redirection operator +@example +[@var{n}]<>@var{word} +@end example +@noindent +causes the file whose name is the expansion of @var{word} +to be opened for both reading and writing on file descriptor +@var{n}, or on file descriptor 0 if @var{n} +is not specified. If the file does not exist, it is created. + +@node Executing Commands +@section Executing Commands + +@menu +* Simple Command Expansion:: How Bash expands simple commands before + executing them. +* Command Search and Execution:: How Bash finds commands and runs them. +* Command Execution Environment:: The environment in which Bash + executes commands that are not + shell builtins. +* Environment:: The environment given to a command. +* Exit Status:: The status returned by commands and how Bash + interprets it. +* Signals:: What happens when Bash or a command it runs + receives a signal. +@end menu + +@node Simple Command Expansion +@subsection Simple Command Expansion +@cindex command expansion + +When a simple command is executed, the shell performs the following +expansions, assignments, and redirections, from left to right. + +@enumerate +@item +The words that the parser has marked as variable assignments (those +preceding the command name) and redirections are saved for later +processing. + +@item +The words that are not variable assignments or redirections are +expanded (@pxref{Shell Expansions}). +If any words remain after expansion, the first word +is taken to be the name of the command and the remaining words are +the arguments. + +@item +Redirections are performed as described above (@pxref{Redirections}). + +@item +The text after the @samp{=} in each variable assignment undergoes tilde +expansion, parameter expansion, command substitution, arithmetic expansion, +and quote removal before being assigned to the variable. +@end enumerate + +If no command name results, the variable assignments affect the current +shell environment. Otherwise, the variables are added to the environment +of the executed command and do not affect the current shell environment. +If any of the assignments attempts to assign a value to a readonly variable, +an error occurs, and the command exits with a non-zero status. + +If no command name results, redirections are performed, but do not +affect the current shell environment. A redirection error causes the +command to exit with a non-zero status. + +If there is a command name left after expansion, execution proceeds as +described below. Otherwise, the command exits. If one of the expansions +contained a command substitution, the exit status of the command is +the exit status of the last command substitution performed. If there +were no command substitutions, the command exits with a status of zero. + +@node Command Search and Execution +@subsection Command Search and Execution +@cindex command execution +@cindex command search + +After a command has been split into words, if it results in a +simple command and an optional list of arguments, the following +actions are taken. + +@enumerate +@item +If the command name contains no slashes, the shell attempts to +locate it. If there exists a shell function by that name, that +function is invoked as described in @ref{Shell Functions}. + +@item +If the name does not match a function, the shell searches for +it in the list of shell builtins. If a match is found, that +builtin is invoked. + +@item +If the name is neither a shell function nor a builtin, +and contains no slashes, Bash searches each element of +@env{$PATH} for a directory containing an executable file +by that name. Bash uses a hash table to remember the full +pathnames of executable files to avoid multiple @env{PATH} searches +(see the description of @code{hash} in @ref{Bourne Shell Builtins}). +A full search of the directories in @env{$PATH} +is performed only if the command is not found in the hash table. +If the search is unsuccessful, the shell searches for a defined shell +function named @code{command_not_found_handle}. +If that function exists, it is invoked with the original command and +the original command's arguments as its arguments, and the function's +exit status becomes the exit status of the shell. +If that function is not defined, the shell prints an error +message and returns an exit status of 127. + +@item +If the search is successful, or if the command name contains +one or more slashes, the shell executes the named program in +a separate execution environment. +Argument 0 is set to the name given, and the remaining arguments +to the command are set to the arguments supplied, if any. + +@item +If this execution fails because the file is not in executable +format, and the file is not a directory, it is assumed to be a +@var{shell script} and the shell executes it as described in +@ref{Shell Scripts}. + +@item +If the command was not begun asynchronously, the shell waits for +the command to complete and collects its exit status. + +@end enumerate + +@node Command Execution Environment +@subsection Command Execution Environment +@cindex execution environment + +The shell has an @var{execution environment}, which consists of the +following: + +@itemize @bullet +@item +open files inherited by the shell at invocation, as modified by +redirections supplied to the @code{exec} builtin + +@item +the current working directory as set by @code{cd}, @code{pushd}, or +@code{popd}, or inherited by the shell at invocation + +@item +the file creation mode mask as set by @code{umask} or inherited from +the shell's parent + +@item +current traps set by @code{trap} + +@item +shell parameters that are set by variable assignment or with @code{set} +or inherited from the shell's parent in the environment + +@item +shell functions defined during execution or inherited from the shell's +parent in the environment + +@item +options enabled at invocation (either by default or with command-line +arguments) or by @code{set} + +@item +options enabled by @code{shopt} (@pxref{The Shopt Builtin}) + +@item +shell aliases defined with @code{alias} (@pxref{Aliases}) + +@item +various process @sc{id}s, including those of background jobs +(@pxref{Lists}), the value of @code{$$}, and the value of +@env{$PPID} + +@end itemize + +When a simple command other than a builtin or shell function +is to be executed, it +is invoked in a separate execution environment that consists of +the following. Unless otherwise noted, the values are inherited +from the shell. + +@itemize @bullet +@item +the shell's open files, plus any modifications and additions specified +by redirections to the command + +@item +the current working directory + +@item +the file creation mode mask + +@item +shell variables and functions marked for export, along with variables +exported for the command, passed in the environment (@pxref{Environment}) + +@item +traps caught by the shell are reset to the values inherited from the +shell's parent, and traps ignored by the shell are ignored + +@end itemize + +A command invoked in this separate environment cannot affect the +shell's execution environment. + +Command substitution, commands grouped with parentheses, +and asynchronous commands are invoked in a +subshell environment that is a duplicate of the shell environment, +except that traps caught by the shell are reset to the values +that the shell inherited from its parent at invocation. Builtin +commands that are invoked as part of a pipeline are also executed +in a subshell environment. Changes made to the subshell environment +cannot affect the shell's execution environment. + +Subshells spawned to execute command substitutions inherit the value of +the @option{-e} option from the parent shell. When not in @sc{posix} mode, +Bash clears the @option{-e} option in such subshells. + +If a command is followed by a @samp{&} and job control is not active, the +default standard input for the command is the empty file @file{/dev/null}. +Otherwise, the invoked command inherits the file descriptors of the calling +shell as modified by redirections. + +@node Environment +@subsection Environment +@cindex environment + +When a program is invoked it is given an array of strings +called the @var{environment}. +This is a list of name-value pairs, of the form @code{name=value}. + +Bash provides several ways to manipulate the environment. +On invocation, the shell scans its own environment and +creates a parameter for each name found, automatically marking +it for @var{export} +to child processes. Executed commands inherit the environment. +The @code{export} and @samp{declare -x} +commands allow parameters and functions to be added to and +deleted from the environment. If the value of a parameter +in the environment is modified, the new value becomes part +of the environment, replacing the old. The environment +inherited by any executed command consists of the shell's +initial environment, whose values may be modified in the shell, +less any pairs removed by the @code{unset} and @samp{export -n} +commands, plus any additions via the @code{export} and +@samp{declare -x} commands. + +The environment for any simple command +or function may be augmented temporarily by prefixing it with +parameter assignments, as described in @ref{Shell Parameters}. +These assignment statements affect only the environment seen +by that command. + +If the @option{-k} option is set (@pxref{The Set Builtin}), then all +parameter assignments are placed in the environment for a command, +not just those that precede the command name. + +When Bash invokes an external command, the variable @samp{$_} +is set to the full pathname of the command and passed to that +command in its environment. + +@node Exit Status +@subsection Exit Status +@cindex exit status + +The exit status of an executed command is the value returned by the +@var{waitpid} system call or equivalent function. Exit statuses +fall between 0 and 255, though, as explained below, the shell may +use values above 125 specially. Exit statuses from shell builtins and +compound commands are also limited to this range. Under certain +circumstances, the shell will use special values to indicate specific +failure modes. + +For the shell's purposes, a command which exits with a +zero exit status has succeeded. +A non-zero exit status indicates failure. +This seemingly counter-intuitive scheme is used so there +is one well-defined way to indicate success and a variety of +ways to indicate various failure modes. +When a command terminates on a fatal signal whose number is @var{N}, +Bash uses the value 128+@var{N} as the exit status. + +If a command is not found, the child process created to +execute it returns a status of 127. If a command is found +but is not executable, the return status is 126. + +If a command fails because of an error during expansion or redirection, +the exit status is greater than zero. + +The exit status is used by the Bash conditional commands +(@pxref{Conditional Constructs}) and some of the list +constructs (@pxref{Lists}). + +All of the Bash builtins return an exit status of zero if they succeed +and a non-zero status on failure, so they may be used by the +conditional and list constructs. +All builtins return an exit status of 2 to indicate incorrect usage. + +@node Signals +@subsection Signals +@cindex signal handling + +When Bash is interactive, in the absence of any traps, it ignores +@code{SIGTERM} (so that @samp{kill 0} does not kill an interactive shell), +and @code{SIGINT} +is caught and handled (so that the @code{wait} builtin is interruptible). +When Bash receives a @code{SIGINT}, it breaks out of any executing loops. +In all cases, Bash ignores @code{SIGQUIT}. +If job control is in effect (@pxref{Job Control}), Bash +ignores @code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}. + +Non-builtin commands started by Bash have signal handlers set to the +values inherited by the shell from its parent. +When job control is not in effect, asynchronous commands +ignore @code{SIGINT} and @code{SIGQUIT} in addition to these inherited +handlers. +Commands run as a result of +command substitution ignore the keyboard-generated job control signals +@code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}. + +The shell exits by default upon receipt of a @code{SIGHUP}. +Before exiting, an interactive shell resends the @code{SIGHUP} to +all jobs, running or stopped. +Stopped jobs are sent @code{SIGCONT} to ensure that they receive +the @code{SIGHUP}. +To prevent the shell from sending the @code{SIGHUP} signal to a +particular job, it should be removed +from the jobs table with the @code{disown} +builtin (@pxref{Job Control Builtins}) or marked +to not receive @code{SIGHUP} using @code{disown -h}. + +If the @code{huponexit} shell option has been set with @code{shopt} +(@pxref{The Shopt Builtin}), Bash sends a @code{SIGHUP} to all jobs when +an interactive login shell exits. + +If Bash is waiting for a command to complete and receives a signal +for which a trap has been set, the trap will not be executed until +the command completes. +When Bash is waiting for an asynchronous +command via the @code{wait} builtin, the reception of a signal for +which a trap has been set will cause the @code{wait} builtin to return +immediately with an exit status greater than 128, immediately after +which the trap is executed. + +@node Shell Scripts +@section Shell Scripts +@cindex shell script + +A shell script is a text file containing shell commands. When such +a file is used as the first non-option argument when invoking Bash, +and neither the @option{-c} nor @option{-s} option is supplied +(@pxref{Invoking Bash}), +Bash reads and executes commands from the file, then exits. This +mode of operation creates a non-interactive shell. The shell first +searches for the file in the current directory, and looks in the +directories in @env{$PATH} if not found there. + +When Bash runs +a shell script, it sets the special parameter @code{0} to the name +of the file, rather than the name of the shell, and the positional +parameters are set to the remaining arguments, if any are given. +If no additional arguments are supplied, the positional parameters +are unset. + +A shell script may be made executable by using the @code{chmod} command +to turn on the execute bit. When Bash finds such a file while +searching the @env{$PATH} for a command, it spawns a subshell to +execute it. In other words, executing +@example +filename @var{arguments} +@end example +@noindent +is equivalent to executing +@example +bash filename @var{arguments} +@end example + +@noindent +if @code{filename} is an executable shell script. +This subshell reinitializes itself, so that the effect is as if a +new shell had been invoked to interpret the script, with the +exception that the locations of commands remembered by the parent +(see the description of @code{hash} in @ref{Bourne Shell Builtins}) +are retained by the child. + +Most versions of Unix make this a part of the operating system's command +execution mechanism. If the first line of a script begins with +the two characters @samp{#!}, the remainder of the line specifies +an interpreter for the program. +Thus, you can specify Bash, @code{awk}, Perl, or some other +interpreter and write the rest of the script file in that language. + +The arguments to the interpreter +consist of a single optional argument following the interpreter +name on the first line of the script file, followed by the name of +the script file, followed by the rest of the arguments. Bash +will perform this action on operating systems that do not handle it +themselves. Note that some older versions of Unix limit the interpreter +name and argument to a maximum of 32 characters. + +Bash scripts often begin with @code{#! /bin/bash} (assuming that +Bash has been installed in @file{/bin}), since this ensures that +Bash will be used to interpret the script, even if it is executed +under another shell. + +@node Shell Builtin Commands +@chapter Shell Builtin Commands + +@menu +* Bourne Shell Builtins:: Builtin commands inherited from the Bourne + Shell. +* Bash Builtins:: Table of builtins specific to Bash. +* Modifying Shell Behavior:: Builtins to modify shell attributes and + optional behavior. +* Special Builtins:: Builtin commands classified specially by + POSIX. +@end menu + +Builtin commands are contained within the shell itself. +When the name of a builtin command is used as the first word of +a simple command (@pxref{Simple Commands}), the shell executes +the command directly, without invoking another program. +Builtin commands are necessary to implement functionality impossible +or inconvenient to obtain with separate utilities. + +This section briefly describes the builtins which Bash inherits from +the Bourne Shell, as well as the builtin commands which are unique +to or have been extended in Bash. + +Several builtin commands are described in other chapters: builtin +commands which provide the Bash interface to the job control +facilities (@pxref{Job Control Builtins}), the directory stack +(@pxref{Directory Stack Builtins}), the command history +(@pxref{Bash History Builtins}), and the programmable completion +facilities (@pxref{Programmable Completion Builtins}). + +Many of the builtins have been extended by @sc{posix} or Bash. + +Unless otherwise noted, each builtin command documented as accepting +options preceded by @samp{-} accepts @samp{--} +to signify the end of the options. +The @code{:}, @code{true}, @code{false}, and @code{test} +builtins do not accept options and do not treat @samp{--} specially. +The @code{exit}, @code{logout}, @code{break}, @code{continue}, @code{let}, +and @code{shift} builtins accept and process arguments beginning +with @samp{-} without requiring @samp{--}. +Other builtins that accept arguments but are not specified as accepting +options interpret arguments beginning with @samp{-} as invalid options and +require @samp{--} to prevent this interpretation. + +@node Bourne Shell Builtins +@section Bourne Shell Builtins + +The following shell builtin commands are inherited from the Bourne Shell. +These commands are implemented as specified by the @sc{posix} standard. + +@table @code +@item : @r{(a colon)} +@btindex : +@example +: [@var{arguments}] +@end example + +Do nothing beyond expanding @var{arguments} and performing redirections. +The return status is zero. + +@item . @r{(a period)} +@btindex . +@example +. @var{filename} [@var{arguments}] +@end example + +Read and execute commands from the @var{filename} argument in the +current shell context. If @var{filename} does not contain a slash, +the @env{PATH} variable is used to find @var{filename}. +When Bash is not in @sc{posix} mode, the current directory is searched +if @var{filename} is not found in @env{$PATH}. +If any @var{arguments} are supplied, they become the positional +parameters when @var{filename} is executed. Otherwise the positional +parameters are unchanged. +The return status is the exit status of the last command executed, or +zero if no commands are executed. If @var{filename} is not found, or +cannot be read, the return status is non-zero. +This builtin is equivalent to @code{source}. + +@item break +@btindex break +@example +break [@var{n}] +@end example + +Exit from a @code{for}, @code{while}, @code{until}, or @code{select} loop. +If @var{n} is supplied, the @var{n}th enclosing loop is exited. +@var{n} must be greater than or equal to 1. +The return status is zero unless @var{n} is not greater than or equal to 1. + +@item cd +@btindex cd +@example +cd [-L|[-P [-e]]] [@var{directory}] +@end example + +Change the current working directory to @var{directory}. +If @var{directory} is not supplied, the value of the @env{HOME} +shell variable is used. +Any additional arguments following @var{directory} are ignored. +If the shell variable +@env{CDPATH} exists, it is used as a search path: +each directory name in @env{CDPATH} is searched for +@var{directory}, with alternative directory names in @env{CDPATH} +separated by a colon (@samp{:}). +If @var{directory} begins with a slash, @env{CDPATH} is not used. + +The @option{-P} option means to not follow symbolic links: symbolic links +are resolved while @code{cd} is traversing @var{directory} and before +processing an instance of @samp{..} in @var{directory}. + +By default, or when the @option{-L} option is supplied, symbolic links +in @var{directory} are resolved after @code{cd} processes an instance +of @samp{..} in @var{directory}. + +If @samp{..} appears in @var{directory}, it is processed by removing the +immediately preceding pathname component, back to a slash or the beginning +of @var{directory}. + +If the @option{-e} option is supplied with @option{-P} +and the current working directory cannot be successfully determined +after a successful directory change, @code{cd} will return an unsuccessful +status. +If @var{directory} is @samp{-}, it is converted to @env{$OLDPWD} +before the directory change is attempted. + +If a non-empty directory name from @env{CDPATH} is used, or if +@samp{-} is the first argument, and the directory change is +successful, the absolute pathname of the new working directory is +written to the standard output. + +The return status is zero if the directory is successfully changed, +non-zero otherwise. + +@item continue +@btindex continue +@example +continue [@var{n}] +@end example + +Resume the next iteration of an enclosing @code{for}, @code{while}, +@code{until}, or @code{select} loop. +If @var{n} is supplied, the execution of the @var{n}th enclosing loop +is resumed. +@var{n} must be greater than or equal to 1. +The return status is zero unless @var{n} is not greater than or equal to 1. + +@item eval +@btindex eval +@example +eval [@var{arguments}] +@end example + +The arguments are concatenated together into a single command, which is +then read and executed, and its exit status returned as the exit status +of @code{eval}. +If there are no arguments or only empty arguments, the return status is +zero. + +@item exec +@btindex exec +@example +exec [-cl] [-a @var{name}] [@var{command} [@var{arguments}]] +@end example + +If @var{command} +is supplied, it replaces the shell without creating a new process. +If the @option{-l} option is supplied, the shell places a dash at the +beginning of the zeroth argument passed to @var{command}. +This is what the @code{login} program does. +The @option{-c} option causes @var{command} to be executed with an empty +environment. +If @option{-a} is supplied, the shell passes @var{name} as the zeroth +argument to @var{command}. +If @var{command} +cannot be executed for some reason, a non-interactive shell exits, +unless the @code{execfail} shell option +is enabled. In that case, it returns failure. +An interactive shell returns failure if the file cannot be executed. +If no @var{command} is specified, redirections may be used to affect +the current shell environment. If there are no redirection errors, the +return status is zero; otherwise the return status is non-zero. + +@item exit +@btindex exit +@example +exit [@var{n}] +@end example + +Exit the shell, returning a status of @var{n} to the shell's parent. +If @var{n} is omitted, the exit status is that of the last command executed. +Any trap on @code{EXIT} is executed before the shell terminates. + +@item export +@btindex export +@example +export [-fn] [-p] [@var{name}[=@var{value}]] +@end example + +Mark each @var{name} to be passed to child processes +in the environment. If the @option{-f} option is supplied, the @var{name}s +refer to shell functions; otherwise the names refer to shell variables. +The @option{-n} option means to no longer mark each @var{name} for export. +If no @var{names} are supplied, or if the @option{-p} option is given, a +list of names of all exported variables is displayed. +The @option{-p} option displays output in a form that may be reused as input. +If a variable name is followed by =@var{value}, the value of +the variable is set to @var{value}. + +The return status is zero unless an invalid option is supplied, one of +the names is not a valid shell variable name, or @option{-f} is supplied +with a name that is not a shell function. + +@item getopts +@btindex getopts +@example +getopts @var{optstring} @var{name} [@var{args}] +@end example + +@code{getopts} is used by shell scripts to parse positional parameters. +@var{optstring} contains the option characters to be recognized; if a +character is followed by a colon, the option is expected to have an +argument, which should be separated from it by whitespace. +The colon (@samp{:}) and question mark (@samp{?}) may not be +used as option characters. +Each time it is invoked, @code{getopts} +places the next option in the shell variable @var{name}, initializing +@var{name} if it does not exist, +and the index of the next argument to be processed into the +variable @env{OPTIND}. +@env{OPTIND} is initialized to 1 each time the shell or a shell script +is invoked. +When an option requires an argument, +@code{getopts} places that argument into the variable @env{OPTARG}. +The shell does not reset @env{OPTIND} automatically; it must be manually +reset between multiple calls to @code{getopts} within the same shell +invocation if a new set of parameters is to be used. + +When the end of options is encountered, @code{getopts} exits with a +return value greater than zero. +@env{OPTIND} is set to the index of the first non-option argument, +and @var{name} is set to @samp{?}. + +@code{getopts} +normally parses the positional parameters, but if more arguments are +given in @var{args}, @code{getopts} parses those instead. + +@code{getopts} can report errors in two ways. If the first character of +@var{optstring} is a colon, @var{silent} +error reporting is used. In normal operation, diagnostic messages +are printed when invalid options or missing option arguments are +encountered. +If the variable @env{OPTERR} +is set to 0, no error messages will be displayed, even if the first +character of @code{optstring} is not a colon. + +If an invalid option is seen, +@code{getopts} places @samp{?} into @var{name} and, if not silent, +prints an error message and unsets @env{OPTARG}. +If @code{getopts} is silent, the option character found is placed in +@env{OPTARG} and no diagnostic message is printed. + +If a required argument is not found, and @code{getopts} +is not silent, a question mark (@samp{?}) is placed in @var{name}, +@code{OPTARG} is unset, and a diagnostic message is printed. +If @code{getopts} is silent, then a colon (@samp{:}) is placed in +@var{name} and @env{OPTARG} is set to the option character found. + +@item hash +@btindex hash +@example +hash [-r] [-p @var{filename}] [-dt] [@var{name}] +@end example + +Each time @code{hash} is invoked, it remembers the full pathnames of the +commands specified as @var{name} arguments, +so they need not be searched for on subsequent invocations. +The commands are found by searching through the directories listed in +@env{$PATH}. +Any previously-remembered pathname is discarded. +The @option{-p} option inhibits the path search, and @var{filename} is +used as the location of @var{name}. +The @option{-r} option causes the shell to forget all remembered locations. +The @option{-d} option causes the shell to forget the remembered location +of each @var{name}. +If the @option{-t} option is supplied, the full pathname to which each +@var{name} corresponds is printed. If multiple @var{name} arguments are +supplied with @option{-t} the @var{name} is printed before the hashed +full pathname. +The @option{-l} option causes output to be displayed in a format +that may be reused as input. +If no arguments are given, or if only @option{-l} is supplied, +information about remembered commands is printed. +The return status is zero unless a @var{name} is not found or an invalid +option is supplied. + +@item pwd +@btindex pwd +@example +pwd [-LP] +@end example + +Print the absolute pathname of the current working directory. +If the @option{-P} option is supplied, the pathname printed will not +contain symbolic links. +If the @option{-L} option is supplied, the pathname printed may contain +symbolic links. +The return status is zero unless an error is encountered while +determining the name of the current directory or an invalid option +is supplied. + +@item readonly +@btindex readonly +@example +readonly [-aAf] [-p] [@var{name}[=@var{value}]] @dots{} +@end example + +Mark each @var{name} as readonly. +The values of these names may not be changed by subsequent assignment. +If the @option{-f} option is supplied, each @var{name} refers to a shell +function. +The @option{-a} option means each @var{name} refers to an indexed +array variable; the @option{-A} option means each @var{name} refers +to an associative array variable. +If both options are supplied, @option{-A} takes precedence. +If no @var{name} arguments are given, or if the @option{-p} +option is supplied, a list of all readonly names is printed. +The other options may be used to restrict the output to a subset of +the set of readonly names. +The @option{-p} option causes output to be displayed in a format that +may be reused as input. +If a variable name is followed by =@var{value}, the value of +the variable is set to @var{value}. +The return status is zero unless an invalid option is supplied, one of +the @var{name} arguments is not a valid shell variable or function name, +or the @option{-f} option is supplied with a name that is not a shell function. + +@item return +@btindex return +@example +return [@var{n}] +@end example + +Cause a shell function to stop executing and return the value @var{n} +to its caller. +If @var{n} is not supplied, the return value is the exit status of the +last command executed in the function. +@code{return} may also be used to terminate execution of a script +being executed with the @code{.} (@code{source}) builtin, +returning either @var{n} or +the exit status of the last command executed within the script as the exit +status of the script. +If @var{n} is supplied, the return value is its least significant +8 bits. +Any command associated with the @code{RETURN} trap is executed +before execution resumes after the function or script. +The return status is non-zero if @code{return} is supplied a non-numeric +argument or is used outside a function +and not during the execution of a script by @code{.} or @code{source}. + +@item shift +@btindex shift +@example +shift [@var{n}] +@end example + +Shift the positional parameters to the left by @var{n}. +The positional parameters from @var{n}+1 @dots{} @code{$#} are +renamed to @code{$1} @dots{} @code{$#}-@var{n}. +Parameters represented by the numbers @code{$#} to @code{$#}-@var{n}+1 +are unset. +@var{n} must be a non-negative number less than or equal to @code{$#}. +If @var{n} is zero or greater than @code{$#}, the positional parameters +are not changed. +If @var{n} is not supplied, it is assumed to be 1. +The return status is zero unless @var{n} is greater than @code{$#} or +less than zero, non-zero otherwise. + +@item test +@itemx [ +@btindex test +@btindex [ +@example +test @var{expr} +@end example + +Evaluate a conditional express +ion @var{expr} and return a status of 0 +(true) or 1 (false). +Each operator and operand must be a separate argument. +Expressions are composed of the primaries described below in +@ref{Bash Conditional Expressions}. +@code{test} does not accept any options, nor does it accept and ignore +an argument of @option{--} as signifying the end of options. + +When the @code{[} form is used, the last argument to the command must +be a @code{]}. + +Expressions may be combined using the following operators, listed in +decreasing order of precedence. +The evaluation depends on the number of arguments; see below. +Operator precedence is used when there are five or more arguments. + +@table @code +@item ! @var{expr} +True if @var{expr} is false. + +@item ( @var{expr} ) +Returns the value of @var{expr}. +This may be used to override the normal precedence of operators. + +@item @var{expr1} -a @var{expr2} +True if both @var{expr1} and @var{expr2} are true. + +@item @var{expr1} -o @var{expr2} +True if either @var{expr1} or @var{expr2} is true. +@end table + +The @code{test} and @code{[} builtins evaluate conditional +expressions using a set of rules based on the number of arguments. + +@table @asis +@item 0 arguments +The expression is false. + +@item 1 argument +The expression is true if and only if the argument is not null. + +@item 2 arguments +If the first argument is @samp{!}, the expression is true if and +only if the second argument is null. +If the first argument is one of the unary conditional operators +(@pxref{Bash Conditional Expressions}), the expression +is true if the unary test is true. +If the first argument is not a valid unary operator, the expression is +false. + +@item 3 arguments +The following conditions are applied in the order listed. +If the second argument is one of the binary conditional +operators (@pxref{Bash Conditional Expressions}), the +result of the expression is the result of the binary test using the +first and third arguments as operands. +The @samp{-a} and @samp{-o} operators are considered binary operators +when there are three arguments. +If the first argument is @samp{!}, the value is the negation of +the two-argument test using the second and third arguments. +If the first argument is exactly @samp{(} and the third argument is +exactly @samp{)}, the result is the one-argument test of the second +argument. +Otherwise, the expression is false. + +@item 4 arguments +If the first argument is @samp{!}, the result is the negation of +the three-argument expression composed of the remaining arguments. +Otherwise, the expression is parsed and evaluated according to +precedence using the rules listed above. + +@item 5 or more arguments +The expression is parsed and evaluated according to precedence +using the rules listed above. +@end table + +When used with @code{test} or @samp{[}, the @samp{<} and @samp{>} +operators sort lexicographically using ASCII ordering. + +@item times +@btindex times +@example +times +@end example + +Print out the user and system times used by the shell and its children. +The return status is zero. + +@item trap +@btindex trap +@example +trap [-lp] [@var{arg}] [@var{sigspec} @dots{}] +@end example + +The commands in @var{arg} are to be read and executed when the +shell receives signal @var{sigspec}. If @var{arg} is absent (and +there is a single @var{sigspec}) or +equal to @samp{-}, each specified signal's disposition is reset +to the value it had when the shell was started. +If @var{arg} is the null string, then the signal specified by +each @var{sigspec} is ignored by the shell and commands it invokes. +If @var{arg} is not present and @option{-p} has been supplied, +the shell displays the trap commands associated with each @var{sigspec}. +If no arguments are supplied, or +only @option{-p} is given, @code{trap} prints the list of commands +associated with each signal number in a form that may be reused as +shell input. +The @option{-l} option causes the shell to print a list of signal names +and their corresponding numbers. +Each @var{sigspec} is either a signal name or a signal number. +Signal names are case insensitive and the @code{SIG} prefix is optional. + +If a @var{sigspec} +is @code{0} or @code{EXIT}, @var{arg} is executed when the shell exits. +If a @var{sigspec} is @code{DEBUG}, the command @var{arg} is executed +before every simple command, @code{for} command, @code{case} command, +@code{select} command, every arithmetic @code{for} command, and before +the first command executes in a shell function. +Refer to the description of the @code{extdebug} option to the +@code{shopt} builtin (@pxref{The Shopt Builtin}) for details of its +effect on the @code{DEBUG} trap. +If a @var{sigspec} is @code{RETURN}, the command @var{arg} is executed +each time a shell function or a script executed with the @code{.} or +@code{source} builtins finishes executing. + +If a @var{sigspec} is @code{ERR}, the command @var{arg} +is executed whenever a simple command has a non-zero exit status, +subject to the following conditions. +The @code{ERR} trap is not executed if the failed command is part of the +command list immediately following an @code{until} or @code{while} keyword, +part of the test following the @code{if} or @code{elif} reserved words, +part of a command executed in a @code{&&} or @code{||} list, +or if the command's return +status is being inverted using @code{!}. +These are the same conditions obeyed by the @code{errexit} option. + +Signals ignored upon entry to the shell cannot be trapped or reset. +Trapped signals that are not being ignored are reset to their original +values in a subshell or subshell environment when one is created. + +The return status is zero unless a @var{sigspec} does not specify a +valid signal. + +@item umask +@btindex umask +@example +umask [-p] [-S] [@var{mode}] +@end example + +Set the shell process's file creation mask to @var{mode}. If +@var{mode} begins with a digit, it is interpreted as an octal number; +if not, it is interpreted as a symbolic mode mask similar +to that accepted by the @code{chmod} command. If @var{mode} is +omitted, the current value of the mask is printed. If the @option{-S} +option is supplied without a @var{mode} argument, the mask is printed +in a symbolic format. +If the @option{-p} option is supplied, and @var{mode} +is omitted, the output is in a form that may be reused as input. +The return status is zero if the mode is successfully changed or if +no @var{mode} argument is supplied, and non-zero otherwise. + +Note that when the mode is interpreted as an octal number, each number +of the umask is subtracted from @code{7}. Thus, a umask of @code{022} +results in permissions of @code{755}. + +@item unset +@btindex unset +@example +unset [-fnv] [@var{name}] +@end example + +Remove each variable or function @var{name}. +If the @option{-v} option is given, each +@var{name} refers to a shell variable and that variable is remvoved. +If the @option{-f} option is given, the @var{name}s refer to shell +functions, and the function definition is removed. +If the @option{-n} option is supplied, and @var{name} is a variable with +the @var{nameref} attribute, @var{name} will be unset rather than the +variable it references. +@option{-n} has no effect if the @option{-f} option is supplied. +If no options are supplied, each @var{name} refers to a variable; if +there is no variable by that name, any function with that name is +unset. +Readonly variables and functions may not be unset. +The return status is zero unless a @var{name} is readonly. +@end table + +@node Bash Builtins +@section Bash Builtin Commands + +This section describes builtin commands which are unique to +or have been extended in Bash. +Some of these commands are specified in the @sc{posix} standard. + +@table @code + +@item alias +@btindex alias +@example +alias [-p] [@var{name}[=@var{value}] @dots{}] +@end example + +Without arguments or with the @option{-p} option, @code{alias} prints +the list of aliases on the standard output in a form that allows +them to be reused as input. +If arguments are supplied, an alias is defined for each @var{name} +whose @var{value} is given. If no @var{value} is given, the name +and value of the alias is printed. +Aliases are described in @ref{Aliases}. + +@item bind +@btindex bind +@example +bind [-m @var{keymap}] [-lpsvPSVX] +bind [-m @var{keymap}] [-q @var{function}] [-u @var{function}] [-r @var{keyseq}] +bind [-m @var{keymap}] -f @var{filename} +bind [-m @var{keymap}] -x @var{keyseq:shell-command} +bind [-m @var{keymap}] @var{keyseq:function-name} +bind @var{readline-command} +@end example + +Display current Readline (@pxref{Command Line Editing}) +key and function bindings, +bind a key sequence to a Readline function or macro, +or set a Readline variable. +Each non-option argument is a command as it would appear in a +Readline initialization file (@pxref{Readline Init File}), +but each binding or command must be passed as a separate argument; e.g., +@samp{"\C-x\C-r":re-read-init-file}. + +Options, if supplied, have the following meanings: + +@table @code +@item -m @var{keymap} +Use @var{keymap} as the keymap to be affected by +the subsequent bindings. Acceptable @var{keymap} +names are +@code{emacs}, +@code{emacs-standard}, +@code{emacs-meta}, +@code{emacs-ctlx}, +@code{vi}, +@code{vi-move}, +@code{vi-command}, and +@code{vi-insert}. +@code{vi} is equivalent to @code{vi-command}; +@code{emacs} is equivalent to @code{emacs-standard}. + +@item -l +List the names of all Readline functions. + +@item -p +Display Readline function names and bindings in such a way that they +can be used as input or in a Readline initialization file. + +@item -P +List current Readline function names and bindings. + +@item -v +Display Readline variable names and values in such a way that they +can be used as input or in a Readline initialization file. + +@item -V +List current Readline variable names and values. + +@item -s +Display Readline key sequences bound to macros and the strings they output +in such a way that they can be used as input or in a Readline +initialization file. + +@item -S +Display Readline key sequences bound to macros and the strings they output. + +@item -f @var{filename} +Read key bindings from @var{filename}. + +@item -q @var{function} +Query about which keys invoke the named @var{function}. + +@item -u @var{function} +Unbind all keys bound to the named @var{function}. + +@item -r @var{keyseq} +Remove any current binding for @var{keyseq}. + +@item -x @var{keyseq:shell-command} +Cause @var{shell-command} to be executed whenever @var{keyseq} is +entered. +When @var{shell-command} is executed, the shell sets the +@code{READLINE_LINE} variable to the contents of the Readline line +buffer and the @code{READLINE_POINT} variable to the current location +of the insertion point. +If the executed command changes the value of @code{READLINE_LINE} or +@code{READLINE_POINT}, those new values will be reflected in the +editing state. + +@item -X +List all key sequences bound to shell commands and the associated commands +in a format that can be reused as input. +@end table + +@noindent +The return status is zero unless an invalid option is supplied or an +error occurs. + +@item builtin +@btindex builtin +@example +builtin [@var{shell-builtin} [@var{args}]] +@end example + +Run a shell builtin, passing it @var{args}, and return its exit status. +This is useful when defining a shell function with the same +name as a shell builtin, retaining the functionality of the builtin within +the function. +The return status is non-zero if @var{shell-builtin} is not a shell +builtin command. + +@item caller +@btindex caller +@example +caller [@var{expr}] +@end example + +Returns the context of any active subroutine call (a shell function or +a script executed with the @code{.} or @code{source} builtins). + +Without @var{expr}, @code{caller} displays the line number and source +filename of the current subroutine call. +If a non-negative integer is supplied as @var{expr}, @code{caller} +displays the line number, subroutine name, and source file corresponding +to that position in the current execution call stack. This extra +information may be used, for example, to print a stack trace. The +current frame is frame 0. + +The return value is 0 unless the shell is not executing a subroutine +call or @var{expr} does not correspond to a valid position in the +call stack. + +@item command +@btindex command +@example +command [-pVv] @var{command} [@var{arguments} @dots{}] +@end example + +Runs @var{command} with @var{arguments} ignoring any shell function +named @var{command}. +Only shell builtin commands or commands found by searching the +@env{PATH} are executed. +If there is a shell function named @code{ls}, running @samp{command ls} +within the function will execute the external command @code{ls} +instead of calling the function recursively. +The @option{-p} option means to use a default value for @env{PATH} +that is guaranteed to find all of the standard utilities. +The return status in this case is 127 if @var{command} cannot be +found or an error occurred, and the exit status of @var{command} +otherwise. + +If either the @option{-V} or @option{-v} option is supplied, a +description of @var{command} is printed. The @option{-v} option +causes a single word indicating the command or file name used to +invoke @var{command} to be displayed; the @option{-V} option produces +a more verbose description. In this case, the return status is +zero if @var{command} is found, and non-zero if not. + +@item declare +@btindex declare +@example +declare [-aAfFgilnrtux] [-p] [@var{name}[=@var{value}] @dots{}] +@end example + +Declare variables and give them attributes. If no @var{name}s +are given, then display the values of variables instead. + +The @option{-p} option will display the attributes and values of each +@var{name}. +When @option{-p} is used with @var{name} arguments, additional options +are ignored. + +When @option{-p} is supplied without @var{name} arguments, @code{declare} +will display the attributes and values of all variables having the +attributes specified by the additional options. +If no other options are supplied with @option{-p}, @code{declare} will +display the attributes and values of all shell variables. The @option{-f} +option will restrict the display to shell functions. + +The @option{-F} option inhibits the display of function definitions; +only the function name and attributes are printed. +If the @code{extdebug} shell option is enabled using @code{shopt} +(@pxref{The Shopt Builtin}), the source file name and line number where +the function is defined are displayed as well. +@option{-F} implies @option{-f}. + +The @option{-g} option forces variables to be created or modified at +the global scope, even when @code{declare} is executed in a shell function. +It is ignored in all other cases. + +The following options can be used to restrict output to variables with +the specified attributes or to give variables attributes: + +@table @code +@item -a +Each @var{name} is an indexed array variable (@pxref{Arrays}). + +@item -A +Each @var{name} is an associative array variable (@pxref{Arrays}). + +@item -f +Use function names only. + +@item -i +The variable is to be treated as +an integer; arithmetic evaluation (@pxref{Shell Arithmetic}) is +performed when the variable is assigned a value. + +@item -l +When the variable is assigned a value, all upper-case characters are +converted to lower-case. +The upper-case attribute is disabled. + +@item -n +Give each @var{name} the @var{nameref} attribute, making +it a name reference to another variable. +That other variable is defined by the value of @var{name}. +All references and assignments to @var{name}, except for changing the +@option{-n} attribute itself, are performed on the variable referenced by +@var{name}'s value. +The @option{-n} attribute cannot be applied to array variables. + +@item -r +Make @var{name}s readonly. These names cannot then be assigned values +by subsequent assignment statements or unset. + +@item -t +Give each @var{name} the @code{trace} attribute. +Traced functions inherit the @code{DEBUG} and @code{RETURN} traps from +the calling shell. +The trace attribute has no special meaning for variables. + +@item -u +When the variable is assigned a value, all lower-case characters are +converted to upper-case. +The lower-case attribute is disabled. + +@item -x +Mark each @var{name} for export to subsequent commands via +the environment. +@end table + +Using @samp{+} instead of @samp{-} turns off the attribute instead, +with the exceptions that @samp{+a} +may not be used to destroy an array variable and @samp{+r} will not +remove the readonly attribute. +When used in a function, @code{declare} makes each @var{name} local, +as with the @code{local} command, unless the @option{-g} option is used. +If a variable name is followed by =@var{value}, the value of the variable +is set to @var{value}. + +The return status is zero unless an invalid option is encountered, +an attempt is made to define a function using @samp{-f foo=bar}, +an attempt is made to assign a value to a readonly variable, +an attempt is made to assign a value to an array variable without +using the compound assignment syntax (@pxref{Arrays}), +one of the @var{names} is not a valid shell variable name, +an attempt is made to turn off readonly status for a readonly variable, +an attempt is made to turn off array status for an array variable, +or an attempt is made to display a non-existent function with @option{-f}. + +@item echo +@btindex echo +@example +echo [-neE] [@var{arg} @dots{}] +@end example + +Output the @var{arg}s, separated by spaces, terminated with a +newline. +The return status is 0 unless a write error occurs. +If @option{-n} is specified, the trailing newline is suppressed. +If the @option{-e} option is given, interpretation of the following +backslash-escaped characters is enabled. +The @option{-E} option disables the interpretation of these escape characters, +even on systems where they are interpreted by default. +The @code{xpg_echo} shell option may be used to +dynamically determine whether or not @code{echo} expands these +escape characters by default. +@code{echo} does not interpret @option{--} to mean the end of options. + +@code{echo} interprets the following escape sequences: +@table @code +@item \a +alert (bell) +@item \b +backspace +@item \c +suppress further output +@item \e +@itemx \E +escape +@item \f +form feed +@item \n +new line +@item \r +carriage return +@item \t +horizontal tab +@item \v +vertical tab +@item \\ +backslash +@item \0@var{nnn} +the eight-bit character whose value is the octal value @var{nnn} +(zero to three octal digits) +@item \x@var{HH} +the eight-bit character whose value is the hexadecimal value @var{HH} +(one or two hex digits) +@item \u@var{HHHH} +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +@var{HHHH} (one to four hex digits) +@item \U@var{HHHHHHHH} +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +@var{HHHHHHHH} (one to eight hex digits) +@end table + +@item enable +@btindex enable +@example +enable [-a] [-dnps] [-f @var{filename}] [@var{name} @dots{}] +@end example + +Enable and disable builtin shell commands. +Disabling a builtin allows a disk command which has the same name +as a shell builtin to be executed without specifying a full pathname, +even though the shell normally searches for builtins before disk commands. +If @option{-n} is used, the @var{name}s become disabled. Otherwise +@var{name}s are enabled. For example, to use the @code{test} binary +found via @env{$PATH} instead of the shell builtin version, type +@samp{enable -n test}. + +If the @option{-p} option is supplied, or no @var{name} arguments appear, +a list of shell builtins is printed. With no other arguments, the list +consists of all enabled shell builtins. +The @option{-a} option means to list +each builtin with an indication of whether or not it is enabled. + +The @option{-f} option means to load the new builtin command @var{name} +from shared object @var{filename}, on systems that support dynamic loading. +The @option{-d} option will delete a builtin loaded with @option{-f}. + +If there are no options, a list of the shell builtins is displayed. +The @option{-s} option restricts @code{enable} to the @sc{posix} special +builtins. If @option{-s} is used with @option{-f}, the new builtin becomes +a special builtin (@pxref{Special Builtins}). + +The return status is zero unless a @var{name} is not a shell builtin +or there is an error loading a new builtin from a shared object. + +@item help +@btindex help +@example +help [-dms] [@var{pattern}] +@end example + +Display helpful information about builtin commands. +If @var{pattern} is specified, @code{help} gives detailed help +on all commands matching @var{pattern}, otherwise a list of +the builtins is printed. + +Options, if supplied, have the following meanings: + +@table @code +@item -d +Display a short description of each @var{pattern} +@item -m +Display the description of each @var{pattern} in a manpage-like format +@item -s +Display only a short usage synopsis for each @var{pattern} +@end table + +The return status is zero unless no command matches @var{pattern}. + +@item let +@btindex let +@example +let @var{expression} [@var{expression} @dots{}] +@end example + +The @code{let} builtin allows arithmetic to be performed on shell +variables. Each @var{expression} is evaluated according to the +rules given below in @ref{Shell Arithmetic}. If the +last @var{expression} evaluates to 0, @code{let} returns 1; +otherwise 0 is returned. + +@item local +@btindex local +@example +local [@var{option}] @var{name}[=@var{value}] @dots{} +@end example + +For each argument, a local variable named @var{name} is created, +and assigned @var{value}. +The @var{option} can be any of the options accepted by @code{declare}. +@code{local} can only be used within a function; it makes the variable +@var{name} have a visible scope restricted to that function and its +children. The return status is zero unless @code{local} is used outside +a function, an invalid @var{name} is supplied, or @var{name} is a +readonly variable. + +@item logout +@btindex logout +@example +logout [@var{n}] +@end example + +Exit a login shell, returning a status of @var{n} to the shell's +parent. + +@item mapfile +@btindex mapfile +@example +mapfile [-n @var{count}] [-O @var{origin}] [-s @var{count}] [-t] [-u @var{fd}] + [-C @var{callback}] [-c @var{quantum}] [@var{array}] +@end example + +Read lines from the standard input into the indexed array variable @var{array}, +or from file descriptor @var{fd} +if the @option{-u} option is supplied. +The variable @code{MAPFILE} is the default @var{array}. +Options, if supplied, have the following meanings: + +@table @code + +@item -n +Copy at most @var{count} lines. If @var{count} is 0, all lines are copied. +@item -O +Begin assigning to @var{array} at index @var{origin}. +The default index is 0. +@item -s +Discard the first @var{count} lines read. +@item -t +Remove a trailing newline from each line read. +@item -u +Read lines from file descriptor @var{fd} instead of the standard input. +@item -C +Evaluate @var{callback} each time @var{quantum}P lines are read. +The @option{-c} option specifies @var{quantum}. +@item -c +Specify the number of lines read between each call to @var{callback}. +@end table + +If @option{-C} is specified without @option{-c}, +the default quantum is 5000. +When @var{callback} is evaluated, it is supplied the index of the next +array element to be assigned and the line to be assigned to that element +as additional arguments. +@var{callback} is evaluated after the line is read but before the +array element is assigned. + +If not supplied with an explicit origin, @code{mapfile} will clear @var{array} +before assigning to it. + +@code{mapfile} returns successfully unless an invalid option or option +argument is supplied, @var{array} is invalid or unassignable, or @var{array} +is not an indexed array. + +@item printf +@btindex printf +@example +printf [-v @var{var}] @var{format} [@var{arguments}] +@end example + +Write the formatted @var{arguments} to the standard output under the +control of the @var{format}. +The @option{-v} option causes the output to be assigned to the variable +@var{var} rather than being printed to the standard output. + +The @var{format} is a character string which contains three types of objects: +plain characters, which are simply copied to standard output, character +escape sequences, which are converted and copied to the standard output, and +format specifications, each of which causes printing of the next successive +@var{argument}. +In addition to the standard @code{printf(1)} formats, @code{printf} +interprets the following extensions: + +@table @code +@item %b +Causes @code{printf} to expand backslash escape sequences in the +corresponding @var{argument}, +except that @samp{\c} terminates output, backslashes in +@samp{\'}, @samp{\"}, and @samp{\?} are not removed, and octal escapes +beginning with @samp{\0} may contain up to four digits. +@item %q +Causes @code{printf} to output the +corresponding @var{argument} in a format that can be reused as shell input. +@item %(@var{datefmt})T +Causes @code{printf} to output the date-time string resulting from using +@var{datefmt} as a format string for @code{strftime}(3). +The corresponding @var{argument} is an integer representing the number of +seconds since the epoch. +Two special argument values may be used: -1 represents the current +time, and -2 represents the time the shell was invoked. +If no argument is specified, conversion behaves as if -1 had been given. +This is an exception to the usual @code{printf} behavior. +@end table + +@noindent +Arguments to non-string format specifiers are treated as C language constants, +except that a leading plus or minus sign is allowed, and if the leading +character is a single or double quote, the value is the ASCII value of +the following character. + +The @var{format} is reused as necessary to consume all of the @var{arguments}. +If the @var{format} requires more @var{arguments} than are supplied, the +extra format specifications behave as if a zero value or null string, as +appropriate, had been supplied. The return value is zero on success, +non-zero on failure. + +@item read +@btindex read +@example +read [-ers] [-a @var{aname}] [-d @var{delim}] [-i @var{text}] [-n @var{nchars}] + [-N @var{nchars}] [-p @var{prompt}] [-t @var{timeout}] [-u @var{fd}] [@var{name} @dots{}] +@end example + +One line is read from the standard input, or from the file descriptor +@var{fd} supplied as an argument to the @option{-u} option, and the first word +is assigned to the first @var{name}, the second word to the second @var{name}, +and so on, with leftover words and their intervening separators assigned +to the last @var{name}. +If there are fewer words read from the input stream than names, +the remaining names are assigned empty values. +The characters in the value of the @env{IFS} variable +are used to split the line into words. +The backslash character @samp{\} may be used to remove any special +meaning for the next character read and for line continuation. +If no names are supplied, the line read is assigned to the +variable @env{REPLY}. +The return code is zero, unless end-of-file is encountered, @code{read} +times out (in which case the return code is greater than 128), +a variable assignment error (such as assigning to a readonly variable) occurs, +or an invalid file descriptor is supplied as the argument to @option{-u}. + +Options, if supplied, have the following meanings: + +@table @code +@item -a @var{aname} +The words are assigned to sequential indices of the array variable +@var{aname}, starting at 0. +All elements are removed from @var{aname} before the assignment. +Other @var{name} arguments are ignored. + +@item -d @var{delim} +The first character of @var{delim} is used to terminate the input line, +rather than newline. + +@item -e +Readline (@pxref{Command Line Editing}) is used to obtain the line. +Readline uses the current (or default, if line editing was not previously +active) editing settings. + +@item -i @var{text} +If Readline is being used to read the line, @var{text} is placed into +the editing buffer before editing begins. + +@item -n @var{nchars} +@code{read} returns after reading @var{nchars} characters rather than +waiting for a complete line of input, but honor a delimiter if fewer +than @var{nchars} characters are read before the delimiter. + +@item -N @var{nchars} +@code{read} returns after reading exactly @var{nchars} characters rather +than waiting for a complete line of input, unless EOF is encountered or +@code{read} times out. +Delimiter characters encountered in the input are +not treated specially and do not cause @code{read} to return until +@var{nchars} characters are read. + +@item -p @var{prompt} +Display @var{prompt}, without a trailing newline, before attempting +to read any input. +The prompt is displayed only if input is coming from a terminal. + +@item -r +If this option is given, backslash does not act as an escape character. +The backslash is considered to be part of the line. +In particular, a backslash-newline pair may not be used as a line +continuation. + +@item -s +Silent mode. If input is coming from a terminal, characters are +not echoed. + +@item -t @var{timeout} +Cause @code{read} to time out and return failure if a complete line of +input is not read within @var{timeout} seconds. +@var{timeout} may be a decimal number with a fractional portion following +the decimal point. +This option is only effective if @code{read} is reading input from a +terminal, pipe, or other special file; it has no effect when reading +from regular files. +If @var{timeout} is 0, @code{read} returns immediately, without trying to +read and data. The exit status is 0 if input is available on +the specified file descriptor, non-zero otherwise. +The exit status is greater than 128 if the timeout is exceeded. + +@item -u @var{fd} +Read input from file descriptor @var{fd}. +@end table + +@item readarray +@btindex readarray +@example +readarray [-n @var{count}] [-O @var{origin}] [-s @var{count}] [-t] [-u @var{fd}] + [-C @var{callback}] [-c @var{quantum}] [@var{array}] +@end example + +Read lines from the standard input into the indexed array variable @var{array}, +or from file descriptor @var{fd} +if the @option{-u} option is supplied. + +A synonym for @code{mapfile}. + +@item source +@btindex source +@example +source @var{filename} +@end example + +A synonym for @code{.} (@pxref{Bourne Shell Builtins}). + +@item type +@btindex type +@example +type [-afptP] [@var{name} @dots{}] +@end example + +For each @var{name}, indicate how it would be interpreted if used as a +command name. + +If the @option{-t} option is used, @code{type} prints a single word +which is one of @samp{alias}, @samp{function}, @samp{builtin}, +@samp{file} or @samp{keyword}, +if @var{name} is an alias, shell function, shell builtin, +disk file, or shell reserved word, respectively. +If the @var{name} is not found, then nothing is printed, and +@code{type} returns a failure status. + +If the @option{-p} option is used, @code{type} either returns the name +of the disk file that would be executed, or nothing if @option{-t} +would not return @samp{file}. + +The @option{-P} option forces a path search for each @var{name}, even if +@option{-t} would not return @samp{file}. + +If a command is hashed, @option{-p} and @option{-P} print the hashed value, +which is not necessarily the file that appears first in @code{$PATH}. + +If the @option{-a} option is used, @code{type} returns all of the places +that contain an executable named @var{file}. +This includes aliases and functions, if and only if the @option{-p} option +is not also used. + +If the @option{-f} option is used, @code{type} does not attempt to find +shell functions, as with the @code{command} builtin. + +The return status is zero if all of the @var{names} are found, non-zero +if any are not found. + +@item typeset +@btindex typeset +@example +typeset [-afFgrxilnrtux] [-p] [@var{name}[=@var{value}] @dots{}] +@end example + +The @code{typeset} command is supplied for compatibility with the Korn +shell. +It is a synonym for the @code{declare} builtin command. + +@item ulimit +@btindex ulimit +@example +ulimit [-abcdefilmnpqrstuvxHST] [@var{limit}] +@end example + +@code{ulimit} provides control over the resources available to processes +started by the shell, on systems that allow such control. If an +option is given, it is interpreted as follows: + +@table @code +@item -S +Change and report the soft limit associated with a resource. + +@item -H +Change and report the hard limit associated with a resource. + +@item -a +All current limits are reported. + +@item -b +The maximum socket buffer size. + +@item -c +The maximum size of core files created. + +@item -d +The maximum size of a process's data segment. + +@item -e +The maximum scheduling priority ("nice"). + +@item -f +The maximum size of files written by the shell and its children. + +@item -i +The maximum number of pending signals. + +@item -l +The maximum size that may be locked into memory. + +@item -m +The maximum resident set size (many systems do not honor this limit). + +@item -n +The maximum number of open file descriptors (most systems do not +allow this value to be set). + +@item -p +The pipe buffer size. + +@item -q +The maximum number of bytes in POSIX message queues. + +@item -r +The maximum real-time scheduling priority. + +@item -s +The maximum stack size. + +@item -t +The maximum amount of cpu time in seconds. + +@item -u +The maximum number of processes available to a single user. + +@item -v +The maximum amount of virtual memory available to the shell, and, on +some systems, to its children. + +@item -x +The maximum number of file locks. + +@item -T +The maximum number of threads. +@end table + +If @var{limit} is given, and the @option{-a} option is not used, +@var{limit} is the new value of the specified resource. +The special @var{limit} values @code{hard}, @code{soft}, and +@code{unlimited} stand for the current hard limit, the current soft limit, +and no limit, respectively. +A hard limit cannot be increased by a non-root user once it is set; +a soft limit may be increased up to the value of the hard limit. +Otherwise, the current value of the soft limit for the specified resource +is printed, unless the @option{-H} option is supplied. +When setting new limits, if neither @option{-H} nor @option{-S} is supplied, +both the hard and soft limits are set. +If no option is given, then @option{-f} is assumed. Values are in 1024-byte +increments, except for @option{-t}, which is in seconds; @option{-p}, +which is in units of 512-byte blocks; and @option{-T}, @option{-b}, +@option{-n} and @option{-u}, which are unscaled values. + +The return status is zero unless an invalid option or argument is supplied, +or an error occurs while setting a new limit. + +@item unalias +@btindex unalias +@example +unalias [-a] [@var{name} @dots{} ] +@end example + +Remove each @var{name} from the list of aliases. If @option{-a} is +supplied, all aliases are removed. +Aliases are described in @ref{Aliases}. +@end table + +@node Modifying Shell Behavior +@section Modifying Shell Behavior + +@menu +* The Set Builtin:: Change the values of shell attributes and + positional parameters. +* The Shopt Builtin:: Modify shell optional behavior. +@end menu + +@node The Set Builtin +@subsection The Set Builtin + +This builtin is so complicated that it deserves its own section. @code{set} +allows you to change the values of shell options and set the positional +parameters, or to display the names and values of shell variables. + +@table @code +@item set +@btindex set +@example +set [--abefhkmnptuvxBCEHPT] [-o @var{option-name}] [@var{argument} @dots{}] +set [+abefhkmnptuvxBCEHPT] [+o @var{option-name}] [@var{argument} @dots{}] +@end example + +If no options or arguments are supplied, @code{set} displays the names +and values of all shell variables and functions, sorted according to the +current locale, in a format that may be reused as input +for setting or resetting the currently-set variables. +Read-only variables cannot be reset. +In @sc{posix} mode, only shell variables are listed. + +When options are supplied, they set or unset shell attributes. +Options, if specified, have the following meanings: + +@table @code +@item -a +Mark variables and function which are modified or created for export +to the environment of subsequent commands. + +@item -b +Cause the status of terminated background jobs to be reported +immediately, rather than before printing the next primary prompt. + +@item -e +Exit immediately if +a pipeline (@pxref{Pipelines}), which may consist of a single simple command +(@pxref{Simple Commands}), +a list (@pxref{Lists}), +or a compound command (@pxref{Compound Commands}) +returns a non-zero status. +The shell does not exit if the command that fails is part of the +command list immediately following a @code{while} or @code{until} keyword, +part of the test in an @code{if} statement, +part of any command executed in a @code{&&} or @code{||} list except +the command following the final @code{&&} or @code{||}, +any command in a pipeline but the last, +or if the command's return status is being inverted with @code{!}. +If a compound command other than a subshell +returns a non-zero status because a command failed +while @option{-e} was being ignored, the shell does not exit. +A trap on @code{ERR}, if set, is executed before the shell exits. + +This option applies to the shell environment and each subshell environment +separately (@pxref{Command Execution Environment}), and may cause +subshells to exit before executing all the commands in the subshell. + +If a shell function executes in a context where @option{-e} is being ignored, +even if @option{-e} is set, none of the commands executed within the function +body will be affected by the @option{-e} setting. +If a shell function sets @option{-e} while executing in a context where +@option{-e} is ignored, that setting will not have any effect until the +command containing the function call completes. + +@item -f +Disable filename expansion (globbing). + +@item -h +Locate and remember (hash) commands as they are looked up for execution. +This option is enabled by default. + +@item -k +All arguments in the form of assignment statements are placed +in the environment for a command, not just those that precede +the command name. + +@item -m +Job control is enabled (@pxref{Job Control}). +All processes run in a separate process group. +When a background job completes, the shell prints a line +containing its exit status. + +@item -n +Read commands but do not execute them; this may be used to check a +script for syntax errors. +This option is ignored by interactive shells. + +@item -o @var{option-name} + +Set the option corresponding to @var{option-name}: + +@table @code +@item allexport +Same as @code{-a}. + +@item braceexpand +Same as @code{-B}. + +@item emacs +Use an @code{emacs}-style line editing interface (@pxref{Command Line Editing}). +This also affects the editing interface used for @code{read -e}. + +@item errexit +Same as @code{-e}. + +@item errtrace +Same as @code{-E}. + +@item functrace +Same as @code{-T}. + +@item hashall +Same as @code{-h}. + +@item histexpand +Same as @code{-H}. + +@item history +Enable command history, as described in @ref{Bash History Facilities}. +This option is on by default in interactive shells. + +@item ignoreeof +An interactive shell will not exit upon reading EOF. + +@item keyword +Same as @code{-k}. + +@item monitor +Same as @code{-m}. + +@item noclobber +Same as @code{-C}. + +@item noexec +Same as @code{-n}. + +@item noglob +Same as @code{-f}. + +@item nolog +Currently ignored. + +@item notify +Same as @code{-b}. + +@item nounset +Same as @code{-u}. + +@item onecmd +Same as @code{-t}. + +@item physical +Same as @code{-P}. + +@item pipefail +If set, the return value of a pipeline is the value of the last +(rightmost) command to exit with a non-zero status, or zero if all +commands in the pipeline exit successfully. +This option is disabled by default. + +@item posix +Change the behavior of Bash where the default operation differs +from the @sc{posix} standard to match the standard +(@pxref{Bash POSIX Mode}). +This is intended to make Bash behave as a strict superset of that +standard. + +@item privileged +Same as @code{-p}. + +@item verbose +Same as @code{-v}. + +@item vi +Use a @code{vi}-style line editing interface. +This also affects the editing interface used for @code{read -e}. + +@item xtrace +Same as @code{-x}. +@end table + +@item -p +Turn on privileged mode. +In this mode, the @env{$BASH_ENV} and @env{$ENV} files are not +processed, shell functions are not inherited from the environment, +and the @env{SHELLOPTS}, @env{BASHOPTS}, @env{CDPATH} and @env{GLOBIGNORE} +variables, if they appear in the environment, are ignored. +If the shell is started with the effective user (group) id not equal to the +real user (group) id, and the @option{-p} option is not supplied, these actions +are taken and the effective user id is set to the real user id. +If the @option{-p} option is supplied at startup, the effective user id is +not reset. +Turning this option off causes the effective user +and group ids to be set to the real user and group ids. + +@item -t +Exit after reading and executing one command. + +@item -u +Treat unset variables and parameters other than the special parameters +@samp{@@} or @samp{*} as an error when performing parameter expansion. +An error message will be written to the standard error, and a non-interactive +shell will exit. + +@item -v +Print shell input lines as they are read. + +@item -x +Print a trace of simple commands, @code{for} commands, @code{case} +commands, @code{select} commands, and arithmetic @code{for} commands +and their arguments or associated word lists after they are +expanded and before they are executed. The value of the @env{PS4} +variable is expanded and the resultant value is printed before +the command and its expanded arguments. + +@item -B +The shell will perform brace expansion (@pxref{Brace Expansion}). +This option is on by default. + +@item -C +Prevent output redirection using @samp{>}, @samp{>&}, and @samp{<>} +from overwriting existing files. + +@item -E +If set, any trap on @code{ERR} is inherited by shell functions, command +substitutions, and commands executed in a subshell environment. +The @code{ERR} trap is normally not inherited in such cases. + +@item -H +Enable @samp{!} style history substitution (@pxref{History Interaction}). +This option is on by default for interactive shells. + +@item -P +If set, do not resolve symbolic links when performing commands such as +@code{cd} which change the current directory. The physical directory +is used instead. By default, Bash follows +the logical chain of directories when performing commands +which change the current directory. + +For example, if @file{/usr/sys} is a symbolic link to @file{/usr/local/sys} +then: +@example +$ cd /usr/sys; echo $PWD +/usr/sys +$ cd ..; pwd +/usr +@end example + +@noindent +If @code{set -P} is on, then: +@example +$ cd /usr/sys; echo $PWD +/usr/local/sys +$ cd ..; pwd +/usr/local +@end example + +@item -T +If set, any trap on @code{DEBUG} and @code{RETURN} are inherited by +shell functions, command substitutions, and commands executed +in a subshell environment. +The @code{DEBUG} and @code{RETURN} traps are normally not inherited +in such cases. + +@item -- +If no arguments follow this option, then the positional parameters are +unset. Otherwise, the positional parameters are set to the +@var{arguments}, even if some of them begin with a @samp{-}. + +@item - +Signal the end of options, cause all remaining @var{arguments} +to be assigned to the positional parameters. The @option{-x} +and @option{-v} options are turned off. +If there are no arguments, the positional parameters remain unchanged. +@end table + +Using @samp{+} rather than @samp{-} causes these options to be +turned off. The options can also be used upon invocation of the +shell. The current set of options may be found in @code{$-}. + +The remaining N @var{arguments} are positional parameters and are +assigned, in order, to @code{$1}, @code{$2}, @dots{} @code{$N}. +The special parameter @code{#} is set to N. + +The return status is always zero unless an invalid option is supplied. +@end table + +@node The Shopt Builtin +@subsection The Shopt Builtin + +This builtin allows you to change additional shell optional behavior. + +@table @code + +@item shopt +@btindex shopt +@example +shopt [-pqsu] [-o] [@var{optname} @dots{}] +@end example + +Toggle the values of variables controlling optional shell behavior. +With no options, or with the @option{-p} option, a list of all settable +options is displayed, with an indication of whether or not each is set. +The @option{-p} option causes output to be displayed in a form that +may be reused as input. +Other options have the following meanings: + +@table @code +@item -s +Enable (set) each @var{optname}. + +@item -u +Disable (unset) each @var{optname}. + +@item -q +Suppresses normal output; the return status +indicates whether the @var{optname} is set or unset. +If multiple @var{optname} arguments are given with @option{-q}, +the return status is zero if all @var{optnames} are enabled; +non-zero otherwise. + +@item -o +Restricts the values of +@var{optname} to be those defined for the @option{-o} option to the +@code{set} builtin (@pxref{The Set Builtin}). +@end table + +If either @option{-s} or @option{-u} +is used with no @var{optname} arguments, @code{shopt} shows only +those options which are set or unset, respectively. + +Unless otherwise noted, the @code{shopt} options are disabled (off) +by default. + +The return status when listing options is zero if all @var{optnames} +are enabled, non-zero otherwise. When setting or unsetting options, +the return status is zero unless an @var{optname} is not a valid shell +option. + +The list of @code{shopt} options is: +@table @code + +@item autocd +If set, a command name that is the name of a directory is executed as if +it were the argument to the @code{cd} command. +This option is only used by interactive shells. + +@item cdable_vars +If this is set, an argument to the @code{cd} builtin command that +is not a directory is assumed to be the name of a variable whose +value is the directory to change to. + +@item cdspell +If set, minor errors in the spelling of a directory component in a +@code{cd} command will be corrected. +The errors checked for are transposed characters, +a missing character, and a character too many. +If a correction is found, the corrected path is printed, +and the command proceeds. +This option is only used by interactive shells. + +@item checkhash +If this is set, Bash checks that a command found in the hash +table exists before trying to execute it. If a hashed command no +longer exists, a normal path search is performed. + +@item checkjobs +If set, Bash lists the status of any stopped and running jobs before +exiting an interactive shell. If any jobs are running, this causes +the exit to be deferred until a second exit is attempted without an +intervening command (@pxref{Job Control}). +The shell always postpones exiting if any jobs are stopped. + +@item checkwinsize +If set, Bash checks the window size after each command + and, if necessary, updates the values of +@env{LINES} and @env{COLUMNS}. + +@item cmdhist +If set, Bash +attempts to save all lines of a multiple-line +command in the same history entry. This allows +easy re-editing of multi-line commands. + +@item compat31 +If set, Bash +changes its behavior to that of version 3.1 with respect to quoted +arguments to the conditional command's @samp{=~} operator +and with respect to locale-specific +string comparison when using the @code{[[} +conditional command's @samp{<} and @samp{>} operators. +Bash versions prior to bash-4.1 use ASCII collation and strcmp(3); +bash-4.1 and later use the current locale's collation sequence and strcoll(3). + +@item compat32 +If set, Bash +changes its behavior to that of version 3.2 with respect to locale-specific +string comparison when using the @code{[[} +conditional command's @samp{<} and @samp{>} operators (see previous item). + +@item compat40 +If set, Bash +changes its behavior to that of version 4.0 with respect to locale-specific +string comparison when using the @code{[[} +conditional command's @samp{<} and @samp{>} operators (see description +of @code{compat31}) +and the effect of interrupting a command list. +Bash versions 4.0 and later interrupt the list as if the shell received the +interrupt; previous versions continue with the next command in the list. + +@item compat41 +If set, Bash, when in posix mode, treats a single quote in a double-quoted +parameter expansion as a special character. The single quotes must match +(an even number) and the characters between the single quotes are considered +quoted. This is the behavior of @sc{posix} mode through version 4.1. +The default Bash behavior remains as in previous versions. + +@item complete_fullquote +If set, Bash +quotes all shell metacharacters in filenames and directory names when +performing completion. +If not set, Bash +removes metacharacters such as the dollar sign from the set of +characters that will be quoted in completed filenames +when these metacharacters appear in shell variable references in words to be +completed. +This means that dollar signs in variable names that expand to directories +will not be quoted; +however, any dollar signs appearing in filenames will not be quoted, either. +This is active only when bash is using backslashes to quote completed +filenames. +This variable is set by default, which is the default Bash behavior in +versions through 4.2. + +@item direxpand +If set, Bash +replaces directory names with the results of word expansion when performing +filename completion. This changes the contents of the readline editing +buffer. +If not set, Bash attempts to preserve what the user typed. + +@item dirspell +If set, Bash +attempts spelling correction on directory names during word completion +if the directory name initially supplied does not exist. + +@item dotglob +If set, Bash includes filenames beginning with a `.' in +the results of filename expansion. + +@item execfail +If this is set, a non-interactive shell will not exit if +it cannot execute the file specified as an argument to the @code{exec} +builtin command. An interactive shell does not exit if @code{exec} +fails. + +@item expand_aliases +If set, aliases are expanded as described below under Aliases, +@ref{Aliases}. +This option is enabled by default for interactive shells. + +@item extdebug +If set, behavior intended for use by debuggers is enabled: + +@enumerate +@item +The @option{-F} option to the @code{declare} builtin (@pxref{Bash Builtins}) +displays the source file name and line number corresponding to each function +name supplied as an argument. + +@item +If the command run by the @code{DEBUG} trap returns a non-zero value, the +next command is skipped and not executed. + +@item +If the command run by the @code{DEBUG} trap returns a value of 2, and the +shell is executing in a subroutine (a shell function or a shell script +executed by the @code{.} or @code{source} builtins), a call to +@code{return} is simulated. + +@item +@code{BASH_ARGC} and @code{BASH_ARGV} are updated as described in their +descriptions (@pxref{Bash Variables}). + +@item +Function tracing is enabled: command substitution, shell functions, and +subshells invoked with @code{( @var{command} )} inherit the +@code{DEBUG} and @code{RETURN} traps. + +@item +Error tracing is enabled: command substitution, shell functions, and +subshells invoked with @code{( @var{command} )} inherit the +@code{ERR} trap. +@end enumerate + +@item extglob +If set, the extended pattern matching features described above +(@pxref{Pattern Matching}) are enabled. + +@item extquote +If set, @code{$'@var{string}'} and @code{$"@var{string}"} quoting is +performed within @code{$@{@var{parameter}@}} expansions +enclosed in double quotes. This option is enabled by default. + +@item failglob +If set, patterns which fail to match filenames during filename expansion +result in an expansion error. + +@item force_fignore +If set, the suffixes specified by the @env{FIGNORE} shell variable +cause words to be ignored when performing word completion even if +the ignored words are the only possible completions. +@xref{Bash Variables}, for a description of @env{FIGNORE}. +This option is enabled by default. + +@item globasciiranges +If set, range expressions used in pattern matching (@pxref{Pattern Matching}) +behave as if in the traditional C locale when performing +comparisons. That is, the current locale's collating sequence +is not taken into account, so +@samp{b} will not collate between @samp{A} and @samp{B}, +and upper-case and lower-case ASCII characters will collate together. + +@item globstar +If set, the pattern @samp{**} used in a filename expansion context will +match all files and zero or more directories and subdirectories. +If the pattern is followed by a @samp{/}, only directories and +subdirectories match. + +@item gnu_errfmt +If set, shell error messages are written in the standard @sc{gnu} error +message format. + +@item histappend +If set, the history list is appended to the file named by the value +of the @env{HISTFILE} +variable when the shell exits, rather than overwriting the file. + +@item histreedit +If set, and Readline +is being used, a user is given the opportunity to re-edit a +failed history substitution. + +@item histverify +If set, and Readline +is being used, the results of history substitution are not immediately +passed to the shell parser. Instead, the resulting line is loaded into +the Readline editing buffer, allowing further modification. + +@item hostcomplete +If set, and Readline is being used, Bash will attempt to perform +hostname completion when a word containing a @samp{@@} is being +completed (@pxref{Commands For Completion}). This option is enabled +by default. + +@item huponexit +If set, Bash will send @code{SIGHUP} to all jobs when an interactive +login shell exits (@pxref{Signals}). + +@item interactive_comments +Allow a word beginning with @samp{#} +to cause that word and all remaining characters on that +line to be ignored in an interactive shell. +This option is enabled by default. + +@item lastpipe +If set, and job control is not active, the shell runs the last command of +a pipeline not executed in the background in the current shell environment. + +@item lithist +If enabled, and the @code{cmdhist} +option is enabled, multi-line commands are saved to the history with +embedded newlines rather than using semicolon separators where possible. + +@item login_shell +The shell sets this option if it is started as a login shell +(@pxref{Invoking Bash}). +The value may not be changed. + +@item mailwarn +If set, and a file that Bash is checking for mail has been +accessed since the last time it was checked, the message +@code{"The mail in @var{mailfile} has been read"} is displayed. + +@item no_empty_cmd_completion +If set, and Readline is being used, Bash will not attempt to search +the @env{PATH} for possible completions when completion is attempted +on an empty line. + +@item nocaseglob +If set, Bash matches filenames in a case-insensitive fashion when +performing filename expansion. + +@item nocasematch +If set, Bash matches patterns in a case-insensitive fashion when +performing matching while executing @code{case} or @code{[[} +conditional commands. + +@item nullglob +If set, Bash allows filename patterns which match no +files to expand to a null string, rather than themselves. + +@item progcomp +If set, the programmable completion facilities +(@pxref{Programmable Completion}) are enabled. +This option is enabled by default. + +@item promptvars +If set, prompt strings undergo +parameter expansion, command substitution, arithmetic +expansion, and quote removal after being expanded +as described below (@pxref{Controlling the Prompt}). +This option is enabled by default. + +@item restricted_shell +The shell sets this option if it is started in restricted mode +(@pxref{The Restricted Shell}). +The value may not be changed. +This is not reset when the startup files are executed, allowing +the startup files to discover whether or not a shell is restricted. + +@item shift_verbose +If this is set, the @code{shift} +builtin prints an error message when the shift count exceeds the +number of positional parameters. + +@item sourcepath +If set, the @code{source} builtin uses the value of @env{PATH} +to find the directory containing the file supplied as an argument. +This option is enabled by default. + +@item xpg_echo +If set, the @code{echo} builtin expands backslash-escape sequences +by default. + +@end table + +@noindent +The return status when listing options is zero if all @var{optnames} +are enabled, non-zero otherwise. +When setting or unsetting options, the return status is zero unless an +@var{optname} is not a valid shell option. +@end table + +@node Special Builtins +@section Special Builtins +@cindex special builtin + +For historical reasons, the @sc{posix} standard has classified +several builtin commands as @emph{special}. +When Bash is executing in @sc{posix} mode, the special builtins +differ from other builtin commands in three respects: + +@enumerate +@item +Special builtins are found before shell functions during command lookup. + +@item +If a special builtin returns an error status, a non-interactive shell exits. + +@item +Assignment statements preceding the command stay in effect in the shell +environment after the command completes. +@end enumerate + +When Bash is not executing in @sc{posix} mode, these builtins behave no +differently than the rest of the Bash builtin commands. +The Bash @sc{posix} mode is described in @ref{Bash POSIX Mode}. + +These are the @sc{posix} special builtins: +@example +@w{break : . continue eval exec exit export readonly return set} +@w{shift trap unset} +@end example + +@node Shell Variables +@chapter Shell Variables + +@menu +* Bourne Shell Variables:: Variables which Bash uses in the same way + as the Bourne Shell. +* Bash Variables:: List of variables that exist in Bash. +@end menu + +This chapter describes the shell variables that Bash uses. +Bash automatically assigns default values to a number of variables. + +@node Bourne Shell Variables +@section Bourne Shell Variables + +Bash uses certain shell variables in the same way as the Bourne shell. +In some cases, Bash assigns a default value to the variable. + +@vtable @code + +@item CDPATH +A colon-separated list of directories used as a search path for +the @code{cd} builtin command. + +@item HOME +The current user's home directory; the default for the @code{cd} builtin +command. +The value of this variable is also used by tilde expansion +(@pxref{Tilde Expansion}). + +@item IFS +A list of characters that separate fields; used when the shell splits +words as part of expansion. + +@item MAIL +If this parameter is set to a filename or directory name +and the @env{MAILPATH} variable +is not set, Bash informs the user of the arrival of mail in +the specified file or Maildir-format directory. + +@item MAILPATH +A colon-separated list of filenames which the shell periodically checks +for new mail. +Each list entry can specify the message that is printed when new mail +arrives in the mail file by separating the filename from the message with +a @samp{?}. +When used in the text of the message, @code{$_} expands to the name of +the current mail file. + +@item OPTARG +The value of the last option argument processed by the @code{getopts} builtin. + +@item OPTIND +The index of the last option argument processed by the @code{getopts} builtin. + +@item PATH +A colon-separated list of directories in which the shell looks for +commands. +A zero-length (null) directory name in the value of @code{PATH} indicates the +current directory. +A null directory name may appear as two adjacent colons, or as an initial +or trailing colon. + + +@item PS1 +The primary prompt string. The default value is @samp{\s-\v\$ }. +@xref{Controlling the Prompt}, for the complete list of escape +sequences that are expanded before @env{PS1} is displayed. + +@item PS2 +The secondary prompt string. The default value is @samp{> }. + +@end vtable + +@node Bash Variables +@section Bash Variables + +These variables are set or used by Bash, but other shells +do not normally treat them specially. + +A few variables used by Bash are described in different chapters: +variables for controlling the job control facilities +(@pxref{Job Control Variables}). + +@vtable @code + +@item BASH +The full pathname used to execute the current instance of Bash. + +@item BASHOPTS +A colon-separated list of enabled shell options. Each word in +the list is a valid argument for the @option{-s} option to the +@code{shopt} builtin command (@pxref{The Shopt Builtin}). +The options appearing in @env{BASHOPTS} are those reported +as @samp{on} by @samp{shopt}. +If this variable is in the environment when Bash +starts up, each shell option in the list will be enabled before +reading any startup files. This variable is readonly. + +@item BASHPID +Expands to the process ID of the current Bash process. +This differs from @code{$$} under certain circumstances, such as subshells +that do not require Bash to be re-initialized. + +@item BASH_ALIASES +An associative array variable whose members correspond to the internal +list of aliases as maintained by the @code{alias} builtin. +(@pxref{Bourne Shell Builtins}). +Elements added to this array appear in the alias list; unsetting array +elements cause aliases to be removed from the alias list. + +@item BASH_ARGC +An array variable whose values are the number of parameters in each +frame of the current bash execution call stack. The number of +parameters to the current subroutine (shell function or script executed +with @code{.} or @code{source}) is at the top of the stack. When a +subroutine is executed, the number of parameters passed is pushed onto +@code{BASH_ARGC}. +The shell sets @code{BASH_ARGC} only when in extended debugging mode +(see @ref{The Shopt Builtin} +for a description of the @code{extdebug} option to the @code{shopt} +builtin). + +@item BASH_ARGV +An array variable containing all of the parameters in the current bash +execution call stack. The final parameter of the last subroutine call +is at the top of the stack; the first parameter of the initial call is +at the bottom. When a subroutine is executed, the parameters supplied +are pushed onto @code{BASH_ARGV}. +The shell sets @code{BASH_ARGV} only when in extended debugging mode +(see @ref{The Shopt Builtin} +for a description of the @code{extdebug} option to the @code{shopt} +builtin). + +@item BASH_CMDS +An associative array variable whose members correspond to the internal +hash table of commands as maintained by the @code{hash} builtin +(@pxref{Bourne Shell Builtins}). +Elements added to this array appear in the hash table; unsetting array +elements cause commands to be removed from the hash table. + +@item BASH_COMMAND +The command currently being executed or about to be executed, unless the +shell is executing a command as the result of a trap, +in which case it is the command executing at the time of the trap. + +@item BASH_ENV +If this variable is set when Bash is invoked to execute a shell +script, its value is expanded and used as the name of a startup file +to read before executing the script. @xref{Bash Startup Files}. + +@item BASH_EXECUTION_STRING +The command argument to the @option{-c} invocation option. + +@item BASH_LINENO +An array variable whose members are the line numbers in source files +where each corresponding member of @var{FUNCNAME} was invoked. +@code{$@{BASH_LINENO[$i]@}} is the line number in the source file +(@code{$@{BASH_SOURCE[$i+1]@}}) where +@code{$@{FUNCNAME[$i]@}} was called (or @code{$@{BASH_LINENO[$i-1]@}} if +referenced within another shell function). +Use @code{LINENO} to obtain the current line number. + +@item BASH_REMATCH +An array variable whose members are assigned by the @samp{=~} binary +operator to the @code{[[} conditional command +(@pxref{Conditional Constructs}). +The element with index 0 is the portion of the string +matching the entire regular expression. +The element with index @var{n} is the portion of the +string matching the @var{n}th parenthesized subexpression. +This variable is read-only. + +@item BASH_SOURCE +An array variable whose members are the source filenames where the +corresponding shell function names in the @code{FUNCNAME} array +variable are defined. +The shell function @code{$@{FUNCNAME[$i]@}} is defined in the file +@code{$@{BASH_SOURCE[$i]@}} and called from @code{$@{BASH_SOURCE[$i+1]@}} + +@item BASH_SUBSHELL +Incremented by one within each subshell or subshell environment when +the shell begins executing in that environment. +The initial value is 0. + +@item BASH_VERSINFO +A readonly array variable (@pxref{Arrays}) +whose members hold version information for this instance of Bash. +The values assigned to the array members are as follows: + +@table @code + +@item BASH_VERSINFO[0] +The major version number (the @var{release}). + +@item BASH_VERSINFO[1] +The minor version number (the @var{version}). + +@item BASH_VERSINFO[2] +The patch level. + +@item BASH_VERSINFO[3] +The build version. + +@item BASH_VERSINFO[4] +The release status (e.g., @var{beta1}). + +@item BASH_VERSINFO[5] +The value of @env{MACHTYPE}. +@end table + +@item BASH_VERSION +The version number of the current instance of Bash. + +@item BASH_XTRACEFD +If set to an integer corresponding to a valid file descriptor, Bash +will write the trace output generated when @samp{set -x} +is enabled to that file descriptor. +This allows tracing output to be separated from diagnostic and error +messages. +The file descriptor is closed when @code{BASH_XTRACEFD} is unset or assigned +a new value. +Unsetting @code{BASH_XTRACEFD} or assigning it the empty string causes the +trace output to be sent to the standard error. +Note that setting @code{BASH_XTRACEFD} to 2 (the standard error file +descriptor) and then unsetting it will result in the standard error +being closed. + +@item CHILD_MAX +Set the number of exited child status values for the shell to remember. +Bash will not allow this value to be decreased below a @sc{posix}-mandated +minimum, and there is a maximum value (currently 8192) that this may +not exceed. +The minimum value is system-dependent. + +@item COLUMNS +Used by the @code{select} command to determine the terminal width +when printing selection lists. Automatically set by an interactive shell +upon receipt of a +@code{SIGWINCH}. + +@item COMP_CWORD +An index into @env{$@{COMP_WORDS@}} of the word containing the current +cursor position. +This variable is available only in shell functions invoked by the +programmable completion facilities (@pxref{Programmable Completion}). + +@item COMP_LINE +The current command line. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (@pxref{Programmable Completion}). + +@item COMP_POINT +The index of the current cursor position relative to the beginning of +the current command. +If the current cursor position is at the end of the current command, +the value of this variable is equal to @code{$@{#COMP_LINE@}}. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (@pxref{Programmable Completion}). + +@item COMP_TYPE +Set to an integer value corresponding to the type of completion attempted +that caused a completion function to be called: +@var{TAB}, for normal completion, +@samp{?}, for listing completions after successive tabs, +@samp{!}, for listing alternatives on partial word completion, +@samp{@@}, to list completions if the word is not unmodified, +or +@samp{%}, for menu completion. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (@pxref{Programmable Completion}). + +@item COMP_KEY +The key (or final key of a key sequence) used to invoke the current +completion function. + +@item COMP_WORDBREAKS +The set of characters that the Readline library treats as word +separators when performing word completion. +If @code{COMP_WORDBREAKS} is unset, it loses its special properties, +even if it is subsequently reset. + +@item COMP_WORDS +An array variable consisting of the individual +words in the current command line. +The line is split into words as Readline would split it, using +@code{COMP_WORDBREAKS} as described above. +This variable is available only in shell functions invoked by the +programmable completion facilities (@pxref{Programmable Completion}). + +@item COMPREPLY +An array variable from which Bash reads the possible completions +generated by a shell function invoked by the programmable completion +facility (@pxref{Programmable Completion}). +Each array element contains one possible completion. + +@item COPROC +An array variable created to hold the file descriptors +for output from and input to an unnamed coprocess (@pxref{Coprocesses}). + +@item DIRSTACK +An array variable containing the current contents of the directory stack. +Directories appear in the stack in the order they are displayed by the +@code{dirs} builtin. +Assigning to members of this array variable may be used to modify +directories already in the stack, but the @code{pushd} and @code{popd} +builtins must be used to add and remove directories. +Assignment to this variable will not change the current directory. +If @env{DIRSTACK} is unset, it loses its special properties, even if +it is subsequently reset. + +@item EMACS +If Bash finds this variable in the environment when the shell +starts with value @samp{t}, it assumes that the shell is running in an +Emacs shell buffer and disables line editing. + +@item ENV +Similar to @code{BASH_ENV}; used when the shell is invoked in +@sc{posix} Mode (@pxref{Bash POSIX Mode}). + +@item EUID +The numeric effective user id of the current user. This variable +is readonly. + +@item FCEDIT +The editor used as a default by the @option{-e} option to the @code{fc} +builtin command. + +@item FIGNORE +A colon-separated list of suffixes to ignore when performing +filename completion. +A filename whose suffix matches one of the entries in +@env{FIGNORE} +is excluded from the list of matched filenames. A sample +value is @samp{.o:~} + +@item FUNCNAME +An array variable containing the names of all shell functions +currently in the execution call stack. +The element with index 0 is the name of any currently-executing +shell function. +The bottom-most element (the one with the highest index) +is @code{"main"}. +This variable exists only when a shell function is executing. +Assignments to @env{FUNCNAME} have no effect and return an error status. +If @env{FUNCNAME} is unset, it loses its special properties, even if +it is subsequently reset. + +This variable can be used with @code{BASH_LINENO} and @code{BASH_SOURCE}. +Each element of @code{FUNCNAME} has corresponding elements in +@code{BASH_LINENO} and @code{BASH_SOURCE} to describe the call stack. +For instance, @code{$@{FUNCNAME[$i]@}} was called from the file +@code{$@{BASH_SOURCE[$i+1]@}} at line number @code{$@{BASH_LINENO[$i]@}}. +The @code{caller} builtin displays the current call stack using this +information. + +@item FUNCNEST +If set to a numeric value greater than 0, defines a maximum function +nesting level. Function invocations that exceed this nesting level +will cause the current command to abort. + +@item GLOBIGNORE +A colon-separated list of patterns defining the set of filenames to +be ignored by filename expansion. +If a filename matched by a filename expansion pattern also matches one +of the patterns in @env{GLOBIGNORE}, it is removed from the list +of matches. + +@item GROUPS +An array variable containing the list of groups of which the current +user is a member. +Assignments to @env{GROUPS} have no effect and return an error status. +If @env{GROUPS} is unset, it loses its special properties, even if it is +subsequently reset. + +@item histchars +Up to three characters which control history expansion, quick +substitution, and tokenization (@pxref{History Interaction}). +The first character is the +@var{history expansion} character, that is, the character which signifies the +start of a history expansion, normally @samp{!}. The second character is the +character which signifies `quick substitution' when seen as the first +character on a line, normally @samp{^}. The optional third character is the +character which indicates that the remainder of the line is a comment when +found as the first character of a word, usually @samp{#}. The history +comment character causes history substitution to be skipped for the +remaining words on the line. It does not necessarily cause the shell +parser to treat the rest of the line as a comment. + +@item HISTCMD +The history number, or index in the history list, of the current +command. If @env{HISTCMD} is unset, it loses its special properties, +even if it is subsequently reset. + +@item HISTCONTROL +A colon-separated list of values controlling how commands are saved on +the history list. +If the list of values includes @samp{ignorespace}, lines which begin +with a space character are not saved in the history list. +A value of @samp{ignoredups} causes lines which match the previous +history entry to not be saved. +A value of @samp{ignoreboth} is shorthand for +@samp{ignorespace} and @samp{ignoredups}. +A value of @samp{erasedups} causes all previous lines matching the +current line to be removed from the history list before that line +is saved. +Any value not in the above list is ignored. +If @env{HISTCONTROL} is unset, or does not include a valid value, +all lines read by the shell parser are saved on the history list, +subject to the value of @env{HISTIGNORE}. +The second and subsequent lines of a multi-line compound command are +not tested, and are added to the history regardless of the value of +@env{HISTCONTROL}. + +@item HISTFILE +The name of the file to which the command history is saved. The +default value is @file{~/.bash_history}. + +@item HISTFILESIZE +The maximum number of lines contained in the history file. +When this variable is assigned a value, the history file is truncated, +if necessary, to contain no more than that number of lines +by removing the oldest entries. +The history file is also truncated to this size after +writing it when a shell exits. +If the value is 0, the history file is truncated to zero size. +Non-numeric values and numeric values less than zero inhibit truncation. +The shell sets the default value to the value of @env{HISTSIZE} +after reading any startup files. + +@item HISTIGNORE +A colon-separated list of patterns used to decide which command +lines should be saved on the history list. Each pattern is +anchored at the beginning of the line and must match the complete +line (no implicit @samp{*} is appended). Each pattern is tested +against the line after the checks specified by @env{HISTCONTROL} +are applied. In addition to the normal shell pattern matching +characters, @samp{&} matches the previous history line. @samp{&} +may be escaped using a backslash; the backslash is removed +before attempting a match. +The second and subsequent lines of a multi-line compound command are +not tested, and are added to the history regardless of the value of +@env{HISTIGNORE}. + +@env{HISTIGNORE} subsumes the function of @env{HISTCONTROL}. A +pattern of @samp{&} is identical to @code{ignoredups}, and a +pattern of @samp{[ ]*} is identical to @code{ignorespace}. +Combining these two patterns, separating them with a colon, +provides the functionality of @code{ignoreboth}. + +@item HISTSIZE +The maximum number of commands to remember on the history list. +If the value is 0, commands are not saved in the history list. +Numeric values less than zero result in every command being saved +on the history list (there is no limit). +The shell sets the default value to 500 after reading any startup files. + +@item HISTTIMEFORMAT +If this variable is set and not null, its value is used as a format string +for @var{strftime} to print the time stamp associated with each history +entry displayed by the @code{history} builtin. +If this variable is set, time stamps are written to the history file so +they may be preserved across shell sessions. +This uses the history comment character to distinguish timestamps from +other history lines. + +@item HOSTFILE +Contains the name of a file in the same format as @file{/etc/hosts} that +should be read when the shell needs to complete a hostname. +The list of possible hostname completions may be changed while the shell +is running; +the next time hostname completion is attempted after the +value is changed, Bash adds the contents of the new file to the +existing list. +If @env{HOSTFILE} is set, but has no value, or does not name a readable file, +Bash attempts to read +@file{/etc/hosts} to obtain the list of possible hostname completions. +When @env{HOSTFILE} is unset, the hostname list is cleared. + +@item HOSTNAME +The name of the current host. + +@item HOSTTYPE +A string describing the machine Bash is running on. + +@item IGNOREEOF +Controls the action of the shell on receipt of an @code{EOF} character +as the sole input. If set, the value denotes the number +of consecutive @code{EOF} characters that can be read as the +first character on an input line +before the shell will exit. If the variable exists but does not +have a numeric value (or has no value) then the default is 10. +If the variable does not exist, then @code{EOF} signifies the end of +input to the shell. This is only in effect for interactive shells. + +@item INPUTRC +The name of the Readline initialization file, overriding the default +of @file{~/.inputrc}. + +@item LANG +Used to determine the locale category for any category not specifically +selected with a variable starting with @code{LC_}. + +@item LC_ALL +This variable overrides the value of @env{LANG} and any other +@code{LC_} variable specifying a locale category. + +@item LC_COLLATE +This variable determines the collation order used when sorting the +results of filename expansion, and +determines the behavior of range expressions, equivalence classes, +and collating sequences within filename expansion and pattern matching +(@pxref{Filename Expansion}). + +@item LC_CTYPE +This variable determines the interpretation of characters and the +behavior of character classes within filename expansion and pattern +matching (@pxref{Filename Expansion}). + +@item LC_MESSAGES +This variable determines the locale used to translate double-quoted +strings preceded by a @samp{$} (@pxref{Locale Translation}). + +@item LC_NUMERIC +This variable determines the locale category used for number formatting. + +@item LINENO +The line number in the script or shell function currently executing. + +@item LINES +Used by the @code{select} command to determine the column length +for printing selection lists. Automatically set by an interactive shell +upon receipt of a +@code{SIGWINCH}. + +@item MACHTYPE +A string that fully describes the system type on which Bash +is executing, in the standard @sc{gnu} @var{cpu-company-system} format. + +@item MAILCHECK +How often (in seconds) that the shell should check for mail in the +files specified in the @env{MAILPATH} or @env{MAIL} variables. +The default is 60 seconds. When it is time to check +for mail, the shell does so before displaying the primary prompt. +If this variable is unset, or set to a value that is not a number +greater than or equal to zero, the shell disables mail checking. + +@item MAPFILE +An array variable created to hold the text read by the +@code{mapfile} builtin when no variable name is supplied. + +@item OLDPWD +The previous working directory as set by the @code{cd} builtin. + +@item OPTERR +If set to the value 1, Bash displays error messages +generated by the @code{getopts} builtin command. + +@item OSTYPE +A string describing the operating system Bash is running on. + +@item PIPESTATUS +An array variable (@pxref{Arrays}) +containing a list of exit status values from the processes +in the most-recently-executed foreground pipeline (which may +contain only a single command). + +@item POSIXLY_CORRECT +If this variable is in the environment when Bash starts, the shell +enters @sc{posix} mode (@pxref{Bash POSIX Mode}) before reading the +startup files, as if the @option{--posix} invocation option had been supplied. +If it is set while the shell is running, Bash enables @sc{posix} mode, +as if the command +@example +@code{set -o posix} +@end example +@noindent +had been executed. + +@item PPID +The process @sc{id} of the shell's parent process. This variable +is readonly. + +@item PROMPT_COMMAND +If set, the value is interpreted as a command to execute +before the printing of each primary prompt (@env{$PS1}). + +@item PROMPT_DIRTRIM +If set to a number greater than zero, the value is used as the number of +trailing directory components to retain when expanding the @code{\w} and +@code{\W} prompt string escapes (@pxref{Controlling the Prompt}). +Characters removed are replaced with an ellipsis. + +@item PS3 +The value of this variable is used as the prompt for the +@code{select} command. If this variable is not set, the +@code{select} command prompts with @samp{#? } + +@item PS4 +The value is the prompt printed before the command line is echoed +when the @option{-x} option is set (@pxref{The Set Builtin}). +The first character of @env{PS4} is replicated multiple times, as +necessary, to indicate multiple levels of indirection. +The default is @samp{+ }. + +@item PWD +The current working directory as set by the @code{cd} builtin. + +@item RANDOM +Each time this parameter is referenced, a random integer +between 0 and 32767 is generated. Assigning a value to this +variable seeds the random number generator. + +@item READLINE_LINE +The contents of the Readline line buffer, for use +with @samp{bind -x} (@pxref{Bash Builtins}). + +@item READLINE_POINT +The position of the insertion point in the Readline line buffer, for use +with @samp{bind -x} (@pxref{Bash Builtins}). + +@item REPLY +The default variable for the @code{read} builtin. + +@item SECONDS +This variable expands to the number of seconds since the +shell was started. Assignment to this variable resets +the count to the value assigned, and the expanded value +becomes the value assigned plus the number of seconds +since the assignment. + +@item SHELL +The full pathname to the shell is kept in this environment variable. +If it is not set when the shell starts, +Bash assigns to it the full pathname of the current user's login shell. + +@item SHELLOPTS +A colon-separated list of enabled shell options. Each word in +the list is a valid argument for the @option{-o} option to the +@code{set} builtin command (@pxref{The Set Builtin}). +The options appearing in @env{SHELLOPTS} are those reported +as @samp{on} by @samp{set -o}. +If this variable is in the environment when Bash +starts up, each shell option in the list will be enabled before +reading any startup files. This variable is readonly. + +@item SHLVL +Incremented by one each time a new instance of Bash is started. This is +intended to be a count of how deeply your Bash shells are nested. + +@item TIMEFORMAT +The value of this parameter is used as a format string specifying +how the timing information for pipelines prefixed with the @code{time} +reserved word should be displayed. +The @samp{%} character introduces an +escape sequence that is expanded to a time value or other +information. +The escape sequences and their meanings are as +follows; the braces denote optional portions. + +@table @code + +@item %% +A literal @samp{%}. + +@item %[@var{p}][l]R +The elapsed time in seconds. + +@item %[@var{p}][l]U +The number of CPU seconds spent in user mode. + +@item %[@var{p}][l]S +The number of CPU seconds spent in system mode. + +@item %P +The CPU percentage, computed as (%U + %S) / %R. +@end table + +The optional @var{p} is a digit specifying the precision, the number of +fractional digits after a decimal point. +A value of 0 causes no decimal point or fraction to be output. +At most three places after the decimal point may be specified; values +of @var{p} greater than 3 are changed to 3. +If @var{p} is not specified, the value 3 is used. + +The optional @code{l} specifies a longer format, including minutes, of +the form @var{MM}m@var{SS}.@var{FF}s. +The value of @var{p} determines whether or not the fraction is included. + +If this variable is not set, Bash acts as if it had the value +@example +@code{$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'} +@end example +If the value is null, no timing information is displayed. +A trailing newline is added when the format string is displayed. + +@item TMOUT +If set to a value greater than zero, @code{TMOUT} is treated as the +default timeout for the @code{read} builtin (@pxref{Bash Builtins}). +The @code{select} command (@pxref{Conditional Constructs}) terminates +if input does not arrive after @code{TMOUT} seconds when input is coming +from a terminal. + +In an interactive shell, the value is interpreted as +the number of seconds to wait for a line of input after issuing +the primary prompt. +Bash +terminates after waiting for that number of seconds if a complete +line of input does not arrive. + +@item TMPDIR +If set, Bash uses its value as the name of a directory in which +Bash creates temporary files for the shell's use. + +@item UID +The numeric real user id of the current user. This variable is readonly. + +@end vtable + +@node Bash Features +@chapter Bash Features + +This chapter describes features unique to Bash. + +@menu +* Invoking Bash:: Command line options that you can give + to Bash. +* Bash Startup Files:: When and how Bash executes scripts. +* Interactive Shells:: What an interactive shell is. +* Bash Conditional Expressions:: Primitives used in composing expressions for + the @code{test} builtin. +* Shell Arithmetic:: Arithmetic on shell variables. +* Aliases:: Substituting one command for another. +* Arrays:: Array Variables. +* The Directory Stack:: History of visited directories. +* Controlling the Prompt:: Customizing the various prompt strings. +* The Restricted Shell:: A more controlled mode of shell execution. +* Bash POSIX Mode:: Making Bash behave more closely to what + the POSIX standard specifies. +@end menu + +@node Invoking Bash +@section Invoking Bash + +@example +bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o @var{option}] [-O @var{shopt_option}] [@var{argument} @dots{}] +bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o @var{option}] [-O @var{shopt_option}] -c @var{string} [@var{argument} @dots{}] +bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @var{option}] [-O @var{shopt_option}] [@var{argument} @dots{}] +@end example + +All of the single-character options used with the @code{set} builtin +(@pxref{The Set Builtin}) can be used as options when the shell is invoked. +In addition, there are several multi-character +options that you can use. These options must appear on the command +line before the single-character options to be recognized. + +@table @code +@item --debugger +Arrange for the debugger profile to be executed before the shell +starts. Turns on extended debugging mode (see @ref{The Shopt Builtin} +for a description of the @code{extdebug} option to the @code{shopt} +builtin). + +@item --dump-po-strings +A list of all double-quoted strings preceded by @samp{$} +is printed on the standard output +in the @sc{gnu} @code{gettext} PO (portable object) file format. +Equivalent to @option{-D} except for the output format. + +@item --dump-strings +Equivalent to @option{-D}. + +@item --help +Display a usage message on standard output and exit successfully. + +@item --init-file @var{filename} +@itemx --rcfile @var{filename} +Execute commands from @var{filename} (instead of @file{~/.bashrc}) +in an interactive shell. + +@item --login +Equivalent to @option{-l}. + +@item --noediting +Do not use the @sc{gnu} Readline library (@pxref{Command Line Editing}) +to read command lines when the shell is interactive. + +@item --noprofile +Don't load the system-wide startup file @file{/etc/profile} +or any of the personal initialization files +@file{~/.bash_profile}, @file{~/.bash_login}, or @file{~/.profile} +when Bash is invoked as a login shell. + +@item --norc +Don't read the @file{~/.bashrc} initialization file in an +interactive shell. This is on by default if the shell is +invoked as @code{sh}. + +@item --posix +Change the behavior of Bash where the default operation differs +from the @sc{posix} standard to match the standard. This +is intended to make Bash behave as a strict superset of that +standard. @xref{Bash POSIX Mode}, for a description of the Bash +@sc{posix} mode. + +@item --restricted +Make the shell a restricted shell (@pxref{The Restricted Shell}). + +@item --verbose +Equivalent to @option{-v}. Print shell input lines as they're read. + +@item --version +Show version information for this instance of +Bash on the standard output and exit successfully. +@end table + +There are several single-character options that may be supplied at +invocation which are not available with the @code{set} builtin. + +@table @code +@item -c +Read and execute commands from the first non-option @var{argument} +after processing the options, then exit. +Any remaining arguments are assigned to the +positional parameters, starting with @code{$0}. + +@item -i +Force the shell to run interactively. Interactive shells are +described in @ref{Interactive Shells}. + +@item -l +Make this shell act as if it had been directly invoked by login. +When the shell is interactive, this is equivalent to starting a +login shell with @samp{exec -l bash}. +When the shell is not interactive, the login shell startup files will +be executed. +@samp{exec bash -l} or @samp{exec bash --login} +will replace the current shell with a Bash login shell. +@xref{Bash Startup Files}, for a description of the special behavior +of a login shell. + +@item -r +Make the shell a restricted shell (@pxref{The Restricted Shell}). + +@item -s +If this option is present, or if no arguments remain after option +processing, then commands are read from the standard input. +This option allows the positional parameters to be set +when invoking an interactive shell. + +@item -D +A list of all double-quoted strings preceded by @samp{$} +is printed on the standard output. +These are the strings that +are subject to language translation when the current locale +is not @code{C} or @code{POSIX} (@pxref{Locale Translation}). +This implies the @option{-n} option; no commands will be executed. + +@item [-+]O [@var{shopt_option}] +@var{shopt_option} is one of the shell options accepted by the +@code{shopt} builtin (@pxref{The Shopt Builtin}). +If @var{shopt_option} is present, @option{-O} sets the value of that option; +@option{+O} unsets it. +If @var{shopt_option} is not supplied, the names and values of the shell +options accepted by @code{shopt} are printed on the standard output. +If the invocation option is @option{+O}, the output is displayed in a format +that may be reused as input. + +@item -- +A @code{--} signals the end of options and disables further option +processing. +Any arguments after the @code{--} are treated as filenames and arguments. +@end table + +@cindex login shell +A @emph{login} shell is one whose first character of argument zero is +@samp{-}, or one invoked with the @option{--login} option. + +@cindex interactive shell +An @emph{interactive} shell is one started without non-option arguments, +unless @option{-s} is specified, +without specifying the @option{-c} option, and whose input and output are both +connected to terminals (as determined by @code{isatty(3)}), or one +started with the @option{-i} option. @xref{Interactive Shells}, for more +information. + +If arguments remain after option processing, and neither the +@option{-c} nor the @option{-s} +option has been supplied, the first argument is assumed to +be the name of a file containing shell commands (@pxref{Shell Scripts}). +When Bash is invoked in this fashion, @code{$0} +is set to the name of the file, and the positional parameters +are set to the remaining arguments. +Bash reads and executes commands from this file, then exits. +Bash's exit status is the exit status of the last command executed +in the script. If no commands are executed, the exit status is 0. + +@node Bash Startup Files +@section Bash Startup Files +@cindex startup files + +This section describes how Bash executes its startup files. +If any of the files exist but cannot be read, Bash reports an error. +Tildes are expanded in filenames as described above under +Tilde Expansion (@pxref{Tilde Expansion}). + +Interactive shells are described in @ref{Interactive Shells}. + +@subsubheading Invoked as an interactive login shell, or with @option{--login} + +When Bash is invoked as an interactive login shell, or as a +non-interactive shell with the @option{--login} option, it first reads and +executes commands from the file @file{/etc/profile}, if that file exists. +After reading that file, it looks for @file{~/.bash_profile}, +@file{~/.bash_login}, and @file{~/.profile}, in that order, and reads +and executes commands from the first one that exists and is readable. +The @option{--noprofile} option may be used when the shell is started to +inhibit this behavior. + +When a login shell exits, Bash reads and executes commands from +the file @file{~/.bash_logout}, if it exists. + +@subsubheading Invoked as an interactive non-login shell + +When an interactive shell that is not a login shell is started, Bash +reads and executes commands from @file{~/.bashrc}, if that file exists. +This may be inhibited by using the @option{--norc} option. +The @option{--rcfile @var{file}} option will force Bash to read and +execute commands from @var{file} instead of @file{~/.bashrc}. + +So, typically, your @file{~/.bash_profile} contains the line +@example +@code{if [ -f ~/.bashrc ]; then . ~/.bashrc; fi} +@end example +@noindent +after (or before) any login-specific initializations. + +@subsubheading Invoked non-interactively + +When Bash is started non-interactively, to run a shell script, +for example, it looks for the variable @env{BASH_ENV} in the environment, +expands its value if it appears there, and uses the expanded value as +the name of a file to read and execute. Bash behaves as if the +following command were executed: +@example +@code{if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi} +@end example +@noindent +but the value of the @env{PATH} variable is not used to search for the +filename. + +As noted above, if a non-interactive shell is invoked with the +@option{--login} option, Bash attempts to read and execute commands from the +login shell startup files. + +@subsubheading Invoked with name @code{sh} + +If Bash is invoked with the name @code{sh}, it tries to mimic the +startup behavior of historical versions of @code{sh} as closely as +possible, while conforming to the @sc{posix} standard as well. + +When invoked as an interactive login shell, or as a non-interactive +shell with the @option{--login} option, it first attempts to read +and execute commands from @file{/etc/profile} and @file{~/.profile}, in +that order. +The @option{--noprofile} option may be used to inhibit this behavior. +When invoked as an interactive shell with the name @code{sh}, Bash +looks for the variable @env{ENV}, expands its value if it is defined, +and uses the expanded value as the name of a file to read and execute. +Since a shell invoked as @code{sh} does not attempt to read and execute +commands from any other startup files, the @option{--rcfile} option has +no effect. +A non-interactive shell invoked with the name @code{sh} does not attempt +to read any other startup files. + +When invoked as @code{sh}, Bash enters @sc{posix} mode after +the startup files are read. + +@subsubheading Invoked in @sc{posix} mode + +When Bash is started in @sc{posix} mode, as with the +@option{--posix} command line option, it follows the @sc{posix} standard +for startup files. +In this mode, interactive shells expand the @env{ENV} variable +and commands are read and executed from the file whose name is the +expanded value. +No other startup files are read. + +@subsubheading Invoked by remote shell daemon + +Bash attempts to determine when it is being run with its standard input +connected to a network connection, as when executed by the remote shell +daemon, usually @code{rshd}, or the secure shell daemon @code{sshd}. +If Bash determines it is being run in +this fashion, it reads and executes commands from @file{~/.bashrc}, if that +file exists and is readable. +It will not do this if invoked as @code{sh}. +The @option{--norc} option may be used to inhibit this behavior, and the +@option{--rcfile} option may be used to force another file to be read, but +@code{rshd} does not generally invoke the shell with those options or +allow them to be specified. + +@subsubheading Invoked with unequal effective and real @sc{uid/gid}s + +If Bash is started with the effective user (group) id not equal to the +real user (group) id, and the @option{-p} option is not supplied, no startup +files are read, shell functions are not inherited from the environment, +the @env{SHELLOPTS}, @env{BASHOPTS}, @env{CDPATH}, and @env{GLOBIGNORE} +variables, if they appear in the environment, are ignored, and the effective +user id is set to the real user id. +If the @option{-p} option is supplied at invocation, the startup behavior is +the same, but the effective user id is not reset. + +@node Interactive Shells +@section Interactive Shells +@cindex interactive shell +@cindex shell, interactive + +@menu +* What is an Interactive Shell?:: What determines whether a shell is Interactive. +* Is this Shell Interactive?:: How to tell if a shell is interactive. +* Interactive Shell Behavior:: What changes in a interactive shell? +@end menu + +@node What is an Interactive Shell? +@subsection What is an Interactive Shell? + +An interactive shell +is one started without non-option arguments, unless @option{-s} is +specified, without specifying the @option{-c} option, and +whose input and error output are both +connected to terminals (as determined by @code{isatty(3)}), +or one started with the @option{-i} option. + +An interactive shell generally reads from and writes to a user's +terminal. + +The @option{-s} invocation option may be used to set the positional parameters +when an interactive shell is started. + +@node Is this Shell Interactive? +@subsection Is this Shell Interactive? + +To determine within a startup script whether or not Bash is +running interactively, +test the value of the @samp{-} special parameter. +It contains @code{i} when the shell is interactive. For example: + +@example +case "$-" in +*i*) echo This shell is interactive ;; +*) echo This shell is not interactive ;; +esac +@end example + +Alternatively, startup scripts may examine the variable +@env{PS1}; it is unset in non-interactive shells, and set in +interactive shells. Thus: + +@example +if [ -z "$PS1" ]; then + echo This shell is not interactive +else + echo This shell is interactive +fi +@end example + +@node Interactive Shell Behavior +@subsection Interactive Shell Behavior + +When the shell is running interactively, it changes its behavior in +several ways. + +@enumerate +@item +Startup files are read and executed as described in @ref{Bash Startup Files}. + +@item +Job Control (@pxref{Job Control}) is enabled by default. When job +control is in effect, Bash ignores the keyboard-generated job control +signals @code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}. + +@item +Bash expands and displays @env{PS1} before reading the first line +of a command, and expands and displays @env{PS2} before reading the +second and subsequent lines of a multi-line command. + +@item +Bash executes the value of the @env{PROMPT_COMMAND} variable as a command +before printing the primary prompt, @env{$PS1} +(@pxref{Bash Variables}). + +@item +Readline (@pxref{Command Line Editing}) is used to read commands from +the user's terminal. + +@item +Bash inspects the value of the @code{ignoreeof} option to @code{set -o} +instead of exiting immediately when it receives an @code{EOF} on its +standard input when reading a command (@pxref{The Set Builtin}). + +@item +Command history (@pxref{Bash History Facilities}) +and history expansion (@pxref{History Interaction}) +are enabled by default. +Bash will save the command history to the file named by @env{$HISTFILE} +when a shell with history enabled exits. + +@item +Alias expansion (@pxref{Aliases}) is performed by default. + +@item +In the absence of any traps, Bash ignores @code{SIGTERM} +(@pxref{Signals}). + +@item +In the absence of any traps, @code{SIGINT} is caught and handled +((@pxref{Signals}). +@code{SIGINT} will interrupt some shell builtins. + +@item +An interactive login shell sends a @code{SIGHUP} to all jobs on exit +if the @code{huponexit} shell option has been enabled (@pxref{Signals}). + +@item +The @option{-n} invocation option is ignored, and @samp{set -n} has +no effect (@pxref{The Set Builtin}). + +@item +Bash will check for mail periodically, depending on the values of the +@env{MAIL}, @env{MAILPATH}, and @env{MAILCHECK} shell variables +(@pxref{Bash Variables}). + +@item +Expansion errors due to references to unbound shell variables after +@samp{set -u} has been enabled will not cause the shell to exit +(@pxref{The Set Builtin}). + +@item +The shell will not exit on expansion errors caused by @var{var} being unset +or null in @code{$@{@var{var}:?@var{word}@}} expansions +(@pxref{Shell Parameter Expansion}). + +@item +Redirection errors encountered by shell builtins will not cause the +shell to exit. + +@item +When running in @sc{posix} mode, a special builtin returning an error +status will not cause the shell to exit (@pxref{Bash POSIX Mode}). + +@item +A failed @code{exec} will not cause the shell to exit +(@pxref{Bourne Shell Builtins}). + +@item +Parser syntax errors will not cause the shell to exit. + +@item +Simple spelling correction for directory arguments to the @code{cd} +builtin is enabled by default (see the description of the @code{cdspell} +option to the @code{shopt} builtin in @ref{The Shopt Builtin}). + +@item +The shell will check the value of the @env{TMOUT} variable and exit +if a command is not read within the specified number of seconds after +printing @env{$PS1} (@pxref{Bash Variables}). + +@end enumerate + +@node Bash Conditional Expressions +@section Bash Conditional Expressions +@cindex expressions, conditional + +Conditional expressions are used by the @code{[[} compound command +and the @code{test} and @code{[} builtin commands. + +Expressions may be unary or binary. +Unary expressions are often used to examine the status of a file. +There are string operators and numeric comparison operators as well. +If the @var{file} argument to one of the primaries is of the form +@file{/dev/fd/@var{N}}, then file descriptor @var{N} is checked. +If the @var{file} argument to one of the primaries is one of +@file{/dev/stdin}, @file{/dev/stdout}, or @file{/dev/stderr}, file +descriptor 0, 1, or 2, respectively, is checked. + +When used with @code{[[}, the @samp{<} and @samp{>} operators sort +lexicographically using the current locale. +The @code{test} command uses ASCII ordering. + +Unless otherwise specified, primaries that operate on files follow symbolic +links and operate on the target of the link, rather than the link itself. + +@table @code +@item -a @var{file} +True if @var{file} exists. + +@item -b @var{file} +True if @var{file} exists and is a block special file. + +@item -c @var{file} +True if @var{file} exists and is a character special file. + +@item -d @var{file} +True if @var{file} exists and is a directory. + +@item -e @var{file} +True if @var{file} exists. + +@item -f @var{file} +True if @var{file} exists and is a regular file. + +@item -g @var{file} +True if @var{file} exists and its set-group-id bit is set. + +@item -h @var{file} +True if @var{file} exists and is a symbolic link. + +@item -k @var{file} +True if @var{file} exists and its "sticky" bit is set. + +@item -p @var{file} +True if @var{file} exists and is a named pipe (FIFO). + +@item -r @var{file} +True if @var{file} exists and is readable. + +@item -s @var{file} +True if @var{file} exists and has a size greater than zero. + +@item -t @var{fd} +True if file descriptor @var{fd} is open and refers to a terminal. + +@item -u @var{file} +True if @var{file} exists and its set-user-id bit is set. + +@item -w @var{file} +True if @var{file} exists and is writable. + +@item -x @var{file} +True if @var{file} exists and is executable. + +@item -G @var{file} +True if @var{file} exists and is owned by the effective group id. + +@item -L @var{file} +True if @var{file} exists and is a symbolic link. + +@item -N @var{file} +True if @var{file} exists and has been modified since it was last read. + +@item -O @var{file} +True if @var{file} exists and is owned by the effective user id. + +@item -S @var{file} +True if @var{file} exists and is a socket. + +@item @var{file1} -ef @var{file2} +True if @var{file1} and @var{file2} refer to the same device and +inode numbers. + +@item @var{file1} -nt @var{file2} +True if @var{file1} is newer (according to modification date) +than @var{file2}, or if @var{file1} exists and @var{file2} does not. + +@item @var{file1} -ot @var{file2} +True if @var{file1} is older than @var{file2}, +or if @var{file2} exists and @var{file1} does not. + +@item -o @var{optname} +True if the shell option @var{optname} is enabled. +The list of options appears in the description of the @option{-o} +option to the @code{set} builtin (@pxref{The Set Builtin}). + +@item -v @var{varname} +True if the shell variable @var{varname} is set (has been assigned a value). + +@item -R @var{varname} +True if the shell variable @var{varname} is set and is a name reference. + +@item -z @var{string} +True if the length of @var{string} is zero. + +@item -n @var{string} +@itemx @var{string} +True if the length of @var{string} is non-zero. + +@item @var{string1} == @var{string2} +@itemx @var{string1} = @var{string2} +True if the strings are equal. +When used with the @code{[[} command, this performs pattern matching as +described above (@pxref{Conditional Constructs}). + +@samp{=} should be used with the @code{test} command for @sc{posix} conformance. + +@item @var{string1} != @var{string2} +True if the strings are not equal. + +@item @var{string1} < @var{string2} +True if @var{string1} sorts before @var{string2} lexicographically. + +@item @var{string1} > @var{string2} +True if @var{string1} sorts after @var{string2} lexicographically. + +@item @var{arg1} OP @var{arg2} +@code{OP} is one of +@samp{-eq}, @samp{-ne}, @samp{-lt}, @samp{-le}, @samp{-gt}, or @samp{-ge}. +These arithmetic binary operators return true if @var{arg1} +is equal to, not equal to, less than, less than or equal to, +greater than, or greater than or equal to @var{arg2}, +respectively. @var{Arg1} and @var{arg2} +may be positive or negative integers. +@end table + +@node Shell Arithmetic +@section Shell Arithmetic +@cindex arithmetic, shell +@cindex shell arithmetic +@cindex expressions, arithmetic +@cindex evaluation, arithmetic +@cindex arithmetic evaluation + +The shell allows arithmetic expressions to be evaluated, as one of +the shell expansions or by the @code{let} and the @option{-i} option +to the @code{declare} builtins. + +Evaluation is done in fixed-width integers with no check for overflow, +though division by 0 is trapped and flagged as an error. +The operators and their precedence, associativity, and values +are the same as in the C language. +The following list of operators is grouped into levels of +equal-precedence operators. +The levels are listed in order of decreasing precedence. + +@table @code + +@item @var{id}++ @var{id}-- +variable post-increment and post-decrement + +@item ++@var{id} --@var{id} +variable pre-increment and pre-decrement + +@item - + +unary minus and plus + +@item ! ~ +logical and bitwise negation + +@item ** +exponentiation + +@item * / % +multiplication, division, remainder + +@item + - +addition, subtraction + +@item << >> +left and right bitwise shifts + +@item <= >= < > +comparison + +@item == != +equality and inequality + +@item & +bitwise AND + +@item ^ +bitwise exclusive OR + +@item | +bitwise OR + +@item && +logical AND + +@item || +logical OR + +@item expr ? expr : expr +conditional operator + +@item = *= /= %= += -= <<= >>= &= ^= |= +assignment + +@item expr1 , expr2 +comma +@end table + +Shell variables are allowed as operands; parameter expansion is +performed before the expression is evaluated. +Within an expression, shell variables may also be referenced by name +without using the parameter expansion syntax. +A shell variable that is null or unset evaluates to 0 when referenced +by name without using the parameter expansion syntax. +The value of a variable is evaluated as an arithmetic expression +when it is referenced, or when a variable which has been given the +@var{integer} attribute using @samp{declare -i} is assigned a value. +A null value evaluates to 0. +A shell variable need not have its @var{integer} attribute turned on +to be used in an expression. + +Constants with a leading 0 are interpreted as octal numbers. +A leading @samp{0x} or @samp{0X} denotes hexadecimal. Otherwise, +numbers take the form [@var{base}@code{#}]@var{n}, where the optional @var{base} +is a decimal number between 2 and 64 representing the arithmetic +base, and @var{n} is a number in that base. +If @var{base}@code{#} is omitted, then base 10 is used. +When specifying @var{n}, +he digits greater than 9 are represented by the lowercase letters, +the uppercase letters, @samp{@@}, and @samp{_}, in that order. +If @var{base} is less than or equal to 36, lowercase and uppercase +letters may be used interchangeably to represent numbers between 10 +and 35. + +Operators are evaluated in order of precedence. Sub-expressions in +parentheses are evaluated first and may override the precedence +rules above. + +@node Aliases +@section Aliases +@cindex alias expansion + +@var{Aliases} allow a string to be substituted for a word when it is used +as the first word of a simple command. +The shell maintains a list of aliases that may be set and unset with +the @code{alias} and @code{unalias} builtin commands. + +The first word of each simple command, if unquoted, is checked to see +if it has an alias. +If so, that word is replaced by the text of the alias. +The characters @samp{/}, @samp{$}, @samp{`}, @samp{=} and any of the +shell metacharacters or quoting characters listed above may not appear +in an alias name. +The replacement text may contain any valid +shell input, including shell metacharacters. +The first word of the replacement text is tested for +aliases, but a word that is identical to an alias being expanded +is not expanded a second time. +This means that one may alias @code{ls} to @code{"ls -F"}, +for instance, and Bash does not try to recursively expand the +replacement text. +If the last character of the alias value is a +@var{blank}, then the next command word following the +alias is also checked for alias expansion. + +Aliases are created and listed with the @code{alias} +command, and removed with the @code{unalias} command. + +There is no mechanism for using arguments in the replacement text, +as in @code{csh}. +If arguments are needed, a shell function should be used +(@pxref{Shell Functions}). + +Aliases are not expanded when the shell is not interactive, +unless the @code{expand_aliases} shell option is set using +@code{shopt} (@pxref{The Shopt Builtin}). + +The rules concerning the definition and use of aliases are +somewhat confusing. Bash +always reads at least one complete line +of input before executing any +of the commands on that line. Aliases are expanded when a +command is read, not when it is executed. Therefore, an +alias definition appearing on the same line as another +command does not take effect until the next line of input is read. +The commands following the alias definition +on that line are not affected by the new alias. +This behavior is also an issue when functions are executed. +Aliases are expanded when a function definition is read, +not when the function is executed, because a function definition +is itself a compound command. As a consequence, aliases +defined in a function are not available until after that +function is executed. To be safe, always put +alias definitions on a separate line, and do not use @code{alias} +in compound commands. + +For almost every purpose, shell functions are preferred over aliases. + +@node Arrays +@section Arrays +@cindex arrays + +Bash provides one-dimensional indexed and associative array variables. +Any variable may be used as an indexed array; +the @code{declare} builtin will explicitly declare an array. +There is no maximum +limit on the size of an array, nor any requirement that members +be indexed or assigned contiguously. +Indexed arrays are referenced using integers (including arithmetic +expressions (@pxref{Shell Arithmetic})) and are zero-based; +associative arrays use arbitrary strings. +Unless otherwise noted, indexed array indices must be non-negative integers. + +An indexed array is created automatically if any variable is assigned to +using the syntax +@example +@var{name}[@var{subscript}]=@var{value} +@end example + +@noindent +The @var{subscript} +is treated as an arithmetic expression that must evaluate to a number. +To explicitly declare an array, use +@example +declare -a @var{name} +@end example +@noindent +The syntax +@example +declare -a @var{name}[@var{subscript}] +@end example +@noindent +is also accepted; the @var{subscript} is ignored. + +@noindent +Associative arrays are created using +@example +declare -A @var{name}. +@end example + +Attributes may be +specified for an array variable using the @code{declare} and +@code{readonly} builtins. Each attribute applies to all members of +an array. + +Arrays are assigned to using compound assignments of the form +@example +@var{name}=(@var{value1} @var{value2} @dots{} ) +@end example +@noindent +where each +@var{value} is of the form @code{[@var{subscript}]=}@var{string}. +Indexed array assignments do not require anything but @var{string}. +When assigning to indexed arrays, if +the optional subscript is supplied, that index is assigned to; +otherwise the index of the element assigned is the last index assigned +to by the statement plus one. Indexing starts at zero. + +When assigning to an associative array, the subscript is required. + +This syntax is also accepted by the @code{declare} +builtin. Individual array elements may be assigned to using the +@code{@var{name}[@var{subscript}]=@var{value}} syntax introduced above. + +When assigning to an indexed array, if @var{name} +is subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +@var{name}, so negative indices count back from the end of the +array, and an index of -1 references the last element. + +Any element of an array may be referenced using +@code{$@{@var{name}[@var{subscript}]@}}. +The braces are required to avoid +conflicts with the shell's filename expansion operators. If the +@var{subscript} is @samp{@@} or @samp{*}, the word expands to all members +of the array @var{name}. These subscripts differ only when the word +appears within double quotes. +If the word is double-quoted, +@code{$@{@var{name}[*]@}} expands to a single word with +the value of each array member separated by the first character of the +@env{IFS} variable, and @code{$@{@var{name}[@@]@}} expands each element of +@var{name} to a separate word. When there are no array members, +@code{$@{@var{name}[@@]@}} expands to nothing. +If the double-quoted expansion occurs within a word, the expansion of +the first parameter is joined with the beginning part of the original +word, and the expansion of the last parameter is joined with the last +part of the original word. +This is analogous to the +expansion of the special parameters @samp{@@} and @samp{*}. +@code{$@{#@var{name}[@var{subscript}]@}} expands to the length of +@code{$@{@var{name}[@var{subscript}]@}}. +If @var{subscript} is @samp{@@} or +@samp{*}, the expansion is the number of elements in the array. +Referencing an array variable without a subscript is equivalent to +referencing with a subscript of 0. +If the @var{subscript} +used to reference an element of an indexed array +evaluates to a number less than zero, it is +interpreted as relative to one greater than the maximum index of the array, +so negative indices count back from the end of the array, +and an index of -1 refers to the last element. + +An array variable is considered set if a subscript has been assigned a +value. The null string is a valid value. + +The @code{unset} builtin is used to destroy arrays. +@code{unset @var{name}[@var{subscript}]} +destroys the array element at index @var{subscript}. +Negative subscripts to indexed arrays are interpreted as described above. +Care must be taken to avoid unwanted side effects caused by filename +expansion. +@code{unset @var{name}}, where @var{name} is an array, removes the +entire array. A subscript of @samp{*} or @samp{@@} also removes the +entire array. + +The @code{declare}, @code{local}, and @code{readonly} +builtins each accept a @option{-a} option to specify an indexed +array and a @option{-A} option to specify an associative array. +If both options are supplied, @option{-A} takes precedence. +The @code{read} builtin accepts a @option{-a} +option to assign a list of words read from the standard input +to an array, and can read values from the standard input into +individual array elements. The @code{set} and @code{declare} +builtins display array values in a way that allows them to be +reused as input. + +@node The Directory Stack +@section The Directory Stack +@cindex directory stack + +@menu +* Directory Stack Builtins:: Bash builtin commands to manipulate + the directory stack. +@end menu + +The directory stack is a list of recently-visited directories. The +@code{pushd} builtin adds directories to the stack as it changes +the current directory, and the @code{popd} builtin removes specified +directories from the stack and changes the current directory to +the directory removed. The @code{dirs} builtin displays the contents +of the directory stack. + +The contents of the directory stack are also visible +as the value of the @env{DIRSTACK} shell variable. + +@node Directory Stack Builtins +@subsection Directory Stack Builtins + +@table @code + +@item dirs +@btindex dirs +@example +dirs [-clpv] [+@var{N} | -@var{N}] +@end example + +Display the list of currently remembered directories. Directories +are added to the list with the @code{pushd} command; the +@code{popd} command removes directories from the list. + +@table @code +@item -c +Clears the directory stack by deleting all of the elements. +@item -l +Produces a listing using full pathnames; +the default listing format uses a tilde to denote the home directory. +@item -p +Causes @code{dirs} to print the directory stack with one entry per +line. +@item -v +Causes @code{dirs} to print the directory stack with one entry per +line, prefixing each entry with its index in the stack. +@item +@var{N} +Displays the @var{N}th directory (counting from the left of the +list printed by @code{dirs} when invoked without options), starting +with zero. +@item -@var{N} +Displays the @var{N}th directory (counting from the right of the +list printed by @code{dirs} when invoked without options), starting +with zero. +@end table + +@item popd +@btindex popd +@example +popd [-n] [+@var{N} | -@var{N}] +@end example + +Remove the top entry from the directory stack, and @code{cd} +to the new top directory. +When no arguments are given, @code{popd} +removes the top directory from the stack and +performs a @code{cd} to the new top directory. The +elements are numbered from 0 starting at the first directory listed with +@code{dirs}; that is, @code{popd} is equivalent to @code{popd +0}. + +@table @code +@item -n +Suppresses the normal change of directory when removing directories +from the stack, so that only the stack is manipulated. +@item +@var{N} +Removes the @var{N}th directory (counting from the left of the +list printed by @code{dirs}), starting with zero. +@item -@var{N} +Removes the @var{N}th directory (counting from the right of the +list printed by @code{dirs}), starting with zero. +@end table + +@btindex pushd +@item pushd +@example +pushd [-n] [@var{+N} | @var{-N} | @var{dir}] +@end example + +Save the current directory on the top of the directory stack +and then @code{cd} to @var{dir}. +With no arguments, @code{pushd} exchanges the top two directories. + +@table @code +@item -n +Suppresses the normal change of directory when adding directories +to the stack, so that only the stack is manipulated. +@item +@var{N} +Brings the @var{N}th directory (counting from the left of the +list printed by @code{dirs}, starting with zero) to the top of +the list by rotating the stack. +@item -@var{N} +Brings the @var{N}th directory (counting from the right of the +list printed by @code{dirs}, starting with zero) to the top of +the list by rotating the stack. +@item @var{dir} +Makes the current working directory be the top of the stack, making +it the new current directory as if it had been supplied as an argument +to the @code{cd} builtin. +@end table +@end table + +@node Controlling the Prompt +@section Controlling the Prompt +@cindex prompting + +The value of the variable @env{PROMPT_COMMAND} is examined just before +Bash prints each primary prompt. If @env{PROMPT_COMMAND} is set and +has a non-null value, then the +value is executed just as if it had been typed on the command line. + +In addition, the following table describes the special characters which +can appear in the prompt variables @env{PS1} to @env{PS4}: + +@table @code +@item \a +A bell character. +@item \d +The date, in "Weekday Month Date" format (e.g., "Tue May 26"). +@item \D@{@var{format}@} +The @var{format} is passed to @code{strftime}(3) and the result is inserted +into the prompt string; an empty @var{format} results in a locale-specific +time representation. The braces are required. +@item \e +An escape character. +@item \h +The hostname, up to the first `.'. +@item \H +The hostname. +@item \j +The number of jobs currently managed by the shell. +@item \l +The basename of the shell's terminal device name. +@item \n +A newline. +@item \r +A carriage return. +@item \s +The name of the shell, the basename of @code{$0} (the portion +following the final slash). +@item \t +The time, in 24-hour HH:MM:SS format. +@item \T +The time, in 12-hour HH:MM:SS format. +@item \@@ +The time, in 12-hour am/pm format. +@item \A +The time, in 24-hour HH:MM format. +@item \u +The username of the current user. +@item \v +The version of Bash (e.g., 2.00) +@item \V +The release of Bash, version + patchlevel (e.g., 2.00.0) +@item \w +The current working directory, with @env{$HOME} abbreviated with a tilde +(uses the @env{$PROMPT_DIRTRIM} variable). +@item \W +The basename of @env{$PWD}, with @env{$HOME} abbreviated with a tilde. +@item \! +The history number of this command. +@item \# +The command number of this command. +@item \$ +If the effective uid is 0, @code{#}, otherwise @code{$}. +@item \@var{nnn} +The character whose ASCII code is the octal value @var{nnn}. +@item \\ +A backslash. +@item \[ +Begin a sequence of non-printing characters. This could be used to +embed a terminal control sequence into the prompt. +@item \] +End a sequence of non-printing characters. +@end table + +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 +(@pxref{Bash History Facilities}), while the command number is +the position in the sequence of commands 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 +@code{promptvars} shell option (@pxref{Bash Builtins}). + +@node The Restricted Shell +@section The Restricted Shell +@cindex restricted shell + +If Bash is started with the name @code{rbash}, or the +@option{--restricted} +or +@option{-r} +option is supplied at invocation, the shell becomes restricted. +A restricted shell is used to +set up an environment more controlled than the standard shell. +A restricted shell behaves identically to @code{bash} +with the exception that the following are disallowed or not performed: + +@itemize @bullet +@item +Changing directories with the @code{cd} builtin. +@item +Setting or unsetting the values of the @env{SHELL}, @env{PATH}, +@env{ENV}, or @env{BASH_ENV} variables. +@item +Specifying command names containing slashes. +@item +Specifying a filename containing a slash as an argument to the @code{.} +builtin command. +@item +Specifying a filename containing a slash as an argument to the @option{-p} +option to the @code{hash} builtin command. +@item +Importing function definitions from the shell environment at startup. +@item +Parsing the value of @env{SHELLOPTS} from the shell environment at startup. +@item +Redirecting output using the @samp{>}, @samp{>|}, @samp{<>}, @samp{>&}, +@samp{&>}, and @samp{>>} redirection operators. +@item +Using the @code{exec} builtin to replace the shell with another command. +@item +Adding or deleting builtin commands with the +@option{-f} and @option{-d} options to the @code{enable} builtin. +@item +Using the @code{enable} builtin command to enable disabled shell builtins. +@item +Specifying the @option{-p} option to the @code{command} builtin. +@item +Turning off restricted mode with @samp{set +r} or @samp{set +o restricted}. +@end itemize + +These restrictions are enforced after any startup files are read. + +When a command that is found to be a shell script is executed +(@pxref{Shell Scripts}), @code{rbash} turns off any restrictions in +the shell spawned to execute the script. + +@node Bash POSIX Mode +@section Bash POSIX Mode +@cindex POSIX Mode + +Starting Bash with the @option{--posix} command-line option or executing +@samp{set -o posix} while Bash is running will cause Bash to conform more +closely to the @sc{posix} standard by changing the behavior to +match that specified by @sc{posix} in areas where the Bash default differs. + +When invoked as @code{sh}, Bash enters @sc{posix} mode after reading the +startup files. + +The following list is what's changed when `@sc{posix} mode' is in effect: + +@enumerate +@item +When a command in the hash table no longer exists, Bash will re-search +@env{$PATH} to find the new location. This is also available with +@samp{shopt -s checkhash}. + +@item +The message printed by the job control code and builtins when a job +exits with a non-zero status is `Done(status)'. + +@item +The message printed by the job control code and builtins when a job +is stopped is `Stopped(@var{signame})', where @var{signame} is, for +example, @code{SIGTSTP}. + +@item +The @code{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. + +@item +Reserved words appearing in a context where reserved words are recognized +do not undergo alias expansion. + +@item +The @sc{posix} @env{PS1} and @env{PS2} expansions of @samp{!} to +the history number and @samp{!!} to @samp{!} are enabled, +and parameter expansion is performed on the values of @env{PS1} and +@env{PS2} regardless of the setting of the @code{promptvars} option. + +@item +The @sc{posix} startup files are executed (@env{$ENV}) rather than +the normal Bash files. + +@item +Tilde expansion is only performed on assignments preceding a command +name, rather than on all assignment statements on the line. + +@item +The @code{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 @code{command}. + +@item +The default history file is @file{~/.sh_history} (this is the +default value of @env{$HISTFILE}). + +@item +The output of @samp{kill -l} prints all the signal names on a single line, +separated by spaces, without the @samp{SIG} prefix. + +@item +The @code{kill} builtin does not accept signal names with a @samp{SIG} +prefix. + +@item +Non-interactive shells exit if @var{filename} in @code{.} @var{filename} +is not found. + +@item +Non-interactive shells exit if a syntax error in an arithmetic expansion +results in an invalid expression. + +@item +Non-interactive shells exit if there is a syntax error in a script read +with the @code{.} or @code{source} builtins, or in a string processed by +the @code{eval} builtin. + +@item +Redirection operators do not perform filename expansion on the word +in the redirection unless the shell is interactive. + +@item +Redirection operators do not perform word splitting on the word in the +redirection. + +@item +Function names must be valid shell @code{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. + +@item +Function names may not be the same as one of the @sc{posix} special +builtins. + +@item +@sc{posix} special builtins are found before shell functions +during command lookup. + +@item +The @code{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 @env{TIMEFORMAT} variable controls the format +of the timing information. + +@item +When parsing and expanding a $@{@dots{}@} 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. + +@item +The parser does not recognize @code{time} as a reserved word if the next +token begins with a @samp{-}. + +@item +If a @sc{posix} special builtin returns an error status, a +non-interactive shell exits. The fatal errors are those listed in +the @sc{posix} standard, and include things like passing incorrect options, +redirection errors, variable assignment errors for assignments preceding +the command name, and so on. + +@item +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. + +@item +A non-interactive shell exists 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. + +@item +A non-interactive shell exits with an error status if the iteration +variable in a @code{for} statement or the selection variable in a +@code{select} statement is a readonly variable. + +@item +Process substitution is not available. + +@item +While variable indirection is available, it may not be applied to the +@samp{#} and @samp{?} special parameters. + +@item +Assignment statements preceding @sc{posix} special builtins +persist in the shell environment after the builtin completes. + +@item +Assignment statements preceding shell function calls persist in the +shell environment after the function returns, as if a @sc{posix} +special builtin command had been executed. + +@item +The @code{export} and @code{readonly} builtin commands display their +output in the format required by @sc{posix}. + +@item +The @code{trap} builtin displays signal names without the leading +@code{SIG}. + +@item +The @code{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 @samp{-} as the +first argument. + +@item +The @code{.} and @code{source} builtins do not search the current directory +for the filename argument if it is not found by searching @env{PATH}. + +@item +Subshells spawned to execute command substitutions inherit the value of +the @option{-e} option from the parent shell. When not in @sc{posix} mode, +Bash clears the @option{-e} option in such subshells. + +@item +Alias expansion is always enabled, even in non-interactive shells. + +@item +When the @code{alias} builtin displays alias definitions, it does not +display them with a leading @samp{alias } unless the @option{-p} option +is supplied. + +@item +When the @code{set} builtin is invoked without options, it does not display +shell function names and definitions. + +@item +When the @code{set} builtin is invoked without options, it displays +variable values without quotes, unless they contain shell metacharacters, +even if the result contains nonprinting characters. + +@item +When the @code{cd} builtin is invoked in @var{logical} mode, and the pathname +constructed from @code{$PWD} and the directory name supplied as an argument +does not refer to an existing directory, @code{cd} will fail instead of +falling back to @var{physical} mode. + +@item +The @code{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 +@option{-P} option. + +@item +When listing the history, the @code{fc} builtin does not include an +indication of whether or not a history entry has been modified. + +@item +The default editor used by @code{fc} is @code{ed}. + +@item +The @code{type} and @code{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 @code{$PATH}. + +@item +The @code{vi} editing mode will invoke the @code{vi} editor directly when +the @samp{v} command is run, instead of checking @code{$VISUAL} and +@code{$EDITOR}. + +@item +When the @code{xpg_echo} option is enabled, Bash does not attempt to interpret +any arguments to @code{echo} as options. Each argument is displayed, after +escape characters are converted. + +@item +The @code{ulimit} builtin uses a block size of 512 bytes for the @option{-c} +and @option{-f} options. + +@item +The arrival of @code{SIGCHLD} when a trap is set on @code{SIGCHLD} does +not interrupt the @code{wait} builtin and cause it to return immediately. +The trap command is run once for each child that exits. + +@item +The @code{read} builtin may be interrupted by a signal for which a trap +has been set. +If Bash receives a trapped signal while executing @code{read}, the trap +handler executes and @code{read} returns an exit status greater than 128. + +@end enumerate + +There is other @sc{posix} behavior that Bash does not implement by +default even when in @sc{posix} mode. +Specifically: + +@enumerate + +@item +The @code{fc} builtin checks @code{$EDITOR} as a program to edit history +entries if @code{FCEDIT} is unset, rather than defaulting directly to +@code{ed}. @code{fc} uses @code{ed} if @code{EDITOR} is unset. + +@item +As noted above, Bash requires the @code{xpg_echo} option to be enabled for +the @code{echo} builtin to be fully conformant. + +@end enumerate + +Bash can be configured to be @sc{posix}-conformant by default, by specifying +the @option{--enable-strict-posix-default} to @code{configure} when building +(@pxref{Optional Features}). + +@node Job Control +@chapter Job Control + +This chapter discusses what job control is, how it works, and how +Bash allows you to access its facilities. + +@menu +* Job Control Basics:: How job control works. +* Job Control Builtins:: Bash builtin commands used to interact + with job control. +* Job Control Variables:: Variables Bash uses to customize job + control. +@end menu + +@node Job Control Basics +@section Job Control Basics +@cindex job control +@cindex foreground +@cindex background +@cindex suspending jobs + +Job control +refers to the ability to selectively stop (suspend) +the execution of processes and continue (resume) +their execution at a later point. A user typically employs +this facility via an interactive interface supplied jointly +by the operating system kernel's terminal driver and Bash. + +The shell associates a @var{job} with each pipeline. It keeps a +table of currently executing jobs, which may be listed with the +@code{jobs} command. When Bash starts a job +asynchronously, it prints a line that looks +like: +@example +[1] 25647 +@end example +@noindent +indicating that this job is job number 1 and that the process @sc{id} +of the last process in the pipeline associated with this job is +25647. All of the processes in a single pipeline are members of +the same job. Bash uses the @var{job} abstraction as the +basis for job control. + +To facilitate the implementation of the user interface to job +control, the operating system maintains the notion of a current terminal +process group @sc{id}. Members of this process group (processes whose +process group @sc{id} is equal to the current terminal process group +@sc{id}) receive keyboard-generated signals such as @code{SIGINT}. +These processes are said to be in the foreground. Background +processes are those whose process group @sc{id} differs from the +terminal's; such processes are immune to keyboard-generated +signals. Only foreground processes are allowed to read from or, if +the user so specifies with @code{stty tostop}, write to the terminal. +Background processes which attempt to +read from (write to when @code{stty tostop} is in effect) the +terminal are sent a @code{SIGTTIN} (@code{SIGTTOU}) +signal by the kernel's terminal driver, +which, unless caught, suspends the process. + +If the operating system on which Bash is running supports +job control, Bash contains facilities to use it. Typing the +@var{suspend} character (typically @samp{^Z}, Control-Z) while a +process is running causes that process to be stopped and returns +control to Bash. Typing the @var{delayed suspend} character +(typically @samp{^Y}, Control-Y) causes the process to be stopped +when it attempts to read input from the terminal, and control to +be returned to Bash. The user then manipulates the state of +this job, using the @code{bg} command to continue it in the +background, the @code{fg} command to continue it in the +foreground, or the @code{kill} command to kill it. A @samp{^Z} +takes effect immediately, and has the additional side effect of +causing pending output and typeahead to be discarded. + +There are a number of ways to refer to a job in the shell. The +character @samp{%} introduces a job specification (@var{jobspec}). + +Job number @code{n} may be referred to as @samp{%n}. +The symbols @samp{%%} and @samp{%+} refer to the shell's notion of the +current job, which is the last job stopped while it was in the foreground +or started in the background. +A single @samp{%} (with no accompanying job specification) also refers +to the current job. +The previous job may be referenced using @samp{%-}. +If there is only a single job, @samp{%+} and @samp{%-} can both be used +to refer to that job. +In output pertaining to jobs (e.g., the output of the @code{jobs} +command), the current job is always flagged with a @samp{+}, and the +previous job with a @samp{-}. + +A job may also be referred to +using a prefix of the name used to start it, or using a substring +that appears in its command line. For example, @samp{%ce} refers +to a stopped @code{ce} job. Using @samp{%?ce}, on the +other hand, refers to any job containing the string @samp{ce} in +its command line. If the prefix or substring matches more than one job, +Bash reports an error. + +Simply naming a job can be used to bring it into the foreground: +@samp{%1} is a synonym for @samp{fg %1}, bringing job 1 from the +background into the foreground. Similarly, @samp{%1 &} resumes +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. +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 +that exits. + +If an attempt to exit Bash is made while jobs are stopped, (or running, if +the @code{checkjobs} option is enabled -- see @ref{The Shopt Builtin}), the +shell prints a warning message, and if the @code{checkjobs} option is +enabled, lists the jobs and their statuses. +The @code{jobs} command may then be used to inspect their status. +If a second attempt to exit is made without an intervening command, +Bash does not print another warning, and any stopped jobs are terminated. + +@node Job Control Builtins +@section Job Control Builtins + +@table @code + +@item bg +@btindex bg +@example +bg [@var{jobspec} @dots{}] +@end example + +Resume each suspended job @var{jobspec} in the background, as if it +had been started with @samp{&}. +If @var{jobspec} is not supplied, the current job is used. +The return status is zero unless it is run when job control is not +enabled, or, when run with job control enabled, any +@var{jobspec} was not found or specifies a job +that was started without job control. + +@item fg +@btindex fg +@example +fg [@var{jobspec}] +@end example + +Resume the job @var{jobspec} in the foreground and make it the current job. +If @var{jobspec} is not supplied, the current job is used. +The return status is that of the command placed into the foreground, +or non-zero if run when job control is disabled or, when run with +job control enabled, @var{jobspec} does not specify a valid job or +@var{jobspec} specifies a job that was started without job control. + +@item jobs +@btindex jobs +@example +jobs [-lnprs] [@var{jobspec}] +jobs -x @var{command} [@var{arguments}] +@end example + +The first form lists the active jobs. The options have the +following meanings: + +@table @code +@item -l +List process @sc{id}s in addition to the normal information. + +@item -n +Display information only about jobs that have changed status since +the user was last notified of their status. + +@item -p +List only the process @sc{id} of the job's process group leader. + +@item -r +Display only running jobs. + +@item -s +Display only stopped jobs. +@end table + +If @var{jobspec} is given, +output is restricted to information about that job. +If @var{jobspec} is not supplied, the status of all jobs is +listed. + +If the @option{-x} option is supplied, @code{jobs} replaces any +@var{jobspec} found in @var{command} or @var{arguments} with the +corresponding process group @sc{id}, and executes @var{command}, +passing it @var{argument}s, returning its exit status. + +@item kill +@btindex kill +@example +kill [-s @var{sigspec}] [-n @var{signum}] [-@var{sigspec}] @var{jobspec} or @var{pid} +kill -l [@var{exit_status}] +@end example + +Send a signal specified by @var{sigspec} or @var{signum} to the process +named by job specification @var{jobspec} or process @sc{id} @var{pid}. +@var{sigspec} is either a case-insensitive signal name such as +@code{SIGINT} (with or without the @code{SIG} prefix) +or a signal number; @var{signum} is a signal number. +If @var{sigspec} and @var{signum} are not present, @code{SIGTERM} is used. +The @option{-l} option lists the signal names. +If any arguments are supplied when @option{-l} is given, the names of the +signals corresponding to the arguments are listed, and the return status +is zero. +@var{exit_status} is a number specifying a signal number or the exit +status of a process terminated by a signal. +The return status is zero if at least one signal was successfully sent, +or non-zero if an error occurs or an invalid option is encountered. + +@item wait +@btindex wait +@example +wait [@var{jobspec} or @var{pid} @dots{}] +@end example + +Wait until the child process specified by each process @sc{id} @var{pid} +or job specification @var{jobspec} exits and return the exit status of the +last command waited for. +If a job spec is given, all processes in the job are waited for. +If no arguments are given, all currently active child processes are +waited for, and the return status is zero. +If the @option{-n} option is supplied, @code{wait} waits for any job to +terminate and returns its exit status. +If neither @var{jobspec} nor @var{pid} specifies an active child process +of the shell, the return status is 127. + +@item disown +@btindex disown +@example +disown [-ar] [-h] [@var{jobspec} @dots{}] +@end example + +Without options, remove each @var{jobspec} from the table of +active jobs. +If the @option{-h} option is given, the job is not removed from the table, +but is marked so that @code{SIGHUP} is not sent to the job if the shell +receives a @code{SIGHUP}. +If @var{jobspec} is not present, and neither the @option{-a} nor @option{-r} +option is supplied, the current job is used. +If no @var{jobspec} is supplied, the @option{-a} option means to remove or +mark all jobs; the @option{-r} option without a @var{jobspec} +argument restricts operation to running jobs. + +@item suspend +@btindex suspend +@example +suspend [-f] +@end example + +Suspend the execution of this shell until it receives a +@code{SIGCONT} signal. +A login shell cannot be suspended; the @option{-f} +option can be used to override this and force the suspension. +@end table + +When job control is not active, the @code{kill} and @code{wait} +builtins do not accept @var{jobspec} arguments. They must be +supplied process @sc{id}s. + +@node Job Control Variables +@section Job Control Variables + +@vtable @code + +@item auto_resume +This variable controls how the shell interacts with the user and +job control. If this variable exists then single word simple +commands without redirections are treated as candidates for resumption +of an existing job. There is no ambiguity allowed; if there is +more than one job beginning with the string typed, then +the most recently accessed job will be selected. +The name of a stopped job, in this context, is the command line +used to start it. If this variable is set to the value @samp{exact}, +the string supplied must match the name of a stopped job exactly; +if set to @samp{substring}, +the string supplied needs to match a substring of the name of a +stopped job. The @samp{substring} value provides functionality +analogous to the @samp{%?} job @sc{id} (@pxref{Job Control Basics}). +If set to any other value, the supplied string must +be a prefix of a stopped job's name; this provides functionality +analogous to the @samp{%} job @sc{id}. + +@end vtable + +@set readline-appendix +@set history-appendix +@cindex Readline, how to use +@include rluser.texi +@cindex History, how to use +@include hsuser.texi +@clear readline-appendix +@clear history-appendix + +@node Installing Bash +@chapter Installing Bash + +This chapter provides basic instructions for installing Bash on +the various supported platforms. The distribution supports the +@sc{gnu} operating systems, nearly every version of Unix, and several +non-Unix systems such as BeOS and Interix. +Other independent ports exist for +@sc{ms-dos}, @sc{os/2}, and Windows platforms. + +@menu +* Basic Installation:: Installation instructions. +* Compilers and Options:: How to set special options for various + systems. +* Compiling For Multiple Architectures:: How to compile Bash for more + than one kind of system from + the same source tree. +* Installation Names:: How to set the various paths used by the installation. +* Specifying the System Type:: How to configure Bash for a particular system. +* Sharing Defaults:: How to share default configuration values among GNU + programs. +* Operation Controls:: Options recognized by the configuration program. +* Optional Features:: How to enable and disable optional features when + building Bash. +@end menu + +@node Basic Installation +@section Basic Installation +@cindex installation +@cindex configuration +@cindex Bash installation +@cindex Bash configuration + +These are installation instructions for Bash. + +The simplest way to compile Bash is: + +@enumerate +@item +@code{cd} to the directory containing the source code and type +@samp{./configure} to configure Bash for your system. If you're +using @code{csh} on an old version of System V, you might need to +type @samp{sh ./configure} instead to prevent @code{csh} from trying +to execute @code{configure} itself. + +Running @code{configure} takes some time. +While running, it prints messages telling which features it is +checking for. + +@item +Type @samp{make} to compile Bash and build the @code{bashbug} bug +reporting script. + +@item +Optionally, type @samp{make tests} to run the Bash test suite. + +@item +Type @samp{make install} to install @code{bash} and @code{bashbug}. +This will also install the manual pages and Info file. + +@end enumerate + +The @code{configure} shell script attempts to guess correct +values for various system-dependent variables used during +compilation. It uses those values to create a @file{Makefile} in +each directory of the package (the top directory, the +@file{builtins}, @file{doc}, and @file{support} directories, +each directory under @file{lib}, and several others). It also creates a +@file{config.h} file containing system-dependent definitions. +Finally, it creates a shell script named @code{config.status} that you +can run in the future to recreate the current configuration, a +file @file{config.cache} that saves the results of its tests to +speed up reconfiguring, and a file @file{config.log} containing +compiler output (useful mainly for debugging @code{configure}). +If at some point +@file{config.cache} contains results you don't want to keep, you +may remove or edit it. + +To find out more about the options and arguments that the +@code{configure} script understands, type + +@example +bash-2.04$ ./configure --help +@end example + +@noindent +at the Bash prompt in your Bash source directory. + +If you need to do unusual things to compile Bash, please +try to figure out how @code{configure} could check whether or not +to do them, and mail diffs or instructions to +@email{bash-maintainers@@gnu.org} so they can be +considered for the next release. + +The file @file{configure.ac} is used to create @code{configure} +by a program called Autoconf. You only need +@file{configure.ac} if you want to change it or regenerate +@code{configure} using a newer version of Autoconf. If +you do this, make sure you are using Autoconf version 2.50 or +newer. + +You can remove the program binaries and object files from the +source code directory by typing @samp{make clean}. To also remove the +files that @code{configure} created (so you can compile Bash for +a different kind of computer), type @samp{make distclean}. + +@node Compilers and Options +@section Compilers and Options + +Some systems require unusual options for compilation or linking +that the @code{configure} script does not know about. You can +give @code{configure} initial values for variables by setting +them in the environment. Using a Bourne-compatible shell, you +can do that on the command line like this: + +@example +CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure +@end example + +On systems that have the @code{env} program, you can do it like this: + +@example +env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure +@end example + +The configuration process uses GCC to build Bash if it +is available. + +@node Compiling For Multiple Architectures +@section Compiling For Multiple Architectures + +You can compile Bash for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of @code{make} that +supports the @code{VPATH} variable, such as GNU @code{make}. +@code{cd} to the +directory where you want the object files and executables to go and run +the @code{configure} script from the source directory. You may need to +supply the @option{--srcdir=PATH} argument to tell @code{configure} where the +source files are. @code{configure} automatically checks for the +source code in the directory that @code{configure} is in and in `..'. + +If you have to use a @code{make} that does not supports the @code{VPATH} +variable, you can compile Bash for one architecture at a +time in the source code directory. After you have installed +Bash for one architecture, use @samp{make distclean} before +reconfiguring for another architecture. + +Alternatively, if your system supports symbolic links, you can use the +@file{support/mkclone} script to create a build tree which has +symbolic links back to each file in the source directory. Here's an +example that creates a build directory in the current directory from a +source directory @file{/usr/gnu/src/bash-2.0}: + +@example +bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 . +@end example + +@noindent +The @code{mkclone} script requires Bash, so you must have already built +Bash for at least one architecture before you can create build +directories for other architectures. + +@node Installation Names +@section Installation Names + +By default, @samp{make install} will install into +@file{/usr/local/bin}, @file{/usr/local/man}, etc. You can +specify an installation prefix other than @file{/usr/local} by +giving @code{configure} the option @option{--prefix=@var{PATH}}, +or by specifying a value for the @code{DESTDIR} @samp{make} +variable when running @samp{make install}. + +You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. +If you give @code{configure} the option +@option{--exec-prefix=@var{PATH}}, @samp{make install} will use +@var{PATH} as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + +@node Specifying the System Type +@section Specifying the System Type + +There may be some features @code{configure} can not figure out +automatically, but need to determine by the type of host Bash +will run on. Usually @code{configure} can figure that +out, but if it prints a message saying it can not guess the host +type, give it the @option{--host=TYPE} option. @samp{TYPE} can +either be a short name for the system type, such as @samp{sun4}, +or a canonical name with three fields: @samp{CPU-COMPANY-SYSTEM} +(e.g., @samp{i386-unknown-freebsd4.2}). + +See the file @file{support/config.sub} for the possible +values of each field. + +@node Sharing Defaults +@section Sharing Defaults + +If you want to set default values for @code{configure} scripts to +share, you can create a site shell script called +@code{config.site} that gives default values for variables like +@code{CC}, @code{cache_file}, and @code{prefix}. @code{configure} +looks for @file{PREFIX/share/config.site} if it exists, then +@file{PREFIX/etc/config.site} if it exists. Or, you can set the +@code{CONFIG_SITE} environment variable to the location of the site +script. A warning: the Bash @code{configure} looks for a site script, +but not all @code{configure} scripts do. + +@node Operation Controls +@section Operation Controls + +@code{configure} recognizes the following options to control how it +operates. + +@table @code + +@item --cache-file=@var{file} +Use and save the results of the tests in +@var{file} instead of @file{./config.cache}. Set @var{file} to +@file{/dev/null} to disable caching, for debugging +@code{configure}. + +@item --help +Print a summary of the options to @code{configure}, and exit. + +@item --quiet +@itemx --silent +@itemx -q +Do not print messages saying which checks are being made. + +@item --srcdir=@var{dir} +Look for the Bash source code in directory @var{dir}. Usually +@code{configure} can determine that directory automatically. + +@item --version +Print the version of Autoconf used to generate the @code{configure} +script, and exit. +@end table + +@code{configure} also accepts some other, not widely used, boilerplate +options. @samp{configure --help} prints the complete list. + +@node Optional Features +@section Optional Features + +The Bash @code{configure} has a number of @option{--enable-@var{feature}} +options, where @var{feature} indicates an optional part of Bash. +There are also several @option{--with-@var{package}} options, +where @var{package} is something like @samp{bash-malloc} or @samp{purify}. +To turn off the default use of a package, use +@option{--without-@var{package}}. To configure Bash without a feature +that is enabled by default, use @option{--disable-@var{feature}}. + +Here is a complete list of the @option{--enable-} and +@option{--with-} options that the Bash @code{configure} recognizes. + +@table @code +@item --with-afs +Define if you are using the Andrew File System from Transarc. + +@item --with-bash-malloc +Use the Bash version of +@code{malloc} in the directory @file{lib/malloc}. This is not the same +@code{malloc} that appears in @sc{gnu} libc, but an older version +originally derived from the 4.2 @sc{bsd} @code{malloc}. This @code{malloc} +is very fast, but wastes some space on each allocation. +This option is enabled by default. +The @file{NOTES} file contains a list of systems for +which this should be turned off, and @code{configure} disables this +option automatically for a number of systems. + +@item --with-curses +Use the curses library instead of the termcap library. This should +be supplied if your system has an inadequate or incomplete termcap +database. + +@item --with-gnu-malloc +A synonym for @code{--with-bash-malloc}. + +@item --with-installed-readline[=@var{PREFIX}] +Define this to make Bash link with a locally-installed version of Readline +rather than the version in @file{lib/readline}. This works only with +Readline 5.0 and later versions. If @var{PREFIX} is @code{yes} or not +supplied, @code{configure} uses the values of the make variables +@code{includedir} and @code{libdir}, which are subdirectories of @code{prefix} +by default, to find the installed version of Readline if it is not in +the standard system include and library directories. +If @var{PREFIX} is @code{no}, Bash links with the version in +@file{lib/readline}. +If @var{PREFIX} is set to any other value, @code{configure} treats it as +a directory pathname and looks for +the installed version of Readline in subdirectories of that directory +(include files in @var{PREFIX}/@code{include} and the library in +@var{PREFIX}/@code{lib}). + +@item --with-purify +Define this to use the Purify memory allocation checker from Rational +Software. + +@item --enable-minimal-config +This produces a shell with minimal features, close to the historical +Bourne shell. +@end table + +There are several @option{--enable-} options that alter how Bash is +compiled and linked, rather than changing run-time features. + +@table @code +@item --enable-largefile +Enable support for @uref{http://www.sas.com/standards/large_file/x_open.20Mar96.html, +large files} if the operating system requires special compiler options +to build programs which can access large files. This is enabled by +default, if the operating system provides large file support. + +@item --enable-profiling +This builds a Bash binary that produces profiling information to be +processed by @code{gprof} each time it is executed. + +@item --enable-static-link +This causes Bash to be linked statically, if @code{gcc} is being used. +This could be used to build a version to use as root's shell. +@end table + +The @samp{minimal-config} option can be used to disable all of +the following options, but it is processed first, so individual +options may be enabled using @samp{enable-@var{feature}}. + +All of the following options except for @samp{disabled-builtins} and +@samp{xpg-echo-default} are +enabled by default, unless the operating system does not provide the +necessary support. + +@table @code +@item --enable-alias +Allow alias expansion and include the @code{alias} and @code{unalias} +builtins (@pxref{Aliases}). + +@item --enable-arith-for-command +Include support for the alternate form of the @code{for} command +that behaves like the C language @code{for} statement +(@pxref{Looping Constructs}). + +@item --enable-array-variables +Include support for one-dimensional array shell variables +(@pxref{Arrays}). + +@item --enable-bang-history +Include support for @code{csh}-like history substitution +(@pxref{History Interaction}). + +@item --enable-brace-expansion +Include @code{csh}-like brace expansion +( @code{b@{a,b@}c} @expansion{} @code{bac bbc} ). +See @ref{Brace Expansion}, for a complete description. + +@item --enable-casemod-attributes +Include support for case-modifying attributes in the @code{declare} builtin +and assignment statements. Variables with the @var{uppercase} attribute, +for example, will have their values converted to uppercase upon assignment. + +@item --enable-casemod-expansion +Include support for case-modifying word expansions. + +@item --enable-command-timing +Include support for recognizing @code{time} as a reserved word and for +displaying timing statistics for the pipeline following @code{time} +(@pxref{Pipelines}). +This allows pipelines as well as shell builtins and functions to be timed. + +@item --enable-cond-command +Include support for the @code{[[} conditional command. +(@pxref{Conditional Constructs}). + +@item --enable-cond-regexp +Include support for matching @sc{posix} regular expressions using the +@samp{=~} binary operator in the @code{[[} conditional command. +(@pxref{Conditional Constructs}). + +@item --enable-coprocesses +Include support for coprocesses and the @code{coproc} reserved word +(@pxref{Pipelines}). + +@item --enable-debugger +Include support for the bash debugger (distributed separately). + +@item --enable-direxpand-default +Cause the @code{direxpand} shell option (@pxref{The Shopt Builtin}) +to be enabled by default when the shell starts. +It is normally disabled by default. + +@item --enable-directory-stack +Include support for a @code{csh}-like directory stack and the +@code{pushd}, @code{popd}, and @code{dirs} builtins +(@pxref{The Directory Stack}). + +@item --enable-disabled-builtins +Allow builtin commands to be invoked via @samp{builtin xxx} +even after @code{xxx} has been disabled using @samp{enable -n xxx}. +See @ref{Bash Builtins}, for details of the @code{builtin} and +@code{enable} builtin commands. + +@item --enable-dparen-arithmetic +Include support for the @code{((@dots{}))} command +(@pxref{Conditional Constructs}). + +@item --enable-extended-glob +Include support for the extended pattern matching features described +above under @ref{Pattern Matching}. + +@item --enable-extended-glob-default +Set the default value of the @var{extglob} shell option described +above under @ref{The Shopt Builtin} to be enabled. + +@item --enable-help-builtin +Include the @code{help} builtin, which displays help on shell builtins and +variables (@pxref{Bash Builtins}). + +@item --enable-history +Include command history and the @code{fc} and @code{history} +builtin commands (@pxref{Bash History Facilities}). + +@item --enable-job-control +This enables the job control features (@pxref{Job Control}), +if the operating system supports them. + +@item --enable-multibyte +This enables support for multibyte characters if the operating +system provides the necessary support. + +@item --enable-net-redirections +This enables the special handling of filenames of the form +@code{/dev/tcp/@var{host}/@var{port}} and +@code{/dev/udp/@var{host}/@var{port}} +when used in redirections (@pxref{Redirections}). + +@item --enable-process-substitution +This enables process substitution (@pxref{Process Substitution}) if +the operating system provides the necessary support. + +@item --enable-progcomp +Enable the programmable completion facilities +(@pxref{Programmable Completion}). +If Readline is not enabled, this option has no effect. + +@item --enable-prompt-string-decoding +Turn on the interpretation of a number of backslash-escaped characters +in the @env{$PS1}, @env{$PS2}, @env{$PS3}, and @env{$PS4} prompt +strings. See @ref{Controlling the Prompt}, for a complete list of prompt +string escape sequences. + +@item --enable-readline +Include support for command-line editing and history with the Bash +version of the Readline library (@pxref{Command Line Editing}). + +@item --enable-restricted +Include support for a @dfn{restricted shell}. If this is enabled, Bash, +when called as @code{rbash}, enters a restricted mode. See +@ref{The Restricted Shell}, for a description of restricted mode. + +@item --enable-select +Include the @code{select} compound command, which allows the generation of +simple menus (@pxref{Conditional Constructs}). + +@item --enable-separate-helpfiles +Use external files for the documentation displayed by the @code{help} builtin +instead of storing the text internally. + +@item --enable-single-help-strings +Store the text displayed by the @code{help} builtin as a single string for +each help topic. This aids in translating the text to different languages. +You may need to disable this if your compiler cannot handle very long string +literals. + +@item --enable-strict-posix-default +Make Bash @sc{posix}-conformant by default (@pxref{Bash POSIX Mode}). + +@item --enable-usg-echo-default +A synonym for @code{--enable-xpg-echo-default}. + +@item --enable-xpg-echo-default +Make the @code{echo} builtin expand backslash-escaped characters by default, +without requiring the @option{-e} option. +This sets the default value of the @code{xpg_echo} shell option to @code{on}, +which makes the Bash @code{echo} behave more like the version specified in +the Single Unix Specification, version 3. +@xref{Bash Builtins}, for a description of the escape sequences that +@code{echo} recognizes. +@end table + +The file @file{config-top.h} contains C Preprocessor +@samp{#define} statements for options which are not settable from +@code{configure}. +Some of these are not meant to be changed; beware of the consequences if +you do. +Read the comments associated with each definition for more +information about its effect. + +@node Reporting Bugs +@appendix Reporting Bugs + +Please report all bugs you find in Bash. +But first, you should +make sure that it really is a bug, and that it appears in the latest +version of Bash. +The latest version of Bash is always available for FTP from +@uref{ftp://ftp.gnu.org/pub/gnu/bash/}. + +Once you have determined that a bug actually exists, use the +@code{bashbug} command to submit a bug report. +If you have a fix, you are encouraged to mail that as well! +Suggestions and `philosophical' bug reports may be mailed +to @email{bug-bash@@gnu.org} or posted to the Usenet +newsgroup @code{gnu.bash.bug}. + +All bug reports should include: +@itemize @bullet +@item +The version number of Bash. +@item +The hardware and operating system. +@item +The compiler used to compile Bash. +@item +A description of the bug behaviour. +@item +A short script or `recipe' which exercises the bug and may be used +to reproduce it. +@end itemize + +@noindent +@code{bashbug} inserts the first three items automatically into +the template it provides for filing a bug report. + +Please send all reports concerning this manual to +@email{bug-bash@@gnu.org}. + +@node Major Differences From The Bourne Shell +@appendix Major Differences From The Bourne Shell + +Bash implements essentially the same grammar, parameter and +variable expansion, redirection, and quoting as the Bourne Shell. +Bash uses the @sc{posix} standard as the specification of +how these features are to be implemented. There are some +differences between the traditional Bourne shell and Bash; this +section quickly details the differences of significance. A +number of these differences are explained in greater depth in +previous sections. +This section uses the version of @code{sh} included in SVR4.2 (the +last version of the historical Bourne shell) as the baseline reference. + +@itemize @bullet + +@item +Bash is @sc{posix}-conformant, even where the @sc{posix} specification +differs from traditional @code{sh} behavior (@pxref{Bash POSIX Mode}). + +@item +Bash has multi-character invocation options (@pxref{Invoking Bash}). + +@item +Bash has command-line editing (@pxref{Command Line Editing}) and +the @code{bind} builtin. + +@item +Bash provides a programmable word completion mechanism +(@pxref{Programmable Completion}), and builtin commands +@code{complete}, @code{compgen}, and @code{compopt}, to +manipulate it. + +@item +Bash has command history (@pxref{Bash History Facilities}) and the +@code{history} and @code{fc} builtins to manipulate it. +The Bash history list maintains timestamp information and uses the +value of the @code{HISTTIMEFORMAT} variable to display it. + +@item +Bash implements @code{csh}-like history expansion +(@pxref{History Interaction}). + +@item +Bash has one-dimensional array variables (@pxref{Arrays}), and the +appropriate variable expansions and assignment syntax to use them. +Several of the Bash builtins take options to act on arrays. +Bash provides a number of built-in array variables. + +@item +The @code{$'@dots{}'} quoting syntax, which expands ANSI-C +backslash-escaped characters in the text between the single quotes, +is supported (@pxref{ANSI-C Quoting}). + +@item +Bash supports the @code{$"@dots{}"} quoting syntax to do +locale-specific translation of the characters between the double +quotes. The @option{-D}, @option{--dump-strings}, and @option{--dump-po-strings} +invocation options list the translatable strings found in a script +(@pxref{Locale Translation}). + +@item +Bash implements the @code{!} keyword to negate the return value of +a pipeline (@pxref{Pipelines}). +Very useful when an @code{if} statement needs to act only if a test fails. +The Bash @samp{-o pipefail} option to @code{set} will cause a pipeline to +return a failure status if any command fails. + +@item +Bash has the @code{time} reserved word and command timing (@pxref{Pipelines}). +The display of the timing statistics may be controlled with the +@env{TIMEFORMAT} variable. + +@item +Bash implements the @code{for (( @var{expr1} ; @var{expr2} ; @var{expr3} ))} +arithmetic for command, similar to the C language (@pxref{Looping Constructs}). + +@item +Bash includes the @code{select} compound command, which allows the +generation of simple menus (@pxref{Conditional Constructs}). + +@item +Bash includes the @code{[[} compound command, which makes conditional +testing part of the shell grammar (@pxref{Conditional Constructs}), including +optional regular expression matching. + +@item +Bash provides optional case-insensitive matching for the @code{case} and +@code{[[} constructs. + +@item +Bash includes brace expansion (@pxref{Brace Expansion}) and tilde +expansion (@pxref{Tilde Expansion}). + +@item +Bash implements command aliases and the @code{alias} and @code{unalias} +builtins (@pxref{Aliases}). + +@item +Bash provides shell arithmetic, the @code{((} compound command +(@pxref{Conditional Constructs}), +and arithmetic expansion (@pxref{Shell Arithmetic}). + +@item +Variables present in the shell's initial environment are automatically +exported to child processes. The Bourne shell does not normally do +this unless the variables are explicitly marked using the @code{export} +command. + +@item +Bash supports the @samp{+=} assignment operator, which appends to the value +of the variable named on the left hand side. + +@item +Bash includes the @sc{posix} pattern removal @samp{%}, @samp{#}, @samp{%%} +and @samp{##} expansions to remove leading or trailing substrings from +variable values (@pxref{Shell Parameter Expansion}). + +@item +The expansion @code{$@{#xx@}}, which returns the length of @code{$@{xx@}}, +is supported (@pxref{Shell Parameter Expansion}). + +@item +The expansion @code{$@{var:}@var{offset}@code{[:}@var{length}@code{]@}}, +which expands to the substring of @code{var}'s value of length +@var{length}, beginning at @var{offset}, is present +(@pxref{Shell Parameter Expansion}). + +@item +The expansion +@code{$@{var/[/]}@var{pattern}@code{[/}@var{replacement}@code{]@}}, +which matches @var{pattern} and replaces it with @var{replacement} in +the value of @code{var}, is available (@pxref{Shell Parameter Expansion}). + +@item +The expansion @code{$@{!@var{prefix}*@}} expansion, which expands to +the names of all shell variables whose names begin with @var{prefix}, +is available (@pxref{Shell Parameter Expansion}). + +@item +Bash has @var{indirect} variable expansion using @code{$@{!word@}} +(@pxref{Shell Parameter Expansion}). + +@item +Bash can expand positional parameters beyond @code{$9} using +@code{$@{@var{num}@}}. + +@item +The @sc{posix} @code{$()} form of command substitution +is implemented (@pxref{Command Substitution}), +and preferred to the Bourne shell's @code{``} (which +is also implemented for backwards compatibility). + +@item +Bash has process substitution (@pxref{Process Substitution}). + +@item +Bash automatically assigns variables that provide information about the +current user (@env{UID}, @env{EUID}, and @env{GROUPS}), the current host +(@env{HOSTTYPE}, @env{OSTYPE}, @env{MACHTYPE}, and @env{HOSTNAME}), +and the instance of Bash that is running (@env{BASH}, +@env{BASH_VERSION}, and @env{BASH_VERSINFO}). @xref{Bash Variables}, +for details. + +@item +The @env{IFS} variable is used to split only the results of expansion, +not all words (@pxref{Word Splitting}). +This closes a longstanding shell security hole. + +@item +The filename expansion bracket expression code uses @samp{!} and @samp{^} +to negate the set of characters between the brackets. +The Bourne shell uses only @samp{!}. + +@item +Bash implements the full set of @sc{posix} filename expansion operators, +including @var{character classes}, @var{equivalence classes}, and +@var{collating symbols} (@pxref{Filename Expansion}). + +@item +Bash implements extended pattern matching features when the @code{extglob} +shell option is enabled (@pxref{Pattern Matching}). + +@item +It is possible to have a variable and a function with the same name; +@code{sh} does not separate the two name spaces. + +@item +Bash functions are permitted to have local variables using the +@code{local} builtin, and thus useful recursive functions may be written +(@pxref{Bash Builtins}). + +@item +Variable assignments preceding commands affect only that command, even +builtins and functions (@pxref{Environment}). +In @code{sh}, all variable assignments +preceding commands are global unless the command is executed from the +file system. + +@item +Bash performs filename expansion on filenames specified as operands +to input and output redirection operators (@pxref{Redirections}). + +@item +Bash contains the @samp{<>} redirection operator, allowing a file to be +opened for both reading and writing, and the @samp{&>} redirection +operator, for directing standard output and standard error to the same +file (@pxref{Redirections}). + +@item +Bash includes the @samp{<<<} redirection operator, allowing a string to +be used as the standard input to a command. + +@item +Bash implements the @samp{[n]<&@var{word}} and @samp{[n]>&@var{word}} +redirection operators, which move one file descriptor to another. + +@item +Bash treats a number of filenames specially when they are +used in redirection operators (@pxref{Redirections}). + +@item +Bash can open network connections to arbitrary machines and services +with the redirection operators (@pxref{Redirections}). + +@item +The @code{noclobber} option is available to avoid overwriting existing +files with output redirection (@pxref{The Set Builtin}). +The @samp{>|} redirection operator may be used to override @code{noclobber}. + +@item +The Bash @code{cd} and @code{pwd} builtins (@pxref{Bourne Shell Builtins}) +each take @option{-L} and @option{-P} options to switch between logical and +physical modes. + +@item +Bash allows a function to override a builtin with the same name, and provides +access to that builtin's functionality within the function via the +@code{builtin} and @code{command} builtins (@pxref{Bash Builtins}). + +@item +The @code{command} builtin allows selective disabling of functions +when command lookup is performed (@pxref{Bash Builtins}). + +@item +Individual builtins may be enabled or disabled using the @code{enable} +builtin (@pxref{Bash Builtins}). + +@item +The Bash @code{exec} builtin takes additional options that allow users +to control the contents of the environment passed to the executed +command, and what the zeroth argument to the command is to be +(@pxref{Bourne Shell Builtins}). + +@item +Shell functions may be exported to children via the environment +using @code{export -f} (@pxref{Shell Functions}). + +@item +The Bash @code{export}, @code{readonly}, and @code{declare} builtins can +take a @option{-f} option to act on shell functions, a @option{-p} option to +display variables with various attributes set in a format that can be +used as shell input, a @option{-n} option to remove various variable +attributes, and @samp{name=value} arguments to set variable attributes +and values simultaneously. + +@item +The Bash @code{hash} builtin allows a name to be associated with +an arbitrary filename, even when that filename cannot be found by +searching the @env{$PATH}, using @samp{hash -p} +(@pxref{Bourne Shell Builtins}). + +@item +Bash includes a @code{help} builtin for quick reference to shell +facilities (@pxref{Bash Builtins}). + +@item +The @code{printf} builtin is available to display formatted output +(@pxref{Bash Builtins}). + +@item +The Bash @code{read} builtin (@pxref{Bash Builtins}) +will read a line ending in @samp{\} with +the @option{-r} option, and will use the @env{REPLY} variable as a +default if no non-option arguments are supplied. +The Bash @code{read} builtin +also accepts a prompt string with the @option{-p} option and will use +Readline to obtain the line when given the @option{-e} option. +The @code{read} builtin also has additional options to control input: +the @option{-s} option will turn off echoing of input characters as +they are read, the @option{-t} option will allow @code{read} to time out +if input does not arrive within a specified number of seconds, the +@option{-n} option will allow reading only a specified number of +characters rather than a full line, and the @option{-d} option will read +until a particular character rather than newline. + +@item +The @code{return} builtin may be used to abort execution of scripts +executed with the @code{.} or @code{source} builtins +(@pxref{Bourne Shell Builtins}). + +@item +Bash includes the @code{shopt} builtin, for finer control of shell +optional capabilities (@pxref{The Shopt Builtin}), and allows these options +to be set and unset at shell invocation (@pxref{Invoking Bash}). + +@item +Bash has much more optional behavior controllable with the @code{set} +builtin (@pxref{The Set Builtin}). + +@item +The @samp{-x} (@option{xtrace}) option displays commands other than +simple commands when performing an execution trace +(@pxref{The Set Builtin}). + +@item +The @code{test} builtin (@pxref{Bourne Shell Builtins}) +is slightly different, as it implements the @sc{posix} algorithm, +which specifies the behavior based on the number of arguments. + +@item +Bash includes the @code{caller} builtin, which displays the context of +any active subroutine call (a shell function or a script executed with +the @code{.} or @code{source} builtins). This supports the bash +debugger. + +@item +The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows a +@code{DEBUG} pseudo-signal specification, similar to @code{EXIT}. +Commands specified with a @code{DEBUG} trap are executed before every +simple command, @code{for} command, @code{case} command, +@code{select} command, every arithmetic @code{for} command, and before +the first command executes in a shell function. +The @code{DEBUG} trap is not inherited by shell functions unless the +function has been given the @code{trace} attribute or the +@code{functrace} option has been enabled using the @code{shopt} builtin. +The @code{extdebug} shell option has additional effects on the +@code{DEBUG} trap. + +The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows an +@code{ERR} pseudo-signal specification, similar to @code{EXIT} and @code{DEBUG}. +Commands specified with an @code{ERR} trap are executed after a simple +command fails, with a few exceptions. +The @code{ERR} trap is not inherited by shell functions unless the +@code{-o errtrace} option to the @code{set} builtin is enabled. + +The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows a +@code{RETURN} pseudo-signal specification, similar to +@code{EXIT} and @code{DEBUG}. +Commands specified with an @code{RETURN} trap are executed before +execution resumes after a shell function or a shell script executed with +@code{.} or @code{source} returns. +The @code{RETURN} trap is not inherited by shell functions unless the +function has been given the @code{trace} attribute or the +@code{functrace} option has been enabled using the @code{shopt} builtin. + +@item +The Bash @code{type} builtin is more extensive and gives more information +about the names it finds (@pxref{Bash Builtins}). + +@item +The Bash @code{umask} builtin permits a @option{-p} option to cause +the output to be displayed in the form of a @code{umask} command +that may be reused as input (@pxref{Bourne Shell Builtins}). + +@item +Bash implements a @code{csh}-like directory stack, and provides the +@code{pushd}, @code{popd}, and @code{dirs} builtins to manipulate it +(@pxref{The Directory Stack}). +Bash also makes the directory stack visible as the value of the +@env{DIRSTACK} shell variable. + +@item +Bash interprets special backslash-escaped characters in the prompt +strings when interactive (@pxref{Controlling the Prompt}). + +@item +The Bash restricted mode is more useful (@pxref{The Restricted Shell}); +the SVR4.2 shell restricted mode is too limited. + +@item +The @code{disown} builtin can remove a job from the internal shell +job table (@pxref{Job Control Builtins}) or suppress the sending +of @code{SIGHUP} to a job when the shell exits as the result of a +@code{SIGHUP}. + +@item +Bash includes a number of features to support a separate debugger for +shell scripts. + +@item +The SVR4.2 shell has two privilege-related builtins +(@code{mldmode} and @code{priv}) not present in Bash. + +@item +Bash does not have the @code{stop} or @code{newgrp} builtins. + +@item +Bash does not use the @env{SHACCT} variable or perform shell accounting. + +@item +The SVR4.2 @code{sh} uses a @env{TIMEOUT} variable like Bash uses +@env{TMOUT}. + +@end itemize + +@noindent +More features unique to Bash may be found in @ref{Bash Features}. + + +@appendixsec Implementation Differences From The SVR4.2 Shell + +Since Bash is a completely new implementation, it does not suffer from +many of the limitations of the SVR4.2 shell. For instance: + +@itemize @bullet + +@item +Bash does not fork a subshell when redirecting into or out of +a shell control structure such as an @code{if} or @code{while} +statement. + +@item +Bash does not allow unbalanced quotes. The SVR4.2 shell will silently +insert a needed closing quote at @code{EOF} under certain circumstances. +This can be the cause of some hard-to-find errors. + +@item +The SVR4.2 shell uses a baroque memory management scheme based on +trapping @code{SIGSEGV}. If the shell is started from a process with +@code{SIGSEGV} blocked (e.g., by using the @code{system()} C library +function call), it misbehaves badly. + +@item +In a questionable attempt at security, the SVR4.2 shell, +when invoked without the @option{-p} option, will alter its real +and effective @sc{uid} and @sc{gid} if they are less than some +magic threshold value, commonly 100. +This can lead to unexpected results. + +@item +The SVR4.2 shell does not allow users to trap @code{SIGSEGV}, +@code{SIGALRM}, or @code{SIGCHLD}. + +@item +The SVR4.2 shell does not allow the @env{IFS}, @env{MAILCHECK}, +@env{PATH}, @env{PS1}, or @env{PS2} variables to be unset. + +@item +The SVR4.2 shell treats @samp{^} as the undocumented equivalent of +@samp{|}. + +@item +Bash allows multiple option arguments when it is invoked (@code{-x -v}); +the SVR4.2 shell allows only one option argument (@code{-xv}). In +fact, some versions of the shell dump core if the second argument begins +with a @samp{-}. + +@item +The SVR4.2 shell exits a script if any builtin fails; Bash exits +a script only if one of the @sc{posix} special builtins fails, and +only for certain failures, as enumerated in the @sc{posix} standard. + +@item +The SVR4.2 shell behaves differently when invoked as @code{jsh} +(it turns on job control). +@end itemize + +@node GNU Free Documentation License +@appendix GNU Free Documentation License + +@include fdl.texi + +@node Indexes +@appendix Indexes + +@menu +* Builtin Index:: Index of Bash builtin commands. +* Reserved Word Index:: Index of Bash reserved words. +* Variable Index:: Quick reference helps you find the + variable you want. +* Function Index:: Index of bindable Readline functions. +* Concept Index:: General index for concepts described in + this manual. +@end menu + +@node Builtin Index +@appendixsec Index of Shell Builtin Commands +@printindex bt + +@node Reserved Word Index +@appendixsec Index of Shell Reserved Words +@printindex rw + +@node Variable Index +@appendixsec Parameter and Variable Index +@printindex vr + +@node Function Index +@appendixsec Function Index +@printindex fn + +@node Concept Index +@appendixsec Concept Index +@printindex cp + +@bye diff --git a/doc/version.texi b/doc/version.texi index 40a779860..6e113d484 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -2,9 +2,9 @@ Copyright (C) 1988-2012 Free Software Foundation, Inc. @end ignore -@set LASTCHANGE Sat Nov 24 15:06:49 EST 2012 +@set LASTCHANGE Sat Dec 15 17:49:50 EST 2012 @set EDITION 4.2 @set VERSION 4.2 -@set UPDATED 24 November 2012 -@set UPDATED-MONTH November 2012 +@set UPDATED 15 December 2012 +@set UPDATED-MONTH December 2012 diff --git a/doc/version.texi~ b/doc/version.texi~ new file mode 100644 index 000000000..baa4f3ac4 --- /dev/null +++ b/doc/version.texi~ @@ -0,0 +1,10 @@ +@ignore +Copyright (C) 1988-2012 Free Software Foundation, Inc. +@end ignore + +@set LASTCHANGE Fri Dec 14 10:13:02 EST 2012 + +@set EDITION 4.2 +@set VERSION 4.2 +@set UPDATED 14 December 2012 +@set UPDATED-MONTH December 2012 diff --git a/execute_cmd.c b/execute_cmd.c index 70a37451a..98dad0242 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -224,6 +224,10 @@ int last_command_exit_value; was terminated by a signal, and, if so, which one. */ int last_command_exit_signal; +/* Are we currently ignoring the -e option for the duration of a builtin's + execution? */ +int builtin_ignoring_errexit = 0; + /* The list of redirections to perform which will undo the redirections that I made in the shell. */ REDIRECT *redirection_undo_list = (REDIRECT *)NULL; @@ -2160,7 +2164,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close) int pipe_in, pipe_out; struct fd_bitmap *fds_to_close; { - int rpipe[2], wpipe[2], estat; + int rpipe[2], wpipe[2], estat, invert; pid_t coproc_pid; Coproc *cp; char *tcmd; @@ -2173,6 +2177,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close) coproc_init (&sh_coproc); #endif + invert = (command->flags & CMD_INVERT_RETURN) != 0; command_string_index = 0; tcmd = make_command_string (command); @@ -2224,7 +2229,7 @@ execute_coproc (command, pipe_in, pipe_out, fds_to_close) DESCRIBE_PID (coproc_pid); run_pending_traps (); - return (EXECUTION_SUCCESS); + return (invert ? EXECUTION_FAILURE : EXECUTION_SUCCESS); } #endif @@ -4219,6 +4224,7 @@ execute_builtin (builtin, words, flags, subshell) error_trap = 0; old_e_flag = exit_immediately_on_error; + /* The eval builtin calls parse_and_execute, which does not know about the setting of flags, and always calls the execution functions with flags that will exit the shell on an error if -e is set. If the @@ -4231,6 +4237,7 @@ execute_builtin (builtin, words, flags, subshell) { begin_unwind_frame ("eval_builtin"); unwind_protect_int (exit_immediately_on_error); + unwind_protect_int (builtin_ignoring_errexit); error_trap = TRAP_STRING (ERROR_TRAP); if (error_trap) { @@ -4240,6 +4247,7 @@ execute_builtin (builtin, words, flags, subshell) restore_default_signal (ERROR_TRAP); } exit_immediately_on_error = 0; + builtin_ignoring_errexit = 1; eval_unwind = 1; } else @@ -4289,7 +4297,8 @@ execute_builtin (builtin, words, flags, subshell) if (eval_unwind) { - exit_immediately_on_error += old_e_flag; + exit_immediately_on_error = errexit_flag; + builtin_ignoring_errexit = 0; if (error_trap) { set_error_trap (error_trap); diff --git a/execute_cmd.c~ b/execute_cmd.c~ new file mode 100644 index 000000000..2c0d22cb8 --- /dev/null +++ b/execute_cmd.c~ @@ -0,0 +1,5393 @@ +/* execute_cmd.c -- Execute a COMMAND structure. */ + +/* Copyright (C) 1987-2012 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see . +*/ + +#include "config.h" + +#if !defined (__GNUC__) && !defined (HAVE_ALLOCA_H) && defined (_AIX) + #pragma alloca +#endif /* _AIX && RISC6000 && !__GNUC__ */ + +#include +#include "chartypes.h" +#include "bashtypes.h" +#if !defined (_MINIX) && defined (HAVE_SYS_FILE_H) +# include +#endif +#include "filecntl.h" +#include "posixstat.h" +#include +#if defined (HAVE_SYS_PARAM_H) +# include +#endif + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "posixtime.h" + +#if defined (HAVE_SYS_RESOURCE_H) && !defined (RLIMTYPE) +# include +#endif + +#if defined (HAVE_SYS_TIMES_H) && defined (HAVE_TIMES) +# include +#endif + +#include + +#if !defined (errno) +extern int errno; +#endif + +#define NEED_FPURGE_DECL + +#include "bashansi.h" +#include "bashintl.h" + +#include "memalloc.h" +#include "shell.h" +#include /* use <...> so we pick it up from the build directory */ +#include "flags.h" +#include "builtins.h" +#include "hashlib.h" +#include "jobs.h" +#include "execute_cmd.h" +#include "findcmd.h" +#include "redir.h" +#include "trap.h" +#include "pathexp.h" +#include "hashcmd.h" + +#if defined (COND_COMMAND) +# include "test.h" +#endif + +#include "builtins/common.h" +#include "builtins/builtext.h" /* list of builtins */ + +#include +#include + +#if defined (BUFFERED_INPUT) +# include "input.h" +#endif + +#if defined (ALIAS) +# include "alias.h" +#endif + +#if defined (HISTORY) +# include "bashhist.h" +#endif + +extern int dollar_dollar_pid; +extern int posixly_correct; +extern int expand_aliases; +extern int autocd; +extern int breaking, continuing, loop_level; +extern int parse_and_execute_level, running_trap, sourcelevel; +extern int command_string_index, line_number; +extern int dot_found_in_search; +extern int already_making_children; +extern int tempenv_assign_error; +extern char *the_printed_command, *shell_name; +extern pid_t last_command_subst_pid; +extern sh_builtin_func_t *last_shell_builtin, *this_shell_builtin; +extern char **subshell_argv, **subshell_envp; +extern int subshell_argc; +extern time_t shell_start_time; +#if 0 +extern char *glob_argv_flags; +#endif + +extern int job_control; /* XXX */ + +extern int close __P((int)); + +/* Static functions defined and used in this file. */ +static void close_pipes __P((int, int)); +static void do_piping __P((int, int)); +static void bind_lastarg __P((char *)); +static int shell_control_structure __P((enum command_type)); +static void cleanup_redirects __P((REDIRECT *)); + +#if defined (JOB_CONTROL) +static int restore_signal_mask __P((sigset_t *)); +#endif + +static void async_redirect_stdin __P((void)); + +static int builtin_status __P((int)); + +static int execute_for_command __P((FOR_COM *)); +#if defined (SELECT_COMMAND) +static int displen __P((const char *)); +static int print_index_and_element __P((int, int, WORD_LIST *)); +static void indent __P((int, int)); +static void print_select_list __P((WORD_LIST *, int, int, int)); +static char *select_query __P((WORD_LIST *, int, char *, int)); +static int execute_select_command __P((SELECT_COM *)); +#endif +#if defined (DPAREN_ARITHMETIC) +static int execute_arith_command __P((ARITH_COM *)); +#endif +#if defined (COND_COMMAND) +static int execute_cond_node __P((COND_COM *)); +static int execute_cond_command __P((COND_COM *)); +#endif +#if defined (COMMAND_TIMING) +static int mkfmt __P((char *, int, int, time_t, int)); +static void print_formatted_time __P((FILE *, char *, + time_t, int, time_t, int, + time_t, int, int)); +static int time_command __P((COMMAND *, int, int, int, struct fd_bitmap *)); +#endif +#if defined (ARITH_FOR_COMMAND) +static intmax_t eval_arith_for_expr __P((WORD_LIST *, int *)); +static int execute_arith_for_command __P((ARITH_FOR_COM *)); +#endif +static int execute_case_command __P((CASE_COM *)); +static int execute_while_command __P((WHILE_COM *)); +static int execute_until_command __P((WHILE_COM *)); +static int execute_while_or_until __P((WHILE_COM *, int)); +static int execute_if_command __P((IF_COM *)); +static int execute_null_command __P((REDIRECT *, int, int, int)); +static void fix_assignment_words __P((WORD_LIST *)); +static int execute_simple_command __P((SIMPLE_COM *, int, int, int, struct fd_bitmap *)); +static int execute_builtin __P((sh_builtin_func_t *, WORD_LIST *, int, int)); +static int execute_function __P((SHELL_VAR *, WORD_LIST *, int, struct fd_bitmap *, int, int)); +static int execute_builtin_or_function __P((WORD_LIST *, sh_builtin_func_t *, + SHELL_VAR *, + REDIRECT *, struct fd_bitmap *, int)); +static void execute_subshell_builtin_or_function __P((WORD_LIST *, REDIRECT *, + sh_builtin_func_t *, + SHELL_VAR *, + int, int, int, + struct fd_bitmap *, + int)); +static int execute_disk_command __P((WORD_LIST *, REDIRECT *, char *, + int, int, int, struct fd_bitmap *, int)); + +static char *getinterp __P((char *, int, int *)); +static void initialize_subshell __P((void)); +static int execute_in_subshell __P((COMMAND *, int, int, int, struct fd_bitmap *)); +#if defined (COPROCESS_SUPPORT) +static int execute_coproc __P((COMMAND *, int, int, struct fd_bitmap *)); +#endif + +static int execute_pipeline __P((COMMAND *, int, int, int, struct fd_bitmap *)); + +static int execute_connection __P((COMMAND *, int, int, int, struct fd_bitmap *)); + +static int execute_intern_function __P((WORD_DESC *, FUNCTION_DEF *)); + +/* Set to 1 if fd 0 was the subject of redirection to a subshell. Global + so that reader_loop can set it to zero before executing a command. */ +int stdin_redir; + +/* The name of the command that is currently being executed. + `test' needs this, for example. */ +char *this_command_name; + +/* The printed representation of the currently-executing command (same as + the_printed_command), except when a trap is being executed. Useful for + a debugger to know where exactly the program is currently executing. */ +char *the_printed_command_except_trap; + +/* For catching RETURN in a function. */ +int return_catch_flag; +int return_catch_value; +procenv_t return_catch; + +/* The value returned by the last synchronous command. */ +int last_command_exit_value; + +/* Whether or not the last command (corresponding to last_command_exit_value) + was terminated by a signal, and, if so, which one. */ +int last_command_exit_signal; + +/* Are we currently ignoring the -e option for the duration of a builtin's + execution? */ +int builtin_ignoring_errexit; + +/* The list of redirections to perform which will undo the redirections + that I made in the shell. */ +REDIRECT *redirection_undo_list = (REDIRECT *)NULL; + +/* The list of redirections to perform which will undo the internal + redirections performed by the `exec' builtin. These are redirections + that must be undone even when exec discards redirection_undo_list. */ +REDIRECT *exec_redirection_undo_list = (REDIRECT *)NULL; + +/* When greater than zero, value is the `level' of builtins we are + currently executing (e.g. `eval echo a' would have it set to 2). */ +int executing_builtin = 0; + +/* Non-zero if we are executing a command list (a;b;c, etc.) */ +int executing_list = 0; + +/* Non-zero if failing commands in a command substitution should not exit the + shell even if -e is set. Used to pass the CMD_IGNORE_RETURN flag down to + commands run in command substitutions by parse_and_execute. */ +int comsub_ignore_return = 0; + +/* Non-zero if we have just forked and are currently running in a subshell + environment. */ +int subshell_environment; + +/* Count of nested subshells, like SHLVL. Available via $BASH_SUBSHELL */ +int subshell_level = 0; + +/* Currently-executing shell function. */ +SHELL_VAR *this_shell_function; + +/* If non-zero, matches in case and [[ ... ]] are case-insensitive */ +int match_ignore_case = 0; + +int executing_command_builtin = 0; + +struct stat SB; /* used for debugging */ + +static int special_builtin_failed; + +static COMMAND *currently_executing_command; + +/* The line number that the currently executing function starts on. */ +static int function_line_number; + +/* XXX - set to 1 if we're running the DEBUG trap and we want to show the line + number containing the function name. Used by executing_line_number to + report the correct line number. Kind of a hack. */ +static int showing_function_line; + +/* $LINENO ($BASH_LINENO) for use by an ERR trap. Global so parse_and_execute + can save and restore it. */ +int line_number_for_err_trap; + +/* A sort of function nesting level counter */ +int funcnest = 0; +int funcnest_max = 0; /* XXX - bash-4.2 */ + +int lastpipe_opt = 0; + +struct fd_bitmap *current_fds_to_close = (struct fd_bitmap *)NULL; + +#define FD_BITMAP_DEFAULT_SIZE 32 + +/* Functions to allocate and deallocate the structures used to pass + information from the shell to its children about file descriptors + to close. */ +struct fd_bitmap * +new_fd_bitmap (size) + int size; +{ + struct fd_bitmap *ret; + + ret = (struct fd_bitmap *)xmalloc (sizeof (struct fd_bitmap)); + + ret->size = size; + + if (size) + { + ret->bitmap = (char *)xmalloc (size); + memset (ret->bitmap, '\0', size); + } + else + ret->bitmap = (char *)NULL; + return (ret); +} + +void +dispose_fd_bitmap (fdbp) + struct fd_bitmap *fdbp; +{ + FREE (fdbp->bitmap); + free (fdbp); +} + +void +close_fd_bitmap (fdbp) + struct fd_bitmap *fdbp; +{ + register int i; + + if (fdbp) + { + for (i = 0; i < fdbp->size; i++) + if (fdbp->bitmap[i]) + { + close (i); + fdbp->bitmap[i] = 0; + } + } +} + +/* Return the line number of the currently executing command. */ +int +executing_line_number () +{ + if (executing && showing_function_line == 0 && + (variable_context == 0 || interactive_shell == 0) && + currently_executing_command) + { +#if defined (COND_COMMAND) + if (currently_executing_command->type == cm_cond) + return currently_executing_command->value.Cond->line; +#endif +#if defined (DPAREN_ARITHMETIC) + else if (currently_executing_command->type == cm_arith) + return currently_executing_command->value.Arith->line; +#endif +#if defined (ARITH_FOR_COMMAND) + else if (currently_executing_command->type == cm_arith_for) + return currently_executing_command->value.ArithFor->line; +#endif + + return line_number; + } + else + return line_number; +} + +/* Execute the command passed in COMMAND. COMMAND is exactly what + read_command () places into GLOBAL_COMMAND. See "command.h" for the + details of the command structure. + + EXECUTION_SUCCESS or EXECUTION_FAILURE are the only possible + return values. Executing a command with nothing in it returns + EXECUTION_SUCCESS. */ +int +execute_command (command) + COMMAND *command; +{ + struct fd_bitmap *bitmap; + int result; + + current_fds_to_close = (struct fd_bitmap *)NULL; + bitmap = new_fd_bitmap (FD_BITMAP_DEFAULT_SIZE); + begin_unwind_frame ("execute-command"); + add_unwind_protect (dispose_fd_bitmap, (char *)bitmap); + + /* Just do the command, but not asynchronously. */ + result = execute_command_internal (command, 0, NO_PIPE, NO_PIPE, bitmap); + + dispose_fd_bitmap (bitmap); + discard_unwind_frame ("execute-command"); + +#if defined (PROCESS_SUBSTITUTION) + /* don't unlink fifos if we're in a shell function; wait until the function + returns. */ + if (variable_context == 0) + unlink_fifo_list (); +#endif /* PROCESS_SUBSTITUTION */ + + QUIT; + return (result); +} + +/* Return 1 if TYPE is a shell control structure type. */ +static int +shell_control_structure (type) + enum command_type type; +{ + switch (type) + { +#if defined (ARITH_FOR_COMMAND) + case cm_arith_for: +#endif +#if defined (SELECT_COMMAND) + case cm_select: +#endif +#if defined (DPAREN_ARITHMETIC) + case cm_arith: +#endif +#if defined (COND_COMMAND) + case cm_cond: +#endif + case cm_case: + case cm_while: + case cm_until: + case cm_if: + case cm_for: + case cm_group: + case cm_function_def: + return (1); + + default: + return (0); + } +} + +/* A function to use to unwind_protect the redirection undo list + for loops. */ +static void +cleanup_redirects (list) + REDIRECT *list; +{ + do_redirections (list, RX_ACTIVE); + dispose_redirects (list); +} + +#if 0 +/* Function to unwind_protect the redirections for functions and builtins. */ +static void +cleanup_func_redirects (list) + REDIRECT *list; +{ + do_redirections (list, RX_ACTIVE); +} +#endif + +void +dispose_exec_redirects () +{ + if (exec_redirection_undo_list) + { + dispose_redirects (exec_redirection_undo_list); + exec_redirection_undo_list = (REDIRECT *)NULL; + } +} + +#if defined (JOB_CONTROL) +/* A function to restore the signal mask to its proper value when the shell + is interrupted or errors occur while creating a pipeline. */ +static int +restore_signal_mask (set) + sigset_t *set; +{ + return (sigprocmask (SIG_SETMASK, set, (sigset_t *)NULL)); +} +#endif /* JOB_CONTROL */ + +#ifdef DEBUG +/* A debugging function that can be called from gdb, for instance. */ +void +open_files () +{ + register int i; + int f, fd_table_size; + + fd_table_size = getdtablesize (); + + fprintf (stderr, "pid %ld open files:", (long)getpid ()); + for (i = 3; i < fd_table_size; i++) + { + if ((f = fcntl (i, F_GETFD, 0)) != -1) + fprintf (stderr, " %d (%s)", i, f ? "close" : "open"); + } + fprintf (stderr, "\n"); +} +#endif + +static void +async_redirect_stdin () +{ + int fd; + + fd = open ("/dev/null", O_RDONLY); + if (fd > 0) + { + dup2 (fd, 0); + close (fd); + } + else if (fd < 0) + internal_error (_("cannot redirect standard input from /dev/null: %s"), strerror (errno)); +} + +#define DESCRIBE_PID(pid) do { if (interactive) describe_pid (pid); } while (0) + +/* Execute the command passed in COMMAND, perhaps doing it asynchrounously. + COMMAND is exactly what read_command () places into GLOBAL_COMMAND. + ASYNCHROUNOUS, if non-zero, says to do this command in the background. + PIPE_IN and PIPE_OUT are file descriptors saying where input comes + from and where it goes. They can have the value of NO_PIPE, which means + I/O is stdin/stdout. + FDS_TO_CLOSE is a list of file descriptors to close once the child has + been forked. This list often contains the unusable sides of pipes, etc. + + EXECUTION_SUCCESS or EXECUTION_FAILURE are the only possible + return values. Executing a command with nothing in it returns + EXECUTION_SUCCESS. */ +int +execute_command_internal (command, asynchronous, pipe_in, pipe_out, + fds_to_close) + COMMAND *command; + int asynchronous; + int pipe_in, pipe_out; + struct fd_bitmap *fds_to_close; +{ + int exec_result, user_subshell, invert, ignore_return, was_error_trap; + REDIRECT *my_undo_list, *exec_undo_list; + char *tcmd; + volatile int last_pid; + volatile int save_line_number; +#if defined (PROCESS_SUBSTITUTION) + volatile int ofifo, nfifo, osize, saved_fifo; + volatile char *ofifo_list; +#endif + + if (breaking || continuing) + return (last_command_exit_value); + if (command == 0 || read_but_dont_execute) + return (EXECUTION_SUCCESS); + + QUIT; + run_pending_traps (); + +#if 0 + if (running_trap == 0) +#endif + currently_executing_command = command; + + invert = (command->flags & CMD_INVERT_RETURN) != 0; + + /* If we're inverting the return value and `set -e' has been executed, + we don't want a failing command to inadvertently cause the shell + to exit. */ + if (exit_immediately_on_error && invert) /* XXX */ + command->flags |= CMD_IGNORE_RETURN; /* XXX */ + + exec_result = EXECUTION_SUCCESS; + + /* If a command was being explicitly run in a subshell, or if it is + a shell control-structure, and it has a pipe, then we do the command + in a subshell. */ + if (command->type == cm_subshell && (command->flags & CMD_NO_FORK)) + return (execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)); + +#if defined (COPROCESS_SUPPORT) + if (command->type == cm_coproc) + return (execute_coproc (command, pipe_in, pipe_out, fds_to_close)); +#endif + + user_subshell = command->type == cm_subshell || ((command->flags & CMD_WANT_SUBSHELL) != 0); + + if (command->type == cm_subshell || + (command->flags & (CMD_WANT_SUBSHELL|CMD_FORCE_SUBSHELL)) || + (shell_control_structure (command->type) && + (pipe_out != NO_PIPE || pipe_in != NO_PIPE || asynchronous))) + { + pid_t paren_pid; + int s; + + /* Fork a subshell, turn off the subshell bit, turn off job + control and call execute_command () on the command again. */ + line_number_for_err_trap = line_number; + tcmd = make_command_string (command); + paren_pid = make_child (savestring (tcmd), asynchronous); + + if (user_subshell && signal_is_trapped (ERROR_TRAP) && + signal_in_progress (DEBUG_TRAP) == 0 && running_trap == 0) + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } + + if (paren_pid == 0) + { + /* We want to run the exit trap for forced {} subshells, and we + want to note this before execute_in_subshell modifies the + COMMAND struct. Need to keep in mind that execute_in_subshell + runs the exit trap for () subshells itself. */ + s = user_subshell == 0 && command->type == cm_group && pipe_in == NO_PIPE && pipe_out == NO_PIPE && asynchronous; + + last_command_exit_value = execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close); + if (s) + subshell_exit (last_command_exit_value); + else + exit (last_command_exit_value); + /* NOTREACHED */ + } + else + { + close_pipes (pipe_in, pipe_out); + +#if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD) + if (variable_context == 0) /* wait until shell function completes */ + unlink_fifo_list (); +#endif + /* If we are part of a pipeline, and not the end of the pipeline, + then we should simply return and let the last command in the + pipe be waited for. If we are not in a pipeline, or are the + last command in the pipeline, then we wait for the subshell + and return its exit status as usual. */ + if (pipe_out != NO_PIPE) + return (EXECUTION_SUCCESS); + + stop_pipeline (asynchronous, (COMMAND *)NULL); + + if (asynchronous == 0) + { + was_error_trap = signal_is_trapped (ERROR_TRAP) && signal_is_ignored (ERROR_TRAP) == 0; + invert = (command->flags & CMD_INVERT_RETURN) != 0; + ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0; + + exec_result = wait_for (paren_pid); + + /* If we have to, invert the return value. */ + if (invert) + exec_result = ((exec_result == EXECUTION_SUCCESS) + ? EXECUTION_FAILURE + : EXECUTION_SUCCESS); + + last_command_exit_value = exec_result; + if (user_subshell && was_error_trap && ignore_return == 0 && invert == 0 && exec_result != EXECUTION_SUCCESS) + { + save_line_number = line_number; + line_number = line_number_for_err_trap; + run_error_trap (); + line_number = save_line_number; + } + + if (user_subshell && ignore_return == 0 && invert == 0 && exit_immediately_on_error && exec_result != EXECUTION_SUCCESS) + { + run_pending_traps (); + jump_to_top_level (ERREXIT); + } + + return (last_command_exit_value); + } + else + { + DESCRIBE_PID (paren_pid); + + run_pending_traps (); + + return (EXECUTION_SUCCESS); + } + } + } + +#if defined (COMMAND_TIMING) + if (command->flags & CMD_TIME_PIPELINE) + { + if (asynchronous) + { + command->flags |= CMD_FORCE_SUBSHELL; + exec_result = execute_command_internal (command, 1, pipe_in, pipe_out, fds_to_close); + } + else + { + exec_result = time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close); +#if 0 + if (running_trap == 0) +#endif + currently_executing_command = (COMMAND *)NULL; + } + return (exec_result); + } +#endif /* COMMAND_TIMING */ + + if (shell_control_structure (command->type) && command->redirects) + stdin_redir = stdin_redirects (command->redirects); + +#if defined (PROCESS_SUBSTITUTION) + if (variable_context != 0) + { + ofifo = num_fifos (); + ofifo_list = copy_fifo_list ((int *)&osize); + saved_fifo = 1; + } + else + saved_fifo = 0; +#endif + + /* Handle WHILE FOR CASE etc. with redirections. (Also '&' input + redirection.) */ + if (do_redirections (command->redirects, RX_ACTIVE|RX_UNDOABLE) != 0) + { + cleanup_redirects (redirection_undo_list); + redirection_undo_list = (REDIRECT *)NULL; + dispose_exec_redirects (); +#if defined (PROCESS_SUBSTITUTION) + if (saved_fifo) + free ((void *)ofifo_list); +#endif + return (last_command_exit_value = EXECUTION_FAILURE); + } + + if (redirection_undo_list) + { + /* XXX - why copy here? */ + my_undo_list = (REDIRECT *)copy_redirects (redirection_undo_list); + dispose_redirects (redirection_undo_list); + redirection_undo_list = (REDIRECT *)NULL; + } + else + my_undo_list = (REDIRECT *)NULL; + + if (exec_redirection_undo_list) + { + /* XXX - why copy here? */ + exec_undo_list = (REDIRECT *)copy_redirects (exec_redirection_undo_list); + dispose_redirects (exec_redirection_undo_list); + exec_redirection_undo_list = (REDIRECT *)NULL; + } + else + exec_undo_list = (REDIRECT *)NULL; + + if (my_undo_list || exec_undo_list) + begin_unwind_frame ("loop_redirections"); + + if (my_undo_list) + add_unwind_protect ((Function *)cleanup_redirects, my_undo_list); + + if (exec_undo_list) + add_unwind_protect ((Function *)dispose_redirects, exec_undo_list); + + ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0; + + QUIT; + + switch (command->type) + { + case cm_simple: + { + save_line_number = line_number; + /* We can't rely on variables retaining their values across a + call to execute_simple_command if a longjmp occurs as the + result of a `return' builtin. This is true for sure with gcc. */ +#if defined (RECYCLES_PIDS) + last_made_pid = NO_PID; +#endif + last_pid = last_made_pid; + was_error_trap = signal_is_trapped (ERROR_TRAP) && signal_is_ignored (ERROR_TRAP) == 0; + + if (ignore_return && command->value.Simple) + command->value.Simple->flags |= CMD_IGNORE_RETURN; + if (command->flags & CMD_STDIN_REDIR) + command->value.Simple->flags |= CMD_STDIN_REDIR; + + line_number_for_err_trap = line_number = command->value.Simple->line; + exec_result = + execute_simple_command (command->value.Simple, pipe_in, pipe_out, + asynchronous, fds_to_close); + line_number = save_line_number; + + /* The temporary environment should be used for only the simple + command immediately following its definition. */ + dispose_used_env_vars (); + +#if (defined (ultrix) && defined (mips)) || defined (C_ALLOCA) + /* Reclaim memory allocated with alloca () on machines which + may be using the alloca emulation code. */ + (void) alloca (0); +#endif /* (ultrix && mips) || C_ALLOCA */ + + /* If we forked to do the command, then we must wait_for () + the child. */ + + /* XXX - this is something to watch out for if there are problems + when the shell is compiled without job control. Don't worry about + whether or not last_made_pid == last_pid; already_making_children + tells us whether or not there are unwaited-for children to wait + for and reap. */ + if (already_making_children && pipe_out == NO_PIPE) + { + stop_pipeline (asynchronous, (COMMAND *)NULL); + + if (asynchronous) + { + DESCRIBE_PID (last_made_pid); + } + else +#if !defined (JOB_CONTROL) + /* Do not wait for asynchronous processes started from + startup files. */ + if (last_made_pid != last_asynchronous_pid) +#endif + /* When executing a shell function that executes other + commands, this causes the last simple command in + the function to be waited for twice. This also causes + subshells forked to execute builtin commands (e.g., in + pipelines) to be waited for twice. */ + exec_result = wait_for (last_made_pid); + } + } + + /* 2009/02/13 -- pipeline failure is processed elsewhere. This handles + only the failure of a simple command. */ + if (was_error_trap && ignore_return == 0 && invert == 0 && pipe_in == NO_PIPE && pipe_out == NO_PIPE && exec_result != EXECUTION_SUCCESS) + { + last_command_exit_value = exec_result; + line_number = line_number_for_err_trap; + run_error_trap (); + line_number = save_line_number; + } + + if (ignore_return == 0 && invert == 0 && + ((posixly_correct && interactive == 0 && special_builtin_failed) || + (exit_immediately_on_error && pipe_in == NO_PIPE && pipe_out == NO_PIPE && exec_result != EXECUTION_SUCCESS))) + { + last_command_exit_value = exec_result; + run_pending_traps (); + jump_to_top_level (ERREXIT); + } + + break; + + case cm_for: + if (ignore_return) + command->value.For->flags |= CMD_IGNORE_RETURN; + exec_result = execute_for_command (command->value.For); + break; + +#if defined (ARITH_FOR_COMMAND) + case cm_arith_for: + if (ignore_return) + command->value.ArithFor->flags |= CMD_IGNORE_RETURN; + exec_result = execute_arith_for_command (command->value.ArithFor); + break; +#endif + +#if defined (SELECT_COMMAND) + case cm_select: + if (ignore_return) + command->value.Select->flags |= CMD_IGNORE_RETURN; + exec_result = execute_select_command (command->value.Select); + break; +#endif + + case cm_case: + if (ignore_return) + command->value.Case->flags |= CMD_IGNORE_RETURN; + exec_result = execute_case_command (command->value.Case); + break; + + case cm_while: + if (ignore_return) + command->value.While->flags |= CMD_IGNORE_RETURN; + exec_result = execute_while_command (command->value.While); + break; + + case cm_until: + if (ignore_return) + command->value.While->flags |= CMD_IGNORE_RETURN; + exec_result = execute_until_command (command->value.While); + break; + + case cm_if: + if (ignore_return) + command->value.If->flags |= CMD_IGNORE_RETURN; + exec_result = execute_if_command (command->value.If); + break; + + case cm_group: + + /* This code can be executed from either of two paths: an explicit + '{}' command, or via a function call. If we are executed via a + function call, we have already taken care of the function being + executed in the background (down there in execute_simple_command ()), + and this command should *not* be marked as asynchronous. If we + are executing a regular '{}' group command, and asynchronous == 1, + we must want to execute the whole command in the background, so we + need a subshell, and we want the stuff executed in that subshell + (this group command) to be executed in the foreground of that + subshell (i.e. there will not be *another* subshell forked). + + What we do is to force a subshell if asynchronous, and then call + execute_command_internal again with asynchronous still set to 1, + but with the original group command, so the printed command will + look right. + + The code above that handles forking off subshells will note that + both subshell and async are on, and turn off async in the child + after forking the subshell (but leave async set in the parent, so + the normal call to describe_pid is made). This turning off + async is *crucial*; if it is not done, this will fall into an + infinite loop of executions through this spot in subshell after + subshell until the process limit is exhausted. */ + + if (asynchronous) + { + command->flags |= CMD_FORCE_SUBSHELL; + exec_result = + execute_command_internal (command, 1, pipe_in, pipe_out, + fds_to_close); + } + else + { + if (ignore_return && command->value.Group->command) + command->value.Group->command->flags |= CMD_IGNORE_RETURN; + exec_result = + execute_command_internal (command->value.Group->command, + asynchronous, pipe_in, pipe_out, + fds_to_close); + } + break; + + case cm_connection: + exec_result = execute_connection (command, asynchronous, + pipe_in, pipe_out, fds_to_close); + break; + +#if defined (DPAREN_ARITHMETIC) + case cm_arith: + was_error_trap = signal_is_trapped (ERROR_TRAP) && signal_is_ignored (ERROR_TRAP) == 0; + if (ignore_return) + command->value.Arith->flags |= CMD_IGNORE_RETURN; + line_number_for_err_trap = save_line_number = line_number; + exec_result = execute_arith_command (command->value.Arith); + line_number = save_line_number; + + if (was_error_trap && ignore_return == 0 && invert == 0 && exec_result != EXECUTION_SUCCESS) + { + last_command_exit_value = exec_result; + save_line_number = line_number; + line_number = line_number_for_err_trap; + run_error_trap (); + line_number = save_line_number; + } + + if (ignore_return == 0 && invert == 0 && exit_immediately_on_error && exec_result != EXECUTION_SUCCESS) + { + last_command_exit_value = exec_result; + run_pending_traps (); + jump_to_top_level (ERREXIT); + } + + break; +#endif + +#if defined (COND_COMMAND) + case cm_cond: + was_error_trap = signal_is_trapped (ERROR_TRAP) && signal_is_ignored (ERROR_TRAP) == 0; + if (ignore_return) + command->value.Cond->flags |= CMD_IGNORE_RETURN; + + line_number_for_err_trap = save_line_number = line_number; + exec_result = execute_cond_command (command->value.Cond); + line_number = save_line_number; + + if (was_error_trap && ignore_return == 0 && invert == 0 && exec_result != EXECUTION_SUCCESS) + { + last_command_exit_value = exec_result; + save_line_number = line_number; + line_number = line_number_for_err_trap; + run_error_trap (); + line_number = save_line_number; + } + + if (ignore_return == 0 && invert == 0 && exit_immediately_on_error && exec_result != EXECUTION_SUCCESS) + { + last_command_exit_value = exec_result; + run_pending_traps (); + jump_to_top_level (ERREXIT); + } + + break; +#endif + + case cm_function_def: + exec_result = execute_intern_function (command->value.Function_def->name, + command->value.Function_def); + break; + + default: + command_error ("execute_command", CMDERR_BADTYPE, command->type, 0); + } + + if (my_undo_list) + { + do_redirections (my_undo_list, RX_ACTIVE); + dispose_redirects (my_undo_list); + } + + if (exec_undo_list) + dispose_redirects (exec_undo_list); + + if (my_undo_list || exec_undo_list) + discard_unwind_frame ("loop_redirections"); + +#if defined (PROCESS_SUBSTITUTION) + if (saved_fifo) + { + nfifo = num_fifos (); + if (nfifo > ofifo) + close_new_fifos ((char *)ofifo_list, osize); + free ((void *)ofifo_list); + } +#endif + + /* Invert the return value if we have to */ + if (invert) + exec_result = (exec_result == EXECUTION_SUCCESS) + ? EXECUTION_FAILURE + : EXECUTION_SUCCESS; + +#if defined (DPAREN_ARITHMETIC) || defined (COND_COMMAND) + /* This is where we set PIPESTATUS from the exit status of the appropriate + compound commands (the ones that look enough like simple commands to + cause confusion). We might be able to optimize by not doing this if + subshell_environment != 0. */ + switch (command->type) + { +# if defined (DPAREN_ARITHMETIC) + case cm_arith: +# endif +# if defined (COND_COMMAND) + case cm_cond: +# endif + set_pipestatus_from_exit (exec_result); + break; + } +#endif + + last_command_exit_value = exec_result; + run_pending_traps (); +#if 0 + if (running_trap == 0) +#endif + currently_executing_command = (COMMAND *)NULL; + + return (last_command_exit_value); +} + +#if defined (COMMAND_TIMING) + +#if defined (HAVE_GETRUSAGE) && defined (HAVE_GETTIMEOFDAY) +extern struct timeval *difftimeval __P((struct timeval *, struct timeval *, struct timeval *)); +extern struct timeval *addtimeval __P((struct timeval *, struct timeval *, struct timeval *)); +extern int timeval_to_cpu __P((struct timeval *, struct timeval *, struct timeval *)); +#endif + +#define POSIX_TIMEFORMAT "real %2R\nuser %2U\nsys %2S" +#define BASH_TIMEFORMAT "\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS" + +static const int precs[] = { 0, 100, 10, 1 }; + +/* Expand one `%'-prefixed escape sequence from a time format string. */ +static int +mkfmt (buf, prec, lng, sec, sec_fraction) + char *buf; + int prec, lng; + time_t sec; + int sec_fraction; +{ + time_t min; + char abuf[INT_STRLEN_BOUND(time_t) + 1]; + int ind, aind; + + ind = 0; + abuf[sizeof(abuf) - 1] = '\0'; + + /* If LNG is non-zero, we want to decompose SEC into minutes and seconds. */ + if (lng) + { + min = sec / 60; + sec %= 60; + aind = sizeof(abuf) - 2; + do + abuf[aind--] = (min % 10) + '0'; + while (min /= 10); + aind++; + while (abuf[aind]) + buf[ind++] = abuf[aind++]; + buf[ind++] = 'm'; + } + + /* Now add the seconds. */ + aind = sizeof (abuf) - 2; + do + abuf[aind--] = (sec % 10) + '0'; + while (sec /= 10); + aind++; + while (abuf[aind]) + buf[ind++] = abuf[aind++]; + + /* We want to add a decimal point and PREC places after it if PREC is + nonzero. PREC is not greater than 3. SEC_FRACTION is between 0 + and 999. */ + if (prec != 0) + { + buf[ind++] = '.'; + for (aind = 1; aind <= prec; aind++) + { + buf[ind++] = (sec_fraction / precs[aind]) + '0'; + sec_fraction %= precs[aind]; + } + } + + if (lng) + buf[ind++] = 's'; + buf[ind] = '\0'; + + return (ind); +} + +/* Interpret the format string FORMAT, interpolating the following escape + sequences: + %[prec][l][RUS] + + where the optional `prec' is a precision, meaning the number of + characters after the decimal point, the optional `l' means to format + using minutes and seconds (MMmNN[.FF]s), like the `times' builtin', + and the last character is one of + + R number of seconds of `real' time + U number of seconds of `user' time + S number of seconds of `system' time + + An occurrence of `%%' in the format string is translated to a `%'. The + result is printed to FP, a pointer to a FILE. The other variables are + the seconds and thousandths of a second of real, user, and system time, + resectively. */ +static void +print_formatted_time (fp, format, rs, rsf, us, usf, ss, ssf, cpu) + FILE *fp; + char *format; + time_t rs; + int rsf; + time_t us; + int usf; + time_t ss; + int ssf, cpu; +{ + int prec, lng, len; + char *str, *s, ts[INT_STRLEN_BOUND (time_t) + sizeof ("mSS.FFFF")]; + time_t sum; + int sum_frac; + int sindex, ssize; + + len = strlen (format); + ssize = (len + 64) - (len % 64); + str = (char *)xmalloc (ssize); + sindex = 0; + + for (s = format; *s; s++) + { + if (*s != '%' || s[1] == '\0') + { + RESIZE_MALLOCED_BUFFER (str, sindex, 1, ssize, 64); + str[sindex++] = *s; + } + else if (s[1] == '%') + { + s++; + RESIZE_MALLOCED_BUFFER (str, sindex, 1, ssize, 64); + str[sindex++] = *s; + } + else if (s[1] == 'P') + { + s++; +#if 0 + /* clamp CPU usage at 100% */ + if (cpu > 10000) + cpu = 10000; +#endif + sum = cpu / 100; + sum_frac = (cpu % 100) * 10; + len = mkfmt (ts, 2, 0, sum, sum_frac); + RESIZE_MALLOCED_BUFFER (str, sindex, len, ssize, 64); + strcpy (str + sindex, ts); + sindex += len; + } + else + { + prec = 3; /* default is three places past the decimal point. */ + lng = 0; /* default is to not use minutes or append `s' */ + s++; + if (DIGIT (*s)) /* `precision' */ + { + prec = *s++ - '0'; + if (prec > 3) prec = 3; + } + if (*s == 'l') /* `length extender' */ + { + lng = 1; + s++; + } + if (*s == 'R' || *s == 'E') + len = mkfmt (ts, prec, lng, rs, rsf); + else if (*s == 'U') + len = mkfmt (ts, prec, lng, us, usf); + else if (*s == 'S') + len = mkfmt (ts, prec, lng, ss, ssf); + else + { + internal_error (_("TIMEFORMAT: `%c': invalid format character"), *s); + free (str); + return; + } + RESIZE_MALLOCED_BUFFER (str, sindex, len, ssize, 64); + strcpy (str + sindex, ts); + sindex += len; + } + } + + str[sindex] = '\0'; + fprintf (fp, "%s\n", str); + fflush (fp); + + free (str); +} + +static int +time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close) + COMMAND *command; + int asynchronous, pipe_in, pipe_out; + struct fd_bitmap *fds_to_close; +{ + int rv, posix_time, old_flags, nullcmd; + time_t rs, us, ss; + int rsf, usf, ssf; + int cpu; + char *time_format; + +#if defined (HAVE_GETRUSAGE) && defined (HAVE_GETTIMEOFDAY) + struct timeval real, user, sys; + struct timeval before, after; +# if defined (HAVE_STRUCT_TIMEZONE) + struct timezone dtz; /* posix doesn't define this */ +# endif + struct rusage selfb, selfa, kidsb, kidsa; /* a = after, b = before */ +#else +# if defined (HAVE_TIMES) + clock_t tbefore, tafter, real, user, sys; + struct tms before, after; +# endif +#endif + +#if defined (HAVE_GETRUSAGE) && defined (HAVE_GETTIMEOFDAY) +# if defined (HAVE_STRUCT_TIMEZONE) + gettimeofday (&before, &dtz); +# else + gettimeofday (&before, (void *)NULL); +# endif /* !HAVE_STRUCT_TIMEZONE */ + getrusage (RUSAGE_SELF, &selfb); + getrusage (RUSAGE_CHILDREN, &kidsb); +#else +# if defined (HAVE_TIMES) + tbefore = times (&before); +# endif +#endif + + posix_time = command && (command->flags & CMD_TIME_POSIX); + + nullcmd = (command == 0) || (command->type == cm_simple && command->value.Simple->words == 0 && command->value.Simple->redirects == 0); + if (posixly_correct && nullcmd) + { +#if defined (HAVE_GETRUSAGE) + selfb.ru_utime.tv_sec = kidsb.ru_utime.tv_sec = selfb.ru_stime.tv_sec = kidsb.ru_stime.tv_sec = 0; + selfb.ru_utime.tv_usec = kidsb.ru_utime.tv_usec = selfb.ru_stime.tv_usec = kidsb.ru_stime.tv_usec = 0; + before.tv_sec = shell_start_time; + before.tv_usec = 0; +#else + before.tms_utime = before.tms_stime = before.tms_cutime = before.tms_cstime = 0; + tbefore = shell_start_time; +#endif + } + + old_flags = command->flags; + command->flags &= ~(CMD_TIME_PIPELINE|CMD_TIME_POSIX); + rv = execute_command_internal (command, asynchronous, pipe_in, pipe_out, fds_to_close); + command->flags = old_flags; + + rs = us = ss = 0; + rsf = usf = ssf = cpu = 0; + +#if defined (HAVE_GETRUSAGE) && defined (HAVE_GETTIMEOFDAY) +# if defined (HAVE_STRUCT_TIMEZONE) + gettimeofday (&after, &dtz); +# else + gettimeofday (&after, (void *)NULL); +# endif /* !HAVE_STRUCT_TIMEZONE */ + getrusage (RUSAGE_SELF, &selfa); + getrusage (RUSAGE_CHILDREN, &kidsa); + + difftimeval (&real, &before, &after); + timeval_to_secs (&real, &rs, &rsf); + + addtimeval (&user, difftimeval(&after, &selfb.ru_utime, &selfa.ru_utime), + difftimeval(&before, &kidsb.ru_utime, &kidsa.ru_utime)); + timeval_to_secs (&user, &us, &usf); + + addtimeval (&sys, difftimeval(&after, &selfb.ru_stime, &selfa.ru_stime), + difftimeval(&before, &kidsb.ru_stime, &kidsa.ru_stime)); + timeval_to_secs (&sys, &ss, &ssf); + + cpu = timeval_to_cpu (&real, &user, &sys); +#else +# if defined (HAVE_TIMES) + tafter = times (&after); + + real = tafter - tbefore; + clock_t_to_secs (real, &rs, &rsf); + + user = (after.tms_utime - before.tms_utime) + (after.tms_cutime - before.tms_cutime); + clock_t_to_secs (user, &us, &usf); + + sys = (after.tms_stime - before.tms_stime) + (after.tms_cstime - before.tms_cstime); + clock_t_to_secs (sys, &ss, &ssf); + + cpu = (real == 0) ? 0 : ((user + sys) * 10000) / real; + +# else + rs = us = ss = 0; + rsf = usf = ssf = cpu = 0; +# endif +#endif + + if (posix_time) + time_format = POSIX_TIMEFORMAT; + else if ((time_format = get_string_value ("TIMEFORMAT")) == 0) + { + if (posixly_correct && nullcmd) + time_format = "user\t%2lU\nsys\t%2lS"; + else + time_format = BASH_TIMEFORMAT; + } + if (time_format && *time_format) + print_formatted_time (stderr, time_format, rs, rsf, us, usf, ss, ssf, cpu); + + return rv; +} +#endif /* COMMAND_TIMING */ + +/* Execute a command that's supposed to be in a subshell. This must be + called after make_child and we must be running in the child process. + The caller will return or exit() immediately with the value this returns. */ +static int +execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close) + COMMAND *command; + int asynchronous; + int pipe_in, pipe_out; + struct fd_bitmap *fds_to_close; +{ + int user_subshell, return_code, function_value, should_redir_stdin, invert; + int ois, user_coproc; + int result; + volatile COMMAND *tcom; + + USE_VAR(user_subshell); + USE_VAR(user_coproc); + USE_VAR(invert); + USE_VAR(tcom); + USE_VAR(asynchronous); + + subshell_level++; + should_redir_stdin = (asynchronous && (command->flags & CMD_STDIN_REDIR) && + pipe_in == NO_PIPE && + stdin_redirects (command->redirects) == 0); + + invert = (command->flags & CMD_INVERT_RETURN) != 0; + user_subshell = command->type == cm_subshell || ((command->flags & CMD_WANT_SUBSHELL) != 0); + user_coproc = command->type == cm_coproc; + + command->flags &= ~(CMD_FORCE_SUBSHELL | CMD_WANT_SUBSHELL | CMD_INVERT_RETURN); + + /* If a command is asynchronous in a subshell (like ( foo ) & or + the special case of an asynchronous GROUP command where the + the subshell bit is turned on down in case cm_group: below), + turn off `asynchronous', so that two subshells aren't spawned. + XXX - asynchronous used to be set to 0 in this block, but that + means that setup_async_signals was never run. Now it's set to + 0 after subshell_environment is set appropriately and setup_async_signals + is run. + + This seems semantically correct to me. For example, + ( foo ) & seems to say ``do the command `foo' in a subshell + environment, but don't wait for that subshell to finish'', + and "{ foo ; bar ; } &" seems to me to be like functions or + builtins in the background, which executed in a subshell + environment. I just don't see the need to fork two subshells. */ + + /* Don't fork again, we are already in a subshell. A `doubly + async' shell is not interactive, however. */ + if (asynchronous) + { +#if defined (JOB_CONTROL) + /* If a construct like ( exec xxx yyy ) & is given while job + control is active, we want to prevent exec from putting the + subshell back into the original process group, carefully + undoing all the work we just did in make_child. */ + original_pgrp = -1; +#endif /* JOB_CONTROL */ + ois = interactive_shell; + interactive_shell = 0; + /* This test is to prevent alias expansion by interactive shells that + run `(command) &' but to allow scripts that have enabled alias + expansion with `shopt -s expand_alias' to continue to expand + aliases. */ + if (ois != interactive_shell) + expand_aliases = 0; + } + + /* Subshells are neither login nor interactive. */ + login_shell = interactive = 0; + + if (user_subshell) + subshell_environment = SUBSHELL_PAREN; + else + { + subshell_environment = 0; /* XXX */ + if (asynchronous) + subshell_environment |= SUBSHELL_ASYNC; + if (pipe_in != NO_PIPE || pipe_out != NO_PIPE) + subshell_environment |= SUBSHELL_PIPE; + if (user_coproc) + subshell_environment |= SUBSHELL_COPROC; + } + + reset_terminating_signals (); /* in sig.c */ + /* Cancel traps, in trap.c. */ + /* Reset the signal handlers in the child, but don't free the + trap strings. Set a flag noting that we have to free the + trap strings if we run trap to change a signal disposition. */ + reset_signal_handlers (); + subshell_environment |= SUBSHELL_RESETTRAP; + + /* Make sure restore_original_signals doesn't undo the work done by + make_child to ensure that asynchronous children are immune to SIGINT + and SIGQUIT. Turn off asynchronous to make sure more subshells are + not spawned. */ + if (asynchronous) + { + setup_async_signals (); + asynchronous = 0; + } + +#if defined (JOB_CONTROL) + set_sigchld_handler (); +#endif /* JOB_CONTROL */ + + set_sigint_handler (); + +#if defined (JOB_CONTROL) + /* Delete all traces that there were any jobs running. This is + only for subshells. */ + without_job_control (); +#endif /* JOB_CONTROL */ + + if (fds_to_close) + close_fd_bitmap (fds_to_close); + + do_piping (pipe_in, pipe_out); + +#if defined (COPROCESS_SUPPORT) + coproc_closeall (); +#endif + + /* If this is a user subshell, set a flag if stdin was redirected. + This is used later to decide whether to redirect fd 0 to + /dev/null for async commands in the subshell. This adds more + sh compatibility, but I'm not sure it's the right thing to do. */ + if (user_subshell) + { + stdin_redir = stdin_redirects (command->redirects); + restore_default_signal (0); + } + + /* If this is an asynchronous command (command &), we want to + redirect the standard input from /dev/null in the absence of + any specific redirection involving stdin. */ + if (should_redir_stdin && stdin_redir == 0) + async_redirect_stdin (); + + /* Do redirections, then dispose of them before recursive call. */ + if (command->redirects) + { + if (do_redirections (command->redirects, RX_ACTIVE) != 0) + exit (invert ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + + dispose_redirects (command->redirects); + command->redirects = (REDIRECT *)NULL; + } + + if (command->type == cm_subshell) + tcom = command->value.Subshell->command; + else if (user_coproc) + tcom = command->value.Coproc->command; + else + tcom = command; + + if (command->flags & CMD_TIME_PIPELINE) + tcom->flags |= CMD_TIME_PIPELINE; + if (command->flags & CMD_TIME_POSIX) + tcom->flags |= CMD_TIME_POSIX; + + /* Make sure the subshell inherits any CMD_IGNORE_RETURN flag. */ + if ((command->flags & CMD_IGNORE_RETURN) && tcom != command) + tcom->flags |= CMD_IGNORE_RETURN; + + /* If this is a simple command, tell execute_disk_command that it + might be able to get away without forking and simply exec. + This means things like ( sleep 10 ) will only cause one fork. + If we're timing the command or inverting its return value, however, + we cannot do this optimization. */ + if ((user_subshell || user_coproc) && (tcom->type == cm_simple || tcom->type == cm_subshell) && + ((tcom->flags & CMD_TIME_PIPELINE) == 0) && + ((tcom->flags & CMD_INVERT_RETURN) == 0)) + { + tcom->flags |= CMD_NO_FORK; + if (tcom->type == cm_simple) + tcom->value.Simple->flags |= CMD_NO_FORK; + } + + invert = (tcom->flags & CMD_INVERT_RETURN) != 0; + tcom->flags &= ~CMD_INVERT_RETURN; + + result = setjmp (top_level); + + /* If we're inside a function while executing this subshell, we + need to handle a possible `return'. */ + function_value = 0; + if (return_catch_flag) + function_value = setjmp (return_catch); + + /* If we're going to exit the shell, we don't want to invert the return + status. */ + if (result == EXITPROG) + invert = 0, return_code = last_command_exit_value; + else if (result) + return_code = EXECUTION_FAILURE; + else if (function_value) + return_code = return_catch_value; + else + return_code = execute_command_internal ((COMMAND *)tcom, asynchronous, NO_PIPE, NO_PIPE, fds_to_close); + + /* If we are asked to, invert the return value. */ + if (invert) + return_code = (return_code == EXECUTION_SUCCESS) ? EXECUTION_FAILURE + : EXECUTION_SUCCESS; + + /* If we were explicitly placed in a subshell with (), we need + to do the `shell cleanup' things, such as running traps[0]. */ + if (user_subshell && signal_is_trapped (0)) + { + last_command_exit_value = return_code; + return_code = run_exit_trap (); + } + + subshell_level--; + return (return_code); + /* NOTREACHED */ +} + +#if defined (COPROCESS_SUPPORT) +#define COPROC_MAX 16 + +typedef struct cpelement + { + struct cpelement *next; + struct coproc *coproc; + } +cpelement_t; + +typedef struct cplist + { + struct cpelement *head; + struct cpelement *tail; + int ncoproc; + int lock; + } +cplist_t; + +static struct cpelement *cpe_alloc __P((struct coproc *)); +static void cpe_dispose __P((struct cpelement *)); +static struct cpelement *cpl_add __P((struct coproc *)); +static struct cpelement *cpl_delete __P((pid_t)); +static void cpl_reap __P((void)); +static void cpl_flush __P((void)); +static void cpl_closeall __P((void)); +static struct cpelement *cpl_search __P((pid_t)); +static struct cpelement *cpl_searchbyname __P((const char *)); +static void cpl_prune __P((void)); + +static void coproc_free __P((struct coproc *)); + +/* Will go away when there is fully-implemented support for multiple coprocs. */ +Coproc sh_coproc = { 0, NO_PID, -1, -1, 0, 0, 0, 0, 0 }; + +cplist_t coproc_list = {0, 0, 0}; + +/* Functions to manage the list of coprocs */ + +static struct cpelement * +cpe_alloc (cp) + Coproc *cp; +{ + struct cpelement *cpe; + + cpe = (struct cpelement *)xmalloc (sizeof (struct cpelement)); + cpe->coproc = cp; + cpe->next = (struct cpelement *)0; + return cpe; +} + +static void +cpe_dispose (cpe) + struct cpelement *cpe; +{ + free (cpe); +} + +static struct cpelement * +cpl_add (cp) + Coproc *cp; +{ + struct cpelement *cpe; + + cpe = cpe_alloc (cp); + + if (coproc_list.head == 0) + { + coproc_list.head = coproc_list.tail = cpe; + coproc_list.ncoproc = 0; /* just to make sure */ + } + else + { + coproc_list.tail->next = cpe; + coproc_list.tail = cpe; + } + coproc_list.ncoproc++; + + return cpe; +} + +static struct cpelement * +cpl_delete (pid) + pid_t pid; +{ + struct cpelement *prev, *p; + + for (prev = p = coproc_list.head; p; prev = p, p = p->next) + if (p->coproc->c_pid == pid) + { + prev->next = p->next; /* remove from list */ + break; + } + + if (p == 0) + return 0; /* not found */ + +#if defined (DEBUG) + itrace("cpl_delete: deleting %d", pid); +#endif + + /* Housekeeping in the border cases. */ + if (p == coproc_list.head) + coproc_list.head = coproc_list.head->next; + else if (p == coproc_list.tail) + coproc_list.tail = prev; + + coproc_list.ncoproc--; + if (coproc_list.ncoproc == 0) + coproc_list.head = coproc_list.tail = 0; + else if (coproc_list.ncoproc == 1) + coproc_list.tail = coproc_list.head; /* just to make sure */ + + return (p); +} + +static void +cpl_reap () +{ + struct cpelement *p, *next, *nh, *nt; + + /* Build a new list by removing dead coprocs and fix up the coproc_list + pointers when done. */ + nh = nt = next = (struct cpelement *)0; + for (p = coproc_list.head; p; p = next) + { + next = p->next; + if (p->coproc->c_flags & COPROC_DEAD) + { + coproc_list.ncoproc--; /* keep running count, fix up pointers later */ + +#if defined (DEBUG) + itrace("cpl_reap: deleting %d", p->coproc->c_pid); +#endif + + coproc_dispose (p->coproc); + cpe_dispose (p); + } + else if (nh == 0) + nh = nt = p; + else + { + nt->next = p; + nt = nt->next; + } + } + + if (coproc_list.ncoproc == 0) + coproc_list.head = coproc_list.tail = 0; + else + { + if (nt) + nt->next = 0; + coproc_list.head = nh; + coproc_list.tail = nt; + if (coproc_list.ncoproc == 1) + coproc_list.tail = coproc_list.head; /* just to make sure */ + } +} + +/* Clear out the list of saved statuses */ +static void +cpl_flush () +{ + struct cpelement *cpe, *p; + + for (cpe = coproc_list.head; cpe; ) + { + p = cpe; + cpe = cpe->next; + + coproc_dispose (p->coproc); + cpe_dispose (p); + } + + coproc_list.head = coproc_list.tail = 0; + coproc_list.ncoproc = 0; +} + +static void +cpl_closeall () +{ + struct cpelement *cpe; + + for (cpe = coproc_list.head; cpe; cpe = cpe->next) + coproc_close (cpe->coproc); +} + +static void +cpl_fdchk (fd) + int fd; +{ + struct cpelement *cpe; + + for (cpe = coproc_list.head; cpe; cpe = cpe->next) + coproc_checkfd (cpe->coproc, fd); +} + +/* Search for PID in the list of coprocs; return the cpelement struct if + found. If not found, return NULL. */ +static struct cpelement * +cpl_search (pid) + pid_t pid; +{ + struct cpelement *cpe; + + for (cpe = coproc_list.head ; cpe; cpe = cpe->next) + if (cpe->coproc->c_pid == pid) + return cpe; + return (struct cpelement *)NULL; +} + +/* Search for the coproc named NAME in the list of coprocs; return the + cpelement struct if found. If not found, return NULL. */ +static struct cpelement * +cpl_searchbyname (name) + const char *name; +{ + struct cpelement *cp; + + for (cp = coproc_list.head ; cp; cp = cp->next) + if (STREQ (cp->coproc->c_name, name)) + return cp; + return (struct cpelement *)NULL; +} + +#if 0 +static void +cpl_prune () +{ + struct cpelement *cp; + + while (coproc_list.head && coproc_list.ncoproc > COPROC_MAX) + { + cp = coproc_list.head; + coproc_list.head = coproc_list.head->next; + coproc_dispose (cp->coproc); + cpe_dispose (cp); + coproc_list.ncoproc--; + } +} +#endif + +/* These currently use a single global "shell coproc" but are written in a + way to not preclude additional coprocs later (using the list management + package above). */ + +struct coproc * +getcoprocbypid (pid) + pid_t pid; +{ +#if MULTIPLE_COPROCS + struct cpelement *p; + + p = cpl_search (pid); + return (p ? p->coproc : 0); +#else + return (pid == sh_coproc.c_pid ? &sh_coproc : 0); +#endif +} + +struct coproc * +getcoprocbyname (name) + const char *name; +{ +#if MULTIPLE_COPROCS + struct cpelement *p; + + p = cpl_searchbyname (name); + return (p ? p->coproc : 0); +#else + return ((sh_coproc.c_name && STREQ (sh_coproc.c_name, name)) ? &sh_coproc : 0); +#endif +} + +void +coproc_init (cp) + struct coproc *cp; +{ + cp->c_name = 0; + cp->c_pid = NO_PID; + cp->c_rfd = cp->c_wfd = -1; + cp->c_rsave = cp->c_wsave = -1; + cp->c_flags = cp->c_status = cp->c_lock = 0; +} + +struct coproc * +coproc_alloc (name, pid) + char *name; + pid_t pid; +{ + struct coproc *cp; + +#if MULTIPLE_COPROCS + cp = (struct coproc *)xmalloc (sizeof (struct coproc)); +#else + cp = &sh_coproc; +#endif + coproc_init (cp); + cp->c_lock = 2; + + cp->c_pid = pid; + cp->c_name = savestring (name); +#if MULTIPLE_COPROCS + cpl_add (cp); +#endif + cp->c_lock = 0; + return (cp); +} + +static void +coproc_free (cp) + struct coproc *cp; +{ + free (cp); +} + +void +coproc_dispose (cp) + struct coproc *cp; +{ + sigset_t set, oset; + + if (cp == 0) + return; + + BLOCK_SIGNAL (SIGCHLD, set, oset); + cp->c_lock = 3; + coproc_unsetvars (cp); + FREE (cp->c_name); + coproc_close (cp); +#if MULTIPLE_COPROCS + coproc_free (cp); +#else + coproc_init (cp); + cp->c_lock = 0; +#endif + UNBLOCK_SIGNAL (oset); +} + +/* Placeholder for now. Will require changes for multiple coprocs */ +void +coproc_flush () +{ +#if MULTIPLE_COPROCS + cpl_flush (); +#else + coproc_dispose (&sh_coproc); +#endif +} + +void +coproc_close (cp) + struct coproc *cp; +{ + if (cp->c_rfd >= 0) + { + close (cp->c_rfd); + cp->c_rfd = -1; + } + if (cp->c_wfd >= 0) + { + close (cp->c_wfd); + cp->c_wfd = -1; + } + cp->c_rsave = cp->c_wsave = -1; +} + +void +coproc_closeall () +{ +#if MULTIPLE_COPROCS + cpl_closeall (); +#else + coproc_close (&sh_coproc); /* XXX - will require changes for multiple coprocs */ +#endif +} + +void +coproc_reap () +{ +#if MULTIPLE_COPROCS + cpl_reap (); +#else + struct coproc *cp; + + cp = &sh_coproc; /* XXX - will require changes for multiple coprocs */ + if (cp && (cp->c_flags & COPROC_DEAD)) + coproc_dispose (cp); +#endif +} + +void +coproc_rclose (cp, fd) + struct coproc *cp; + int fd; +{ + if (cp->c_rfd >= 0 && cp->c_rfd == fd) + { + close (cp->c_rfd); + cp->c_rfd = -1; + } +} + +void +coproc_wclose (cp, fd) + struct coproc *cp; + int fd; +{ + if (cp->c_wfd >= 0 && cp->c_wfd == fd) + { + close (cp->c_wfd); + cp->c_wfd = -1; + } +} + +void +coproc_checkfd (cp, fd) + struct coproc *cp; + int fd; +{ + int update; + + update = 0; + if (cp->c_rfd >= 0 && cp->c_rfd == fd) + update = cp->c_rfd = -1; + if (cp->c_wfd >= 0 && cp->c_wfd == fd) + update = cp->c_wfd = -1; + if (update) + coproc_setvars (cp); +} + +void +coproc_fdchk (fd) + int fd; +{ +#if MULTIPLE_COPROCS + cpl_fdchk (fd); +#else + coproc_checkfd (&sh_coproc, fd); +#endif +} + +void +coproc_fdclose (cp, fd) + struct coproc *cp; + int fd; +{ + coproc_rclose (cp, fd); + coproc_wclose (cp, fd); + coproc_setvars (cp); +} + +void +coproc_fdsave (cp) + struct coproc *cp; +{ + cp->c_rsave = cp->c_rfd; + cp->c_wsave = cp->c_wfd; +} + +void +coproc_fdrestore (cp) + struct coproc *cp; +{ + cp->c_rfd = cp->c_rsave; + cp->c_wfd = cp->c_wsave; +} + +void +coproc_pidchk (pid, status) + pid_t pid; +{ + struct coproc *cp; + +#if MULTIPLE_COPROCS + struct cpelement *cpe; + + cpe = cpl_delete (pid); + cp = cpe ? cpe->coproc : 0; +#else + cp = getcoprocbypid (pid); +#endif + if (cp) + { + cp->c_lock = 4; + cp->c_status = status; + cp->c_flags |= COPROC_DEAD; + cp->c_flags &= ~COPROC_RUNNING; + /* Don't dispose the coproc or unset the COPROC_XXX variables because + this is executed in a signal handler context. Wait until coproc_reap + takes care of it. */ + cp->c_lock = 0; + } +} + +void +coproc_setvars (cp) + struct coproc *cp; +{ + SHELL_VAR *v; + char *namevar, *t; + int l; +#if defined (ARRAY_VARS) + arrayind_t ind; +#endif + + if (cp->c_name == 0) + return; + + l = strlen (cp->c_name); + namevar = xmalloc (l + 16); + +#if defined (ARRAY_VARS) + v = find_variable (cp->c_name); + if (v == 0) + v = make_new_array_variable (cp->c_name); + if (array_p (v) == 0) + v = convert_var_to_array (v); + + t = itos (cp->c_rfd); + ind = 0; + v = bind_array_variable (cp->c_name, ind, t, 0); + free (t); + + t = itos (cp->c_wfd); + ind = 1; + bind_array_variable (cp->c_name, ind, t, 0); + free (t); +#else + sprintf (namevar, "%s_READ", cp->c_name); + t = itos (cp->c_rfd); + bind_variable (namevar, t, 0); + free (t); + sprintf (namevar, "%s_WRITE", cp->c_name); + t = itos (cp->c_wfd); + bind_variable (namevar, t, 0); + free (t); +#endif + + sprintf (namevar, "%s_PID", cp->c_name); + t = itos (cp->c_pid); + bind_variable (namevar, t, 0); + free (t); + + free (namevar); +} + +void +coproc_unsetvars (cp) + struct coproc *cp; +{ + int l; + char *namevar; + + if (cp->c_name == 0) + return; + + l = strlen (cp->c_name); + namevar = xmalloc (l + 16); + + sprintf (namevar, "%s_PID", cp->c_name); + unbind_variable (namevar); + +#if defined (ARRAY_VARS) + unbind_variable (cp->c_name); +#else + sprintf (namevar, "%s_READ", cp->c_name); + unbind_variable (namevar); + sprintf (namevar, "%s_WRITE", cp->c_name); + unbind_variable (namevar); +#endif + + free (namevar); +} + +static int +execute_coproc (command, pipe_in, pipe_out, fds_to_close) + COMMAND *command; + int pipe_in, pipe_out; + struct fd_bitmap *fds_to_close; +{ + int rpipe[2], wpipe[2], estat, invert; + pid_t coproc_pid; + Coproc *cp; + char *tcmd; + sigset_t set, oset; + + /* XXX -- can be removed after changes to handle multiple coprocs */ +#if !MULTIPLE_COPROCS + if (sh_coproc.c_pid != NO_PID) + internal_warning ("execute_coproc: coproc [%d:%s] still exists", sh_coproc.c_pid, sh_coproc.c_name); + coproc_init (&sh_coproc); +#endif + + invert = (command->flags & CMD_INVERT_RETURN) != 0; + command_string_index = 0; + tcmd = make_command_string (command); + + sh_openpipe ((int *)&rpipe); /* 0 = parent read, 1 = child write */ + sh_openpipe ((int *)&wpipe); /* 0 = child read, 1 = parent write */ + + BLOCK_SIGNAL (SIGCHLD, set, oset); + + coproc_pid = make_child (savestring (tcmd), 1); + + if (coproc_pid == 0) + { + close (rpipe[0]); + close (wpipe[1]); + + UNBLOCK_SIGNAL (oset); + estat = execute_in_subshell (command, 1, wpipe[0], rpipe[1], fds_to_close); + + fflush (stdout); + fflush (stderr); + + exit (estat); + } + + close (rpipe[1]); + close (wpipe[0]); + + /* XXX - possibly run Coproc->name through word expansion? */ + cp = coproc_alloc (command->value.Coproc->name, coproc_pid); + cp->c_rfd = rpipe[0]; + cp->c_wfd = wpipe[1]; + + SET_CLOSE_ON_EXEC (cp->c_rfd); + SET_CLOSE_ON_EXEC (cp->c_wfd); + + coproc_setvars (cp); + + UNBLOCK_SIGNAL (oset); + +#if 0 + itrace ("execute_coproc: [%d] %s", coproc_pid, the_printed_command); +#endif + + close_pipes (pipe_in, pipe_out); +#if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD) + unlink_fifo_list (); +#endif + stop_pipeline (1, (COMMAND *)NULL); + DESCRIBE_PID (coproc_pid); + run_pending_traps (); + + return (invert ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} +#endif + +static void +restore_stdin (s) + int s; +{ + dup2 (s, 0); + close (s); +} + +/* Catch-all cleanup function for lastpipe code for unwind-protects */ +static void +lastpipe_cleanup (s) + int s; +{ + unfreeze_jobs_list (); +} + +static int +execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) + COMMAND *command; + int asynchronous, pipe_in, pipe_out; + struct fd_bitmap *fds_to_close; +{ + int prev, fildes[2], new_bitmap_size, dummyfd, ignore_return, exec_result; + int lstdin, lastpipe_flag, lastpipe_jid; + COMMAND *cmd; + struct fd_bitmap *fd_bitmap; + pid_t lastpid; + +#if defined (JOB_CONTROL) + sigset_t set, oset; + BLOCK_CHILD (set, oset); +#endif /* JOB_CONTROL */ + + ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0; + + prev = pipe_in; + cmd = command; + + while (cmd && cmd->type == cm_connection && + cmd->value.Connection && cmd->value.Connection->connector == '|') + { + /* Make a pipeline between the two commands. */ + if (pipe (fildes) < 0) + { + sys_error (_("pipe error")); +#if defined (JOB_CONTROL) + terminate_current_pipeline (); + kill_current_pipeline (); + UNBLOCK_CHILD (oset); +#endif /* JOB_CONTROL */ + last_command_exit_value = EXECUTION_FAILURE; + /* The unwind-protects installed below will take care + of closing all of the open file descriptors. */ + throw_to_top_level (); + return (EXECUTION_FAILURE); /* XXX */ + } + + /* Here is a problem: with the new file close-on-exec + code, the read end of the pipe (fildes[0]) stays open + in the first process, so that process will never get a + SIGPIPE. There is no way to signal the first process + that it should close fildes[0] after forking, so it + remains open. No SIGPIPE is ever sent because there + is still a file descriptor open for reading connected + to the pipe. We take care of that here. This passes + around a bitmap of file descriptors that must be + closed after making a child process in execute_simple_command. */ + + /* We need fd_bitmap to be at least as big as fildes[0]. + If fildes[0] is less than fds_to_close->size, then + use fds_to_close->size. */ + new_bitmap_size = (fildes[0] < fds_to_close->size) + ? fds_to_close->size + : fildes[0] + 8; + + fd_bitmap = new_fd_bitmap (new_bitmap_size); + + /* Now copy the old information into the new bitmap. */ + xbcopy ((char *)fds_to_close->bitmap, (char *)fd_bitmap->bitmap, fds_to_close->size); + + /* And mark the pipe file descriptors to be closed. */ + fd_bitmap->bitmap[fildes[0]] = 1; + + /* In case there are pipe or out-of-processes errors, we + want all these file descriptors to be closed when + unwind-protects are run, and the storage used for the + bitmaps freed up. */ + begin_unwind_frame ("pipe-file-descriptors"); + add_unwind_protect (dispose_fd_bitmap, fd_bitmap); + add_unwind_protect (close_fd_bitmap, fd_bitmap); + if (prev >= 0) + add_unwind_protect (close, prev); + dummyfd = fildes[1]; + add_unwind_protect (close, dummyfd); + +#if defined (JOB_CONTROL) + add_unwind_protect (restore_signal_mask, &oset); +#endif /* JOB_CONTROL */ + + if (ignore_return && cmd->value.Connection->first) + cmd->value.Connection->first->flags |= CMD_IGNORE_RETURN; + execute_command_internal (cmd->value.Connection->first, asynchronous, + prev, fildes[1], fd_bitmap); + + if (prev >= 0) + close (prev); + + prev = fildes[0]; + close (fildes[1]); + + dispose_fd_bitmap (fd_bitmap); + discard_unwind_frame ("pipe-file-descriptors"); + + cmd = cmd->value.Connection->second; + } + + lastpid = last_made_pid; + + /* Now execute the rightmost command in the pipeline. */ + if (ignore_return && cmd) + cmd->flags |= CMD_IGNORE_RETURN; + + lastpipe_flag = 0; + + begin_unwind_frame ("lastpipe-exec"); + lstdin = -1; + /* If the `lastpipe' option is set with shopt, and job control is not + enabled, execute the last element of non-async pipelines in the + current shell environment. */ + if (lastpipe_opt && job_control == 0 && asynchronous == 0 && pipe_out == NO_PIPE && prev > 0) + { + lstdin = move_to_high_fd (0, 1, -1); + if (lstdin > 0) + { + do_piping (prev, pipe_out); + prev = NO_PIPE; + add_unwind_protect (restore_stdin, lstdin); + lastpipe_flag = 1; + freeze_jobs_list (); + lastpipe_jid = stop_pipeline (0, (COMMAND *)NULL); /* XXX */ + add_unwind_protect (lastpipe_cleanup, lastpipe_jid); + } + if (cmd) + cmd->flags |= CMD_LASTPIPE; + } + if (prev >= 0) + add_unwind_protect (close, prev); + + exec_result = execute_command_internal (cmd, asynchronous, prev, pipe_out, fds_to_close); + + if (lstdin > 0) + restore_stdin (lstdin); + + if (prev >= 0) + close (prev); + +#if defined (JOB_CONTROL) + UNBLOCK_CHILD (oset); +#endif + + QUIT; + + if (lastpipe_flag) + { +#if defined (JOB_CONTROL) + append_process (savestring (the_printed_command), dollar_dollar_pid, exec_result, lastpipe_jid); +#endif + lstdin = wait_for (lastpid); +#if defined (JOB_CONTROL) + exec_result = job_exit_status (lastpipe_jid); +#endif + unfreeze_jobs_list (); + } + + discard_unwind_frame ("lastpipe-exec"); + + return (exec_result); +} + +static int +execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close) + COMMAND *command; + int asynchronous, pipe_in, pipe_out; + struct fd_bitmap *fds_to_close; +{ + COMMAND *tc, *second; + int ignore_return, exec_result, was_error_trap, invert; + volatile int save_line_number; + + ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0; + + switch (command->value.Connection->connector) + { + /* Do the first command asynchronously. */ + case '&': + tc = command->value.Connection->first; + if (tc == 0) + return (EXECUTION_SUCCESS); + + if (ignore_return) + tc->flags |= CMD_IGNORE_RETURN; + tc->flags |= CMD_AMPERSAND; + + /* If this shell was compiled without job control support, + if we are currently in a subshell via `( xxx )', or if job + control is not active then the standard input for an + asynchronous command is forced to /dev/null. */ +#if defined (JOB_CONTROL) + if ((subshell_environment || !job_control) && !stdin_redir) +#else + if (!stdin_redir) +#endif /* JOB_CONTROL */ + tc->flags |= CMD_STDIN_REDIR; + + exec_result = execute_command_internal (tc, 1, pipe_in, pipe_out, fds_to_close); + QUIT; + + if (tc->flags & CMD_STDIN_REDIR) + tc->flags &= ~CMD_STDIN_REDIR; + + second = command->value.Connection->second; + if (second) + { + if (ignore_return) + second->flags |= CMD_IGNORE_RETURN; + + exec_result = execute_command_internal (second, asynchronous, pipe_in, pipe_out, fds_to_close); + } + + break; + + /* Just call execute command on both sides. */ + case ';': + if (ignore_return) + { + if (command->value.Connection->first) + command->value.Connection->first->flags |= CMD_IGNORE_RETURN; + if (command->value.Connection->second) + command->value.Connection->second->flags |= CMD_IGNORE_RETURN; + } + executing_list++; + QUIT; + execute_command (command->value.Connection->first); + QUIT; + exec_result = execute_command_internal (command->value.Connection->second, + asynchronous, pipe_in, pipe_out, + fds_to_close); + executing_list--; + break; + + case '|': + was_error_trap = signal_is_trapped (ERROR_TRAP) && signal_is_ignored (ERROR_TRAP) == 0; + invert = (command->flags & CMD_INVERT_RETURN) != 0; + ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0; + + line_number_for_err_trap = line_number; + exec_result = execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close); + + if (was_error_trap && ignore_return == 0 && invert == 0 && exec_result != EXECUTION_SUCCESS) + { + last_command_exit_value = exec_result; + save_line_number = line_number; + line_number = line_number_for_err_trap; + run_error_trap (); + line_number = save_line_number; + } + + if (ignore_return == 0 && invert == 0 && exit_immediately_on_error && exec_result != EXECUTION_SUCCESS) + { + last_command_exit_value = exec_result; + run_pending_traps (); + jump_to_top_level (ERREXIT); + } + + break; + + case AND_AND: + case OR_OR: + if (asynchronous) + { + /* If we have something like `a && b &' or `a || b &', run the + && or || stuff in a subshell. Force a subshell and just call + execute_command_internal again. Leave asynchronous on + so that we get a report from the parent shell about the + background job. */ + command->flags |= CMD_FORCE_SUBSHELL; + exec_result = execute_command_internal (command, 1, pipe_in, pipe_out, fds_to_close); + break; + } + + /* Execute the first command. If the result of that is successful + and the connector is AND_AND, or the result is not successful + and the connector is OR_OR, then execute the second command, + otherwise return. */ + + executing_list++; + if (command->value.Connection->first) + command->value.Connection->first->flags |= CMD_IGNORE_RETURN; + + exec_result = execute_command (command->value.Connection->first); + QUIT; + if (((command->value.Connection->connector == AND_AND) && + (exec_result == EXECUTION_SUCCESS)) || + ((command->value.Connection->connector == OR_OR) && + (exec_result != EXECUTION_SUCCESS))) + { + if (ignore_return && command->value.Connection->second) + command->value.Connection->second->flags |= CMD_IGNORE_RETURN; + + exec_result = execute_command (command->value.Connection->second); + } + executing_list--; + break; + + default: + command_error ("execute_connection", CMDERR_BADCONN, command->value.Connection->connector, 0); + jump_to_top_level (DISCARD); + exec_result = EXECUTION_FAILURE; + } + + return exec_result; +} + +#define REAP() \ + do \ + { \ + if (!interactive_shell) \ + reap_dead_jobs (); \ + } \ + while (0) + +/* Execute a FOR command. The syntax is: FOR word_desc IN word_list; + DO command; DONE */ +static int +execute_for_command (for_command) + FOR_COM *for_command; +{ + register WORD_LIST *releaser, *list; + SHELL_VAR *v; + char *identifier; + int retval, save_line_number; +#if 0 + SHELL_VAR *old_value = (SHELL_VAR *)NULL; /* Remember the old value of x. */ +#endif + + save_line_number = line_number; + if (check_identifier (for_command->name, 1) == 0) + { + if (posixly_correct && interactive_shell == 0) + { + last_command_exit_value = EX_BADUSAGE; + jump_to_top_level (ERREXIT); + } + return (EXECUTION_FAILURE); + } + + loop_level++; + identifier = for_command->name->word; + + list = releaser = expand_words_no_vars (for_command->map_list); + + begin_unwind_frame ("for"); + add_unwind_protect (dispose_words, releaser); + +#if 0 + if (lexical_scoping) + { + old_value = copy_variable (find_variable (identifier)); + if (old_value) + add_unwind_protect (dispose_variable, old_value); + } +#endif + + if (for_command->flags & CMD_IGNORE_RETURN) + for_command->action->flags |= CMD_IGNORE_RETURN; + + for (retval = EXECUTION_SUCCESS; list; list = list->next) + { + QUIT; + + line_number = for_command->line; + + /* Remember what this command looks like, for debugger. */ + command_string_index = 0; + print_for_command_head (for_command); + + if (echo_command_at_execute) + xtrace_print_for_command_head (for_command); + + /* Save this command unless it's a trap command and we're not running + a debug trap. */ + if (signal_in_progress (DEBUG_TRAP) == 0 && running_trap == 0) + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } + + retval = run_debug_trap (); +#if defined (DEBUGGER) + /* In debugging mode, if the DEBUG trap returns a non-zero status, we + skip the command. */ + if (debugging_mode && retval != EXECUTION_SUCCESS) + continue; +#endif + + this_command_name = (char *)NULL; + /* XXX - special ksh93 for command index variable handling */ + v = find_variable_last_nameref (identifier); + if (v && nameref_p (v)) + { + v = bind_variable_value (v, list->word->word, 0); + } + else + v = bind_variable (identifier, list->word->word, 0); + if (readonly_p (v) || noassign_p (v)) + { + line_number = save_line_number; + if (readonly_p (v) && interactive_shell == 0 && posixly_correct) + { + last_command_exit_value = EXECUTION_FAILURE; + jump_to_top_level (FORCE_EOF); + } + else + { + dispose_words (releaser); + discard_unwind_frame ("for"); + loop_level--; + return (EXECUTION_FAILURE); + } + } + retval = execute_command (for_command->action); + REAP (); + QUIT; + + if (breaking) + { + breaking--; + break; + } + + if (continuing) + { + continuing--; + if (continuing) + break; + } + } + + loop_level--; + line_number = save_line_number; + +#if 0 + if (lexical_scoping) + { + if (!old_value) + unbind_variable (identifier); + else + { + SHELL_VAR *new_value; + + new_value = bind_variable (identifier, value_cell(old_value), 0); + new_value->attributes = old_value->attributes; + dispose_variable (old_value); + } + } +#endif + + dispose_words (releaser); + discard_unwind_frame ("for"); + return (retval); +} + +#if defined (ARITH_FOR_COMMAND) +/* Execute an arithmetic for command. The syntax is + + for (( init ; step ; test )) + do + body + done + + The execution should be exactly equivalent to + + eval \(\( init \)\) + while eval \(\( test \)\) ; do + body; + eval \(\( step \)\) + done +*/ +static intmax_t +eval_arith_for_expr (l, okp) + WORD_LIST *l; + int *okp; +{ + WORD_LIST *new; + intmax_t expresult; + int r; + + new = expand_words_no_vars (l); + if (new) + { + if (echo_command_at_execute) + xtrace_print_arith_cmd (new); + this_command_name = "(("; /* )) for expression error messages */ + + command_string_index = 0; + print_arith_command (new); + if (signal_in_progress (DEBUG_TRAP) == 0) + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } + + r = run_debug_trap (); + /* In debugging mode, if the DEBUG trap returns a non-zero status, we + skip the command. */ +#if defined (DEBUGGER) + if (debugging_mode == 0 || r == EXECUTION_SUCCESS) + expresult = evalexp (new->word->word, okp); + else + { + expresult = 0; + if (okp) + *okp = 1; + } +#else + expresult = evalexp (new->word->word, okp); +#endif + dispose_words (new); + } + else + { + expresult = 0; + if (okp) + *okp = 1; + } + return (expresult); +} + +static int +execute_arith_for_command (arith_for_command) + ARITH_FOR_COM *arith_for_command; +{ + intmax_t expresult; + int expok, body_status, arith_lineno, save_lineno; + + body_status = EXECUTION_SUCCESS; + loop_level++; + save_lineno = line_number; + + if (arith_for_command->flags & CMD_IGNORE_RETURN) + arith_for_command->action->flags |= CMD_IGNORE_RETURN; + + this_command_name = "(("; /* )) for expression error messages */ + + /* save the starting line number of the command so we can reset + line_number before executing each expression -- for $LINENO + and the DEBUG trap. */ + line_number = arith_lineno = arith_for_command->line; + if (variable_context && interactive_shell) + line_number -= function_line_number; + + /* Evaluate the initialization expression. */ + expresult = eval_arith_for_expr (arith_for_command->init, &expok); + if (expok == 0) + { + line_number = save_lineno; + return (EXECUTION_FAILURE); + } + + while (1) + { + /* Evaluate the test expression. */ + line_number = arith_lineno; + expresult = eval_arith_for_expr (arith_for_command->test, &expok); + line_number = save_lineno; + + if (expok == 0) + { + body_status = EXECUTION_FAILURE; + break; + } + REAP (); + if (expresult == 0) + break; + + /* Execute the body of the arithmetic for command. */ + QUIT; + body_status = execute_command (arith_for_command->action); + QUIT; + + /* Handle any `break' or `continue' commands executed by the body. */ + if (breaking) + { + breaking--; + break; + } + + if (continuing) + { + continuing--; + if (continuing) + break; + } + + /* Evaluate the step expression. */ + line_number = arith_lineno; + expresult = eval_arith_for_expr (arith_for_command->step, &expok); + line_number = save_lineno; + + if (expok == 0) + { + body_status = EXECUTION_FAILURE; + break; + } + } + + loop_level--; + line_number = save_lineno; + + return (body_status); +} +#endif + +#if defined (SELECT_COMMAND) +static int LINES, COLS, tabsize; + +#define RP_SPACE ") " +#define RP_SPACE_LEN 2 + +/* XXX - does not handle numbers > 1000000 at all. */ +#define NUMBER_LEN(s) \ +((s < 10) ? 1 \ + : ((s < 100) ? 2 \ + : ((s < 1000) ? 3 \ + : ((s < 10000) ? 4 \ + : ((s < 100000) ? 5 \ + : 6))))) + +static int +displen (s) + const char *s; +{ +#if defined (HANDLE_MULTIBYTE) + wchar_t *wcstr; + size_t slen; + int wclen; + + wcstr = 0; + slen = mbstowcs (wcstr, s, 0); + if (slen == -1) + slen = 0; + wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (slen + 1)); + mbstowcs (wcstr, s, slen + 1); + wclen = wcswidth (wcstr, slen); + free (wcstr); + return (wclen < 0 ? STRLEN(s) : wclen); +#else + return (STRLEN (s)); +#endif +} + +static int +print_index_and_element (len, ind, list) + int len, ind; + WORD_LIST *list; +{ + register WORD_LIST *l; + register int i; + + if (list == 0) + return (0); + for (i = ind, l = list; l && --i; l = l->next) + ; + if (l == 0) /* don't think this can happen */ + return (0); + fprintf (stderr, "%*d%s%s", len, ind, RP_SPACE, l->word->word); + return (displen (l->word->word)); +} + +static void +indent (from, to) + int from, to; +{ + while (from < to) + { + if ((to / tabsize) > (from / tabsize)) + { + putc ('\t', stderr); + from += tabsize - from % tabsize; + } + else + { + putc (' ', stderr); + from++; + } + } +} + +static void +print_select_list (list, list_len, max_elem_len, indices_len) + WORD_LIST *list; + int list_len, max_elem_len, indices_len; +{ + int ind, row, elem_len, pos, cols, rows; + int first_column_indices_len, other_indices_len; + + if (list == 0) + { + putc ('\n', stderr); + return; + } + + cols = max_elem_len ? COLS / max_elem_len : 1; + if (cols == 0) + cols = 1; + rows = list_len ? list_len / cols + (list_len % cols != 0) : 1; + cols = list_len ? list_len / rows + (list_len % rows != 0) : 1; + + if (rows == 1) + { + rows = cols; + cols = 1; + } + + first_column_indices_len = NUMBER_LEN (rows); + other_indices_len = indices_len; + + for (row = 0; row < rows; row++) + { + ind = row; + pos = 0; + while (1) + { + indices_len = (pos == 0) ? first_column_indices_len : other_indices_len; + elem_len = print_index_and_element (indices_len, ind + 1, list); + elem_len += indices_len + RP_SPACE_LEN; + ind += rows; + if (ind >= list_len) + break; + indent (pos + elem_len, pos + max_elem_len); + pos += max_elem_len; + } + putc ('\n', stderr); + } +} + +/* Print the elements of LIST, one per line, preceded by an index from 1 to + LIST_LEN. Then display PROMPT and wait for the user to enter a number. + If the number is between 1 and LIST_LEN, return that selection. If EOF + is read, return a null string. If a blank line is entered, or an invalid + number is entered, the loop is executed again. */ +static char * +select_query (list, list_len, prompt, print_menu) + WORD_LIST *list; + int list_len; + char *prompt; + int print_menu; +{ + int max_elem_len, indices_len, len; + intmax_t reply; + WORD_LIST *l; + char *repl_string, *t; + +#if 0 + t = get_string_value ("LINES"); + LINES = (t && *t) ? atoi (t) : 24; +#endif + t = get_string_value ("COLUMNS"); + COLS = (t && *t) ? atoi (t) : 80; + +#if 0 + t = get_string_value ("TABSIZE"); + tabsize = (t && *t) ? atoi (t) : 8; + if (tabsize <= 0) + tabsize = 8; +#else + tabsize = 8; +#endif + + max_elem_len = 0; + for (l = list; l; l = l->next) + { + len = displen (l->word->word); + if (len > max_elem_len) + max_elem_len = len; + } + indices_len = NUMBER_LEN (list_len); + max_elem_len += indices_len + RP_SPACE_LEN + 2; + + while (1) + { + if (print_menu) + print_select_list (list, list_len, max_elem_len, indices_len); + fprintf (stderr, "%s", prompt); + fflush (stderr); + QUIT; + + if (read_builtin ((WORD_LIST *)NULL) != EXECUTION_SUCCESS) + { + putchar ('\n'); + return ((char *)NULL); + } + repl_string = get_string_value ("REPLY"); + if (*repl_string == 0) + { + print_menu = 1; + continue; + } + if (legal_number (repl_string, &reply) == 0) + return ""; + if (reply < 1 || reply > list_len) + return ""; + + for (l = list; l && --reply; l = l->next) + ; + return (l->word->word); /* XXX - can't be null? */ + } +} + +/* Execute a SELECT command. The syntax is: + SELECT word IN list DO command_list DONE + Only `break' or `return' in command_list will terminate + the command. */ +static int +execute_select_command (select_command) + SELECT_COM *select_command; +{ + WORD_LIST *releaser, *list; + SHELL_VAR *v; + char *identifier, *ps3_prompt, *selection; + int retval, list_len, show_menu, save_line_number; + + if (check_identifier (select_command->name, 1) == 0) + return (EXECUTION_FAILURE); + + save_line_number = line_number; + line_number = select_command->line; + + command_string_index = 0; + print_select_command_head (select_command); + + if (echo_command_at_execute) + xtrace_print_select_command_head (select_command); + +#if 0 + if (signal_in_progress (DEBUG_TRAP) == 0 && (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0))) +#else + if (signal_in_progress (DEBUG_TRAP) == 0 && running_trap == 0) +#endif + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } + + retval = run_debug_trap (); +#if defined (DEBUGGER) + /* In debugging mode, if the DEBUG trap returns a non-zero status, we + skip the command. */ + if (debugging_mode && retval != EXECUTION_SUCCESS) + return (EXECUTION_SUCCESS); +#endif + + loop_level++; + identifier = select_command->name->word; + + /* command and arithmetic substitution, parameter and variable expansion, + word splitting, pathname expansion, and quote removal. */ + list = releaser = expand_words_no_vars (select_command->map_list); + list_len = list_length (list); + if (list == 0 || list_len == 0) + { + if (list) + dispose_words (list); + line_number = save_line_number; + return (EXECUTION_SUCCESS); + } + + begin_unwind_frame ("select"); + add_unwind_protect (dispose_words, releaser); + + if (select_command->flags & CMD_IGNORE_RETURN) + select_command->action->flags |= CMD_IGNORE_RETURN; + + retval = EXECUTION_SUCCESS; + show_menu = 1; + + while (1) + { + line_number = select_command->line; + ps3_prompt = get_string_value ("PS3"); + if (ps3_prompt == 0) + ps3_prompt = "#? "; + + QUIT; + selection = select_query (list, list_len, ps3_prompt, show_menu); + QUIT; + if (selection == 0) + { + /* select_query returns EXECUTION_FAILURE if the read builtin + fails, so we want to return failure in this case. */ + retval = EXECUTION_FAILURE; + break; + } + + v = bind_variable (identifier, selection, 0); + if (readonly_p (v) || noassign_p (v)) + { + if (readonly_p (v) && interactive_shell == 0 && posixly_correct) + { + last_command_exit_value = EXECUTION_FAILURE; + jump_to_top_level (FORCE_EOF); + } + else + { + dispose_words (releaser); + discard_unwind_frame ("select"); + loop_level--; + line_number = save_line_number; + return (EXECUTION_FAILURE); + } + } + + retval = execute_command (select_command->action); + + REAP (); + QUIT; + + if (breaking) + { + breaking--; + break; + } + + if (continuing) + { + continuing--; + if (continuing) + break; + } + +#if defined (KSH_COMPATIBLE_SELECT) + show_menu = 0; + selection = get_string_value ("REPLY"); + if (selection && *selection == '\0') + show_menu = 1; +#endif + } + + loop_level--; + line_number = save_line_number; + + dispose_words (releaser); + discard_unwind_frame ("select"); + return (retval); +} +#endif /* SELECT_COMMAND */ + +/* Execute a CASE command. The syntax is: CASE word_desc IN pattern_list ESAC. + The pattern_list is a linked list of pattern clauses; each clause contains + some patterns to compare word_desc against, and an associated command to + execute. */ +static int +execute_case_command (case_command) + CASE_COM *case_command; +{ + register WORD_LIST *list; + WORD_LIST *wlist, *es; + PATTERN_LIST *clauses; + char *word, *pattern; + int retval, match, ignore_return, save_line_number; + + save_line_number = line_number; + line_number = case_command->line; + + command_string_index = 0; + print_case_command_head (case_command); + + if (echo_command_at_execute) + xtrace_print_case_command_head (case_command); + +#if 0 + if (signal_in_progress (DEBUG_TRAP) == 0 && (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0))) +#else + if (signal_in_progress (DEBUG_TRAP) == 0 && running_trap == 0) +#endif + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } + + retval = run_debug_trap(); +#if defined (DEBUGGER) + /* In debugging mode, if the DEBUG trap returns a non-zero status, we + skip the command. */ + if (debugging_mode && retval != EXECUTION_SUCCESS) + { + line_number = save_line_number; + return (EXECUTION_SUCCESS); + } +#endif + + wlist = expand_word_unsplit (case_command->word, 0); + word = wlist ? string_list (wlist) : savestring (""); + dispose_words (wlist); + + retval = EXECUTION_SUCCESS; + ignore_return = case_command->flags & CMD_IGNORE_RETURN; + + begin_unwind_frame ("case"); + add_unwind_protect ((Function *)xfree, word); + +#define EXIT_CASE() goto exit_case_command + + for (clauses = case_command->clauses; clauses; clauses = clauses->next) + { + QUIT; + for (list = clauses->patterns; list; list = list->next) + { + es = expand_word_leave_quoted (list->word, 0); + + if (es && es->word && es->word->word && *(es->word->word)) + pattern = quote_string_for_globbing (es->word->word, QGLOB_CVTNULL); + else + { + pattern = (char *)xmalloc (1); + pattern[0] = '\0'; + } + + /* Since the pattern does not undergo quote removal (as per + Posix.2, section 3.9.4.3), the strmatch () call must be able + to recognize backslashes as escape characters. */ + match = strmatch (pattern, word, FNMATCH_EXTFLAG|FNMATCH_IGNCASE) != FNM_NOMATCH; + free (pattern); + + dispose_words (es); + + if (match) + { + do + { + if (clauses->action && ignore_return) + clauses->action->flags |= CMD_IGNORE_RETURN; + retval = execute_command (clauses->action); + } + while ((clauses->flags & CASEPAT_FALLTHROUGH) && (clauses = clauses->next)); + if (clauses == 0 || (clauses->flags & CASEPAT_TESTNEXT) == 0) + EXIT_CASE (); + else + break; + } + + QUIT; + } + } + +exit_case_command: + free (word); + discard_unwind_frame ("case"); + line_number = save_line_number; + return (retval); +} + +#define CMD_WHILE 0 +#define CMD_UNTIL 1 + +/* The WHILE command. Syntax: WHILE test DO action; DONE. + Repeatedly execute action while executing test produces + EXECUTION_SUCCESS. */ +static int +execute_while_command (while_command) + WHILE_COM *while_command; +{ + return (execute_while_or_until (while_command, CMD_WHILE)); +} + +/* UNTIL is just like WHILE except that the test result is negated. */ +static int +execute_until_command (while_command) + WHILE_COM *while_command; +{ + return (execute_while_or_until (while_command, CMD_UNTIL)); +} + +/* The body for both while and until. The only difference between the + two is that the test value is treated differently. TYPE is + CMD_WHILE or CMD_UNTIL. The return value for both commands should + be EXECUTION_SUCCESS if no commands in the body are executed, and + the status of the last command executed in the body otherwise. */ +static int +execute_while_or_until (while_command, type) + WHILE_COM *while_command; + int type; +{ + int return_value, body_status; + + body_status = EXECUTION_SUCCESS; + loop_level++; + + while_command->test->flags |= CMD_IGNORE_RETURN; + if (while_command->flags & CMD_IGNORE_RETURN) + while_command->action->flags |= CMD_IGNORE_RETURN; + + while (1) + { + return_value = execute_command (while_command->test); + REAP (); + + /* Need to handle `break' in the test when we would break out of the + loop. The job control code will set `breaking' to loop_level + when a job in a loop is stopped with SIGTSTP. If the stopped job + is in the loop test, `breaking' will not be reset unless we do + this, and the shell will cease to execute commands. */ + if (type == CMD_WHILE && return_value != EXECUTION_SUCCESS) + { + if (breaking) + breaking--; + break; + } + if (type == CMD_UNTIL && return_value == EXECUTION_SUCCESS) + { + if (breaking) + breaking--; + break; + } + + QUIT; + body_status = execute_command (while_command->action); + QUIT; + + if (breaking) + { + breaking--; + break; + } + + if (continuing) + { + continuing--; + if (continuing) + break; + } + } + loop_level--; + + return (body_status); +} + +/* IF test THEN command [ELSE command]. + IF also allows ELIF in the place of ELSE IF, but + the parser makes *that* stupidity transparent. */ +static int +execute_if_command (if_command) + IF_COM *if_command; +{ + int return_value, save_line_number; + + save_line_number = line_number; + if_command->test->flags |= CMD_IGNORE_RETURN; + return_value = execute_command (if_command->test); + line_number = save_line_number; + + if (return_value == EXECUTION_SUCCESS) + { + QUIT; + + if (if_command->true_case && (if_command->flags & CMD_IGNORE_RETURN)) + if_command->true_case->flags |= CMD_IGNORE_RETURN; + + return (execute_command (if_command->true_case)); + } + else + { + QUIT; + + if (if_command->false_case && (if_command->flags & CMD_IGNORE_RETURN)) + if_command->false_case->flags |= CMD_IGNORE_RETURN; + + return (execute_command (if_command->false_case)); + } +} + +#if defined (DPAREN_ARITHMETIC) +static int +execute_arith_command (arith_command) + ARITH_COM *arith_command; +{ + int expok, save_line_number, retval; + intmax_t expresult; + WORD_LIST *new; + char *exp; + + expresult = 0; + + save_line_number = line_number; + this_command_name = "(("; /* )) */ + line_number = arith_command->line; + /* If we're in a function, update the line number information. */ + if (variable_context && interactive_shell) + line_number -= function_line_number; + + command_string_index = 0; + print_arith_command (arith_command->exp); + + if (signal_in_progress (DEBUG_TRAP) == 0) + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } + + /* Run the debug trap before each arithmetic command, but do it after we + update the line number information and before we expand the various + words in the expression. */ + retval = run_debug_trap (); +#if defined (DEBUGGER) + /* In debugging mode, if the DEBUG trap returns a non-zero status, we + skip the command. */ + if (debugging_mode && retval != EXECUTION_SUCCESS) + { + line_number = save_line_number; + return (EXECUTION_SUCCESS); + } +#endif + + new = expand_words_no_vars (arith_command->exp); + + /* If we're tracing, make a new word list with `((' at the front and `))' + at the back and print it. */ + if (echo_command_at_execute) + xtrace_print_arith_cmd (new); + + if (new) + { + exp = new->next ? string_list (new) : new->word->word; + expresult = evalexp (exp, &expok); + line_number = save_line_number; + if (exp != new->word->word) + free (exp); + dispose_words (new); + } + else + { + expresult = 0; + expok = 1; + } + + if (expok == 0) + return (EXECUTION_FAILURE); + + return (expresult == 0 ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} +#endif /* DPAREN_ARITHMETIC */ + +#if defined (COND_COMMAND) + +static char * const nullstr = ""; + +/* XXX - can COND ever be NULL when this is called? */ +static int +execute_cond_node (cond) + COND_COM *cond; +{ + int result, invert, patmatch, rmatch, mflags, ignore; + char *arg1, *arg2; + + invert = (cond->flags & CMD_INVERT_RETURN); + ignore = (cond->flags & CMD_IGNORE_RETURN); + if (ignore) + { + if (cond->left) + cond->left->flags |= CMD_IGNORE_RETURN; + if (cond->right) + cond->right->flags |= CMD_IGNORE_RETURN; + } + + if (cond->type == COND_EXPR) + result = execute_cond_node (cond->left); + else if (cond->type == COND_OR) + { + result = execute_cond_node (cond->left); + if (result != EXECUTION_SUCCESS) + result = execute_cond_node (cond->right); + } + else if (cond->type == COND_AND) + { + result = execute_cond_node (cond->left); + if (result == EXECUTION_SUCCESS) + result = execute_cond_node (cond->right); + } + else if (cond->type == COND_UNARY) + { + if (ignore) + comsub_ignore_return++; + arg1 = cond_expand_word (cond->left->op, 0); + if (ignore) + comsub_ignore_return--; + if (arg1 == 0) + arg1 = nullstr; + if (echo_command_at_execute) + xtrace_print_cond_term (cond->type, invert, cond->op, arg1, (char *)NULL); + result = unary_test (cond->op->word, arg1) ? EXECUTION_SUCCESS : EXECUTION_FAILURE; + if (arg1 != nullstr) + free (arg1); + } + else if (cond->type == COND_BINARY) + { + rmatch = 0; + patmatch = (((cond->op->word[1] == '=') && (cond->op->word[2] == '\0') && + (cond->op->word[0] == '!' || cond->op->word[0] == '=')) || + (cond->op->word[0] == '=' && cond->op->word[1] == '\0')); +#if defined (COND_REGEXP) + rmatch = (cond->op->word[0] == '=' && cond->op->word[1] == '~' && + cond->op->word[2] == '\0'); +#endif + + if (ignore) + comsub_ignore_return++; + arg1 = cond_expand_word (cond->left->op, 0); + if (ignore) + comsub_ignore_return--; + if (arg1 == 0) + arg1 = nullstr; + if (ignore) + comsub_ignore_return++; + arg2 = cond_expand_word (cond->right->op, + (rmatch && shell_compatibility_level > 31) ? 2 : (patmatch ? 1 : 0)); + if (ignore) + comsub_ignore_return--; + if (arg2 == 0) + arg2 = nullstr; + + if (echo_command_at_execute) + xtrace_print_cond_term (cond->type, invert, cond->op, arg1, arg2); + +#if defined (COND_REGEXP) + if (rmatch) + { + mflags = SHMAT_PWARN; +#if defined (ARRAY_VARS) + mflags |= SHMAT_SUBEXP; +#endif + + result = sh_regmatch (arg1, arg2, mflags); + } + else +#endif /* COND_REGEXP */ + { + int oe; + oe = extended_glob; + extended_glob = 1; + result = binary_test (cond->op->word, arg1, arg2, TEST_PATMATCH|TEST_ARITHEXP|TEST_LOCALE) + ? EXECUTION_SUCCESS + : EXECUTION_FAILURE; + extended_glob = oe; + } + if (arg1 != nullstr) + free (arg1); + if (arg2 != nullstr) + free (arg2); + } + else + { + command_error ("execute_cond_node", CMDERR_BADTYPE, cond->type, 0); + jump_to_top_level (DISCARD); + result = EXECUTION_FAILURE; + } + + if (invert) + result = (result == EXECUTION_SUCCESS) ? EXECUTION_FAILURE : EXECUTION_SUCCESS; + + return result; +} + +static int +execute_cond_command (cond_command) + COND_COM *cond_command; +{ + int retval, save_line_number; + + retval = EXECUTION_SUCCESS; + save_line_number = line_number; + + this_command_name = "[["; + line_number = cond_command->line; + /* If we're in a function, update the line number information. */ + if (variable_context && interactive_shell) + line_number -= function_line_number; + command_string_index = 0; + print_cond_command (cond_command); + + if (signal_in_progress (DEBUG_TRAP) == 0) + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = savestring (the_printed_command); + } + + /* Run the debug trap before each conditional command, but do it after we + update the line number information. */ + retval = run_debug_trap (); +#if defined (DEBUGGER) + /* In debugging mode, if the DEBUG trap returns a non-zero status, we + skip the command. */ + if (debugging_mode && retval != EXECUTION_SUCCESS) + { + line_number = save_line_number; + return (EXECUTION_SUCCESS); + } +#endif + +#if 0 + debug_print_cond_command (cond_command); +#endif + + last_command_exit_value = retval = execute_cond_node (cond_command); + line_number = save_line_number; + return (retval); +} +#endif /* COND_COMMAND */ + +static void +bind_lastarg (arg) + char *arg; +{ + SHELL_VAR *var; + + if (arg == 0) + arg = ""; + var = bind_variable ("_", arg, 0); + VUNSETATTR (var, att_exported); +} + +/* Execute a null command. Fork a subshell if the command uses pipes or is + to be run asynchronously. This handles all the side effects that are + supposed to take place. */ +static int +execute_null_command (redirects, pipe_in, pipe_out, async) + REDIRECT *redirects; + int pipe_in, pipe_out, async; +{ + int r; + int forcefork; + REDIRECT *rd; + + for (forcefork = 0, rd = redirects; rd; rd = rd->next) + forcefork += rd->rflags & REDIR_VARASSIGN; + + if (forcefork || pipe_in != NO_PIPE || pipe_out != NO_PIPE || async) + { + /* We have a null command, but we really want a subshell to take + care of it. Just fork, do piping and redirections, and exit. */ + if (make_child ((char *)NULL, async) == 0) + { + /* Cancel traps, in trap.c. */ + restore_original_signals (); /* XXX */ + + do_piping (pipe_in, pipe_out); + +#if defined (COPROCESS_SUPPORT) + coproc_closeall (); +#endif + + subshell_environment = 0; + if (async) + subshell_environment |= SUBSHELL_ASYNC; + if (pipe_in != NO_PIPE || pipe_out != NO_PIPE) + subshell_environment |= SUBSHELL_PIPE; + + if (do_redirections (redirects, RX_ACTIVE) == 0) + exit (EXECUTION_SUCCESS); + else + exit (EXECUTION_FAILURE); + } + else + { + close_pipes (pipe_in, pipe_out); +#if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD) + if (pipe_out == NO_PIPE) + unlink_fifo_list (); +#endif + return (EXECUTION_SUCCESS); + } + } + else + { + /* Even if there aren't any command names, pretend to do the + redirections that are specified. The user expects the side + effects to take place. If the redirections fail, then return + failure. Otherwise, if a command substitution took place while + expanding the command or a redirection, return the value of that + substitution. Otherwise, return EXECUTION_SUCCESS. */ + + r = do_redirections (redirects, RX_ACTIVE|RX_UNDOABLE); + cleanup_redirects (redirection_undo_list); + redirection_undo_list = (REDIRECT *)NULL; + + if (r != 0) + return (EXECUTION_FAILURE); + else if (last_command_subst_pid != NO_PID) + return (last_command_exit_value); + else + return (EXECUTION_SUCCESS); + } +} + +/* This is a hack to suppress word splitting for assignment statements + given as arguments to builtins with the ASSIGNMENT_BUILTIN flag set. */ +static void +fix_assignment_words (words) + WORD_LIST *words; +{ + WORD_LIST *w, *wcmd; + struct builtin *b; + int assoc, global; + + if (words == 0) + return; + + b = 0; + assoc = global = 0; + + wcmd = words; + for (w = words; w; w = w->next) + if (w->word->flags & W_ASSIGNMENT) + { + if (b == 0) + { + /* Posix (post-2008) says that `command' doesn't change whether + or not the builtin it shadows is a `declaration command', even + though it removes other special builtin properties. In Posix + mode, we skip over one or more instances of `command' and + deal with the next word as the assignment builtin. */ + while (posixly_correct && wcmd && wcmd->word && wcmd->word->word && STREQ (wcmd->word->word, "command")) + wcmd = wcmd->next; + b = builtin_address_internal (wcmd->word->word, 0); + if (b == 0 || (b->flags & ASSIGNMENT_BUILTIN) == 0) + return; + else if (b && (b->flags & ASSIGNMENT_BUILTIN)) + wcmd->word->flags |= W_ASSNBLTIN; + } + w->word->flags |= (W_NOSPLIT|W_NOGLOB|W_TILDEEXP|W_ASSIGNARG); +#if defined (ARRAY_VARS) + if (assoc) + w->word->flags |= W_ASSIGNASSOC; + if (global) + w->word->flags |= W_ASSNGLOBAL; +#endif + } +#if defined (ARRAY_VARS) + /* Note that we saw an associative array option to a builtin that takes + assignment statements. This is a bit of a kludge. */ + else if (w->word->word[0] == '-' && (strchr (w->word->word+1, 'A') || strchr (w->word->word+1, 'g'))) +#else + else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g')) +#endif + { + if (b == 0) + { + while (posixly_correct && wcmd && wcmd->word && wcmd->word->word && STREQ (wcmd->word->word, "command")) + wcmd = wcmd->next; + b = builtin_address_internal (wcmd->word->word, 0); + if (b == 0 || (b->flags & ASSIGNMENT_BUILTIN) == 0) + return; + else if (b && (b->flags & ASSIGNMENT_BUILTIN)) + wcmd->word->flags |= W_ASSNBLTIN; + } + if ((wcmd->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A')) + assoc = 1; + if ((wcmd->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g')) + global = 1; + } +} + +/* Return 1 if the file found by searching $PATH for PATHNAME, defaulting + to PATHNAME, is a directory. Used by the autocd code below. */ +static int +is_dirname (pathname) + char *pathname; +{ + char *temp; + int ret; + + temp = search_for_command (pathname, 0); + ret = (temp ? file_isdir (temp) : file_isdir (pathname)); + free (temp); + return ret; +} + +/* The meaty part of all the executions. We have to start hacking the + real execution of commands here. Fork a process, set things up, + execute the command. */ +static int +execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close) + SIMPLE_COM *simple_command; + int pipe_in, pipe_out, async; + struct fd_bitmap *fds_to_close; +{ + WORD_LIST *words, *lastword; + char *command_line, *lastarg, *temp; + int first_word_quoted, result, builtin_is_special, already_forked, dofork; + pid_t old_last_async_pid; + sh_builtin_func_t *builtin; + SHELL_VAR *func; + volatile int old_builtin, old_command_builtin; + + result = EXECUTION_SUCCESS; + special_builtin_failed = builtin_is_special = 0; + command_line = (char *)0; + + QUIT; + + /* If we're in a function, update the line number information. */ + if (variable_context && interactive_shell && sourcelevel == 0) + line_number -= function_line_number; + + /* Remember what this command line looks like at invocation. */ + command_string_index = 0; + print_simple_command (simple_command); + +#if 0 + if (signal_in_progress (DEBUG_TRAP) == 0 && (this_command_name == 0 || (STREQ (this_command_name, "trap") == 0))) +#else + if (signal_in_progress (DEBUG_TRAP) == 0 && running_trap == 0) +#endif + { + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = the_printed_command ? savestring (the_printed_command) : (char *)0; + } + + /* Run the debug trap before each simple command, but do it after we + update the line number information. */ + result = run_debug_trap (); +#if defined (DEBUGGER) + /* In debugging mode, if the DEBUG trap returns a non-zero status, we + skip the command. */ + if (debugging_mode && result != EXECUTION_SUCCESS) + return (EXECUTION_SUCCESS); +#endif + + first_word_quoted = + simple_command->words ? (simple_command->words->word->flags & W_QUOTED) : 0; + + last_command_subst_pid = NO_PID; + old_last_async_pid = last_asynchronous_pid; + + already_forked = dofork = 0; + + /* If we're in a pipeline or run in the background, set DOFORK so we + make the child early, before word expansion. This keeps assignment + statements from affecting the parent shell's environment when they + should not. */ + dofork = pipe_in != NO_PIPE || pipe_out != NO_PIPE || async; + + /* Something like `%2 &' should restart job 2 in the background, not cause + the shell to fork here. */ + if (dofork && pipe_in == NO_PIPE && pipe_out == NO_PIPE && + simple_command->words && simple_command->words->word && + simple_command->words->word->word && + (simple_command->words->word->word[0] == '%')) + dofork = 0; + + if (dofork) + { + /* Do this now, because execute_disk_command will do it anyway in the + vast majority of cases. */ + maybe_make_export_env (); + + /* Don't let a DEBUG trap overwrite the command string to be saved with + the process/job associated with this child. */ + if (make_child (savestring (the_printed_command_except_trap), async) == 0) + { + already_forked = 1; + simple_command->flags |= CMD_NO_FORK; + + subshell_environment = SUBSHELL_FORK; + if (pipe_in != NO_PIPE || pipe_out != NO_PIPE) + subshell_environment |= SUBSHELL_PIPE; + if (async) + subshell_environment |= SUBSHELL_ASYNC; + + /* We need to do this before piping to handle some really + pathological cases where one of the pipe file descriptors + is < 2. */ + if (fds_to_close) + close_fd_bitmap (fds_to_close); + + do_piping (pipe_in, pipe_out); + pipe_in = pipe_out = NO_PIPE; +#if defined (COPROCESS_SUPPORT) + coproc_closeall (); +#endif + + last_asynchronous_pid = old_last_async_pid; + } + else + { + /* Don't let simple commands that aren't the last command in a + pipeline change $? for the rest of the pipeline (or at all). */ + if (pipe_out != NO_PIPE) + result = last_command_exit_value; + close_pipes (pipe_in, pipe_out); +#if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD) + /* Close /dev/fd file descriptors in the parent after forking the + last child in a (possibly one-element) pipeline. */ + if (pipe_out == NO_PIPE) /* XXX */ + unlink_fifo_list (); /* XXX */ +#endif + command_line = (char *)NULL; /* don't free this. */ + bind_lastarg ((char *)NULL); + return (result); + } + } + + /* If we are re-running this as the result of executing the `command' + builtin, do not expand the command words a second time. */ + if ((simple_command->flags & CMD_INHIBIT_EXPANSION) == 0) + { + current_fds_to_close = fds_to_close; + fix_assignment_words (simple_command->words); + /* Pass the ignore return flag down to command substitutions */ + if (simple_command->flags & CMD_IGNORE_RETURN) /* XXX */ + comsub_ignore_return++; + words = expand_words (simple_command->words); + if (simple_command->flags & CMD_IGNORE_RETURN) + comsub_ignore_return--; + current_fds_to_close = (struct fd_bitmap *)NULL; + } + else + words = copy_word_list (simple_command->words); + + /* It is possible for WORDS not to have anything left in it. + Perhaps all the words consisted of `$foo', and there was + no variable `$foo'. */ + if (words == 0) + { + this_command_name = 0; + result = execute_null_command (simple_command->redirects, + pipe_in, pipe_out, + already_forked ? 0 : async); + if (already_forked) + exit (result); + else + { + bind_lastarg ((char *)NULL); + set_pipestatus_from_exit (result); + return (result); + } + } + + lastarg = (char *)NULL; + + begin_unwind_frame ("simple-command"); + + if (echo_command_at_execute) + xtrace_print_word_list (words, 1); + + builtin = (sh_builtin_func_t *)NULL; + func = (SHELL_VAR *)NULL; + if ((simple_command->flags & CMD_NO_FUNCTIONS) == 0) + { + /* Posix.2 says special builtins are found before functions. We + don't set builtin_is_special anywhere other than here, because + this path is followed only when the `command' builtin is *not* + being used, and we don't want to exit the shell if a special + builtin executed with `command builtin' fails. `command' is not + a special builtin. */ + if (posixly_correct) + { + builtin = find_special_builtin (words->word->word); + if (builtin) + builtin_is_special = 1; + } + if (builtin == 0) + func = find_function (words->word->word); + } + + /* In POSIX mode, assignment errors in the temporary environment cause a + non-interactive shell to exit. */ + if (builtin_is_special && interactive_shell == 0 && tempenv_assign_error) + { + last_command_exit_value = EXECUTION_FAILURE; + jump_to_top_level (ERREXIT); + } + + add_unwind_protect (dispose_words, words); + QUIT; + + /* Bind the last word in this command to "$_" after execution. */ + for (lastword = words; lastword->next; lastword = lastword->next) + ; + lastarg = lastword->word->word; + +#if defined (JOB_CONTROL) + /* Is this command a job control related thing? */ + if (words->word->word[0] == '%' && already_forked == 0) + { + this_command_name = async ? "bg" : "fg"; + last_shell_builtin = this_shell_builtin; + this_shell_builtin = builtin_address (this_command_name); + result = (*this_shell_builtin) (words); + goto return_result; + } + + /* One other possiblilty. The user may want to resume an existing job. + If they do, find out whether this word is a candidate for a running + job. */ + if (job_control && already_forked == 0 && async == 0 && + !first_word_quoted && + !words->next && + words->word->word[0] && + !simple_command->redirects && + pipe_in == NO_PIPE && + pipe_out == NO_PIPE && + (temp = get_string_value ("auto_resume"))) + { + int job, jflags, started_status; + + jflags = JM_STOPPED|JM_FIRSTMATCH; + if (STREQ (temp, "exact")) + jflags |= JM_EXACT; + else if (STREQ (temp, "substring")) + jflags |= JM_SUBSTRING; + else + jflags |= JM_PREFIX; + job = get_job_by_name (words->word->word, jflags); + if (job != NO_JOB) + { + run_unwind_frame ("simple-command"); + this_command_name = "fg"; + last_shell_builtin = this_shell_builtin; + this_shell_builtin = builtin_address ("fg"); + + started_status = start_job (job, 1); + return ((started_status < 0) ? EXECUTION_FAILURE : started_status); + } + } +#endif /* JOB_CONTROL */ + +run_builtin: + /* Remember the name of this command globally. */ + this_command_name = words->word->word; + + QUIT; + + /* This command could be a shell builtin or a user-defined function. + We have already found special builtins by this time, so we do not + set builtin_is_special. If this is a function or builtin, and we + have pipes, then fork a subshell in here. Otherwise, just execute + the command directly. */ + if (func == 0 && builtin == 0) + builtin = find_shell_builtin (this_command_name); + + last_shell_builtin = this_shell_builtin; + this_shell_builtin = builtin; + + if (builtin || func) + { + if (builtin) + { + old_builtin = executing_builtin; + old_command_builtin = executing_command_builtin; + unwind_protect_int (executing_builtin); /* modified in execute_builtin */ + unwind_protect_int (executing_command_builtin); /* ditto */ + } + if (already_forked) + { + /* reset_terminating_signals (); */ /* XXX */ + /* Reset the signal handlers in the child, but don't free the + trap strings. Set a flag noting that we have to free the + trap strings if we run trap to change a signal disposition. */ + reset_signal_handlers (); + subshell_environment |= SUBSHELL_RESETTRAP; + + if (async) + { + if ((simple_command->flags & CMD_STDIN_REDIR) && + pipe_in == NO_PIPE && + (stdin_redirects (simple_command->redirects) == 0)) + async_redirect_stdin (); + setup_async_signals (); + } + + subshell_level++; + execute_subshell_builtin_or_function + (words, simple_command->redirects, builtin, func, + pipe_in, pipe_out, async, fds_to_close, + simple_command->flags); + subshell_level--; + } + else + { + result = execute_builtin_or_function + (words, builtin, func, simple_command->redirects, fds_to_close, + simple_command->flags); + if (builtin) + { + if (result > EX_SHERRBASE) + { + result = builtin_status (result); + if (builtin_is_special) + special_builtin_failed = 1; + } + /* In POSIX mode, if there are assignment statements preceding + a special builtin, they persist after the builtin + completes. */ + if (posixly_correct && builtin_is_special && temporary_env) + merge_temporary_env (); + } + else /* function */ + { + if (result == EX_USAGE) + result = EX_BADUSAGE; + else if (result > EX_SHERRBASE) + result = EXECUTION_FAILURE; + } + + set_pipestatus_from_exit (result); + + goto return_result; + } + } + + if (autocd && interactive && words->word && is_dirname (words->word->word)) + { + words = make_word_list (make_word ("cd"), words); + xtrace_print_word_list (words, 0); + goto run_builtin; + } + + if (command_line == 0) + command_line = savestring (the_printed_command_except_trap ? the_printed_command_except_trap : ""); + +#if defined (PROCESS_SUBSTITUTION) + if ((subshell_environment & SUBSHELL_COMSUB) && (simple_command->flags & CMD_NO_FORK) && fifos_pending() > 0) + simple_command->flags &= ~CMD_NO_FORK; +#endif + + result = execute_disk_command (words, simple_command->redirects, command_line, + pipe_in, pipe_out, async, fds_to_close, + simple_command->flags); + + return_result: + bind_lastarg (lastarg); + FREE (command_line); + dispose_words (words); + if (builtin) + { + executing_builtin = old_builtin; + executing_command_builtin = old_command_builtin; + } + discard_unwind_frame ("simple-command"); + this_command_name = (char *)NULL; /* points to freed memory now */ + return (result); +} + +/* Translate the special builtin exit statuses. We don't really need a + function for this; it's a placeholder for future work. */ +static int +builtin_status (result) + int result; +{ + int r; + + switch (result) + { + case EX_USAGE: + r = EX_BADUSAGE; + break; + case EX_REDIRFAIL: + case EX_BADSYNTAX: + case EX_BADASSIGN: + case EX_EXPFAIL: + r = EXECUTION_FAILURE; + break; + default: + r = EXECUTION_SUCCESS; + break; + } + return (r); +} + +static int +execute_builtin (builtin, words, flags, subshell) + sh_builtin_func_t *builtin; + WORD_LIST *words; + int flags, subshell; +{ + int old_e_flag, result, eval_unwind; + int isbltinenv; + char *error_trap; + + error_trap = 0; + old_e_flag = exit_immediately_on_error; + + /* The eval builtin calls parse_and_execute, which does not know about + the setting of flags, and always calls the execution functions with + flags that will exit the shell on an error if -e is set. If the + eval builtin is being called, and we're supposed to ignore the exit + value of the command, we turn the -e flag off ourselves and disable + the ERR trap, then restore them when the command completes. This is + also a problem (as below) for the command and source/. builtins. */ + if (subshell == 0 && (flags & CMD_IGNORE_RETURN) && + (builtin == eval_builtin || builtin == command_builtin || builtin == source_builtin)) + { + begin_unwind_frame ("eval_builtin"); + unwind_protect_int (exit_immediately_on_error); + unwind_protect_int (builtin_ignoring_errexit); + error_trap = TRAP_STRING (ERROR_TRAP); + if (error_trap) + { + error_trap = savestring (error_trap); + add_unwind_protect (xfree, error_trap); + add_unwind_protect (set_error_trap, error_trap); + restore_default_signal (ERROR_TRAP); + } + exit_immediately_on_error = 0; + builtin_ignoring_errexit = 1; + eval_unwind = 1; + } + else + eval_unwind = 0; + + /* The temporary environment for a builtin is supposed to apply to + all commands executed by that builtin. Currently, this is a + problem only with the `unset', `source' and `eval' builtins. */ + + isbltinenv = (builtin == source_builtin || builtin == eval_builtin || builtin == unset_builtin); + + if (isbltinenv) + { + if (subshell == 0) + begin_unwind_frame ("builtin_env"); + + if (temporary_env) + { + push_scope (VC_BLTNENV, temporary_env); + if (subshell == 0) + add_unwind_protect (pop_scope, (flags & CMD_COMMAND_BUILTIN) ? 0 : "1"); + temporary_env = (HASH_TABLE *)NULL; + } + } + + /* `return' does a longjmp() back to a saved environment in execute_function. + If a variable assignment list preceded the command, and the shell is + running in POSIX mode, we need to merge that into the shell_variables + table, since `return' is a POSIX special builtin. */ + if (posixly_correct && subshell == 0 && builtin == return_builtin && temporary_env) + { + begin_unwind_frame ("return_temp_env"); + add_unwind_protect (merge_temporary_env, (char *)NULL); + } + + executing_builtin++; + executing_command_builtin |= builtin == command_builtin; + result = ((*builtin) (words->next)); + + /* This shouldn't happen, but in case `return' comes back instead of + longjmp'ing, we need to unwind. */ + if (posixly_correct && subshell == 0 && builtin == return_builtin && temporary_env) + discard_unwind_frame ("return_temp_env"); + + if (subshell == 0 && isbltinenv) + run_unwind_frame ("builtin_env"); + + if (eval_unwind) + { + exit_immediately_on_error = errexit_flag; + builtin_ignoring_errexit = 0; + if (error_trap) + { + set_error_trap (error_trap); + xfree (error_trap); + } + discard_unwind_frame ("eval_builtin"); + } + + return (result); +} + +static int +execute_function (var, words, flags, fds_to_close, async, subshell) + SHELL_VAR *var; + WORD_LIST *words; + int flags; + struct fd_bitmap *fds_to_close; + int async, subshell; +{ + int return_val, result; + COMMAND *tc, *fc, *save_current; + char *debug_trap, *error_trap, *return_trap; +#if defined (ARRAY_VARS) + SHELL_VAR *funcname_v, *nfv, *bash_source_v, *bash_lineno_v; + ARRAY *funcname_a; + volatile ARRAY *bash_source_a; + volatile ARRAY *bash_lineno_a; +#endif + FUNCTION_DEF *shell_fn; + char *sfile, *t; + + USE_VAR(fc); + + if (funcnest_max > 0 && funcnest >= funcnest_max) + { + internal_error (_("%s: maximum function nesting level exceeded (%d)"), var->name, funcnest); + funcnest = 0; /* XXX - should we reset it somewhere else? */ + jump_to_top_level (DISCARD); + } + +#if defined (ARRAY_VARS) + GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a); + GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a); + GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a); +#endif + + tc = (COMMAND *)copy_command (function_cell (var)); + if (tc && (flags & CMD_IGNORE_RETURN)) + tc->flags |= CMD_IGNORE_RETURN; + + if (subshell == 0) + { + begin_unwind_frame ("function_calling"); + push_context (var->name, subshell, temporary_env); + add_unwind_protect (pop_context, (char *)NULL); + unwind_protect_int (line_number); + unwind_protect_int (return_catch_flag); + unwind_protect_jmp_buf (return_catch); + add_unwind_protect (dispose_command, (char *)tc); + unwind_protect_pointer (this_shell_function); + unwind_protect_int (loop_level); + unwind_protect_int (funcnest); + } + else + push_context (var->name, subshell, temporary_env); /* don't unwind-protect for subshells */ + + temporary_env = (HASH_TABLE *)NULL; + + this_shell_function = var; + make_funcname_visible (1); + + debug_trap = TRAP_STRING(DEBUG_TRAP); + error_trap = TRAP_STRING(ERROR_TRAP); + return_trap = TRAP_STRING(RETURN_TRAP); + + /* The order of the unwind protects for debug_trap, error_trap and + return_trap is important here! unwind-protect commands are run + in reverse order of registration. If this causes problems, take + out the xfree unwind-protect calls and live with the small memory leak. */ + + /* function_trace_mode != 0 means that all functions inherit the DEBUG trap. + if the function has the trace attribute set, it inherits the DEBUG trap */ + if (debug_trap && ((trace_p (var) == 0) && function_trace_mode == 0)) + { + if (subshell == 0) + { + debug_trap = savestring (debug_trap); + add_unwind_protect (xfree, debug_trap); + add_unwind_protect (set_debug_trap, debug_trap); + } + restore_default_signal (DEBUG_TRAP); + } + + /* error_trace_mode != 0 means that functions inherit the ERR trap. */ + if (error_trap && error_trace_mode == 0) + { + if (subshell == 0) + { + error_trap = savestring (error_trap); + add_unwind_protect (xfree, error_trap); + add_unwind_protect (set_error_trap, error_trap); + } + restore_default_signal (ERROR_TRAP); + } + + /* Shell functions inherit the RETURN trap if function tracing is on + globally or on individually for this function. */ +#if 0 + if (return_trap && ((trace_p (var) == 0) && function_trace_mode == 0)) +#else + if (return_trap && (signal_in_progress (DEBUG_TRAP) || ((trace_p (var) == 0) && function_trace_mode == 0))) +#endif + { + if (subshell == 0) + { + return_trap = savestring (return_trap); + add_unwind_protect (xfree, return_trap); + add_unwind_protect (set_return_trap, return_trap); + } + restore_default_signal (RETURN_TRAP); + } + + funcnest++; +#if defined (ARRAY_VARS) + /* This is quite similar to the code in shell.c and elsewhere. */ + shell_fn = find_function_def (this_shell_function->name); + sfile = shell_fn ? shell_fn->source_file : ""; + array_push ((ARRAY *)funcname_a, this_shell_function->name); + + array_push ((ARRAY *)bash_source_a, sfile); + t = itos (executing_line_number ()); + array_push ((ARRAY *)bash_lineno_a, t); + free (t); +#endif + + /* The temporary environment for a function is supposed to apply to + all commands executed within the function body. */ + + remember_args (words->next, 1); + + /* Update BASH_ARGV and BASH_ARGC */ + if (debugging_mode) + push_args (words->next); + + /* Number of the line on which the function body starts. */ + line_number = function_line_number = tc->line; + +#if defined (JOB_CONTROL) + if (subshell) + stop_pipeline (async, (COMMAND *)NULL); +#endif + + fc = tc; + + return_catch_flag++; + return_val = setjmp (return_catch); + + if (return_val) + { + result = return_catch_value; + /* Run the RETURN trap in the function's context. */ + save_current = currently_executing_command; + run_return_trap (); + currently_executing_command = save_current; + } + else + { + /* Run the debug trap here so we can trap at the start of a function's + execution rather than the execution of the body's first command. */ + showing_function_line = 1; + save_current = currently_executing_command; + result = run_debug_trap (); +#if defined (DEBUGGER) + /* In debugging mode, if the DEBUG trap returns a non-zero status, we + skip the command. */ + if (debugging_mode == 0 || result == EXECUTION_SUCCESS) + { + showing_function_line = 0; + currently_executing_command = save_current; + result = execute_command_internal (fc, 0, NO_PIPE, NO_PIPE, fds_to_close); + + /* Run the RETURN trap in the function's context */ + save_current = currently_executing_command; + run_return_trap (); + currently_executing_command = save_current; + } +#else + result = execute_command_internal (fc, 0, NO_PIPE, NO_PIPE, fds_to_close); + + save_current = currently_executing_command; + run_return_trap (); + currently_executing_command = save_current; +#endif + showing_function_line = 0; + } + + /* Restore BASH_ARGC and BASH_ARGV */ + if (debugging_mode) + pop_args (); + + if (subshell == 0) + run_unwind_frame ("function_calling"); + +#if defined (ARRAY_VARS) + /* These two variables cannot be unset, and cannot be affected by the + function. */ + array_pop ((ARRAY *)bash_source_a); + array_pop ((ARRAY *)bash_lineno_a); + + /* FUNCNAME can be unset, and so can potentially be changed by the + function. */ + GET_ARRAY_FROM_VAR ("FUNCNAME", nfv, funcname_a); + if (nfv == funcname_v) + array_pop (funcname_a); +#endif + + if (variable_context == 0 || this_shell_function == 0) + { + make_funcname_visible (0); +#if defined (PROCESS_SUBSTITUTION) + unlink_fifo_list (); +#endif + } + + return (result); +} + +/* A convenience routine for use by other parts of the shell to execute + a particular shell function. */ +int +execute_shell_function (var, words) + SHELL_VAR *var; + WORD_LIST *words; +{ + int ret; + struct fd_bitmap *bitmap; + + bitmap = new_fd_bitmap (FD_BITMAP_DEFAULT_SIZE); + begin_unwind_frame ("execute-shell-function"); + add_unwind_protect (dispose_fd_bitmap, (char *)bitmap); + + ret = execute_function (var, words, 0, bitmap, 0, 0); + + dispose_fd_bitmap (bitmap); + discard_unwind_frame ("execute-shell-function"); + + return ret; +} + +/* Execute a shell builtin or function in a subshell environment. This + routine does not return; it only calls exit(). If BUILTIN is non-null, + it points to a function to call to execute a shell builtin; otherwise + VAR points at the body of a function to execute. WORDS is the arguments + to the command, REDIRECTS specifies redirections to perform before the + command is executed. */ +static void +execute_subshell_builtin_or_function (words, redirects, builtin, var, + pipe_in, pipe_out, async, fds_to_close, + flags) + WORD_LIST *words; + REDIRECT *redirects; + sh_builtin_func_t *builtin; + SHELL_VAR *var; + int pipe_in, pipe_out, async; + struct fd_bitmap *fds_to_close; + int flags; +{ + int result, r, funcvalue; +#if defined (JOB_CONTROL) + int jobs_hack; + + jobs_hack = (builtin == jobs_builtin) && + ((subshell_environment & SUBSHELL_ASYNC) == 0 || pipe_out != NO_PIPE); +#endif + + /* A subshell is neither a login shell nor interactive. */ + login_shell = interactive = 0; + + if (async) + subshell_environment |= SUBSHELL_ASYNC; + if (pipe_in != NO_PIPE || pipe_out != NO_PIPE) + subshell_environment |= SUBSHELL_PIPE; + + maybe_make_export_env (); /* XXX - is this needed? */ + +#if defined (JOB_CONTROL) + /* Eradicate all traces of job control after we fork the subshell, so + all jobs begun by this subshell are in the same process group as + the shell itself. */ + + /* Allow the output of `jobs' to be piped. */ + if (jobs_hack) + kill_current_pipeline (); + else + without_job_control (); + + set_sigchld_handler (); +#endif /* JOB_CONTROL */ + + set_sigint_handler (); + + if (fds_to_close) + close_fd_bitmap (fds_to_close); + + do_piping (pipe_in, pipe_out); + + if (do_redirections (redirects, RX_ACTIVE) != 0) + exit (EXECUTION_FAILURE); + + if (builtin) + { + /* Give builtins a place to jump back to on failure, + so we don't go back up to main(). */ + result = setjmp (top_level); + + /* Give the return builtin a place to jump to when executed in a subshell + or pipeline */ + funcvalue = 0; + if (return_catch_flag && builtin == return_builtin) + funcvalue = setjmp (return_catch); + + if (result == EXITPROG) + exit (last_command_exit_value); + else if (result) + exit (EXECUTION_FAILURE); + else if (funcvalue) + exit (return_catch_value); + else + { + r = execute_builtin (builtin, words, flags, 1); + fflush (stdout); + if (r == EX_USAGE) + r = EX_BADUSAGE; + exit (r); + } + } + else + { + r = execute_function (var, words, flags, fds_to_close, async, 1); + fflush (stdout); + exit (r); + } +} + +/* Execute a builtin or function in the current shell context. If BUILTIN + is non-null, it is the builtin command to execute, otherwise VAR points + to the body of a function. WORDS are the command's arguments, REDIRECTS + are the redirections to perform. FDS_TO_CLOSE is the usual bitmap of + file descriptors to close. + + If BUILTIN is exec_builtin, the redirections specified in REDIRECTS are + not undone before this function returns. */ +static int +execute_builtin_or_function (words, builtin, var, redirects, + fds_to_close, flags) + WORD_LIST *words; + sh_builtin_func_t *builtin; + SHELL_VAR *var; + REDIRECT *redirects; + struct fd_bitmap *fds_to_close; + int flags; +{ + int result; + REDIRECT *saved_undo_list; +#if defined (PROCESS_SUBSTITUTION) + int ofifo, nfifo, osize; + char *ofifo_list; +#endif + + +#if defined (PROCESS_SUBSTITUTION) + ofifo = num_fifos (); + ofifo_list = copy_fifo_list (&osize); +#endif + + if (do_redirections (redirects, RX_ACTIVE|RX_UNDOABLE) != 0) + { + cleanup_redirects (redirection_undo_list); + redirection_undo_list = (REDIRECT *)NULL; + dispose_exec_redirects (); +#if defined (PROCESS_SUBSTITUTION) + free (ofifo_list); +#endif + return (EX_REDIRFAIL); /* was EXECUTION_FAILURE */ + } + + saved_undo_list = redirection_undo_list; + + /* Calling the "exec" builtin changes redirections forever. */ + if (builtin == exec_builtin) + { + dispose_redirects (saved_undo_list); + saved_undo_list = exec_redirection_undo_list; + exec_redirection_undo_list = (REDIRECT *)NULL; + } + else + dispose_exec_redirects (); + + if (saved_undo_list) + { + begin_unwind_frame ("saved redirects"); + add_unwind_protect (cleanup_redirects, (char *)saved_undo_list); + } + + redirection_undo_list = (REDIRECT *)NULL; + + if (builtin) + result = execute_builtin (builtin, words, flags, 0); + else + result = execute_function (var, words, flags, fds_to_close, 0, 0); + + /* We do this before undoing the effects of any redirections. */ + fflush (stdout); + fpurge (stdout); + if (ferror (stdout)) + clearerr (stdout); + + /* If we are executing the `command' builtin, but this_shell_builtin is + set to `exec_builtin', we know that we have something like + `command exec [redirection]', since otherwise `exec' would have + overwritten the shell and we wouldn't get here. In this case, we + want to behave as if the `command' builtin had not been specified + and preserve the redirections. */ + if (builtin == command_builtin && this_shell_builtin == exec_builtin) + { + int discard; + + discard = 0; + if (saved_undo_list) + { + dispose_redirects (saved_undo_list); + discard = 1; + } + redirection_undo_list = exec_redirection_undo_list; + saved_undo_list = exec_redirection_undo_list = (REDIRECT *)NULL; + if (discard) + discard_unwind_frame ("saved redirects"); + } + + if (saved_undo_list) + { + redirection_undo_list = saved_undo_list; + discard_unwind_frame ("saved redirects"); + } + + if (redirection_undo_list) + { + cleanup_redirects (redirection_undo_list); + redirection_undo_list = (REDIRECT *)NULL; + } + +#if defined (PROCESS_SUBSTITUTION) + /* Close any FIFOs created by this builtin or function. */ + nfifo = num_fifos (); + if (nfifo > ofifo) + close_new_fifos (ofifo_list, osize); + free (ofifo_list); +#endif + + return (result); +} + +void +setup_async_signals () +{ +#if defined (__BEOS__) + set_signal_handler (SIGHUP, SIG_IGN); /* they want csh-like behavior */ +#endif + +#if defined (JOB_CONTROL) + if (job_control == 0) +#endif + { + set_signal_handler (SIGINT, SIG_IGN); + set_signal_ignored (SIGINT); + set_signal_handler (SIGQUIT, SIG_IGN); + set_signal_ignored (SIGQUIT); + } +} + +/* Execute a simple command that is hopefully defined in a disk file + somewhere. + + 1) fork () + 2) connect pipes + 3) look up the command + 4) do redirections + 5) execve () + 6) If the execve failed, see if the file has executable mode set. + If so, and it isn't a directory, then execute its contents as + a shell script. + + Note that the filename hashing stuff has to take place up here, + in the parent. This is probably why the Bourne style shells + don't handle it, since that would require them to go through + this gnarly hair, for no good reason. + + NOTE: callers expect this to fork or exit(). */ + +/* Name of a shell function to call when a command name is not found. */ +#ifndef NOTFOUND_HOOK +# define NOTFOUND_HOOK "command_not_found_handle" +#endif + +static int +execute_disk_command (words, redirects, command_line, pipe_in, pipe_out, + async, fds_to_close, cmdflags) + WORD_LIST *words; + REDIRECT *redirects; + char *command_line; + int pipe_in, pipe_out, async; + struct fd_bitmap *fds_to_close; + int cmdflags; +{ + char *pathname, *command, **args; + int nofork, result; + pid_t pid; + SHELL_VAR *hookf; + WORD_LIST *wl; + + nofork = (cmdflags & CMD_NO_FORK); /* Don't fork, just exec, if no pipes */ + pathname = words->word->word; + + result = EXECUTION_SUCCESS; +#if defined (RESTRICTED_SHELL) + command = (char *)NULL; + if (restricted && mbschr (pathname, '/')) + { + internal_error (_("%s: restricted: cannot specify `/' in command names"), + pathname); + result = last_command_exit_value = EXECUTION_FAILURE; + + /* If we're not going to fork below, we must already be in a child + process or a context in which it's safe to call exit(2). */ + if (nofork && pipe_in == NO_PIPE && pipe_out == NO_PIPE) + exit (last_command_exit_value); + else + goto parent_return; + } +#endif /* RESTRICTED_SHELL */ + + command = search_for_command (pathname, 1); + + if (command) + { + maybe_make_export_env (); + put_command_name_into_env (command); + } + + /* We have to make the child before we check for the non-existence + of COMMAND, since we want the error messages to be redirected. */ + /* If we can get away without forking and there are no pipes to deal with, + don't bother to fork, just directly exec the command. */ + if (nofork && pipe_in == NO_PIPE && pipe_out == NO_PIPE) + pid = 0; + else + pid = make_child (savestring (command_line), async); + + if (pid == 0) + { + int old_interactive; + +#if 0 + /* This has been disabled for the time being. */ +#if !defined (ARG_MAX) || ARG_MAX >= 10240 + if (posixly_correct == 0) + put_gnu_argv_flags_into_env ((long)getpid (), glob_argv_flags); +#endif +#endif + + reset_terminating_signals (); /* XXX */ + /* Cancel traps, in trap.c. */ + restore_original_signals (); + + /* restore_original_signals may have undone the work done + by make_child to ensure that SIGINT and SIGQUIT are ignored + in asynchronous children. */ + if (async) + { + if ((cmdflags & CMD_STDIN_REDIR) && + pipe_in == NO_PIPE && + (stdin_redirects (redirects) == 0)) + async_redirect_stdin (); + setup_async_signals (); + } + + /* This functionality is now provided by close-on-exec of the + file descriptors manipulated by redirection and piping. + Some file descriptors still need to be closed in all children + because of the way bash does pipes; fds_to_close is a + bitmap of all such file descriptors. */ + if (fds_to_close) + close_fd_bitmap (fds_to_close); + + do_piping (pipe_in, pipe_out); + + old_interactive = interactive; + if (async) + interactive = 0; + + subshell_environment = SUBSHELL_FORK; + + if (redirects && (do_redirections (redirects, RX_ACTIVE) != 0)) + { +#if defined (PROCESS_SUBSTITUTION) + /* Try to remove named pipes that may have been created as the + result of redirections. */ + unlink_fifo_list (); +#endif /* PROCESS_SUBSTITUTION */ + exit (EXECUTION_FAILURE); + } + + if (async) + interactive = old_interactive; + + if (command == 0) + { + hookf = find_function (NOTFOUND_HOOK); + if (hookf == 0) + { + /* Make sure filenames are displayed using printable characters */ + if (ansic_shouldquote (pathname)) + pathname = ansic_quote (pathname, 0, NULL); + internal_error (_("%s: command not found"), pathname); + exit (EX_NOTFOUND); /* Posix.2 says the exit status is 127 */ + } + + /* May need to reinitialize more of the job control state here. */ + kill_current_pipeline (); + + wl = make_word_list (make_word (NOTFOUND_HOOK), words); + exit (execute_shell_function (hookf, wl)); + } + + /* Execve expects the command name to be in args[0]. So we + leave it there, in the same format that the user used to + type it in. */ + args = strvec_from_word_list (words, 0, 0, (int *)NULL); + exit (shell_execve (command, args, export_env)); + } + else + { +parent_return: + QUIT; + + /* Make sure that the pipes are closed in the parent. */ + close_pipes (pipe_in, pipe_out); +#if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD) + if (variable_context == 0) + unlink_fifo_list (); +#endif + FREE (command); + return (result); + } +} + +/* CPP defines to decide whether a particular index into the #! line + corresponds to a valid interpreter name or argument character, or + whitespace. The MSDOS define is to allow \r to be treated the same + as \n. */ + +#if !defined (MSDOS) +# define STRINGCHAR(ind) \ + (ind < sample_len && !whitespace (sample[ind]) && sample[ind] != '\n') +# define WHITECHAR(ind) \ + (ind < sample_len && whitespace (sample[ind])) +#else /* MSDOS */ +# define STRINGCHAR(ind) \ + (ind < sample_len && !whitespace (sample[ind]) && sample[ind] != '\n' && sample[ind] != '\r') +# define WHITECHAR(ind) \ + (ind < sample_len && whitespace (sample[ind])) +#endif /* MSDOS */ + +static char * +getinterp (sample, sample_len, endp) + char *sample; + int sample_len, *endp; +{ + register int i; + char *execname; + int start; + + /* Find the name of the interpreter to exec. */ + for (i = 2; i < sample_len && whitespace (sample[i]); i++) + ; + + for (start = i; STRINGCHAR(i); i++) + ; + + execname = substring (sample, start, i); + + if (endp) + *endp = i; + return execname; +} + +#if !defined (HAVE_HASH_BANG_EXEC) +/* If the operating system on which we're running does not handle + the #! executable format, then help out. SAMPLE is the text read + from the file, SAMPLE_LEN characters. COMMAND is the name of + the script; it and ARGS, the arguments given by the user, will + become arguments to the specified interpreter. ENV is the environment + to pass to the interpreter. + + The word immediately following the #! is the interpreter to execute. + A single argument to the interpreter is allowed. */ + +static int +execute_shell_script (sample, sample_len, command, args, env) + char *sample; + int sample_len; + char *command; + char **args, **env; +{ + char *execname, *firstarg; + int i, start, size_increment, larry; + + /* Find the name of the interpreter to exec. */ + execname = getinterp (sample, sample_len, &i); + size_increment = 1; + + /* Now the argument, if any. */ + for (firstarg = (char *)NULL, start = i; WHITECHAR(i); i++) + ; + + /* If there is more text on the line, then it is an argument for the + interpreter. */ + + if (STRINGCHAR(i)) + { + for (start = i; STRINGCHAR(i); i++) + ; + firstarg = substring ((char *)sample, start, i); + size_increment = 2; + } + + larry = strvec_len (args) + size_increment; + args = strvec_resize (args, larry + 1); + + for (i = larry - 1; i; i--) + args[i] = args[i - size_increment]; + + args[0] = execname; + if (firstarg) + { + args[1] = firstarg; + args[2] = command; + } + else + args[1] = command; + + args[larry] = (char *)NULL; + + return (shell_execve (execname, args, env)); +} +#undef STRINGCHAR +#undef WHITECHAR + +#endif /* !HAVE_HASH_BANG_EXEC */ + +static void +initialize_subshell () +{ +#if defined (ALIAS) + /* Forget about any aliases that we knew of. We are in a subshell. */ + delete_all_aliases (); +#endif /* ALIAS */ + +#if defined (HISTORY) + /* Forget about the history lines we have read. This is a non-interactive + subshell. */ + history_lines_this_session = 0; +#endif + +#if defined (JOB_CONTROL) + /* Forget about the way job control was working. We are in a subshell. */ + without_job_control (); + set_sigchld_handler (); + init_job_stats (); +#endif /* JOB_CONTROL */ + + /* Reset the values of the shell flags and options. */ + reset_shell_flags (); + reset_shell_options (); + reset_shopt_options (); + + /* Zero out builtin_env, since this could be a shell script run from a + sourced file with a temporary environment supplied to the `source/.' + builtin. Such variables are not supposed to be exported (empirical + testing with sh and ksh). Just throw it away; don't worry about a + memory leak. */ + if (vc_isbltnenv (shell_variables)) + shell_variables = shell_variables->down; + + clear_unwind_protect_list (0); + /* XXX -- are there other things we should be resetting here? */ + parse_and_execute_level = 0; /* nothing left to restore it */ + + /* We're no longer inside a shell function. */ + variable_context = return_catch_flag = funcnest = 0; + + executing_list = 0; /* XXX */ + + /* If we're not interactive, close the file descriptor from which we're + reading the current shell script. */ + if (interactive_shell == 0) + unset_bash_input (0); +} + +#if defined (HAVE_SETOSTYPE) && defined (_POSIX_SOURCE) +# define SETOSTYPE(x) __setostype(x) +#else +# define SETOSTYPE(x) +#endif + +#define READ_SAMPLE_BUF(file, buf, len) \ + do \ + { \ + fd = open(file, O_RDONLY); \ + if (fd >= 0) \ + { \ + len = read (fd, buf, 80); \ + close (fd); \ + } \ + else \ + len = -1; \ + } \ + while (0) + +/* Call execve (), handling interpreting shell scripts, and handling + exec failures. */ +int +shell_execve (command, args, env) + char *command; + char **args, **env; +{ + int larray, i, fd; + char sample[80]; + int sample_len; + + SETOSTYPE (0); /* Some systems use for USG/POSIX semantics */ + execve (command, args, env); + i = errno; /* error from execve() */ + CHECK_TERMSIG; + SETOSTYPE (1); + + /* If we get to this point, then start checking out the file. + Maybe it is something we can hack ourselves. */ + if (i != ENOEXEC) + { + if (file_isdir (command)) +#if defined (EISDIR) + internal_error (_("%s: %s"), command, strerror (EISDIR)); +#else + internal_error (_("%s: is a directory"), command); +#endif + else if (executable_file (command) == 0) + { + errno = i; + file_error (command); + } + /* errors not involving the path argument to execve. */ + else if (i == E2BIG || i == ENOMEM) + { + errno = i; + file_error (command); + } + else + { + /* The file has the execute bits set, but the kernel refuses to + run it for some reason. See why. */ +#if defined (HAVE_HASH_BANG_EXEC) + READ_SAMPLE_BUF (command, sample, sample_len); + sample[sample_len - 1] = '\0'; + if (sample_len > 2 && sample[0] == '#' && sample[1] == '!') + { + char *interp; + int ilen; + + interp = getinterp (sample, sample_len, (int *)NULL); + ilen = strlen (interp); + errno = i; + if (interp[ilen - 1] == '\r') + { + interp = xrealloc (interp, ilen + 2); + interp[ilen - 1] = '^'; + interp[ilen] = 'M'; + interp[ilen + 1] = '\0'; + } + sys_error (_("%s: %s: bad interpreter"), command, interp ? interp : ""); + FREE (interp); + return (EX_NOEXEC); + } +#endif + errno = i; + file_error (command); + } + return ((i == ENOENT) ? EX_NOTFOUND : EX_NOEXEC); /* XXX Posix.2 says that exit status is 126 */ + } + + /* This file is executable. + If it begins with #!, then help out people with losing operating + systems. Otherwise, check to see if it is a binary file by seeing + if the contents of the first line (or up to 80 characters) are in the + ASCII set. If it's a text file, execute the contents as shell commands, + otherwise return 126 (EX_BINARY_FILE). */ + READ_SAMPLE_BUF (command, sample, sample_len); + + if (sample_len == 0) + return (EXECUTION_SUCCESS); + + /* Is this supposed to be an executable script? + If so, the format of the line is "#! interpreter [argument]". + A single argument is allowed. The BSD kernel restricts + the length of the entire line to 32 characters (32 bytes + being the size of the BSD exec header), but we allow 80 + characters. */ + if (sample_len > 0) + { +#if !defined (HAVE_HASH_BANG_EXEC) + if (sample_len > 2 && sample[0] == '#' && sample[1] == '!') + return (execute_shell_script (sample, sample_len, command, args, env)); + else +#endif + if (check_binary_file (sample, sample_len)) + { + internal_error (_("%s: cannot execute binary file: %s"), command, strerror (i)); + return (EX_BINARY_FILE); + } + } + + /* We have committed to attempting to execute the contents of this file + as shell commands. */ + + initialize_subshell (); + + set_sigint_handler (); + + /* Insert the name of this shell into the argument list. */ + larray = strvec_len (args) + 1; + args = strvec_resize (args, larray + 1); + + for (i = larray - 1; i; i--) + args[i] = args[i - 1]; + + args[0] = shell_name; + args[1] = command; + args[larray] = (char *)NULL; + + if (args[0][0] == '-') + args[0]++; + +#if defined (RESTRICTED_SHELL) + if (restricted) + change_flag ('r', FLAG_OFF); +#endif + + if (subshell_argv) + { + /* Can't free subshell_argv[0]; that is shell_name. */ + for (i = 1; i < subshell_argc; i++) + free (subshell_argv[i]); + free (subshell_argv); + } + + dispose_command (currently_executing_command); /* XXX */ + currently_executing_command = (COMMAND *)NULL; + + subshell_argc = larray; + subshell_argv = args; + subshell_envp = env; + + unbind_args (); /* remove the positional parameters */ + + longjmp (subshell_top_level, 1); + /*NOTREACHED*/ +} + +static int +execute_intern_function (name, funcdef) + WORD_DESC *name; + FUNCTION_DEF *funcdef; +{ + SHELL_VAR *var; + + if (check_identifier (name, posixly_correct) == 0) + { + if (posixly_correct && interactive_shell == 0) + { + last_command_exit_value = EX_BADUSAGE; + jump_to_top_level (ERREXIT); + } + return (EXECUTION_FAILURE); + } + + /* Posix interpretation 383 */ + if (posixly_correct && find_special_builtin (name->word)) + { + internal_error (_("`%s': is a special builtin"), name->word); + last_command_exit_value = EX_BADUSAGE; + jump_to_top_level (ERREXIT); + } + + var = find_function (name->word); + if (var && (readonly_p (var) || noassign_p (var))) + { + if (readonly_p (var)) + internal_error (_("%s: readonly function"), var->name); + return (EXECUTION_FAILURE); + } + +#if defined (DEBUGGER) + bind_function_def (name->word, funcdef); +#endif + + bind_function (name->word, funcdef->command); + return (EXECUTION_SUCCESS); +} + +#if defined (INCLUDE_UNUSED) +#if defined (PROCESS_SUBSTITUTION) +void +close_all_files () +{ + register int i, fd_table_size; + + fd_table_size = getdtablesize (); + if (fd_table_size > 256) /* clamp to a reasonable value */ + fd_table_size = 256; + + for (i = 3; i < fd_table_size; i++) + close (i); +} +#endif /* PROCESS_SUBSTITUTION */ +#endif + +static void +close_pipes (in, out) + int in, out; +{ + if (in >= 0) + close (in); + if (out >= 0) + close (out); +} + +static void +dup_error (oldd, newd) + int oldd, newd; +{ + sys_error (_("cannot duplicate fd %d to fd %d"), oldd, newd); +} + +/* Redirect input and output to be from and to the specified pipes. + NO_PIPE and REDIRECT_BOTH are handled correctly. */ +static void +do_piping (pipe_in, pipe_out) + int pipe_in, pipe_out; +{ + if (pipe_in != NO_PIPE) + { + if (dup2 (pipe_in, 0) < 0) + dup_error (pipe_in, 0); + if (pipe_in > 0) + close (pipe_in); +#ifdef __CYGWIN__ + /* Let stdio know the fd may have changed from text to binary mode. */ + freopen (NULL, "r", stdin); +#endif /* __CYGWIN__ */ + } + if (pipe_out != NO_PIPE) + { + if (pipe_out != REDIRECT_BOTH) + { + if (dup2 (pipe_out, 1) < 0) + dup_error (pipe_out, 1); + if (pipe_out == 0 || pipe_out > 1) + close (pipe_out); + } + else + { + if (dup2 (1, 2) < 0) + dup_error (1, 2); + } +#ifdef __CYGWIN__ + /* Let stdio know the fd may have changed from text to binary mode, and + make sure to preserve stdout line buffering. */ + freopen (NULL, "w", stdout); + sh_setlinebuf (stdout); +#endif /* __CYGWIN__ */ + } +} diff --git a/flags.c b/flags.c index 8b531e656..eaec9aae8 100644 --- a/flags.c +++ b/flags.c @@ -40,6 +40,7 @@ extern char *shell_name; #endif extern int shell_initialized; +extern int builtin_ignoring_errexit; /* -c, -s invocation options -- not really flags, but they show up in $- */ extern int want_pending_command, read_from_stdin; @@ -59,7 +60,9 @@ int mark_modified_vars = 0; int asynchronous_notification = 0; /* Non-zero means exit immediately if a command exits with a non-zero - exit status. */ + exit status. The first is what controls set -e; the second is what + bash uses internally. */ +int errexit_flag = 0; int exit_immediately_on_error = 0; /* Non-zero means disable filename globbing. */ @@ -179,7 +182,7 @@ const struct flags_alist shell_flags[] = { #if defined (JOB_CONTROL) { 'b', &asynchronous_notification }, #endif /* JOB_CONTROL */ - { 'e', &exit_immediately_on_error }, + { 'e', &errexit_flag }, { 'f', &disallow_filename_globbing }, { 'h', &hashing_enabled }, { 'i', &forced_interactive }, @@ -272,6 +275,11 @@ change_flag (flag, on_or_off) break; #endif /* JOB_CONTROL */ + case 'e': + if (builtin_ignoring_errexit == 0) + exit_immediately_on_error = errexit_flag; + break; + case 'n': if (interactive_shell) read_but_dont_execute = 0; diff --git a/flags.c~ b/flags.c~ new file mode 100644 index 000000000..1ee6bf245 --- /dev/null +++ b/flags.c~ @@ -0,0 +1,364 @@ +/* flags.c -- Everything about flags except the `set' command. That + is in builtins.c */ + +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see . +*/ + +#include "config.h" +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "shell.h" +#include "flags.h" + +#if defined (BANG_HISTORY) +# include "bashhist.h" +#endif + +#if defined (JOB_CONTROL) +extern int set_job_control __P((int)); +#endif + +#if defined (RESTRICTED_SHELL) +extern char *shell_name; +#endif + +extern int shell_initialized; +extern int builtin_ignoring_errexit; + +/* -c, -s invocation options -- not really flags, but they show up in $- */ +extern int want_pending_command, read_from_stdin; + +/* **************************************************************** */ +/* */ +/* The Standard sh Flags. */ +/* */ +/* **************************************************************** */ + +/* Non-zero means automatically mark variables which are modified or created + as auto export variables. */ +int mark_modified_vars = 0; + +/* Non-zero causes asynchronous job notification. Otherwise, job state + notification only takes place just before a primary prompt is printed. */ +int asynchronous_notification = 0; + +/* Non-zero means exit immediately if a command exits with a non-zero + exit status. The first is what controls set -e; the second is what + bash uses internally. */ +int errexit_flag = 0; +int exit_immediately_on_error = 0; + +/* Non-zero means disable filename globbing. */ +int disallow_filename_globbing = 0; + +/* Non-zero means that all keyword arguments are placed into the environment + for a command, not just those that appear on the line before the command + name. */ +int place_keywords_in_env = 0; + +/* Non-zero means read commands, but don't execute them. This is useful + for debugging shell scripts that should do something hairy and possibly + destructive. */ +int read_but_dont_execute = 0; + +/* Non-zero means end of file is after one command. */ +int just_one_command = 0; + +/* Non-zero means don't overwrite existing files while doing redirections. */ +int noclobber = 0; + +/* Non-zero means trying to get the value of $i where $i is undefined + causes an error, instead of a null substitution. */ +int unbound_vars_is_error = 0; + +/* Non-zero means type out input lines after you read them. */ +int echo_input_at_read = 0; + +/* Non-zero means type out the command definition after reading, but + before executing. */ +int echo_command_at_execute = 0; + +/* Non-zero means turn on the job control features. */ +int jobs_m_flag = 0; + +/* Non-zero means this shell is interactive, even if running under a + pipe. */ +int forced_interactive = 0; + +/* By default, follow the symbolic links as if they were real directories + while hacking the `cd' command. This means that `cd ..' moves up in + the string of symbolic links that make up the current directory, instead + of the absolute directory. The shell variable `nolinks' also controls + this flag. */ +int no_symbolic_links = 0; + +/* **************************************************************** */ +/* */ +/* Non-Standard Flags Follow Here. */ +/* */ +/* **************************************************************** */ + +#if 0 +/* Non-zero means do lexical scoping in the body of a FOR command. */ +int lexical_scoping = 0; +#endif + +/* Non-zero means no such thing as invisible variables. */ +int no_invisible_vars = 0; + +/* Non-zero means look up and remember command names in a hash table, */ +int hashing_enabled = 1; + +#if defined (BANG_HISTORY) +/* Non-zero means that we are doing history expansion. The default. + This means !22 gets the 22nd line of history. */ +# if defined (STRICT_POSIX) +int history_expansion = 0; +# else +int history_expansion = 1; +# endif +#endif /* BANG_HISTORY */ + +/* Non-zero means that we allow comments to appear in interactive commands. */ +int interactive_comments = 1; + +#if defined (RESTRICTED_SHELL) +/* Non-zero means that this shell is `restricted'. A restricted shell + disallows: changing directories, command or path names containing `/', + unsetting or resetting the values of $PATH and $SHELL, and any type of + output redirection. */ +int restricted = 0; /* currently restricted */ +int restricted_shell = 0; /* shell was started in restricted mode. */ +#endif /* RESTRICTED_SHELL */ + +/* Non-zero means that this shell is running in `privileged' mode. This + is required if the shell is to run setuid. If the `-p' option is + not supplied at startup, and the real and effective uids or gids + differ, disable_priv_mode is called to relinquish setuid status. */ +int privileged_mode = 0; + +#if defined (BRACE_EXPANSION) +/* Zero means to disable brace expansion: foo{a,b} -> fooa foob */ +int brace_expansion = 1; +#endif + +/* Non-zero means that shell functions inherit the DEBUG trap. */ +int function_trace_mode = 0; + +/* Non-zero means that shell functions inherit the ERR trap. */ +int error_trace_mode = 0; + +/* Non-zero means that the rightmost non-zero exit status in a pipeline + is the exit status of the entire pipeline. If each processes exits + with a 0 status, the status of the pipeline is 0. */ +int pipefail_opt = 0; + +/* **************************************************************** */ +/* */ +/* The Flags ALIST. */ +/* */ +/* **************************************************************** */ + +const struct flags_alist shell_flags[] = { + /* Standard sh flags. */ + { 'a', &mark_modified_vars }, +#if defined (JOB_CONTROL) + { 'b', &asynchronous_notification }, +#endif /* JOB_CONTROL */ + { 'e', &errexit_flag }, + { 'f', &disallow_filename_globbing }, + { 'h', &hashing_enabled }, + { 'i', &forced_interactive }, + { 'k', &place_keywords_in_env }, +#if defined (JOB_CONTROL) + { 'm', &jobs_m_flag }, +#endif /* JOB_CONTROL */ + { 'n', &read_but_dont_execute }, + { 'p', &privileged_mode }, +#if defined (RESTRICTED_SHELL) + { 'r', &restricted }, +#endif /* RESTRICTED_SHELL */ + { 't', &just_one_command }, + { 'u', &unbound_vars_is_error }, + { 'v', &echo_input_at_read }, + { 'x', &echo_command_at_execute }, + + /* New flags that control non-standard things. */ +#if 0 + { 'l', &lexical_scoping }, +#endif +#if defined (BRACE_EXPANSION) + { 'B', &brace_expansion }, +#endif + { 'C', &noclobber }, + { 'E', &error_trace_mode }, +#if defined (BANG_HISTORY) + { 'H', &history_expansion }, +#endif /* BANG_HISTORY */ + { 'I', &no_invisible_vars }, + { 'P', &no_symbolic_links }, + { 'T', &function_trace_mode }, + {0, (int *)NULL} +}; + +#define NUM_SHELL_FLAGS (sizeof (shell_flags) / sizeof (struct flags_alist)) + +char optflags[NUM_SHELL_FLAGS+4] = { '+' }; + +int * +find_flag (name) + int name; +{ + int i; + for (i = 0; shell_flags[i].name; i++) + { + if (shell_flags[i].name == name) + return (shell_flags[i].value); + } + return (FLAG_UNKNOWN); +} + +/* Change the state of a flag, and return it's original value, or return + FLAG_ERROR if there is no flag FLAG. ON_OR_OFF must be either + FLAG_ON or FLAG_OFF. */ +int +change_flag (flag, on_or_off) + int flag; + int on_or_off; +{ + int *value, old_value; + +#if defined (RESTRICTED_SHELL) + /* Don't allow "set +r" in a shell which is `restricted'. */ + if (restricted && flag == 'r' && on_or_off == FLAG_OFF) + return (FLAG_ERROR); +#endif /* RESTRICTED_SHELL */ + + value = find_flag (flag); + + if ((value == (int *)FLAG_UNKNOWN) || (on_or_off != FLAG_ON && on_or_off != FLAG_OFF)) + return (FLAG_ERROR); + + old_value = *value; + *value = (on_or_off == FLAG_ON) ? 1 : 0; + + /* Special cases for a few flags. */ + switch (flag) + { +#if defined (BANG_HISTORY) + case 'H': + if (on_or_off == FLAG_ON) + bash_initialize_history (); + break; +#endif + +#if defined (JOB_CONTROL) + case 'm': + set_job_control (on_or_off == FLAG_ON); + break; +#endif /* JOB_CONTROL */ + + case 'e': + exit_immediately_on_error = errexit_flag; + break; + + case 'n': + if (interactive_shell) + read_but_dont_execute = 0; + break; + + case 'p': + if (on_or_off == FLAG_OFF) + disable_priv_mode (); + break; + +#if defined (RESTRICTED_SHELL) + case 'r': + if (on_or_off == FLAG_ON && shell_initialized) + maybe_make_restricted (shell_name); + break; +#endif + + } + + return (old_value); +} + +/* Return a string which is the names of all the currently + set shell flags. */ +char * +which_set_flags () +{ + char *temp; + int i, string_index; + + temp = (char *)xmalloc (1 + NUM_SHELL_FLAGS + read_from_stdin + want_pending_command); + for (i = string_index = 0; shell_flags[i].name; i++) + if (*(shell_flags[i].value)) + temp[string_index++] = shell_flags[i].name; + + if (want_pending_command) + temp[string_index++] = 'c'; + if (read_from_stdin) + temp[string_index++] = 's'; + + temp[string_index] = '\0'; + return (temp); +} + +void +reset_shell_flags () +{ + mark_modified_vars = exit_immediately_on_error = disallow_filename_globbing = 0; + place_keywords_in_env = read_but_dont_execute = just_one_command = 0; + noclobber = unbound_vars_is_error = echo_input_at_read = 0; + echo_command_at_execute = jobs_m_flag = forced_interactive = 0; + no_symbolic_links = no_invisible_vars = privileged_mode = pipefail_opt = 0; + + hashing_enabled = interactive_comments = 1; + +#if defined (JOB_CONTROL) + asynchronous_notification = 0; +#endif + +#if defined (BANG_HISTORY) + history_expansion = 1; +#endif + +#if defined (BRACE_EXPANSION) + brace_expansion = 1; +#endif + +#if defined (RESTRICTED_SHELL) + restricted = 0; +#endif +} + +void +initialize_flags () +{ + register int i; + + for (i = 0; shell_flags[i].name; i++) + optflags[i+1] = shell_flags[i].name; + optflags[++i] = 'o'; + optflags[++i] = ';'; + optflags[i+1] = '\0'; +} diff --git a/flags.h b/flags.h index e174f1e80..830edab40 100644 --- a/flags.h +++ b/flags.h @@ -41,7 +41,8 @@ extern const struct flags_alist shell_flags[]; extern char optflags[]; extern int - mark_modified_vars, exit_immediately_on_error, disallow_filename_globbing, + mark_modified_vars, errexit_flag, exit_immediately_on_error, + disallow_filename_globbing, place_keywords_in_env, read_but_dont_execute, just_one_command, unbound_vars_is_error, echo_input_at_read, echo_command_at_execute, no_invisible_vars, noclobber, diff --git a/flags.h~ b/flags.h~ new file mode 100644 index 000000000..e174f1e80 --- /dev/null +++ b/flags.h~ @@ -0,0 +1,79 @@ +/* flags.h -- a list of all the flags that the shell knows about. You add + a flag to this program by adding the name here, and in flags.c. */ + +/* Copyright (C) 1993-2009 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see . +*/ + +#if !defined (_FLAGS_H_) +#define _FLAGS_H_ + +#include "stdc.h" + +/* Welcome to the world of Un*x, where everything is slightly backwards. */ +#define FLAG_ON '-' +#define FLAG_OFF '+' + +#define FLAG_ERROR -1 +#define FLAG_UNKNOWN (int *)0 + +/* The thing that we build the array of flags out of. */ +struct flags_alist { + char name; + int *value; +}; + +extern const struct flags_alist shell_flags[]; +extern char optflags[]; + +extern int + mark_modified_vars, exit_immediately_on_error, disallow_filename_globbing, + place_keywords_in_env, read_but_dont_execute, + just_one_command, unbound_vars_is_error, echo_input_at_read, + echo_command_at_execute, no_invisible_vars, noclobber, + hashing_enabled, forced_interactive, privileged_mode, jobs_m_flag, + asynchronous_notification, interactive_comments, no_symbolic_links, + function_trace_mode, error_trace_mode, pipefail_opt; + +#if 0 +extern int lexical_scoping; +#endif + +#if defined (BRACE_EXPANSION) +extern int brace_expansion; +#endif + +#if defined (BANG_HISTORY) +extern int history_expansion; +#endif /* BANG_HISTORY */ + +#if defined (RESTRICTED_SHELL) +extern int restricted; +extern int restricted_shell; +#endif /* RESTRICTED_SHELL */ + +extern int *find_flag __P((int)); +extern int change_flag __P((int, int)); +extern char *which_set_flags __P((void)); +extern void reset_shell_flags __P((void)); + +extern void initialize_flags __P((void)); + +/* A macro for efficiency. */ +#define change_flag_char(flag, on_or_off) change_flag (flag, on_or_off) + +#endif /* _FLAGS_H_ */ diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c index f4ca34550..b4344b00b 100644 --- a/lib/glob/sm_loop.c +++ b/lib/glob/sm_loop.c @@ -547,6 +547,9 @@ PATSCAN (string, end, delim) cchar = 0; bfirst = NULL; + if (string == end) + return (NULL); + for (s = string; c = *s; s++) { if (s >= end) diff --git a/lib/readline/display.c b/lib/readline/display.c index d74ca911e..b86526e24 100644 --- a/lib/readline/display.c +++ b/lib/readline/display.c @@ -169,6 +169,7 @@ int _rl_last_v_pos = 0; static int cpos_adjusted; static int cpos_buffer_position; +static int displaying_prompt_first_line; static int prompt_multibyte_chars; /* Number of lines currently on screen minus 1. */ @@ -964,7 +965,7 @@ rl_redisplay () /* If we can move the cursor up and down, then use multiple lines, otherwise, let long lines display in a single terminal line, and horizontally scroll it. */ - + displaying_prompt_first_line = 1; if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up) { int nleft, pos, changed_screen_line, tx; @@ -1218,6 +1219,8 @@ rl_redisplay () else lmargin = last_lmargin; + displaying_prompt_first_line = lmargin < nleft; + /* If the first character on the screen isn't the first character in the display line, indicate this with a special character. */ if (lmargin > 0) @@ -1243,7 +1246,8 @@ rl_redisplay () _rl_screenwidth + (lmargin ? 0 : wrap_offset), 0); - if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT()) + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && + displaying_prompt_first_line && OLD_CPOS_IN_PROMPT()) _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */ /* If the visible new line is shorter than the old, but the number @@ -1251,7 +1255,7 @@ rl_redisplay () the new line, we need to clear to eol. */ t = _rl_last_c_pos - M_OFFSET (lmargin, wrap_offset); if ((M_OFFSET (lmargin, wrap_offset) > visible_wrap_offset) && - (_rl_last_c_pos == out) && + (_rl_last_c_pos == out) && displaying_prompt_first_line && t < visible_first_line_len) { nleft = _rl_screenwidth - t; @@ -1672,7 +1676,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) /* If nfd begins before any invisible characters in the prompt, adjust _rl_last_c_pos to account for wrap_offset and set cpos_adjusted to let the caller know. */ - if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + if (current_line == 0 && wrap_offset && + displaying_prompt_first_line && + ((nfd - new) <= prompt_last_invisible)) { _rl_last_c_pos -= wrap_offset; cpos_adjusted = 1; @@ -1729,7 +1735,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) /* If nfd begins before the last invisible character in the prompt, adjust _rl_last_c_pos to account for wrap_offset and set cpos_adjusted to let the caller know. */ - if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && displaying_prompt_first_line && wrap_offset && ((nfd - new) <= prompt_last_invisible)) { _rl_last_c_pos -= wrap_offset; cpos_adjusted = 1; @@ -1753,7 +1759,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) /* If nfd begins before the last invisible character in the prompt, adjust _rl_last_c_pos to account for wrap_offset and set cpos_adjusted to let the caller know. */ - if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && displaying_prompt_first_line && wrap_offset && ((nfd - new) <= prompt_last_invisible)) { _rl_last_c_pos -= wrap_offset; cpos_adjusted = 1; @@ -1771,6 +1777,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) a physical character position. */ if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == prompt_last_screen_line && wrap_offset && + displaying_prompt_first_line && wrap_offset != prompt_invis_chars_first_line && ((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth)))) { @@ -1788,9 +1795,18 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) prompt string, don't bother. It screws up the assumptions about what's on the screen. */ if (_rl_horizontal_scroll_mode && _rl_last_c_pos == 0 && + displaying_prompt_first_line && -lendiff == visible_wrap_offset) col_lendiff = 0; + /* If we have moved lmargin and we're shrinking the line, we've + already moved the cursor to the first character of the new line, + so deleting -col_lendiff characters will mess up the cursor + position calculation */ + if (_rl_horizontal_scroll_mode && displaying_prompt_first_line == 0 && + col_lendiff && _rl_last_c_pos < -col_lendiff) + col_lendiff = 0; + if (col_lendiff) delete_chars (-col_lendiff); /* delete (diff) characters */ @@ -1806,7 +1822,10 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { _rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1); - if (current_line == 0 && wrap_offset && _rl_last_c_pos > wrap_offset && ((nfd - new) <= prompt_last_invisible)) + if (current_line == 0 && wrap_offset && + displaying_prompt_first_line && + _rl_last_c_pos > wrap_offset && + ((nfd - new) <= prompt_last_invisible)) { _rl_last_c_pos -= wrap_offset; cpos_adjusted = 1; @@ -1814,6 +1833,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) } else _rl_last_c_pos += temp; + + if (_rl_horizontal_scroll_mode && ((oe-old) > (ne-new))) + goto clear_rest_of_line; } } /* Otherwise, print over the existing material. */ @@ -1829,13 +1851,17 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) _rl_last_c_pos += col_temp; /* XXX */ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { - if (current_line == 0 && wrap_offset && _rl_last_c_pos > wrap_offset && ((nfd - new) <= prompt_last_invisible)) + if (current_line == 0 && wrap_offset && + displaying_prompt_first_line && + _rl_last_c_pos > wrap_offset && + ((nfd - new) <= prompt_last_invisible)) { _rl_last_c_pos -= wrap_offset; cpos_adjusted = 1; } } } +clear_rest_of_line: lendiff = (oe - old) - (ne - new); if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1); @@ -2003,6 +2029,9 @@ _rl_move_cursor_relative (new, data) else dpos = _rl_col_width (data, 0, new, 1); + if (displaying_prompt_first_line == 0) + adjust = 0; + /* Use NEW when comparing against the last invisible character in the prompt string, since they're both buffer indices and DPOS is a desired display position. */ diff --git a/lib/readline/display.c~ b/lib/readline/display.c~ new file mode 100644 index 000000000..4dfefad3f --- /dev/null +++ b/lib/readline/display.c~ @@ -0,0 +1,2834 @@ +/* display.c -- readline redisplay facility. */ + +/* Copyright (C) 1987-2012 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library (Readline), a library + for reading lines of text with interactive input and history editing. + + Readline is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Readline is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Readline. If not, see . +*/ + +#define READLINE_LIBRARY + +#if defined (HAVE_CONFIG_H) +# include +#endif + +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif /* HAVE_UNISTD_H */ + +#include "posixstat.h" + +#if defined (HAVE_STDLIB_H) +# include +#else +# include "ansi_stdlib.h" +#endif /* HAVE_STDLIB_H */ + +#include + +#ifdef __MSDOS__ +# include +#endif + +/* System-specific feature definitions and include files. */ +#include "rldefs.h" +#include "rlmbutil.h" + +/* Termcap library stuff. */ +#include "tcap.h" + +/* Some standard library routines. */ +#include "readline.h" +#include "history.h" + +#include "rlprivate.h" +#include "xmalloc.h" + +#if !defined (strchr) && !defined (__STDC__) +extern char *strchr (), *strrchr (); +#endif /* !strchr && !__STDC__ */ + +static void update_line PARAMS((char *, char *, int, int, int, int)); +static void space_to_eol PARAMS((int)); +static void delete_chars PARAMS((int)); +static void insert_some_chars PARAMS((char *, int, int)); +static void cr PARAMS((void)); + +/* State of visible and invisible lines. */ +struct line_state + { + char *line; + int *lbreaks; + int lbsize; +#if defined (HANDLE_MULTIBYTE) + int *wrapped_line; + int wbsize; +#endif + }; + +/* The line display buffers. One is the line currently displayed on + the screen. The other is the line about to be displayed. */ +static struct line_state line_state_array[2]; +static struct line_state *line_state_visible = &line_state_array[0]; +static struct line_state *line_state_invisible = &line_state_array[1]; +static int line_structures_initialized = 0; + +/* Backwards-compatible names. */ +#define inv_lbreaks (line_state_invisible->lbreaks) +#define inv_lbsize (line_state_invisible->lbsize) +#define vis_lbreaks (line_state_visible->lbreaks) +#define vis_lbsize (line_state_visible->lbsize) + +#define visible_line (line_state_visible->line) +#define invisible_line (line_state_invisible->line) + +#if defined (HANDLE_MULTIBYTE) +static int _rl_col_width PARAMS((const char *, int, int, int)); +#else +# define _rl_col_width(l, s, e, f) (((e) <= (s)) ? 0 : (e) - (s)) +#endif + +/* Heuristic used to decide whether it is faster to move from CUR to NEW + by backing up or outputting a carriage return and moving forward. CUR + and NEW are either both buffer positions or absolute screen positions. */ +#define CR_FASTER(new, cur) (((new) + 1) < ((cur) - (new))) + +/* _rl_last_c_pos is an absolute cursor position in multibyte locales and a + buffer index in others. This macro is used when deciding whether the + current cursor position is in the middle of a prompt string containing + invisible characters. XXX - might need to take `modmark' into account. */ +#define PROMPT_ENDING_INDEX \ + ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1) + + +/* **************************************************************** */ +/* */ +/* Display stuff */ +/* */ +/* **************************************************************** */ + +/* This is the stuff that is hard for me. I never seem to write good + display routines in C. Let's see how I do this time. */ + +/* (PWP) Well... Good for a simple line updater, but totally ignores + the problems of input lines longer than the screen width. + + update_line and the code that calls it makes a multiple line, + automatically wrapping line update. Careful attention needs + to be paid to the vertical position variables. */ + +/* Keep two buffers; one which reflects the current contents of the + screen, and the other to draw what we think the new contents should + be. Then compare the buffers, and make whatever changes to the + screen itself that we should. Finally, make the buffer that we + just drew into be the one which reflects the current contents of the + screen, and place the cursor where it belongs. + + Commands that want to can fix the display themselves, and then let + this function know that the display has been fixed by setting the + RL_DISPLAY_FIXED variable. This is good for efficiency. */ + +/* Application-specific redisplay function. */ +rl_voidfunc_t *rl_redisplay_function = rl_redisplay; + +/* Global variables declared here. */ +/* What YOU turn on when you have handled all redisplay yourself. */ +int rl_display_fixed = 0; + +int _rl_suppress_redisplay = 0; +int _rl_want_redisplay = 0; + +/* The stuff that gets printed out before the actual text of the line. + This is usually pointing to rl_prompt. */ +char *rl_display_prompt = (char *)NULL; + +/* Pseudo-global variables declared here. */ + +/* The visible cursor position. If you print some text, adjust this. */ +/* NOTE: _rl_last_c_pos is used as a buffer index when not in a locale + supporting multibyte characters, and an absolute cursor position when + in such a locale. This is an artifact of the donated multibyte support. + Care must be taken when modifying its value. */ +int _rl_last_c_pos = 0; +int _rl_last_v_pos = 0; + +static int cpos_adjusted; +static int cpos_buffer_position; +static int displaying_prompt_first_line; +static int prompt_multibyte_chars; + +/* Number of lines currently on screen minus 1. */ +int _rl_vis_botlin = 0; + +/* Variables used only in this file. */ +/* The last left edge of text that was displayed. This is used when + doing horizontal scrolling. It shifts in thirds of a screenwidth. */ +static int last_lmargin; + +/* A buffer for `modeline' messages. */ +static char *msg_buf = 0; +static int msg_bufsiz = 0; + +/* Non-zero forces the redisplay even if we thought it was unnecessary. */ +static int forced_display; + +/* Default and initial buffer size. Can grow. */ +static int line_size = 1024; + +/* Variables to keep track of the expanded prompt string, which may + include invisible characters. */ + +static char *local_prompt, *local_prompt_prefix; +static int local_prompt_len; +static int prompt_visible_length, prompt_prefix_length; + +/* The number of invisible characters in the line currently being + displayed on the screen. */ +static int visible_wrap_offset; + +/* The number of invisible characters in the prompt string. Static so it + can be shared between rl_redisplay and update_line */ +static int wrap_offset; + +/* The index of the last invisible character in the prompt string. */ +static int prompt_last_invisible; + +/* The length (buffer offset) of the first line of the last (possibly + multi-line) buffer displayed on the screen. */ +static int visible_first_line_len; + +/* Number of invisible characters on the first physical line of the prompt. + Only valid when the number of physical characters in the prompt exceeds + (or is equal to) _rl_screenwidth. */ +static int prompt_invis_chars_first_line; + +static int prompt_last_screen_line; + +static int prompt_physical_chars; + +/* set to a non-zero value by rl_redisplay if we are marking modified history + lines and the current line is so marked. */ +static int modmark; + +/* Variables to save and restore prompt and display information. */ + +/* These are getting numerous enough that it's time to create a struct. */ + +static char *saved_local_prompt; +static char *saved_local_prefix; +static int saved_last_invisible; +static int saved_visible_length; +static int saved_prefix_length; +static int saved_local_length; +static int saved_invis_chars_first_line; +static int saved_physical_chars; + +/* Return a character indicating the editing mode, for use in the prompt. */ +static int +prompt_modechar () +{ + if (rl_editing_mode == emacs_mode) + return '@'; + else if (_rl_keymap == vi_insertion_keymap) + return '+'; /* vi insert mode */ + else + return ':'; /* vi command mode */ +} + +/* Expand the prompt string S and return the number of visible + characters in *LP, if LP is not null. This is currently more-or-less + a placeholder for expansion. LIP, if non-null is a place to store the + index of the last invisible character in the returned string. NIFLP, + if non-zero, is a place to store the number of invisible characters in + the first prompt line. The previous are used as byte counts -- indexes + into a character buffer. */ + +/* Current implementation: + \001 (^A) start non-visible characters + \002 (^B) end non-visible characters + all characters except \001 and \002 (following a \001) are copied to + the returned string; all characters except those between \001 and + \002 are assumed to be `visible'. */ + +static char * +expand_prompt (pmt, lp, lip, niflp, vlp) + char *pmt; + int *lp, *lip, *niflp, *vlp; +{ + char *r, *ret, *p, *igstart; + int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars; + + /* Short-circuit if we can. */ + if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0) + { + if (pmt == rl_prompt && _rl_show_mode_in_prompt) + { + l = strlen (pmt); + r = (char *)xmalloc (l + 2); + r[0] = prompt_modechar (); + strcpy (r + 1, pmt); + } + else + r = savestring (pmt); + + if (lp) + *lp = strlen (r); + if (lip) + *lip = 0; + if (niflp) + *niflp = 0; + if (vlp) + *vlp = lp ? *lp : strlen (r); + return r; + } + + l = strlen (pmt); + r = ret = (char *)xmalloc (l + 2); + + rl = physchars = 0; /* move up here so mode show can set them */ + if (pmt == rl_prompt && _rl_show_mode_in_prompt) + { + *r++ = prompt_modechar (); + rl = physchars = 1; + } + + invfl = 0; /* invisible chars in first line of prompt */ + invflset = 0; /* we only want to set invfl once */ + + igstart = 0; + for (ignoring = last = ninvis = 0, p = pmt; p && *p; p++) + { + /* This code strips the invisible character string markers + RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */ + if (ignoring == 0 && *p == RL_PROMPT_START_IGNORE) /* XXX - check ignoring? */ + { + ignoring = 1; + igstart = p; + continue; + } + else if (ignoring && *p == RL_PROMPT_END_IGNORE) + { + ignoring = 0; + if (p != (igstart + 1)) + last = r - ret - 1; + continue; + } + else + { +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + pind = p - pmt; + ind = _rl_find_next_mbchar (pmt, pind, 1, MB_FIND_NONZERO); + l = ind - pind; + while (l--) + *r++ = *p++; + if (!ignoring) + { + /* rl ends up being assigned to prompt_visible_length, + which is the number of characters in the buffer that + contribute to characters on the screen, which might + not be the same as the number of physical characters + on the screen in the presence of multibyte characters */ + rl += ind - pind; + physchars += _rl_col_width (pmt, pind, ind, 0); + } + else + ninvis += ind - pind; + p--; /* compensate for later increment */ + } + else +#endif + { + *r++ = *p; + if (!ignoring) + { + rl++; /* visible length byte counter */ + physchars++; + } + else + ninvis++; /* invisible chars byte counter */ + } + + if (invflset == 0 && rl >= _rl_screenwidth) + { + invfl = ninvis; + invflset = 1; + } + } + } + + if (rl < _rl_screenwidth) + invfl = ninvis; + + *r = '\0'; + if (lp) + *lp = rl; + if (lip) + *lip = last; + if (niflp) + *niflp = invfl; + if (vlp) + *vlp = physchars; + return ret; +} + +/* Just strip out RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE from + PMT and return the rest of PMT. */ +char * +_rl_strip_prompt (pmt) + char *pmt; +{ + char *ret; + + ret = expand_prompt (pmt, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL); + return ret; +} + +void +_rl_reset_prompt () +{ + rl_visible_prompt_length = rl_expand_prompt (rl_prompt); +} + +/* + * Expand the prompt string into the various display components, if + * necessary. + * + * local_prompt = expanded last line of string in rl_display_prompt + * (portion after the final newline) + * local_prompt_prefix = portion before last newline of rl_display_prompt, + * expanded via expand_prompt + * prompt_visible_length = number of visible characters in local_prompt + * prompt_prefix_length = number of visible characters in local_prompt_prefix + * + * This function is called once per call to readline(). It may also be + * called arbitrarily to expand the primary prompt. + * + * The return value is the number of visible characters on the last line + * of the (possibly multi-line) prompt. + */ +int +rl_expand_prompt (prompt) + char *prompt; +{ + char *p, *t; + int c; + + /* Clear out any saved values. */ + FREE (local_prompt); + FREE (local_prompt_prefix); + + local_prompt = local_prompt_prefix = (char *)0; + local_prompt_len = 0; + prompt_last_invisible = prompt_invis_chars_first_line = 0; + prompt_visible_length = prompt_physical_chars = 0; + + if (prompt == 0 || *prompt == 0) + return (0); + + p = strrchr (prompt, '\n'); + if (!p) + { + /* The prompt is only one logical line, though it might wrap. */ + local_prompt = expand_prompt (prompt, &prompt_visible_length, + &prompt_last_invisible, + &prompt_invis_chars_first_line, + &prompt_physical_chars); + local_prompt_prefix = (char *)0; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; + return (prompt_visible_length); + } + else + { + /* The prompt spans multiple lines. */ + t = ++p; + local_prompt = expand_prompt (p, &prompt_visible_length, + &prompt_last_invisible, + &prompt_invis_chars_first_line, + &prompt_physical_chars); + c = *t; *t = '\0'; + /* The portion of the prompt string up to and including the + final newline is now null-terminated. */ + local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length, + (int *)NULL, + (int *)NULL, + (int *)NULL); + *t = c; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; + return (prompt_prefix_length); + } +} + +/* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated + arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE + and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is + increased. If the lines have already been allocated, this ensures that + they can hold at least MINSIZE characters. */ +static void +init_line_structures (minsize) + int minsize; +{ + register int n; + + if (invisible_line == 0) /* initialize it */ + { + if (line_size < minsize) + line_size = minsize; + visible_line = (char *)xmalloc (line_size); + invisible_line = (char *)xmalloc (line_size); + } + else if (line_size < minsize) /* ensure it can hold MINSIZE chars */ + { + line_size *= 2; + if (line_size < minsize) + line_size = minsize; + visible_line = (char *)xrealloc (visible_line, line_size); + invisible_line = (char *)xrealloc (invisible_line, line_size); + } + + for (n = minsize; n < line_size; n++) + { + visible_line[n] = 0; + invisible_line[n] = 1; + } + + if (vis_lbreaks == 0) + { + /* should be enough. */ + inv_lbsize = vis_lbsize = 256; + +#if defined (HANDLE_MULTIBYTE) + line_state_visible->wbsize = vis_lbsize; + line_state_visible->wrapped_line = (int *)xmalloc (line_state_visible->wbsize * sizeof (int)); + + line_state_invisible->wbsize = inv_lbsize; + line_state_invisible->wrapped_line = (int *)xmalloc (line_state_invisible->wbsize * sizeof (int)); +#endif + + inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int)); + vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int)); + inv_lbreaks[0] = vis_lbreaks[0] = 0; + } + + line_structures_initialized = 1; +} + +/* Basic redisplay algorithm. */ +void +rl_redisplay () +{ + register int in, out, c, linenum, cursor_linenum; + register char *line; + int inv_botlin, lb_botlin, lb_linenum, o_cpos; + int newlines, lpos, temp, n0, num, prompt_lines_estimate; + char *prompt_this_line; +#if defined (HANDLE_MULTIBYTE) + wchar_t wc; + size_t wc_bytes; + int wc_width; + mbstate_t ps; + int _rl_wrapped_multicolumn = 0; +#endif + + if (_rl_echoing_p == 0) + return; + + /* Block keyboard interrupts because this function manipulates global + data structures. */ + _rl_block_sigint (); + RL_SETSTATE (RL_STATE_REDISPLAYING); + + if (!rl_display_prompt) + rl_display_prompt = ""; + + if (line_structures_initialized == 0) + { + init_line_structures (0); + rl_on_new_line (); + } + + /* Draw the line into the buffer. */ + cpos_buffer_position = -1; + + prompt_multibyte_chars = prompt_visible_length - prompt_physical_chars; + + line = invisible_line; + out = inv_botlin = 0; + + /* Mark the line as modified or not. We only do this for history + lines. */ + modmark = 0; + if (_rl_mark_modified_lines && current_history () && rl_undo_list) + { + line[out++] = '*'; + line[out] = '\0'; + modmark = 1; + } + + /* If someone thought that the redisplay was handled, but the currently + visible line has a different modification state than the one about + to become visible, then correct the caller's misconception. */ + if (visible_line[0] != invisible_line[0]) + rl_display_fixed = 0; + + /* If the prompt to be displayed is the `primary' readline prompt (the + one passed to readline()), use the values we have already expanded. + If not, use what's already in rl_display_prompt. WRAP_OFFSET is the + number of non-visible characters in the prompt string. */ + if (rl_display_prompt == rl_prompt || local_prompt) + { + if (local_prompt_prefix && forced_display) + _rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix)); + + if (local_prompt_len > 0) + { + temp = local_prompt_len + out + 2; + if (temp >= line_size) + { + line_size = (temp + 1024) - (temp % 1024); + visible_line = (char *)xrealloc (visible_line, line_size); + line = invisible_line = (char *)xrealloc (invisible_line, line_size); + } + strncpy (line + out, local_prompt, local_prompt_len); + out += local_prompt_len; + } + line[out] = '\0'; + wrap_offset = local_prompt_len - prompt_visible_length; + } + else + { + int pmtlen; + prompt_this_line = strrchr (rl_display_prompt, '\n'); + if (!prompt_this_line) + prompt_this_line = rl_display_prompt; + else + { + prompt_this_line++; + pmtlen = prompt_this_line - rl_display_prompt; /* temp var */ + if (forced_display) + { + _rl_output_some_chars (rl_display_prompt, pmtlen); + /* Make sure we are at column zero even after a newline, + regardless of the state of terminal output processing. */ + if (pmtlen < 2 || prompt_this_line[-2] != '\r') + cr (); + } + } + + prompt_physical_chars = pmtlen = strlen (prompt_this_line); + temp = pmtlen + out + 2; + if (temp >= line_size) + { + line_size = (temp + 1024) - (temp % 1024); + visible_line = (char *)xrealloc (visible_line, line_size); + line = invisible_line = (char *)xrealloc (invisible_line, line_size); + } + strncpy (line + out, prompt_this_line, pmtlen); + out += pmtlen; + line[out] = '\0'; + wrap_offset = prompt_invis_chars_first_line = 0; + } + +#define CHECK_INV_LBREAKS() \ + do { \ + if (newlines >= (inv_lbsize - 2)) \ + { \ + inv_lbsize *= 2; \ + inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ + } \ + } while (0) + +#if defined (HANDLE_MULTIBYTE) +#define CHECK_LPOS() \ + do { \ + lpos++; \ + if (lpos >= _rl_screenwidth) \ + { \ + if (newlines >= (inv_lbsize - 2)) \ + { \ + inv_lbsize *= 2; \ + inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ + } \ + inv_lbreaks[++newlines] = out; \ + if (newlines >= (line_state_invisible->wbsize - 1)) \ + { \ + line_state_invisible->wbsize *= 2; \ + line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, line_state_invisible->wbsize * sizeof(int)); \ + } \ + line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; \ + lpos = 0; \ + } \ + } while (0) +#else +#define CHECK_LPOS() \ + do { \ + lpos++; \ + if (lpos >= _rl_screenwidth) \ + { \ + if (newlines >= (inv_lbsize - 2)) \ + { \ + inv_lbsize *= 2; \ + inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ + } \ + inv_lbreaks[++newlines] = out; \ + lpos = 0; \ + } \ + } while (0) +#endif + + /* inv_lbreaks[i] is where line i starts in the buffer. */ + inv_lbreaks[newlines = 0] = 0; + lpos = prompt_physical_chars + modmark; + +#if defined (HANDLE_MULTIBYTE) + memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wbsize * sizeof (int)); + num = 0; +#endif + + /* prompt_invis_chars_first_line is the number of invisible characters in + the first physical line of the prompt. + wrap_offset - prompt_invis_chars_first_line is the number of invis + chars on the second (or, more generally, last) line. */ + + /* This is zero-based, used to set the newlines */ + prompt_lines_estimate = lpos / _rl_screenwidth; + + /* what if lpos is already >= _rl_screenwidth before we start drawing the + contents of the command line? */ + while (lpos >= _rl_screenwidth) + { + int z; + /* fix from Darin Johnson for prompt string with + invisible characters that is longer than the screen width. The + prompt_invis_chars_first_line variable could be made into an array + saying how many invisible characters there are per line, but that's + probably too much work for the benefit gained. How many people have + prompts that exceed two physical lines? + Additional logic fix from Edward Catmur */ +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0) + { + n0 = num; + temp = local_prompt_len; + while (num < temp) + { + z = _rl_col_width (local_prompt, n0, num, 1); + if (z > _rl_screenwidth) + { + num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY); + break; + } + else if (z == _rl_screenwidth) + break; + num++; + } + temp = num; + } + else +#endif /* !HANDLE_MULTIBYTE */ + temp = ((newlines + 1) * _rl_screenwidth); + + /* Now account for invisible characters in the current line. */ + /* XXX - this assumes that the invisible characters may be split, but only + between the first and the last lines. */ + temp += ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line + : ((newlines == prompt_lines_estimate) ? wrap_offset : prompt_invis_chars_first_line)) + : ((newlines == 0) ? wrap_offset : 0)); + + inv_lbreaks[++newlines] = temp; +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0) + lpos -= _rl_col_width (local_prompt, n0, num, 1); + else +#endif + lpos -= _rl_screenwidth; + } + + prompt_last_screen_line = newlines; + + /* Draw the rest of the line (after the prompt) into invisible_line, keeping + track of where the cursor is (cpos_buffer_position), the number of the line containing + the cursor (lb_linenum), the last line number (lb_botlin and inv_botlin). + It maintains an array of line breaks for display (inv_lbreaks). + This handles expanding tabs for display and displaying meta characters. */ + lb_linenum = 0; +#if defined (HANDLE_MULTIBYTE) + in = 0; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + memset (&ps, 0, sizeof (mbstate_t)); + /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */ + wc_bytes = mbrtowc (&wc, rl_line_buffer, rl_end, &ps); + } + else + wc_bytes = 1; + while (in < rl_end) +#else + for (in = 0; in < rl_end; in++) +#endif + { + c = (unsigned char)rl_line_buffer[in]; + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + if (MB_INVALIDCH (wc_bytes)) + { + /* Byte sequence is invalid or shortened. Assume that the + first byte represents a character. */ + wc_bytes = 1; + /* Assume that a character occupies a single column. */ + wc_width = 1; + memset (&ps, 0, sizeof (mbstate_t)); + } + else if (MB_NULLWCH (wc_bytes)) + break; /* Found '\0' */ + else + { + temp = WCWIDTH (wc); + wc_width = (temp >= 0) ? temp : 1; + } + } +#endif + + if (out + 8 >= line_size) /* XXX - 8 for \t */ + { + line_size *= 2; + visible_line = (char *)xrealloc (visible_line, line_size); + invisible_line = (char *)xrealloc (invisible_line, line_size); + line = invisible_line; + } + + if (in == rl_point) + { + cpos_buffer_position = out; + lb_linenum = newlines; + } + +#if defined (HANDLE_MULTIBYTE) + if (META_CHAR (c) && _rl_output_meta_chars == 0) /* XXX - clean up */ +#else + if (META_CHAR (c)) +#endif + { + if (_rl_output_meta_chars == 0) + { + sprintf (line + out, "\\%o", c); + + if (lpos + 4 >= _rl_screenwidth) + { + temp = _rl_screenwidth - lpos; + CHECK_INV_LBREAKS (); + inv_lbreaks[++newlines] = out + temp; + lpos = 4 - temp; + } + else + lpos += 4; + + out += 4; + } + else + { + line[out++] = c; + CHECK_LPOS(); + } + } +#if defined (DISPLAY_TABS) + else if (c == '\t') + { + register int newout; + +#if 0 + newout = (out | (int)7) + 1; +#else + newout = out + 8 - lpos % 8; +#endif + temp = newout - out; + if (lpos + temp >= _rl_screenwidth) + { + register int temp2; + temp2 = _rl_screenwidth - lpos; + CHECK_INV_LBREAKS (); + inv_lbreaks[++newlines] = out + temp2; + lpos = temp - temp2; + while (out < newout) + line[out++] = ' '; + } + else + { + while (out < newout) + line[out++] = ' '; + lpos += temp; + } + } +#endif + else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up) + { + line[out++] = '\0'; /* XXX - sentinel */ + CHECK_INV_LBREAKS (); + inv_lbreaks[++newlines] = out; + lpos = 0; + } + else if (CTRL_CHAR (c) || c == RUBOUT) + { + line[out++] = '^'; + CHECK_LPOS(); + line[out++] = CTRL_CHAR (c) ? UNCTRL (c) : '?'; + CHECK_LPOS(); + } + else + { +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + register int i; + + _rl_wrapped_multicolumn = 0; + + if (_rl_screenwidth < lpos + wc_width) + for (i = lpos; i < _rl_screenwidth; i++) + { + /* The space will be removed in update_line() */ + line[out++] = ' '; + _rl_wrapped_multicolumn++; + CHECK_LPOS(); + } + if (in == rl_point) + { + cpos_buffer_position = out; + lb_linenum = newlines; + } + for (i = in; i < in+wc_bytes; i++) + line[out++] = rl_line_buffer[i]; + for (i = 0; i < wc_width; i++) + CHECK_LPOS(); + } + else + { + line[out++] = c; + CHECK_LPOS(); + } +#else + line[out++] = c; + CHECK_LPOS(); +#endif + } + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + in += wc_bytes; + /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */ + wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps); + } + else + in++; +#endif + + } + line[out] = '\0'; + if (cpos_buffer_position < 0) + { + cpos_buffer_position = out; + lb_linenum = newlines; + } + + inv_botlin = lb_botlin = newlines; + CHECK_INV_LBREAKS (); + inv_lbreaks[newlines+1] = out; + cursor_linenum = lb_linenum; + + /* CPOS_BUFFER_POSITION == position in buffer where cursor should be placed. + CURSOR_LINENUM == line number where the cursor should be placed. */ + + /* PWP: now is when things get a bit hairy. The visible and invisible + line buffers are really multiple lines, which would wrap every + (screenwidth - 1) characters. Go through each in turn, finding + the changed region and updating it. The line order is top to bottom. */ + + /* If we can move the cursor up and down, then use multiple lines, + otherwise, let long lines display in a single terminal line, and + horizontally scroll it. */ + displaying_prompt_first_line = 1; + if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up) + { + int nleft, pos, changed_screen_line, tx; + + if (!rl_display_fixed || forced_display) + { + forced_display = 0; + + /* If we have more than a screenful of material to display, then + only display a screenful. We should display the last screen, + not the first. */ + if (out >= _rl_screenchars) + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY); + else + out = _rl_screenchars - 1; + } + + /* The first line is at character position 0 in the buffer. The + second and subsequent lines start at inv_lbreaks[N], offset by + OFFSET (which has already been calculated above). */ + +#define INVIS_FIRST() (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset) +#define WRAP_OFFSET(line, offset) ((line == 0) \ + ? (offset ? INVIS_FIRST() : 0) \ + : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0)) +#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0) +#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l])) +#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l]) +#define VIS_CHARS(line) (visible_line + vis_lbreaks[line]) +#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line) +#define INV_LINE(line) (invisible_line + inv_lbreaks[line]) + +#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \ + _rl_last_c_pos != o_cpos && \ + _rl_last_c_pos > wrap_offset && \ + o_cpos < prompt_last_invisible) + + /* For each line in the buffer, do the updating display. */ + for (linenum = 0; linenum <= inv_botlin; linenum++) + { + /* This can lead us astray if we execute a program that changes + the locale from a non-multibyte to a multibyte one. */ + o_cpos = _rl_last_c_pos; + cpos_adjusted = 0; + update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum, + VIS_LLEN(linenum), INV_LLEN(linenum), inv_botlin); + + /* update_line potentially changes _rl_last_c_pos, but doesn't + take invisible characters into account, since _rl_last_c_pos + is an absolute cursor position in a multibyte locale. See + if compensating here is the right thing, or if we have to + change update_line itself. There are several cases in which + update_line adjusts _rl_last_c_pos itself (so it can pass + _rl_move_cursor_relative accurate values); it communicates + this back by setting cpos_adjusted. If we assume that + _rl_last_c_pos is correct (an absolute cursor position) each + time update_line is called, then we can assume in our + calculations that o_cpos does not need to be adjusted by + wrap_offset. */ + if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT()) + _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */ + else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth && + (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && + cpos_adjusted == 0 && + _rl_last_c_pos != o_cpos && + _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line)) + _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line); + + /* If this is the line with the prompt, we might need to + compensate for invisible characters in the new line. Do + this only if there is not more than one new line (which + implies that we completely overwrite the old visible line) + and the new line is shorter than the old. Make sure we are + at the end of the new line before clearing. */ + if (linenum == 0 && + inv_botlin == 0 && _rl_last_c_pos == out && + (wrap_offset > visible_wrap_offset) && + (_rl_last_c_pos < visible_first_line_len)) + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + nleft = _rl_screenwidth - _rl_last_c_pos; + else + nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos; + if (nleft) + _rl_clear_to_eol (nleft); + } +#if 0 + /* This segment is intended to handle the case where the prompt + has invisible characters on the second line and the new line + to be displayed needs to clear the rest of the old characters + out (e.g., when printing the i-search prompt). In general, + the case of the new line being shorter than the old. + Incomplete */ + else if (linenum == prompt_last_screen_line && + prompt_physical_chars > _rl_screenwidth && + wrap_offset != prompt_invis_chars_first_line && + _rl_last_c_pos == out && +#endif + + + /* Since the new first line is now visible, save its length. */ + if (linenum == 0) + visible_first_line_len = (inv_botlin > 0) ? inv_lbreaks[1] : out - wrap_offset; + } + + /* We may have deleted some lines. If so, clear the left over + blank ones at the bottom out. */ + if (_rl_vis_botlin > inv_botlin) + { + char *tt; + for (; linenum <= _rl_vis_botlin; linenum++) + { + tt = VIS_CHARS (linenum); + _rl_move_vert (linenum); + _rl_move_cursor_relative (0, tt); + _rl_clear_to_eol + ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth); + } + } + _rl_vis_botlin = inv_botlin; + + /* CHANGED_SCREEN_LINE is set to 1 if we have moved to a + different screen line during this redisplay. */ + changed_screen_line = _rl_last_v_pos != cursor_linenum; + if (changed_screen_line) + { + _rl_move_vert (cursor_linenum); + /* If we moved up to the line with the prompt using _rl_term_up, + the physical cursor position on the screen stays the same, + but the buffer position needs to be adjusted to account + for invisible characters. */ + if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset) + _rl_last_c_pos += wrap_offset; + } + + /* We have to reprint the prompt if it contains invisible + characters, since it's not generally OK to just reprint + the characters from the current cursor position. But we + only need to reprint it if the cursor is before the last + invisible character in the prompt string. */ + nleft = prompt_visible_length + wrap_offset; + if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 && +#if 0 + _rl_last_c_pos <= PROMPT_ENDING_INDEX && local_prompt) +#else + _rl_last_c_pos < PROMPT_ENDING_INDEX && local_prompt) +#endif + { +#if defined (__MSDOS__) + putc ('\r', rl_outstream); +#else + if (_rl_term_cr) + tputs (_rl_term_cr, 1, _rl_output_character_function); +#endif + if (modmark) + _rl_output_some_chars ("*", 1); + + _rl_output_some_chars (local_prompt, nleft); + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark; + else + _rl_last_c_pos = nleft + modmark; + } + + /* Where on that line? And where does that line start + in the buffer? */ + pos = inv_lbreaks[cursor_linenum]; + /* nleft == number of characters in the line buffer between the + start of the line and the desired cursor position. */ + nleft = cpos_buffer_position - pos; + + /* NLEFT is now a number of characters in a buffer. When in a + multibyte locale, however, _rl_last_c_pos is an absolute cursor + position that doesn't take invisible characters in the prompt + into account. We use a fudge factor to compensate. */ + + /* Since _rl_backspace() doesn't know about invisible characters in the + prompt, and there's no good way to tell it, we compensate for + those characters here and call _rl_backspace() directly. */ + if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos) + { + /* TX == new physical cursor position in multibyte locale. */ + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset; + else + tx = nleft; + if (tx >= 0 && _rl_last_c_pos > tx) + { + _rl_backspace (_rl_last_c_pos - tx); /* XXX */ + _rl_last_c_pos = tx; + } + } + + /* We need to note that in a multibyte locale we are dealing with + _rl_last_c_pos as an absolute cursor position, but moving to a + point specified by a buffer position (NLEFT) that doesn't take + invisible characters into account. */ + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_move_cursor_relative (nleft, &invisible_line[pos]); + else if (nleft != _rl_last_c_pos) + _rl_move_cursor_relative (nleft, &invisible_line[pos]); + } + } + else /* Do horizontal scrolling. */ + { +#define M_OFFSET(margin, offset) ((margin) == 0 ? offset : 0) + int lmargin, ndisp, nleft, phys_c_pos, t; + + /* Always at top line. */ + _rl_last_v_pos = 0; + + /* Compute where in the buffer the displayed line should start. This + will be LMARGIN. */ + + /* The number of characters that will be displayed before the cursor. */ + ndisp = cpos_buffer_position - wrap_offset; + nleft = prompt_visible_length + wrap_offset; + /* Where the new cursor position will be on the screen. This can be + longer than SCREENWIDTH; if it is, lmargin will be adjusted. */ + phys_c_pos = cpos_buffer_position - (last_lmargin ? last_lmargin : wrap_offset); + t = _rl_screenwidth / 3; + + /* If the number of characters had already exceeded the screenwidth, + last_lmargin will be > 0. */ + + /* If the number of characters to be displayed is more than the screen + width, compute the starting offset so that the cursor is about + two-thirds of the way across the screen. */ + if (phys_c_pos > _rl_screenwidth - 2) + { + lmargin = cpos_buffer_position - (2 * t); + if (lmargin < 0) + lmargin = 0; + /* If the left margin would be in the middle of a prompt with + invisible characters, don't display the prompt at all. */ + if (wrap_offset && lmargin > 0 && lmargin < nleft) + lmargin = nleft; + } + else if (ndisp < _rl_screenwidth - 2) /* XXX - was -1 */ + lmargin = 0; + else if (phys_c_pos < 1) + { + /* If we are moving back towards the beginning of the line and + the last margin is no longer correct, compute a new one. */ + lmargin = ((cpos_buffer_position - 1) / t) * t; /* XXX */ + if (wrap_offset && lmargin > 0 && lmargin < nleft) + lmargin = nleft; + } + else + lmargin = last_lmargin; + + displaying_prompt_first_line = lmargin < nleft; + + /* If the first character on the screen isn't the first character + in the display line, indicate this with a special character. */ + if (lmargin > 0) + line[lmargin] = '<'; + + /* If SCREENWIDTH characters starting at LMARGIN do not encompass + the whole line, indicate that with a special character at the + right edge of the screen. If LMARGIN is 0, we need to take the + wrap offset into account. */ + t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth; + if (t < out) + line[t - 1] = '>'; + + if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin) + { + forced_display = 0; + o_cpos = _rl_last_c_pos; + cpos_adjusted = 0; + update_line (&visible_line[last_lmargin], + &invisible_line[lmargin], + 0, + _rl_screenwidth + visible_wrap_offset, + _rl_screenwidth + (lmargin ? 0 : wrap_offset), + 0); + + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && + displaying_prompt_first_line && OLD_CPOS_IN_PROMPT()) + _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */ + + /* If the visible new line is shorter than the old, but the number + of invisible characters is greater, and we are at the end of + the new line, we need to clear to eol. */ + t = _rl_last_c_pos - M_OFFSET (lmargin, wrap_offset); + if ((M_OFFSET (lmargin, wrap_offset) > visible_wrap_offset) && + (_rl_last_c_pos == out) && displaying_prompt_first_line && + t < visible_first_line_len) + { + nleft = _rl_screenwidth - t; + _rl_clear_to_eol (nleft); + } + visible_first_line_len = out - lmargin - M_OFFSET (lmargin, wrap_offset); + if (visible_first_line_len > _rl_screenwidth) + visible_first_line_len = _rl_screenwidth; + + _rl_move_cursor_relative (cpos_buffer_position - lmargin, &invisible_line[lmargin]); + last_lmargin = lmargin; + } + } + fflush (rl_outstream); + + /* Swap visible and non-visible lines. */ + { + struct line_state *vtemp = line_state_visible; + + line_state_visible = line_state_invisible; + line_state_invisible = vtemp; + + rl_display_fixed = 0; + /* If we are displaying on a single line, and last_lmargin is > 0, we + are not displaying any invisible characters, so set visible_wrap_offset + to 0. */ + if (_rl_horizontal_scroll_mode && last_lmargin) + visible_wrap_offset = 0; + else + visible_wrap_offset = wrap_offset; + } + + RL_UNSETSTATE (RL_STATE_REDISPLAYING); + _rl_release_sigint (); +} + +/* PWP: update_line() is based on finding the middle difference of each + line on the screen; vis: + + /old first difference + /beginning of line | /old last same /old EOL + v v v v +old: eddie> Oh, my little gruntle-buggy is to me, as lurgid as +new: eddie> Oh, my little buggy says to me, as lurgid as + ^ ^ ^ ^ + \beginning of line | \new last same \new end of line + \new first difference + + All are character pointers for the sake of speed. Special cases for + no differences, as well as for end of line additions must be handled. + + Could be made even smarter, but this works well enough */ +static void +update_line (old, new, current_line, omax, nmax, inv_botlin) + register char *old, *new; + int current_line, omax, nmax, inv_botlin; +{ + register char *ofd, *ols, *oe, *nfd, *nls, *ne; + int temp, lendiff, wsatend, od, nd, twidth, o_cpos; + int current_invis_chars; + int col_lendiff, col_temp; +#if defined (HANDLE_MULTIBYTE) + mbstate_t ps_new, ps_old; + int new_offset, old_offset; +#endif + + /* If we're at the right edge of a terminal that supports xn, we're + ready to wrap around, so do so. This fixes problems with knowing + the exact cursor position and cut-and-paste with certain terminal + emulators. In this calculation, TEMP is the physical screen + position of the cursor. */ + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + temp = _rl_last_c_pos; + else + temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset); + if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode + && _rl_last_v_pos == current_line - 1) + { +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + wchar_t wc; + mbstate_t ps; + int tempwidth, bytes; + size_t ret; + + /* This fixes only double-column characters, but if the wrapped + character comsumes more than three columns, spaces will be + inserted in the string buffer. */ + if (current_line < line_state_visible->wbsize && line_state_visible->wrapped_line[current_line] > 0) + _rl_clear_to_eol (line_state_visible->wrapped_line[current_line]); + + memset (&ps, 0, sizeof (mbstate_t)); + ret = mbrtowc (&wc, new, MB_CUR_MAX, &ps); + if (MB_INVALIDCH (ret)) + { + tempwidth = 1; + ret = 1; + } + else if (MB_NULLWCH (ret)) + tempwidth = 0; + else + tempwidth = WCWIDTH (wc); + + if (tempwidth > 0) + { + int count, i; + bytes = ret; + for (count = 0; count < bytes; count++) + putc (new[count], rl_outstream); + _rl_last_c_pos = tempwidth; + _rl_last_v_pos++; + memset (&ps, 0, sizeof (mbstate_t)); + ret = mbrtowc (&wc, old, MB_CUR_MAX, &ps); + if (ret != 0 && bytes != 0) + { + if (MB_INVALIDCH (ret)) + ret = 1; + memmove (old+bytes, old+ret, strlen (old+ret)); + memcpy (old, new, bytes); + /* Fix up indices if we copy data from one line to another */ + omax += bytes - ret; + for (i = current_line+1; i < inv_botlin+1; i++) + vis_lbreaks[i] += bytes - ret; + } + } + else + { + putc (' ', rl_outstream); + _rl_last_c_pos = 1; + _rl_last_v_pos++; + if (old[0] && new[0]) + old[0] = new[0]; + } + } + else +#endif + { + if (new[0]) + putc (new[0], rl_outstream); + else + putc (' ', rl_outstream); + _rl_last_c_pos = 1; + _rl_last_v_pos++; + if (old[0] && new[0]) + old[0] = new[0]; + } + } + + + /* Find first difference. */ +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + /* See if the old line is a subset of the new line, so that the + only change is adding characters. */ + temp = (omax < nmax) ? omax : nmax; + if (memcmp (old, new, temp) == 0) /* adding at the end */ + { + new_offset = old_offset = temp; + ofd = old + temp; + nfd = new + temp; + } + else + { + memset (&ps_new, 0, sizeof(mbstate_t)); + memset (&ps_old, 0, sizeof(mbstate_t)); + + if (omax == nmax && STREQN (new, old, omax)) + { + old_offset = omax; + new_offset = nmax; + ofd = old + omax; + nfd = new + nmax; + } + else + { + new_offset = old_offset = 0; + for (ofd = old, nfd = new; + (ofd - old < omax) && *ofd && + _rl_compare_chars(old, old_offset, &ps_old, new, new_offset, &ps_new); ) + { + old_offset = _rl_find_next_mbchar (old, old_offset, 1, MB_FIND_ANY); + new_offset = _rl_find_next_mbchar (new, new_offset, 1, MB_FIND_ANY); + + ofd = old + old_offset; + nfd = new + new_offset; + } + } + } + } + else +#endif + for (ofd = old, nfd = new; + (ofd - old < omax) && *ofd && (*ofd == *nfd); + ofd++, nfd++) + ; + + /* Move to the end of the screen line. ND and OD are used to keep track + of the distance between ne and new and oe and old, respectively, to + move a subtraction out of each loop. */ + for (od = ofd - old, oe = ofd; od < omax && *oe; oe++, od++); + for (nd = nfd - new, ne = nfd; nd < nmax && *ne; ne++, nd++); + + /* If no difference, continue to next line. */ + if (ofd == oe && nfd == ne) + return; + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_utf8locale) + { + wchar_t wc; + mbstate_t ps = { 0 }; + int t; + + /* If the first character in the difference is a zero-width character, + assume it's a combining character and back one up so the two base + characters no longer compare equivalently. */ + t = mbrtowc (&wc, ofd, MB_CUR_MAX, &ps); + if (t > 0 && UNICODE_COMBINING_CHAR (wc) && WCWIDTH (wc) == 0) + { + old_offset = _rl_find_prev_mbchar (old, ofd - old, MB_FIND_ANY); + new_offset = _rl_find_prev_mbchar (new, nfd - new, MB_FIND_ANY); + ofd = old + old_offset; /* equal by definition */ + nfd = new + new_offset; + } + } +#endif + + wsatend = 1; /* flag for trailing whitespace */ + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + ols = old + _rl_find_prev_mbchar (old, oe - old, MB_FIND_ANY); + nls = new + _rl_find_prev_mbchar (new, ne - new, MB_FIND_ANY); + + while ((ols > ofd) && (nls > nfd)) + { + memset (&ps_old, 0, sizeof (mbstate_t)); + memset (&ps_new, 0, sizeof (mbstate_t)); + +#if 0 + /* On advice from jir@yamato.ibm.com */ + _rl_adjust_point (old, ols - old, &ps_old); + _rl_adjust_point (new, nls - new, &ps_new); +#endif + + if (_rl_compare_chars (old, ols - old, &ps_old, new, nls - new, &ps_new) == 0) + break; + + if (*ols == ' ') + wsatend = 0; + + ols = old + _rl_find_prev_mbchar (old, ols - old, MB_FIND_ANY); + nls = new + _rl_find_prev_mbchar (new, nls - new, MB_FIND_ANY); + } + } + else + { +#endif /* HANDLE_MULTIBYTE */ + ols = oe - 1; /* find last same */ + nls = ne - 1; + while ((ols > ofd) && (nls > nfd) && (*ols == *nls)) + { + if (*ols != ' ') + wsatend = 0; + ols--; + nls--; + } +#if defined (HANDLE_MULTIBYTE) + } +#endif + + if (wsatend) + { + ols = oe; + nls = ne; + } +#if defined (HANDLE_MULTIBYTE) + /* This may not work for stateful encoding, but who cares? To handle + stateful encoding properly, we have to scan each string from the + beginning and compare. */ + else if (_rl_compare_chars (ols, 0, NULL, nls, 0, NULL) == 0) +#else + else if (*ols != *nls) +#endif + { + if (*ols) /* don't step past the NUL */ + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + ols = old + _rl_find_next_mbchar (old, ols - old, 1, MB_FIND_ANY); + else + ols++; + } + if (*nls) + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + nls = new + _rl_find_next_mbchar (new, nls - new, 1, MB_FIND_ANY); + else + nls++; + } + } + + /* count of invisible characters in the current invisible line. */ + current_invis_chars = W_OFFSET (current_line, wrap_offset); + if (_rl_last_v_pos != current_line) + { + _rl_move_vert (current_line); + if ((MB_CUR_MAX == 1 || rl_byte_oriented) && current_line == 0 && visible_wrap_offset) + _rl_last_c_pos += visible_wrap_offset; + } + + /* If this is the first line and there are invisible characters in the + prompt string, and the prompt string has not changed, and the current + cursor position is before the last invisible character in the prompt, + and the index of the character to move to is past the end of the prompt + string, then redraw the entire prompt string. We can only do this + reliably if the terminal supports a `cr' capability. + + This is not an efficiency hack -- there is a problem with redrawing + portions of the prompt string if they contain terminal escape + sequences (like drawing the `unbold' sequence without a corresponding + `bold') that manifests itself on certain terminals. */ + + lendiff = local_prompt_len; + od = ofd - old; /* index of first difference in visible line */ + if (current_line == 0 && !_rl_horizontal_scroll_mode && + _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 && + od >= lendiff && _rl_last_c_pos < PROMPT_ENDING_INDEX) + { +#if defined (__MSDOS__) + putc ('\r', rl_outstream); +#else + tputs (_rl_term_cr, 1, _rl_output_character_function); +#endif + if (modmark) + _rl_output_some_chars ("*", 1); + _rl_output_some_chars (local_prompt, lendiff); + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + /* We take wrap_offset into account here so we can pass correct + information to _rl_move_cursor_relative. */ + _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff, 1) - wrap_offset + modmark; + cpos_adjusted = 1; + } + else + _rl_last_c_pos = lendiff + modmark; + } + + o_cpos = _rl_last_c_pos; + + /* When this function returns, _rl_last_c_pos is correct, and an absolute + cursor postion in multibyte mode, but a buffer index when not in a + multibyte locale. */ + _rl_move_cursor_relative (od, old); +#if 1 +#if defined (HANDLE_MULTIBYTE) + /* We need to indicate that the cursor position is correct in the presence of + invisible characters in the prompt string. Let's see if setting this when + we make sure we're at the end of the drawn prompt string works. */ + if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && + (_rl_last_c_pos > 0 || o_cpos > 0) && + _rl_last_c_pos == prompt_physical_chars) + cpos_adjusted = 1; +#endif +#endif + + /* if (len (new) > len (old)) + lendiff == difference in buffer + col_lendiff == difference on screen + When not using multibyte characters, these are equal */ + lendiff = (nls - nfd) - (ols - ofd); + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + col_lendiff = _rl_col_width (new, nfd - new, nls - new, 1) - _rl_col_width (old, ofd - old, ols - old, 1); + else + col_lendiff = lendiff; + + /* If we are changing the number of invisible characters in a line, and + the spot of first difference is before the end of the invisible chars, + lendiff needs to be adjusted. */ + if (current_line == 0 && !_rl_horizontal_scroll_mode && + current_invis_chars != visible_wrap_offset) + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + lendiff += visible_wrap_offset - current_invis_chars; + col_lendiff += visible_wrap_offset - current_invis_chars; + } + else + { + lendiff += visible_wrap_offset - current_invis_chars; + col_lendiff = lendiff; + } + } + + /* Insert (diff (len (old), len (new)) ch. */ + temp = ne - nfd; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + col_temp = _rl_col_width (new, nfd - new, ne - new, 1); + else + col_temp = temp; + + if (col_lendiff > 0) /* XXX - was lendiff */ + { + /* Non-zero if we're increasing the number of lines. */ + int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin; + /* If col_lendiff is > 0, implying that the new string takes up more + screen real estate than the old, but lendiff is < 0, meaning that it + takes fewer bytes, we need to just output the characters starting + from the first difference. These will overwrite what is on the + display, so there's no reason to do a smart update. This can really + only happen in a multibyte environment. */ + if (lendiff < 0) + { + _rl_output_some_chars (nfd, temp); + _rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1); + /* If nfd begins before any invisible characters in the prompt, + adjust _rl_last_c_pos to account for wrap_offset and set + cpos_adjusted to let the caller know. */ + if (current_line == 0 && wrap_offset && + displaying_prompt_first_line && + ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } + return; + } + /* Sometimes it is cheaper to print the characters rather than + use the terminal's capabilities. If we're growing the number + of lines, make sure we actually cause the new line to wrap + around on auto-wrapping terminals. */ + else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl)) + { + /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and + _rl_horizontal_scroll_mode == 1, inserting the characters with + _rl_term_IC or _rl_term_ic will screw up the screen because of the + invisible characters. We need to just draw them. */ + /* The same thing happens if we're trying to draw before the last + invisible character in the prompt string or we're increasing the + number of invisible characters in the line and we're not drawing + the entire prompt string. */ + if (*ols && ((_rl_horizontal_scroll_mode && + _rl_last_c_pos == 0 && + lendiff > prompt_visible_length && + current_invis_chars > 0) == 0) && + (((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && + current_line == 0 && wrap_offset && + ((nfd - new) <= prompt_last_invisible) && + (col_lendiff < prompt_visible_length)) == 0) && + (visible_wrap_offset >= current_invis_chars)) + { + insert_some_chars (nfd, lendiff, col_lendiff); + _rl_last_c_pos += col_lendiff; + } +#if 0 /* XXX - for now */ + else if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && _rl_last_c_pos == 0 && wrap_offset && (nfd-new) <= prompt_last_invisible && col_lendiff < prompt_visible_length && visible_wrap_offset >= current_invis_chars) + { + _rl_output_some_chars (nfd, lendiff); + _rl_last_c_pos += col_lendiff; + } +#endif + else if ((MB_CUR_MAX == 1 || rl_byte_oriented != 0) && *ols == 0 && lendiff > 0) + { + /* At the end of a line the characters do not have to + be "inserted". They can just be placed on the screen. */ + /* However, this screws up the rest of this block, which + assumes you've done the insert because you can. */ + _rl_output_some_chars (nfd, lendiff); + _rl_last_c_pos += col_lendiff; + } + else + { + _rl_output_some_chars (nfd, temp); + _rl_last_c_pos += col_temp; + /* If nfd begins before the last invisible character in the + prompt, adjust _rl_last_c_pos to account for wrap_offset + and set cpos_adjusted to let the caller know. */ + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && displaying_prompt_first_line && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } + return; + } + /* Copy (new) chars to screen from first diff to last match. */ + temp = nls - nfd; + if ((temp - lendiff) > 0) + { + _rl_output_some_chars (nfd + lendiff, temp - lendiff); + /* XXX -- this bears closer inspection. Fixes a redisplay bug + reported against bash-3.0-alpha by Andreas Schwab involving + multibyte characters and prompt strings with invisible + characters, but was previously disabled. */ + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff, 1); + else + twidth = temp - lendiff; + _rl_last_c_pos += twidth; + /* If nfd begins before the last invisible character in the + prompt, adjust _rl_last_c_pos to account for wrap_offset + and set cpos_adjusted to let the caller know. */ + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && current_line == 0 && displaying_prompt_first_line && wrap_offset && ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } + } + } + else + { + /* cannot insert chars, write to EOL */ + _rl_output_some_chars (nfd, temp); + _rl_last_c_pos += col_temp; + /* If we're in a multibyte locale and were before the last invisible + char in the current line (which implies we just output some invisible + characters) we need to adjust _rl_last_c_pos, since it represents + a physical character position. */ + if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && + current_line == prompt_last_screen_line && wrap_offset && + displaying_prompt_first_line && + wrap_offset != prompt_invis_chars_first_line && + ((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth)))) + { + _rl_last_c_pos -= wrap_offset - prompt_invis_chars_first_line; + cpos_adjusted = 1; + } + } + } + else /* Delete characters from line. */ + { + /* If possible and inexpensive to use terminal deletion, then do so. */ + if (_rl_term_dc && (2 * col_temp) >= -col_lendiff) + { + /* If all we're doing is erasing the invisible characters in the + prompt string, don't bother. It screws up the assumptions + about what's on the screen. */ + if (_rl_horizontal_scroll_mode && _rl_last_c_pos == 0 && + displaying_prompt_first_line && + -lendiff == visible_wrap_offset) + col_lendiff = 0; + + /* If we have moved lmargin and we're shrinking the line, we've + already moved the cursor to the first character of the new line, + so deleting -col_lendiff characters will mess up the cursor + position calculation */ + if (_rl_horizontal_scroll_mode && displaying_prompt_first_line == 0 && + col_lendiff && _rl_last_c_pos < -col_lendiff) + col_lendiff = 0; + + if (col_lendiff) + delete_chars (-col_lendiff); /* delete (diff) characters */ + + /* Copy (new) chars to screen from first diff to last match */ + temp = nls - nfd; + if (temp > 0) + { + /* If nfd begins at the prompt, or before the invisible + characters in the prompt, we need to adjust _rl_last_c_pos + in a multibyte locale to account for the wrap offset and + set cpos_adjusted accordingly. */ + _rl_output_some_chars (nfd, temp); + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + _rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1); + if (current_line == 0 && wrap_offset && + displaying_prompt_frst_line && + _rl_last_c_pos > wrap_offset && + ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } + } + else + _rl_last_c_pos += temp; + + if (_rl_horizontal_scroll_mode && ((oe-old) > (ne-new))) + goto clear_rest_of_line; + } + } + /* Otherwise, print over the existing material. */ + else + { + if (temp > 0) + { + /* If nfd begins at the prompt, or before the invisible + characters in the prompt, we need to adjust _rl_last_c_pos + in a multibyte locale to account for the wrap offset and + set cpos_adjusted accordingly. */ + _rl_output_some_chars (nfd, temp); + _rl_last_c_pos += col_temp; /* XXX */ + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + if (current_line == 0 && wrap_offset && + displaying_prompt_first_line && + _rl_last_c_pos > wrap_offset && + ((nfd - new) <= prompt_last_invisible)) + { + _rl_last_c_pos -= wrap_offset; + cpos_adjusted = 1; + } + } + } +clear_rest_of_line: + lendiff = (oe - old) - (ne - new); + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1); + else + col_lendiff = lendiff; + +#if 0 + if (col_lendiff) +#else + /* If we've already printed over the entire width of the screen, + including the old material, then col_lendiff doesn't matter and + space_to_eol will insert too many spaces. XXX - maybe we should + adjust col_lendiff based on the difference between _rl_last_c_pos + and _rl_screenwidth */ + if (col_lendiff && ((MB_CUR_MAX == 1 || rl_byte_oriented) || (_rl_last_c_pos < _rl_screenwidth))) +#endif + { + if (_rl_term_autowrap && current_line < inv_botlin) + space_to_eol (col_lendiff); + else + _rl_clear_to_eol (col_lendiff); + } + } + } +} + +/* Tell the update routines that we have moved onto a new (empty) line. */ +int +rl_on_new_line () +{ + if (visible_line) + visible_line[0] = '\0'; + + _rl_last_c_pos = _rl_last_v_pos = 0; + _rl_vis_botlin = last_lmargin = 0; + if (vis_lbreaks) + vis_lbreaks[0] = vis_lbreaks[1] = 0; + visible_wrap_offset = 0; + return 0; +} + +/* Tell the update routines that we have moved onto a new line with the + prompt already displayed. Code originally from the version of readline + distributed with CLISP. rl_expand_prompt must have already been called + (explicitly or implicitly). This still doesn't work exactly right. */ +int +rl_on_new_line_with_prompt () +{ + int prompt_size, i, l, real_screenwidth, newlines; + char *prompt_last_line, *lprompt; + + /* Initialize visible_line and invisible_line to ensure that they can hold + the already-displayed prompt. */ + prompt_size = strlen (rl_prompt) + 1; + init_line_structures (prompt_size); + + /* Make sure the line structures hold the already-displayed prompt for + redisplay. */ + lprompt = local_prompt ? local_prompt : rl_prompt; + strcpy (visible_line, lprompt); + strcpy (invisible_line, lprompt); + + /* If the prompt contains newlines, take the last tail. */ + prompt_last_line = strrchr (rl_prompt, '\n'); + if (!prompt_last_line) + prompt_last_line = rl_prompt; + + l = strlen (prompt_last_line); + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l, 1); /* XXX */ + else + _rl_last_c_pos = l; + + /* Dissect prompt_last_line into screen lines. Note that here we have + to use the real screenwidth. Readline's notion of screenwidth might be + one less, see terminal.c. */ + real_screenwidth = _rl_screenwidth + (_rl_term_autowrap ? 0 : 1); + _rl_last_v_pos = l / real_screenwidth; + /* If the prompt length is a multiple of real_screenwidth, we don't know + whether the cursor is at the end of the last line, or already at the + beginning of the next line. Output a newline just to be safe. */ + if (l > 0 && (l % real_screenwidth) == 0) + _rl_output_some_chars ("\n", 1); + last_lmargin = 0; + + newlines = 0; i = 0; + while (i <= l) + { + _rl_vis_botlin = newlines; + vis_lbreaks[newlines++] = i; + i += real_screenwidth; + } + vis_lbreaks[newlines] = l; + visible_wrap_offset = 0; + + rl_display_prompt = rl_prompt; /* XXX - make sure it's set */ + + return 0; +} + +/* Actually update the display, period. */ +int +rl_forced_update_display () +{ + register char *temp; + + if (visible_line) + { + temp = visible_line; + while (*temp) + *temp++ = '\0'; + } + rl_on_new_line (); + forced_display++; + (*rl_redisplay_function) (); + return 0; +} + +/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices. + (Well, when we don't have multibyte characters, _rl_last_c_pos is a + buffer index.) + DATA is the contents of the screen line of interest; i.e., where + the movement is being done. */ +void +_rl_move_cursor_relative (new, data) + int new; + const char *data; +{ + register int i; + int woff; /* number of invisible chars on current line */ + int cpos, dpos; /* current and desired cursor positions */ + int adjust; + + woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset); + cpos = _rl_last_c_pos; + + if (cpos == 0 && cpos == new) + return; + +#if defined (HANDLE_MULTIBYTE) + /* If we have multibyte characters, NEW is indexed by the buffer point in + a multibyte string, but _rl_last_c_pos is the display position. In + this case, NEW's display position is not obvious and must be + calculated. We need to account for invisible characters in this line, + as long as we are past them and they are counted by _rl_col_width. */ + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + adjust = 1; + /* Try to short-circuit common cases and eliminate a bunch of multibyte + character function calls. */ + /* 1. prompt string */ + if (new == local_prompt_len && memcmp (data, local_prompt, new) == 0) + { + dpos = prompt_physical_chars; + cpos_adjusted = 1; + adjust = 0; + } + /* 2. prompt_string + line contents */ + else if (new > local_prompt_len && local_prompt && memcmp (data, local_prompt, local_prompt_len) == 0) + { + dpos = prompt_physical_chars + _rl_col_width (data, local_prompt_len, new, 1); + cpos_adjusted = 1; + adjust = 0; + } + else + dpos = _rl_col_width (data, 0, new, 1); + + if (displaying_prompt_first_line == 0) + adjust = 0; + + /* Use NEW when comparing against the last invisible character in the + prompt string, since they're both buffer indices and DPOS is a + desired display position. */ + if (adjust && ((new > prompt_last_invisible) || /* XXX - don't use woff here */ + (prompt_physical_chars >= _rl_screenwidth && + _rl_last_v_pos == prompt_last_screen_line && + wrap_offset >= woff && dpos >= woff && + new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset)))) + /* XXX last comparison might need to be >= */ + { + dpos -= woff; + /* Since this will be assigned to _rl_last_c_pos at the end (more + precisely, _rl_last_c_pos == dpos when this function returns), + let the caller know. */ + cpos_adjusted = 1; + } + } + else +#endif + dpos = new; + + /* If we don't have to do anything, then return. */ + if (cpos == dpos) + return; + + /* It may be faster to output a CR, and then move forwards instead + of moving backwards. */ + /* i == current physical cursor position. */ +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + i = _rl_last_c_pos; + else +#endif + i = _rl_last_c_pos - woff; + if (dpos == 0 || CR_FASTER (dpos, _rl_last_c_pos) || + (_rl_term_autowrap && i == _rl_screenwidth)) + { +#if defined (__MSDOS__) + putc ('\r', rl_outstream); +#else + tputs (_rl_term_cr, 1, _rl_output_character_function); +#endif /* !__MSDOS__ */ + cpos = _rl_last_c_pos = 0; + } + + if (cpos < dpos) + { + /* Move the cursor forward. We do it by printing the command + to move the cursor forward if there is one, else print that + portion of the output buffer again. Which is cheaper? */ + + /* The above comment is left here for posterity. It is faster + to print one character (non-control) than to print a control + sequence telling the terminal to move forward one character. + That kind of control is for people who don't know what the + data is underneath the cursor. */ + + /* However, we need a handle on where the current display position is + in the buffer for the immediately preceding comment to be true. + In multibyte locales, we don't currently have that info available. + Without it, we don't know where the data we have to display begins + in the buffer and we have to go back to the beginning of the screen + line. In this case, we can use the terminal sequence to move forward + if it's available. */ + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + if (_rl_term_forward_char) + { + for (i = cpos; i < dpos; i++) + tputs (_rl_term_forward_char, 1, _rl_output_character_function); + } + else + { + tputs (_rl_term_cr, 1, _rl_output_character_function); + for (i = 0; i < new; i++) + putc (data[i], rl_outstream); + } + } + else + for (i = cpos; i < new; i++) + putc (data[i], rl_outstream); + } + +#if defined (HANDLE_MULTIBYTE) + /* NEW points to the buffer point, but _rl_last_c_pos is the display point. + The byte length of the string is probably bigger than the column width + of the string, which means that if NEW == _rl_last_c_pos, then NEW's + display point is less than _rl_last_c_pos. */ +#endif + else if (cpos > dpos) + _rl_backspace (cpos - dpos); + + _rl_last_c_pos = dpos; +} + +/* PWP: move the cursor up or down. */ +void +_rl_move_vert (to) + int to; +{ + register int delta, i; + + if (_rl_last_v_pos == to || to > _rl_screenheight) + return; + + if ((delta = to - _rl_last_v_pos) > 0) + { + for (i = 0; i < delta; i++) + putc ('\n', rl_outstream); +#if defined (__MSDOS__) + putc ('\r', rl_outstream); +#else + tputs (_rl_term_cr, 1, _rl_output_character_function); +#endif + _rl_last_c_pos = 0; + } + else + { /* delta < 0 */ +#ifdef __DJGPP__ + int row, col; + + fflush (rl_outstream); + ScreenGetCursor (&row, &col); + ScreenSetCursor (row + delta, col); + i = -delta; +#else + if (_rl_term_up && *_rl_term_up) + for (i = 0; i < -delta; i++) + tputs (_rl_term_up, 1, _rl_output_character_function); +#endif /* !__DJGPP__ */ + } + + _rl_last_v_pos = to; /* Now TO is here */ +} + +/* Physically print C on rl_outstream. This is for functions which know + how to optimize the display. Return the number of characters output. */ +int +rl_show_char (c) + int c; +{ + int n = 1; + if (META_CHAR (c) && (_rl_output_meta_chars == 0)) + { + fprintf (rl_outstream, "M-"); + n += 2; + c = UNMETA (c); + } + +#if defined (DISPLAY_TABS) + if ((CTRL_CHAR (c) && c != '\t') || c == RUBOUT) +#else + if (CTRL_CHAR (c) || c == RUBOUT) +#endif /* !DISPLAY_TABS */ + { + fprintf (rl_outstream, "C-"); + n += 2; + c = CTRL_CHAR (c) ? UNCTRL (c) : '?'; + } + + putc (c, rl_outstream); + fflush (rl_outstream); + return n; +} + +int +rl_character_len (c, pos) + register int c, pos; +{ + unsigned char uc; + + uc = (unsigned char)c; + + if (META_CHAR (uc)) + return ((_rl_output_meta_chars == 0) ? 4 : 1); + + if (uc == '\t') + { +#if defined (DISPLAY_TABS) + return (((pos | 7) + 1) - pos); +#else + return (2); +#endif /* !DISPLAY_TABS */ + } + + if (CTRL_CHAR (c) || c == RUBOUT) + return (2); + + return ((ISPRINT (uc)) ? 1 : 2); +} +/* How to print things in the "echo-area". The prompt is treated as a + mini-modeline. */ +static int msg_saved_prompt = 0; + +#if defined (USE_VARARGS) +int +#if defined (PREFER_STDARG) +rl_message (const char *format, ...) +#else +rl_message (va_alist) + va_dcl +#endif +{ + va_list args; +#if defined (PREFER_VARARGS) + char *format; +#endif +#if defined (HAVE_VSNPRINTF) + int bneed; +#endif + +#if defined (PREFER_STDARG) + va_start (args, format); +#else + va_start (args); + format = va_arg (args, char *); +#endif + + if (msg_buf == 0) + msg_buf = xmalloc (msg_bufsiz = 128); + +#if defined (HAVE_VSNPRINTF) + bneed = vsnprintf (msg_buf, msg_bufsiz - 1, format, args); + if (bneed >= msg_bufsiz - 1) + { + msg_bufsiz = bneed + 1; + msg_buf = xrealloc (msg_buf, msg_bufsiz); + va_end (args); + +#if defined (PREFER_STDARG) + va_start (args, format); +#else + va_start (args); + format = va_arg (args, char *); +#endif + vsnprintf (msg_buf, msg_bufsiz - 1, format, args); + } +#else + vsprintf (msg_buf, format, args); + msg_buf[msg_bufsiz - 1] = '\0'; /* overflow? */ +#endif + va_end (args); + + if (saved_local_prompt == 0) + { + rl_save_prompt (); + msg_saved_prompt = 1; + } + else if (local_prompt != saved_local_prompt) + { + FREE (local_prompt); + FREE (local_prompt_prefix); + local_prompt = (char *)NULL; + } + rl_display_prompt = msg_buf; + local_prompt = expand_prompt (msg_buf, &prompt_visible_length, + &prompt_last_invisible, + &prompt_invis_chars_first_line, + &prompt_physical_chars); + local_prompt_prefix = (char *)NULL; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; + (*rl_redisplay_function) (); + + return 0; +} +#else /* !USE_VARARGS */ +int +rl_message (format, arg1, arg2) + char *format; +{ + if (msg_buf == 0) + msg_buf = xmalloc (msg_bufsiz = 128); + + sprintf (msg_buf, format, arg1, arg2); + msg_buf[msg_bufsiz - 1] = '\0'; /* overflow? */ + + rl_display_prompt = msg_buf; + if (saved_local_prompt == 0) + { + rl_save_prompt (); + msg_saved_prompt = 1; + } + else if (local_prompt != saved_local_prompt) + { + FREE (local_prompt); + FREE (local_prompt_prefix); + local_prompt = (char *)NULL; + } + local_prompt = expand_prompt (msg_buf, &prompt_visible_length, + &prompt_last_invisible, + &prompt_invis_chars_first_line, + &prompt_physical_chars); + local_prompt_prefix = (char *)NULL; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; + (*rl_redisplay_function) (); + + return 0; +} +#endif /* !USE_VARARGS */ + +/* How to clear things from the "echo-area". */ +int +rl_clear_message () +{ + rl_display_prompt = rl_prompt; + if (msg_saved_prompt) + { + rl_restore_prompt (); + msg_saved_prompt = 0; + } + (*rl_redisplay_function) (); + return 0; +} + +int +rl_reset_line_state () +{ + rl_on_new_line (); + + rl_display_prompt = rl_prompt ? rl_prompt : ""; + forced_display = 1; + return 0; +} + +void +rl_save_prompt () +{ + saved_local_prompt = local_prompt; + saved_local_prefix = local_prompt_prefix; + saved_prefix_length = prompt_prefix_length; + saved_local_length = local_prompt_len; + saved_last_invisible = prompt_last_invisible; + saved_visible_length = prompt_visible_length; + saved_invis_chars_first_line = prompt_invis_chars_first_line; + saved_physical_chars = prompt_physical_chars; + + local_prompt = local_prompt_prefix = (char *)0; + local_prompt_len = 0; + prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0; + prompt_invis_chars_first_line = prompt_physical_chars = 0; +} + +void +rl_restore_prompt () +{ + FREE (local_prompt); + FREE (local_prompt_prefix); + + local_prompt = saved_local_prompt; + local_prompt_prefix = saved_local_prefix; + local_prompt_len = saved_local_length; + prompt_prefix_length = saved_prefix_length; + prompt_last_invisible = saved_last_invisible; + prompt_visible_length = saved_visible_length; + prompt_invis_chars_first_line = saved_invis_chars_first_line; + prompt_physical_chars = saved_physical_chars; + + /* can test saved_local_prompt to see if prompt info has been saved. */ + saved_local_prompt = saved_local_prefix = (char *)0; + saved_local_length = 0; + saved_last_invisible = saved_visible_length = saved_prefix_length = 0; + saved_invis_chars_first_line = saved_physical_chars = 0; +} + +char * +_rl_make_prompt_for_search (pchar) + int pchar; +{ + int len; + char *pmt, *p; + + rl_save_prompt (); + + /* We've saved the prompt, and can do anything with the various prompt + strings we need before they're restored. We want the unexpanded + portion of the prompt string after any final newline. */ + p = rl_prompt ? strrchr (rl_prompt, '\n') : 0; + if (p == 0) + { + len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0; + pmt = (char *)xmalloc (len + 2); + if (len) + strcpy (pmt, rl_prompt); + pmt[len] = pchar; + pmt[len+1] = '\0'; + } + else + { + p++; + len = strlen (p); + pmt = (char *)xmalloc (len + 2); + if (len) + strcpy (pmt, p); + pmt[len] = pchar; + pmt[len+1] = '\0'; + } + + /* will be overwritten by expand_prompt, called from rl_message */ + prompt_physical_chars = saved_physical_chars + 1; + return pmt; +} + +/* Quick redisplay hack when erasing characters at the end of the line. */ +void +_rl_erase_at_end_of_line (l) + int l; +{ + register int i; + + _rl_backspace (l); + for (i = 0; i < l; i++) + putc (' ', rl_outstream); + _rl_backspace (l); + for (i = 0; i < l; i++) + visible_line[--_rl_last_c_pos] = '\0'; + rl_display_fixed++; +} + +/* Clear to the end of the line. COUNT is the minimum + number of character spaces to clear, */ +void +_rl_clear_to_eol (count) + int count; +{ +#ifndef __MSDOS__ + if (_rl_term_clreol) + tputs (_rl_term_clreol, 1, _rl_output_character_function); + else +#endif + if (count) + space_to_eol (count); +} + +/* Clear to the end of the line using spaces. COUNT is the minimum + number of character spaces to clear, */ +static void +space_to_eol (count) + int count; +{ + register int i; + + for (i = 0; i < count; i++) + putc (' ', rl_outstream); + + _rl_last_c_pos += count; +} + +void +_rl_clear_screen () +{ +#ifndef __DJGPP__ + if (_rl_term_clrpag) + tputs (_rl_term_clrpag, 1, _rl_output_character_function); + else + rl_crlf (); +#else + ScreenClear (); + ScreenSetCursor (0, 0); +#endif /* __DJGPP__ */ +} + +/* Insert COUNT characters from STRING to the output stream at column COL. */ +static void +insert_some_chars (string, count, col) + char *string; + int count, col; +{ +#if defined (__MSDOS__) || defined (__MINGW32__) + _rl_output_some_chars (string, count); +#else + /* DEBUGGING */ + if (MB_CUR_MAX == 1 || rl_byte_oriented) + if (count != col) + _rl_ttymsg ("debug: insert_some_chars: count (%d) != col (%d)", count, col); + + /* If IC is defined, then we do not have to "enter" insert mode. */ + if (_rl_term_IC) + { + char *buffer; + + buffer = tgoto (_rl_term_IC, 0, col); + tputs (buffer, 1, _rl_output_character_function); + _rl_output_some_chars (string, count); + } + else + { + register int i; + + /* If we have to turn on insert-mode, then do so. */ + if (_rl_term_im && *_rl_term_im) + tputs (_rl_term_im, 1, _rl_output_character_function); + + /* If there is a special command for inserting characters, then + use that first to open up the space. */ + if (_rl_term_ic && *_rl_term_ic) + { + for (i = col; i--; ) + tputs (_rl_term_ic, 1, _rl_output_character_function); + } + + /* Print the text. */ + _rl_output_some_chars (string, count); + + /* If there is a string to turn off insert mode, we had best use + it now. */ + if (_rl_term_ei && *_rl_term_ei) + tputs (_rl_term_ei, 1, _rl_output_character_function); + } +#endif /* __MSDOS__ || __MINGW32__ */ +} + +/* Delete COUNT characters from the display line. */ +static void +delete_chars (count) + int count; +{ + if (count > _rl_screenwidth) /* XXX */ + return; + +#if !defined (__MSDOS__) && !defined (__MINGW32__) + if (_rl_term_DC && *_rl_term_DC) + { + char *buffer; + buffer = tgoto (_rl_term_DC, count, count); + tputs (buffer, count, _rl_output_character_function); + } + else + { + if (_rl_term_dc && *_rl_term_dc) + while (count--) + tputs (_rl_term_dc, 1, _rl_output_character_function); + } +#endif /* !__MSDOS__ && !__MINGW32__ */ +} + +void +_rl_update_final () +{ + int full_lines; + + full_lines = 0; + /* If the cursor is the only thing on an otherwise-blank last line, + compensate so we don't print an extra CRLF. */ + if (_rl_vis_botlin && _rl_last_c_pos == 0 && + visible_line[vis_lbreaks[_rl_vis_botlin]] == 0) + { + _rl_vis_botlin--; + full_lines = 1; + } + _rl_move_vert (_rl_vis_botlin); + /* If we've wrapped lines, remove the final xterm line-wrap flag. */ + if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == _rl_screenwidth)) + { + char *last_line; + + last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]]; + cpos_buffer_position = -1; /* don't know where we are in buffer */ + _rl_move_cursor_relative (_rl_screenwidth - 1, last_line); /* XXX */ + _rl_clear_to_eol (0); + putc (last_line[_rl_screenwidth - 1], rl_outstream); + } + _rl_vis_botlin = 0; + rl_crlf (); + fflush (rl_outstream); + rl_display_fixed++; +} + +/* Move to the start of the current line. */ +static void +cr () +{ + if (_rl_term_cr) + { +#if defined (__MSDOS__) + putc ('\r', rl_outstream); +#else + tputs (_rl_term_cr, 1, _rl_output_character_function); +#endif + _rl_last_c_pos = 0; + } +} + +/* Redraw the last line of a multi-line prompt that may possibly contain + terminal escape sequences. Called with the cursor at column 0 of the + line to draw the prompt on. */ +static void +redraw_prompt (t) + char *t; +{ + char *oldp; + + oldp = rl_display_prompt; + rl_save_prompt (); + + rl_display_prompt = t; + local_prompt = expand_prompt (t, &prompt_visible_length, + &prompt_last_invisible, + &prompt_invis_chars_first_line, + &prompt_physical_chars); + local_prompt_prefix = (char *)NULL; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; + + rl_forced_update_display (); + + rl_display_prompt = oldp; + rl_restore_prompt(); +} + +/* Redisplay the current line after a SIGWINCH is received. */ +void +_rl_redisplay_after_sigwinch () +{ + char *t; + + /* Clear the last line (assuming that the screen size change will result in + either more or fewer characters on that line only) and put the cursor at + column 0. Make sure the right thing happens if we have wrapped to a new + screen line. */ + if (_rl_term_cr) + { + _rl_move_vert (_rl_vis_botlin); + +#if defined (__MSDOS__) + putc ('\r', rl_outstream); +#else + tputs (_rl_term_cr, 1, _rl_output_character_function); +#endif + _rl_last_c_pos = 0; +#if defined (__MSDOS__) + space_to_eol (_rl_screenwidth); + putc ('\r', rl_outstream); +#else + if (_rl_term_clreol) + tputs (_rl_term_clreol, 1, _rl_output_character_function); + else + { + space_to_eol (_rl_screenwidth); + tputs (_rl_term_cr, 1, _rl_output_character_function); + } +#endif + if (_rl_last_v_pos > 0) + _rl_move_vert (0); + } + else + rl_crlf (); + + /* Redraw only the last line of a multi-line prompt. */ + t = strrchr (rl_display_prompt, '\n'); + if (t) + redraw_prompt (++t); + else + rl_forced_update_display (); +} + +void +_rl_clean_up_for_exit () +{ + if (_rl_echoing_p) + { + _rl_move_vert (_rl_vis_botlin); + _rl_vis_botlin = 0; + fflush (rl_outstream); + rl_restart_output (1, 0); + } +} + +void +_rl_erase_entire_line () +{ + cr (); + _rl_clear_to_eol (0); + cr (); + fflush (rl_outstream); +} + +/* return the `current display line' of the cursor -- the number of lines to + move up to get to the first screen line of the current readline line. */ +int +_rl_current_display_line () +{ + int ret, nleft; + + /* Find out whether or not there might be invisible characters in the + editing buffer. */ + if (rl_display_prompt == rl_prompt) + nleft = _rl_last_c_pos - _rl_screenwidth - rl_visible_prompt_length; + else + nleft = _rl_last_c_pos - _rl_screenwidth; + + if (nleft > 0) + ret = 1 + nleft / _rl_screenwidth; + else + ret = 0; + + return ret; +} + +#if defined (HANDLE_MULTIBYTE) +/* Calculate the number of screen columns occupied by STR from START to END. + In the case of multibyte characters with stateful encoding, we have to + scan from the beginning of the string to take the state into account. */ +static int +_rl_col_width (str, start, end, flags) + const char *str; + int start, end, flags; +{ + wchar_t wc; + mbstate_t ps; + int tmp, point, width, max; + + if (end <= start) + return 0; + if (MB_CUR_MAX == 1 || rl_byte_oriented) +{ +_rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1"); + return (end - start); +} + + memset (&ps, 0, sizeof (mbstate_t)); + + point = 0; + max = end; + + /* Try to short-circuit common cases. The adjustment to remove wrap_offset + is done by the caller. */ + /* 1. prompt string */ + if (flags && start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0) + return (prompt_physical_chars + wrap_offset); + /* 2. prompt string + line contents */ + else if (flags && start == 0 && local_prompt_len > 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0) + { + tmp = prompt_physical_chars + wrap_offset; + /* XXX - try to call ourselves recursively with non-prompt portion */ + tmp += _rl_col_width (str, local_prompt_len, end, flags); + return (tmp); + } + + while (point < start) + { + tmp = mbrlen (str + point, max, &ps); + if (MB_INVALIDCH ((size_t)tmp)) + { + /* In this case, the bytes are invalid or too short to compose a + multibyte character, so we assume that the first byte represents + a single character. */ + point++; + max--; + + /* Clear the state of the byte sequence, because in this case the + effect of mbstate is undefined. */ + memset (&ps, 0, sizeof (mbstate_t)); + } + else if (MB_NULLWCH (tmp)) + break; /* Found '\0' */ + else + { + point += tmp; + max -= tmp; + } + } + + /* If START is not a byte that starts a character, then POINT will be + greater than START. In this case, assume that (POINT - START) gives + a byte count that is the number of columns of difference. */ + width = point - start; + + while (point < end) + { + tmp = mbrtowc (&wc, str + point, max, &ps); + if (MB_INVALIDCH ((size_t)tmp)) + { + /* In this case, the bytes are invalid or too short to compose a + multibyte character, so we assume that the first byte represents + a single character. */ + point++; + max--; + + /* and assume that the byte occupies a single column. */ + width++; + + /* Clear the state of the byte sequence, because in this case the + effect of mbstate is undefined. */ + memset (&ps, 0, sizeof (mbstate_t)); + } + else if (MB_NULLWCH (tmp)) + break; /* Found '\0' */ + else + { + point += tmp; + max -= tmp; + tmp = WCWIDTH(wc); + width += (tmp >= 0) ? tmp : 1; + } + } + + width += point - end; + + return width; +} +#endif /* HANDLE_MULTIBYTE */ diff --git a/lib/readline/readline.c b/lib/readline/readline.c index fd10c389d..1946ff146 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -1239,6 +1239,10 @@ bind_arrow_keys_internal (map) rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history); rl_bind_keyseq_if_unbound ("\340M", rl_forward_char); rl_bind_keyseq_if_unbound ("\340K", rl_backward_char); + rl_bind_keyseq_if_unbound ("\340G", rl_beg_of_line); + rl_bind_keyseq_if_unbound ("\340O", rl_end_of_line); + rl_bind_keyseq_if_unbound ("\340S", rl_delete); + rl_bind_keyseq_if_unbound ("\340R", rl_overwrite_mode); #endif _rl_keymap = xkeymap; diff --git a/lib/sh/zread.c b/lib/sh/zread.c index 66007922d..832a43c79 100644 --- a/lib/sh/zread.c +++ b/lib/sh/zread.c @@ -150,6 +150,8 @@ zreadcintr (fd, cp) return 1; } +/* Like zreadc, but read a specified number of characters at a time. Used + for `read -N'. */ ssize_t zreadn (fd, cp, len) int fd; diff --git a/lib/sh/zread.c~ b/lib/sh/zread.c~ index 7ba81049a..66007922d 100644 --- a/lib/sh/zread.c~ +++ b/lib/sh/zread.c~ @@ -150,6 +150,32 @@ zreadcintr (fd, cp) return 1; } +ssize_t +zreadn (fd, cp, len) + int fd; + char *cp; + size_t len; +{ + ssize_t nr; + + if (lind == lused || lused == 0) + { + if (len > sizeof (lbuf)) + len = sizeof (lbuf); + nr = zread (fd, lbuf, len); + lind = 0; + if (nr <= 0) + { + lused = 0; + return nr; + } + lused = nr; + } + if (cp) + *cp = lbuf[lind++]; + return 1; +} + void zreset () { diff --git a/subst.c b/subst.c index d342d85ab..f9953b03c 100644 --- a/subst.c +++ b/subst.c @@ -166,6 +166,7 @@ extern struct fd_bitmap *current_fds_to_close; extern int wordexp_only; extern int expanding_redir; extern int tempenv_assign_error; +extern int builtin_ignoring_errexit; #if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE) extern wchar_t *wcsdup __P((const wchar_t *)); @@ -5394,7 +5395,8 @@ command_substitute (string, quoted) the -e flag. */ if (posixly_correct == 0) { - exit_immediately_on_error = 0; + builtin_ignoring_errexit = 0; + change_flag ('e', FLAG_OFF); set_shellopts (); } diff --git a/subst.c~ b/subst.c~ new file mode 100644 index 000000000..a6cdf2a39 --- /dev/null +++ b/subst.c~ @@ -0,0 +1,9556 @@ +/* subst.c -- The part of the shell that does parameter, command, arithmetic, + and globbing substitutions. */ + +/* ``Have a little faith, there's magic in the night. You ain't a + beauty, but, hey, you're alright.'' */ + +/* Copyright (C) 1987-2012 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Bash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bash. If not, see . +*/ + +#include "config.h" + +#include "bashtypes.h" +#include +#include "chartypes.h" +#if defined (HAVE_PWD_H) +# include +#endif +#include +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "bashansi.h" +#include "posixstat.h" +#include "bashintl.h" + +#include "shell.h" +#include "parser.h" +#include "flags.h" +#include "jobs.h" +#include "execute_cmd.h" +#include "filecntl.h" +#include "trap.h" +#include "pathexp.h" +#include "mailcheck.h" + +#include "shmbutil.h" +#include "typemax.h" + +#include "builtins/getopt.h" +#include "builtins/common.h" + +#include "builtins/builtext.h" + +#include +#include + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +/* The size that strings change by. */ +#define DEFAULT_INITIAL_ARRAY_SIZE 112 +#define DEFAULT_ARRAY_SIZE 128 + +/* Variable types. */ +#define VT_VARIABLE 0 +#define VT_POSPARMS 1 +#define VT_ARRAYVAR 2 +#define VT_ARRAYMEMBER 3 +#define VT_ASSOCVAR 4 + +#define VT_STARSUB 128 /* $* or ${array[*]} -- used to split */ + +/* Flags for quoted_strchr */ +#define ST_BACKSL 0x01 +#define ST_CTLESC 0x02 +#define ST_SQUOTE 0x04 /* unused yet */ +#define ST_DQUOTE 0x08 /* unused yet */ + +/* Flags for the `pflags' argument to param_expand() */ +#define PF_NOCOMSUB 0x01 /* Do not perform command substitution */ +#define PF_IGNUNBOUND 0x02 /* ignore unbound vars even if -u set */ +#define PF_NOSPLIT2 0x04 /* same as W_NOSPLIT2 */ +#define PF_ASSIGNRHS 0x08 /* same as W_ASSIGNRHS */ + +/* These defs make it easier to use the editor. */ +#define LBRACE '{' +#define RBRACE '}' +#define LPAREN '(' +#define RPAREN ')' + +#if defined (HANDLE_MULTIBYTE) +#define WLPAREN L'(' +#define WRPAREN L')' +#endif + +/* Evaluates to 1 if C is one of the shell's special parameters whose length + can be taken, but is also one of the special expansion characters. */ +#define VALID_SPECIAL_LENGTH_PARAM(c) \ + ((c) == '-' || (c) == '?' || (c) == '#') + +/* Evaluates to 1 if C is one of the shell's special parameters for which an + indirect variable reference may be made. */ +#define VALID_INDIR_PARAM(c) \ + ((posixly_correct == 0 && (c) == '#') || (posixly_correct == 0 && (c) == '?') || (c) == '@' || (c) == '*') + +/* Evaluates to 1 if C is one of the OP characters that follows the parameter + in ${parameter[:]OPword}. */ +#define VALID_PARAM_EXPAND_CHAR(c) (sh_syntaxtab[(unsigned char)c] & CSUBSTOP) + +/* Evaluates to 1 if this is one of the shell's special variables. */ +#define SPECIAL_VAR(name, wi) \ + ((DIGIT (*name) && all_digits (name)) || \ + (name[1] == '\0' && (sh_syntaxtab[(unsigned char)*name] & CSPECVAR)) || \ + (wi && name[2] == '\0' && VALID_INDIR_PARAM (name[1]))) + +/* An expansion function that takes a string and a quoted flag and returns + a WORD_LIST *. Used as the type of the third argument to + expand_string_if_necessary(). */ +typedef WORD_LIST *EXPFUNC __P((char *, int)); + +/* Process ID of the last command executed within command substitution. */ +pid_t last_command_subst_pid = NO_PID; +pid_t current_command_subst_pid = NO_PID; + +/* Variables used to keep track of the characters in IFS. */ +SHELL_VAR *ifs_var; +char *ifs_value; +unsigned char ifs_cmap[UCHAR_MAX + 1]; + +#if defined (HANDLE_MULTIBYTE) +unsigned char ifs_firstc[MB_LEN_MAX]; +size_t ifs_firstc_len; +#else +unsigned char ifs_firstc; +#endif + +/* Sentinel to tell when we are performing variable assignments preceding a + command name and putting them into the environment. Used to make sure + we use the temporary environment when looking up variable values. */ +int assigning_in_environment; + +/* Used to hold a list of variable assignments preceding a command. Global + so the SIGCHLD handler in jobs.c can unwind-protect it when it runs a + SIGCHLD trap and so it can be saved and restored by the trap handlers. */ +WORD_LIST *subst_assign_varlist = (WORD_LIST *)NULL; + +/* Extern functions and variables from different files. */ +extern int last_command_exit_value, last_command_exit_signal; +extern int subshell_environment, line_number; +extern int subshell_level, parse_and_execute_level, sourcelevel; +extern int eof_encountered; +extern int return_catch_flag, return_catch_value; +extern pid_t dollar_dollar_pid; +extern int posixly_correct; +extern char *this_command_name; +extern struct fd_bitmap *current_fds_to_close; +extern int wordexp_only; +extern int expanding_redir; +extern int tempenv_assign_error; + +#if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE) +extern wchar_t *wcsdup __P((const wchar_t *)); +#endif + +/* Non-zero means to allow unmatched globbed filenames to expand to + a null file. */ +int allow_null_glob_expansion; + +/* Non-zero means to throw an error when globbing fails to match anything. */ +int fail_glob_expansion; + +#if 0 +/* Variables to keep track of which words in an expanded word list (the + output of expand_word_list_internal) are the result of globbing + expansions. GLOB_ARGV_FLAGS is used by execute_cmd.c. + (CURRENTLY UNUSED). */ +char *glob_argv_flags; +static int glob_argv_flags_size; +#endif + +static WORD_LIST expand_word_error, expand_word_fatal; +static WORD_DESC expand_wdesc_error, expand_wdesc_fatal; +static char expand_param_error, expand_param_fatal; +static char extract_string_error, extract_string_fatal; + +/* Tell the expansion functions to not longjmp back to top_level on fatal + errors. Enabled when doing completion and prompt string expansion. */ +static int no_longjmp_on_fatal_error = 0; + +/* Set by expand_word_unsplit; used to inhibit splitting and re-joining + $* on $IFS, primarily when doing assignment statements. */ +static int expand_no_split_dollar_star = 0; + +/* A WORD_LIST of words to be expanded by expand_word_list_internal, + without any leading variable assignments. */ +static WORD_LIST *garglist = (WORD_LIST *)NULL; + +static char *quoted_substring __P((char *, int, int)); +static int quoted_strlen __P((char *)); +static char *quoted_strchr __P((char *, int, int)); + +static char *expand_string_if_necessary __P((char *, int, EXPFUNC *)); +static inline char *expand_string_to_string_internal __P((char *, int, EXPFUNC *)); +static WORD_LIST *call_expand_word_internal __P((WORD_DESC *, int, int, int *, int *)); +static WORD_LIST *expand_string_internal __P((char *, int)); +static WORD_LIST *expand_string_leave_quoted __P((char *, int)); +static WORD_LIST *expand_string_for_rhs __P((char *, int, int *, int *)); + +static WORD_LIST *list_quote_escapes __P((WORD_LIST *)); +static char *make_quoted_char __P((int)); +static WORD_LIST *quote_list __P((WORD_LIST *)); + +static int unquoted_substring __P((char *, char *)); +static int unquoted_member __P((int, char *)); + +#if defined (ARRAY_VARS) +static SHELL_VAR *do_compound_assignment __P((char *, char *, int)); +#endif +static int do_assignment_internal __P((const WORD_DESC *, int)); + +static char *string_extract_verbatim __P((char *, size_t, int *, char *, int)); +static char *string_extract __P((char *, int *, char *, int)); +static char *string_extract_double_quoted __P((char *, int *, int)); +static inline char *string_extract_single_quoted __P((char *, int *)); +static inline int skip_single_quoted __P((const char *, size_t, int)); +static int skip_double_quoted __P((char *, size_t, int)); +static char *extract_delimited_string __P((char *, int *, char *, char *, char *, int)); +static char *extract_dollar_brace_string __P((char *, int *, int, int)); +static int skip_matched_pair __P((const char *, int, int, int, int)); + +static char *pos_params __P((char *, int, int, int)); + +static unsigned char *mb_getcharlens __P((char *, int)); + +static char *remove_upattern __P((char *, char *, int)); +#if defined (HANDLE_MULTIBYTE) +static wchar_t *remove_wpattern __P((wchar_t *, size_t, wchar_t *, int)); +#endif +static char *remove_pattern __P((char *, char *, int)); + +static int match_upattern __P((char *, char *, int, char **, char **)); +#if defined (HANDLE_MULTIBYTE) +static int match_wpattern __P((wchar_t *, char **, size_t, wchar_t *, int, char **, char **)); +#endif +static int match_pattern __P((char *, char *, int, char **, char **)); +static int getpatspec __P((int, char *)); +static char *getpattern __P((char *, int, int)); +static char *variable_remove_pattern __P((char *, char *, int, int)); +static char *list_remove_pattern __P((WORD_LIST *, char *, int, int, int)); +static char *parameter_list_remove_pattern __P((int, char *, int, int)); +#ifdef ARRAY_VARS +static char *array_remove_pattern __P((SHELL_VAR *, char *, int, char *, int)); +#endif +static char *parameter_brace_remove_pattern __P((char *, char *, int, char *, int, int, int)); + +static char *process_substitute __P((char *, int)); + +static char *read_comsub __P((int, int, int *)); + +#ifdef ARRAY_VARS +static arrayind_t array_length_reference __P((char *)); +#endif + +static int valid_brace_expansion_word __P((char *, int)); +static int chk_atstar __P((char *, int, int *, int *)); +static int chk_arithsub __P((const char *, int)); + +static WORD_DESC *parameter_brace_expand_word __P((char *, int, int, int, arrayind_t *)); +static WORD_DESC *parameter_brace_expand_indir __P((char *, int, int, int *, int *)); +static WORD_DESC *parameter_brace_expand_rhs __P((char *, char *, int, int, int *, int *)); +static void parameter_brace_expand_error __P((char *, char *)); + +static int valid_length_expression __P((char *)); +static intmax_t parameter_brace_expand_length __P((char *)); + +static char *skiparith __P((char *, int)); +static int verify_substring_values __P((SHELL_VAR *, char *, char *, int, intmax_t *, intmax_t *)); +static int get_var_and_type __P((char *, char *, arrayind_t, int, int, SHELL_VAR **, char **)); +static char *mb_substring __P((char *, int, int)); +static char *parameter_brace_substring __P((char *, char *, int, char *, int, int)); + +static int shouldexp_replacement __P((char *)); + +static char *pos_params_pat_subst __P((char *, char *, char *, int)); + +static char *parameter_brace_patsub __P((char *, char *, int, char *, int, int)); + +static char *pos_params_casemod __P((char *, char *, int, int)); +static char *parameter_brace_casemod __P((char *, char *, int, int, char *, int, int)); + +static WORD_DESC *parameter_brace_expand __P((char *, int *, int, int, int *, int *)); +static WORD_DESC *param_expand __P((char *, int *, int, int *, int *, int *, int *, int)); + +static WORD_LIST *expand_word_internal __P((WORD_DESC *, int, int, int *, int *)); + +static WORD_LIST *word_list_split __P((WORD_LIST *)); + +static void exp_jump_to_top_level __P((int)); + +static WORD_LIST *separate_out_assignments __P((WORD_LIST *)); +static WORD_LIST *glob_expand_word_list __P((WORD_LIST *, int)); +#ifdef BRACE_EXPANSION +static WORD_LIST *brace_expand_word_list __P((WORD_LIST *, int)); +#endif +#if defined (ARRAY_VARS) +static int make_internal_declare __P((char *, char *)); +#endif +static WORD_LIST *shell_expand_word_list __P((WORD_LIST *, int)); +static WORD_LIST *expand_word_list_internal __P((WORD_LIST *, int)); + +/* **************************************************************** */ +/* */ +/* Utility Functions */ +/* */ +/* **************************************************************** */ + +#if defined (DEBUG) +void +dump_word_flags (flags) + int flags; +{ + int f; + + f = flags; + fprintf (stderr, "%d -> ", f); + if (f & W_ASSIGNASSOC) + { + f &= ~W_ASSIGNASSOC; + fprintf (stderr, "W_ASSIGNASSOC%s", f ? "|" : ""); + } + if (f & W_HASCTLESC) + { + f &= ~W_HASCTLESC; + fprintf (stderr, "W_HASCTLESC%s", f ? "|" : ""); + } + if (f & W_NOPROCSUB) + { + f &= ~W_NOPROCSUB; + fprintf (stderr, "W_NOPROCSUB%s", f ? "|" : ""); + } + if (f & W_DQUOTE) + { + f &= ~W_DQUOTE; + fprintf (stderr, "W_DQUOTE%s", f ? "|" : ""); + } + if (f & W_HASQUOTEDNULL) + { + f &= ~W_HASQUOTEDNULL; + fprintf (stderr, "W_HASQUOTEDNULL%s", f ? "|" : ""); + } + if (f & W_ASSIGNARG) + { + f &= ~W_ASSIGNARG; + fprintf (stderr, "W_ASSIGNARG%s", f ? "|" : ""); + } + if (f & W_ASSNBLTIN) + { + f &= ~W_ASSNBLTIN; + fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : ""); + } + if (f & W_ASSNGLOBAL) + { + f &= ~W_ASSNGLOBAL; + fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : ""); + } + if (f & W_COMPASSIGN) + { + f &= ~W_COMPASSIGN; + fprintf (stderr, "W_COMPASSIGN%s", f ? "|" : ""); + } + if (f & W_NOEXPAND) + { + f &= ~W_NOEXPAND; + fprintf (stderr, "W_NOEXPAND%s", f ? "|" : ""); + } + if (f & W_ITILDE) + { + f &= ~W_ITILDE; + fprintf (stderr, "W_ITILDE%s", f ? "|" : ""); + } + if (f & W_NOTILDE) + { + f &= ~W_NOTILDE; + fprintf (stderr, "W_NOTILDE%s", f ? "|" : ""); + } + if (f & W_ASSIGNRHS) + { + f &= ~W_ASSIGNRHS; + fprintf (stderr, "W_ASSIGNRHS%s", f ? "|" : ""); + } + if (f & W_NOCOMSUB) + { + f &= ~W_NOCOMSUB; + fprintf (stderr, "W_NOCOMSUB%s", f ? "|" : ""); + } + if (f & W_DOLLARSTAR) + { + f &= ~W_DOLLARSTAR; + fprintf (stderr, "W_DOLLARSTAR%s", f ? "|" : ""); + } + if (f & W_DOLLARAT) + { + f &= ~W_DOLLARAT; + fprintf (stderr, "W_DOLLARAT%s", f ? "|" : ""); + } + if (f & W_TILDEEXP) + { + f &= ~W_TILDEEXP; + fprintf (stderr, "W_TILDEEXP%s", f ? "|" : ""); + } + if (f & W_NOSPLIT2) + { + f &= ~W_NOSPLIT2; + fprintf (stderr, "W_NOSPLIT2%s", f ? "|" : ""); + } + if (f & W_NOSPLIT) + { + f &= ~W_NOSPLIT; + fprintf (stderr, "W_NOSPLIT%s", f ? "|" : ""); + } + if (f & W_NOBRACE) + { + f &= ~W_NOBRACE; + fprintf (stderr, "W_NOBRACE%s", f ? "|" : ""); + } + if (f & W_NOGLOB) + { + f &= ~W_NOGLOB; + fprintf (stderr, "W_NOGLOB%s", f ? "|" : ""); + } + if (f & W_GLOBEXP) + { + f &= ~W_GLOBEXP; + fprintf (stderr, "W_GLOBEXP%s", f ? "|" : ""); + } + if (f & W_ASSIGNMENT) + { + f &= ~W_ASSIGNMENT; + fprintf (stderr, "W_ASSIGNMENT%s", f ? "|" : ""); + } + if (f & W_QUOTED) + { + f &= ~W_QUOTED; + fprintf (stderr, "W_QUOTED%s", f ? "|" : ""); + } + if (f & W_HASDOLLAR) + { + f &= ~W_HASDOLLAR; + fprintf (stderr, "W_HASDOLLAR%s", f ? "|" : ""); + } + fprintf (stderr, "\n"); + fflush (stderr); +} +#endif + +#ifdef INCLUDE_UNUSED +static char * +quoted_substring (string, start, end) + char *string; + int start, end; +{ + register int len, l; + register char *result, *s, *r; + + len = end - start; + + /* Move to string[start], skipping quoted characters. */ + for (s = string, l = 0; *s && l < start; ) + { + if (*s == CTLESC) + { + s++; + continue; + } + l++; + if (*s == 0) + break; + } + + r = result = (char *)xmalloc (2*len + 1); /* save room for quotes */ + + /* Copy LEN characters, including quote characters. */ + s = string + l; + for (l = 0; l < len; s++) + { + if (*s == CTLESC) + *r++ = *s++; + *r++ = *s; + l++; + if (*s == 0) + break; + } + *r = '\0'; + return result; +} +#endif + +#ifdef INCLUDE_UNUSED +/* Return the length of S, skipping over quoted characters */ +static int +quoted_strlen (s) + char *s; +{ + register char *p; + int i; + + i = 0; + for (p = s; *p; p++) + { + if (*p == CTLESC) + { + p++; + if (*p == 0) + return (i + 1); + } + i++; + } + + return i; +} +#endif + +/* Find the first occurrence of character C in string S, obeying shell + quoting rules. If (FLAGS & ST_BACKSL) is non-zero, backslash-escaped + characters are skipped. If (FLAGS & ST_CTLESC) is non-zero, characters + escaped with CTLESC are skipped. */ +static char * +quoted_strchr (s, c, flags) + char *s; + int c, flags; +{ + register char *p; + + for (p = s; *p; p++) + { + if (((flags & ST_BACKSL) && *p == '\\') + || ((flags & ST_CTLESC) && *p == CTLESC)) + { + p++; + if (*p == '\0') + return ((char *)NULL); + continue; + } + else if (*p == c) + return p; + } + return ((char *)NULL); +} + +/* Return 1 if CHARACTER appears in an unquoted portion of + STRING. Return 0 otherwise. CHARACTER must be a single-byte character. */ +static int +unquoted_member (character, string) + int character; + char *string; +{ + size_t slen; + int sindex, c; + DECLARE_MBSTATE; + + slen = strlen (string); + sindex = 0; + while (c = string[sindex]) + { + if (c == character) + return (1); + + switch (c) + { + default: + ADVANCE_CHAR (string, slen, sindex); + break; + + case '\\': + sindex++; + if (string[sindex]) + ADVANCE_CHAR (string, slen, sindex); + break; + + case '\'': + sindex = skip_single_quoted (string, slen, ++sindex); + break; + + case '"': + sindex = skip_double_quoted (string, slen, ++sindex); + break; + } + } + return (0); +} + +/* Return 1 if SUBSTR appears in an unquoted portion of STRING. */ +static int +unquoted_substring (substr, string) + char *substr, *string; +{ + size_t slen; + int sindex, c, sublen; + DECLARE_MBSTATE; + + if (substr == 0 || *substr == '\0') + return (0); + + slen = strlen (string); + sublen = strlen (substr); + for (sindex = 0; c = string[sindex]; ) + { + if (STREQN (string + sindex, substr, sublen)) + return (1); + + switch (c) + { + case '\\': + sindex++; + if (string[sindex]) + ADVANCE_CHAR (string, slen, sindex); + break; + + case '\'': + sindex = skip_single_quoted (string, slen, ++sindex); + break; + + case '"': + sindex = skip_double_quoted (string, slen, ++sindex); + break; + + default: + ADVANCE_CHAR (string, slen, sindex); + break; + } + } + return (0); +} + +/* Most of the substitutions must be done in parallel. In order + to avoid using tons of unclear goto's, I have some functions + for manipulating malloc'ed strings. They all take INDX, a + pointer to an integer which is the offset into the string + where manipulation is taking place. They also take SIZE, a + pointer to an integer which is the current length of the + character array for this string. */ + +/* Append SOURCE to TARGET at INDEX. SIZE is the current amount + of space allocated to TARGET. SOURCE can be NULL, in which + case nothing happens. Gets rid of SOURCE by freeing it. + Returns TARGET in case the location has changed. */ +INLINE char * +sub_append_string (source, target, indx, size) + char *source, *target; + int *indx, *size; +{ + if (source) + { + int srclen, n; + + srclen = STRLEN (source); + if (srclen >= (int)(*size - *indx)) + { + n = srclen + *indx; + n = (n + DEFAULT_ARRAY_SIZE) - (n % DEFAULT_ARRAY_SIZE); + target = (char *)xrealloc (target, (*size = n)); + } + + FASTCOPY (source, target + *indx, srclen); + *indx += srclen; + target[*indx] = '\0'; + + free (source); + } + return (target); +} + +#if 0 +/* UNUSED */ +/* Append the textual representation of NUMBER to TARGET. + INDX and SIZE are as in SUB_APPEND_STRING. */ +char * +sub_append_number (number, target, indx, size) + intmax_t number; + int *indx, *size; + char *target; +{ + char *temp; + + temp = itos (number); + return (sub_append_string (temp, target, indx, size)); +} +#endif + +/* Extract a substring from STRING, starting at SINDEX and ending with + one of the characters in CHARLIST. Don't make the ending character + part of the string. Leave SINDEX pointing at the ending character. + Understand about backslashes in the string. If (flags & SX_VARNAME) + is non-zero, and array variables have been compiled into the shell, + everything between a `[' and a corresponding `]' is skipped over. + If (flags & SX_NOALLOC) is non-zero, don't return the substring, just + update SINDEX. If (flags & SX_REQMATCH) is non-zero, the string must + contain a closing character from CHARLIST. */ +static char * +string_extract (string, sindex, charlist, flags) + char *string; + int *sindex; + char *charlist; + int flags; +{ + register int c, i; + int found; + size_t slen; + char *temp; + DECLARE_MBSTATE; + + slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0; + i = *sindex; + found = 0; + while (c = string[i]) + { + if (c == '\\') + { + if (string[i + 1]) + i++; + else + break; + } +#if defined (ARRAY_VARS) + else if ((flags & SX_VARNAME) && c == '[') + { + int ni; + /* If this is an array subscript, skip over it and continue. */ + ni = skipsubscript (string, i, 0); + if (string[ni] == ']') + i = ni; + } +#endif + else if (MEMBER (c, charlist)) + { + found = 1; + break; + } + + ADVANCE_CHAR (string, slen, i); + } + + /* If we had to have a matching delimiter and didn't find one, return an + error and let the caller deal with it. */ + if ((flags & SX_REQMATCH) && found == 0) + { + *sindex = i; + return (&extract_string_error); + } + + temp = (flags & SX_NOALLOC) ? (char *)NULL : substring (string, *sindex, i); + *sindex = i; + + return (temp); +} + +/* Extract the contents of STRING as if it is enclosed in double quotes. + SINDEX, when passed in, is the offset of the character immediately + following the opening double quote; on exit, SINDEX is left pointing after + the closing double quote. If STRIPDQ is non-zero, unquoted double + quotes are stripped and the string is terminated by a null byte. + Backslashes between the embedded double quotes are processed. If STRIPDQ + is zero, an unquoted `"' terminates the string. */ +static char * +string_extract_double_quoted (string, sindex, stripdq) + char *string; + int *sindex, stripdq; +{ + size_t slen; + char *send; + int j, i, t; + unsigned char c; + char *temp, *ret; /* The new string we return. */ + int pass_next, backquote, si; /* State variables for the machine. */ + int dquote; + DECLARE_MBSTATE; + + slen = strlen (string + *sindex) + *sindex; + send = string + slen; + + pass_next = backquote = dquote = 0; + temp = (char *)xmalloc (1 + slen - *sindex); + + j = 0; + i = *sindex; + while (c = string[i]) + { + /* Process a character that was quoted by a backslash. */ + if (pass_next) + { + /* XXX - take another look at this in light of Interp 221 */ + /* Posix.2 sez: + + ``The backslash shall retain its special meaning as an escape + character only when followed by one of the characters: + $ ` " \ ''. + + If STRIPDQ is zero, we handle the double quotes here and let + expand_word_internal handle the rest. If STRIPDQ is non-zero, + we have already been through one round of backslash stripping, + and want to strip these backslashes only if DQUOTE is non-zero, + indicating that we are inside an embedded double-quoted string. */ + + /* If we are in an embedded quoted string, then don't strip + backslashes before characters for which the backslash + retains its special meaning, but remove backslashes in + front of other characters. If we are not in an + embedded quoted string, don't strip backslashes at all. + This mess is necessary because the string was already + surrounded by double quotes (and sh has some really weird + quoting rules). + The returned string will be run through expansion as if + it were double-quoted. */ + if ((stripdq == 0 && c != '"') || + (stripdq && ((dquote && (sh_syntaxtab[c] & CBSDQUOTE)) || dquote == 0))) + temp[j++] = '\\'; + pass_next = 0; + +add_one_character: + COPY_CHAR_I (temp, j, string, send, i); + continue; + } + + /* A backslash protects the next character. The code just above + handles preserving the backslash in front of any character but + a double quote. */ + if (c == '\\') + { + pass_next++; + i++; + continue; + } + + /* Inside backquotes, ``the portion of the quoted string from the + initial backquote and the characters up to the next backquote + that is not preceded by a backslash, having escape characters + removed, defines that command''. */ + if (backquote) + { + if (c == '`') + backquote = 0; + temp[j++] = c; + i++; + continue; + } + + if (c == '`') + { + temp[j++] = c; + backquote++; + i++; + continue; + } + + /* Pass everything between `$(' and the matching `)' or a quoted + ${ ... } pair through according to the Posix.2 specification. */ + if (c == '$' && ((string[i + 1] == LPAREN) || (string[i + 1] == LBRACE))) + { + int free_ret = 1; + + si = i + 2; + if (string[i + 1] == LPAREN) + ret = extract_command_subst (string, &si, 0); + else + ret = extract_dollar_brace_string (string, &si, Q_DOUBLE_QUOTES, 0); + + temp[j++] = '$'; + temp[j++] = string[i + 1]; + + /* Just paranoia; ret will not be 0 unless no_longjmp_on_fatal_error + is set. */ + if (ret == 0 && no_longjmp_on_fatal_error) + { + free_ret = 0; + ret = string + i + 2; + } + + for (t = 0; ret[t]; t++, j++) + temp[j] = ret[t]; + temp[j] = string[si]; + + if (string[si]) + { + j++; + i = si + 1; + } + else + i = si; + + if (free_ret) + free (ret); + continue; + } + + /* Add any character but a double quote to the quoted string we're + accumulating. */ + if (c != '"') + goto add_one_character; + + /* c == '"' */ + if (stripdq) + { + dquote ^= 1; + i++; + continue; + } + + break; + } + temp[j] = '\0'; + + /* Point to after the closing quote. */ + if (c) + i++; + *sindex = i; + + return (temp); +} + +/* This should really be another option to string_extract_double_quoted. */ +static int +skip_double_quoted (string, slen, sind) + char *string; + size_t slen; + int sind; +{ + int c, i; + char *ret; + int pass_next, backquote, si; + DECLARE_MBSTATE; + + pass_next = backquote = 0; + i = sind; + while (c = string[i]) + { + if (pass_next) + { + pass_next = 0; + ADVANCE_CHAR (string, slen, i); + continue; + } + else if (c == '\\') + { + pass_next++; + i++; + continue; + } + else if (backquote) + { + if (c == '`') + backquote = 0; + ADVANCE_CHAR (string, slen, i); + continue; + } + else if (c == '`') + { + backquote++; + i++; + continue; + } + else if (c == '$' && ((string[i + 1] == LPAREN) || (string[i + 1] == LBRACE))) + { + si = i + 2; + if (string[i + 1] == LPAREN) + ret = extract_command_subst (string, &si, SX_NOALLOC); + else + ret = extract_dollar_brace_string (string, &si, Q_DOUBLE_QUOTES, SX_NOALLOC); + + i = si + 1; + continue; + } + else if (c != '"') + { + ADVANCE_CHAR (string, slen, i); + continue; + } + else + break; + } + + if (c) + i++; + + return (i); +} + +/* Extract the contents of STRING as if it is enclosed in single quotes. + SINDEX, when passed in, is the offset of the character immediately + following the opening single quote; on exit, SINDEX is left pointing after + the closing single quote. */ +static inline char * +string_extract_single_quoted (string, sindex) + char *string; + int *sindex; +{ + register int i; + size_t slen; + char *t; + DECLARE_MBSTATE; + + /* Don't need slen for ADVANCE_CHAR unless multibyte chars possible. */ + slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0; + i = *sindex; + while (string[i] && string[i] != '\'') + ADVANCE_CHAR (string, slen, i); + + t = substring (string, *sindex, i); + + if (string[i]) + i++; + *sindex = i; + + return (t); +} + +static inline int +skip_single_quoted (string, slen, sind) + const char *string; + size_t slen; + int sind; +{ + register int c; + DECLARE_MBSTATE; + + c = sind; + while (string[c] && string[c] != '\'') + ADVANCE_CHAR (string, slen, c); + + if (string[c]) + c++; + return c; +} + +/* Just like string_extract, but doesn't hack backslashes or any of + that other stuff. Obeys CTLESC quoting. Used to do splitting on $IFS. */ +static char * +string_extract_verbatim (string, slen, sindex, charlist, flags) + char *string; + size_t slen; + int *sindex; + char *charlist; + int flags; +{ + register int i; +#if defined (HANDLE_MULTIBYTE) + size_t clen; + wchar_t *wcharlist; +#endif + int c; + char *temp; + DECLARE_MBSTATE; + + if (charlist[0] == '\'' && charlist[1] == '\0') + { + temp = string_extract_single_quoted (string, sindex); + --*sindex; /* leave *sindex at separator character */ + return temp; + } + + i = *sindex; +#if 0 + /* See how the MBLEN and ADVANCE_CHAR macros work to understand why we need + this only if MB_CUR_MAX > 1. */ + slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 1; +#endif +#if defined (HANDLE_MULTIBYTE) + clen = strlen (charlist); + wcharlist = 0; +#endif + while (c = string[i]) + { +#if defined (HANDLE_MULTIBYTE) + size_t mblength; +#endif + if ((flags & SX_NOCTLESC) == 0 && c == CTLESC) + { + i += 2; + continue; + } + /* Even if flags contains SX_NOCTLESC, we let CTLESC quoting CTLNUL + through, to protect the CTLNULs from later calls to + remove_quoted_nulls. */ + else if ((flags & SX_NOESCCTLNUL) == 0 && c == CTLESC && string[i+1] == CTLNUL) + { + i += 2; + continue; + } + +#if defined (HANDLE_MULTIBYTE) + mblength = MBLEN (string + i, slen - i); + if (mblength > 1) + { + wchar_t wc; + mblength = mbtowc (&wc, string + i, slen - i); + if (MB_INVALIDCH (mblength)) + { + if (MEMBER (c, charlist)) + break; + } + else + { + if (wcharlist == 0) + { + size_t len; + len = mbstowcs (wcharlist, charlist, 0); + if (len == -1) + len = 0; + wcharlist = (wchar_t *)xmalloc (sizeof (wchar_t) * (len + 1)); + mbstowcs (wcharlist, charlist, len + 1); + } + + if (wcschr (wcharlist, wc)) + break; + } + } + else +#endif + if (MEMBER (c, charlist)) + break; + + ADVANCE_CHAR (string, slen, i); + } + +#if defined (HANDLE_MULTIBYTE) + FREE (wcharlist); +#endif + + temp = substring (string, *sindex, i); + *sindex = i; + + return (temp); +} + +/* Extract the $( construct in STRING, and return a new string. + Start extracting at (SINDEX) as if we had just seen "$(". + Make (SINDEX) get the position of the matching ")". ) + XFLAGS is additional flags to pass to other extraction functions. */ +char * +extract_command_subst (string, sindex, xflags) + char *string; + int *sindex; + int xflags; +{ + if (string[*sindex] == LPAREN) + return (extract_delimited_string (string, sindex, "$(", "(", ")", xflags|SX_COMMAND)); /*)*/ + else + { + xflags |= (no_longjmp_on_fatal_error ? SX_NOLONGJMP : 0); + return (xparse_dolparen (string, string+*sindex, sindex, xflags)); + } +} + +/* Extract the $[ construct in STRING, and return a new string. (]) + Start extracting at (SINDEX) as if we had just seen "$[". + Make (SINDEX) get the position of the matching "]". */ +char * +extract_arithmetic_subst (string, sindex) + char *string; + int *sindex; +{ + return (extract_delimited_string (string, sindex, "$[", "[", "]", 0)); /*]*/ +} + +#if defined (PROCESS_SUBSTITUTION) +/* Extract the <( or >( construct in STRING, and return a new string. + Start extracting at (SINDEX) as if we had just seen "<(". + Make (SINDEX) get the position of the matching ")". */ /*))*/ +char * +extract_process_subst (string, starter, sindex) + char *string; + char *starter; + int *sindex; +{ + return (extract_delimited_string (string, sindex, starter, "(", ")", SX_COMMAND)); +} +#endif /* PROCESS_SUBSTITUTION */ + +#if defined (ARRAY_VARS) +/* This can be fooled by unquoted right parens in the passed string. If + each caller verifies that the last character in STRING is a right paren, + we don't even need to call extract_delimited_string. */ +char * +extract_array_assignment_list (string, sindex) + char *string; + int *sindex; +{ + int slen; + char *ret; + + slen = strlen (string); /* ( */ + if (string[slen - 1] == ')') + { + ret = substring (string, *sindex, slen - 1); + *sindex = slen - 1; + return ret; + } + return 0; +} +#endif + +/* Extract and create a new string from the contents of STRING, a + character string delimited with OPENER and CLOSER. SINDEX is + the address of an int describing the current offset in STRING; + it should point to just after the first OPENER found. On exit, + SINDEX gets the position of the last character of the matching CLOSER. + If OPENER is more than a single character, ALT_OPENER, if non-null, + contains a character string that can also match CLOSER and thus + needs to be skipped. */ +static char * +extract_delimited_string (string, sindex, opener, alt_opener, closer, flags) + char *string; + int *sindex; + char *opener, *alt_opener, *closer; + int flags; +{ + int i, c, si; + size_t slen; + char *t, *result; + int pass_character, nesting_level, in_comment; + int len_closer, len_opener, len_alt_opener; + DECLARE_MBSTATE; + + slen = strlen (string + *sindex) + *sindex; + len_opener = STRLEN (opener); + len_alt_opener = STRLEN (alt_opener); + len_closer = STRLEN (closer); + + pass_character = in_comment = 0; + + nesting_level = 1; + i = *sindex; + + while (nesting_level) + { + c = string[i]; + + if (c == 0) + break; + + if (in_comment) + { + if (c == '\n') + in_comment = 0; + ADVANCE_CHAR (string, slen, i); + continue; + } + + if (pass_character) /* previous char was backslash */ + { + pass_character = 0; + ADVANCE_CHAR (string, slen, i); + continue; + } + + /* Not exactly right yet; should handle shell metacharacters and + multibyte characters, too. See COMMENT_BEGIN define in parse.y */ + if ((flags & SX_COMMAND) && c == '#' && (i == 0 || string[i - 1] == '\n' || shellblank (string[i - 1]))) + { + in_comment = 1; + ADVANCE_CHAR (string, slen, i); + continue; + } + + if (c == CTLESC || c == '\\') + { + pass_character++; + i++; + continue; + } + + /* Process a nested command substitution, but only if we're parsing an + arithmetic substitution. */ + if ((flags & SX_COMMAND) && string[i] == '$' && string[i+1] == LPAREN) + { + si = i + 2; + t = extract_command_subst (string, &si, flags|SX_NOALLOC); + i = si + 1; + continue; + } + + /* Process a nested OPENER. */ + if (STREQN (string + i, opener, len_opener)) + { + si = i + len_opener; + t = extract_delimited_string (string, &si, opener, alt_opener, closer, flags|SX_NOALLOC); + i = si + 1; + continue; + } + + /* Process a nested ALT_OPENER */ + if (len_alt_opener && STREQN (string + i, alt_opener, len_alt_opener)) + { + si = i + len_alt_opener; + t = extract_delimited_string (string, &si, alt_opener, alt_opener, closer, flags|SX_NOALLOC); + i = si + 1; + continue; + } + + /* If the current substring terminates the delimited string, decrement + the nesting level. */ + if (STREQN (string + i, closer, len_closer)) + { + i += len_closer - 1; /* move to last byte of the closer */ + nesting_level--; + if (nesting_level == 0) + break; + } + + /* Pass old-style command substitution through verbatim. */ + if (c == '`') + { + si = i + 1; + t = string_extract (string, &si, "`", flags|SX_NOALLOC); + i = si + 1; + continue; + } + + /* Pass single-quoted and double-quoted strings through verbatim. */ + if (c == '\'' || c == '"') + { + si = i + 1; + i = (c == '\'') ? skip_single_quoted (string, slen, si) + : skip_double_quoted (string, slen, si); + continue; + } + + /* move past this character, which was not special. */ + ADVANCE_CHAR (string, slen, i); + } + + if (c == 0 && nesting_level) + { + if (no_longjmp_on_fatal_error == 0) + { + last_command_exit_value = EXECUTION_FAILURE; + report_error (_("bad substitution: no closing `%s' in %s"), closer, string); + exp_jump_to_top_level (DISCARD); + } + else + { + *sindex = i; + return (char *)NULL; + } + } + + si = i - *sindex - len_closer + 1; + if (flags & SX_NOALLOC) + result = (char *)NULL; + else + { + result = (char *)xmalloc (1 + si); + strncpy (result, string + *sindex, si); + result[si] = '\0'; + } + *sindex = i; + + return (result); +} + +/* Extract a parameter expansion expression within ${ and } from STRING. + Obey the Posix.2 rules for finding the ending `}': count braces while + skipping over enclosed quoted strings and command substitutions. + SINDEX is the address of an int describing the current offset in STRING; + it should point to just after the first `{' found. On exit, SINDEX + gets the position of the matching `}'. QUOTED is non-zero if this + occurs inside double quotes. */ +/* XXX -- this is very similar to extract_delimited_string -- XXX */ +static char * +extract_dollar_brace_string (string, sindex, quoted, flags) + char *string; + int *sindex, quoted, flags; +{ + register int i, c; + size_t slen; + int pass_character, nesting_level, si, dolbrace_state; + char *result, *t; + DECLARE_MBSTATE; + + pass_character = 0; + nesting_level = 1; + slen = strlen (string + *sindex) + *sindex; + + /* The handling of dolbrace_state needs to agree with the code in parse.y: + parse_matched_pair(). The different initial value is to handle the + case where this function is called to parse the word in + ${param op word} (SX_WORD). */ + dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM; + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP)) + dolbrace_state = DOLBRACE_QUOTE; + + i = *sindex; + while (c = string[i]) + { + if (pass_character) + { + pass_character = 0; + ADVANCE_CHAR (string, slen, i); + continue; + } + + /* CTLESCs and backslashes quote the next character. */ + if (c == CTLESC || c == '\\') + { + pass_character++; + i++; + continue; + } + + if (string[i] == '$' && string[i+1] == LBRACE) + { + nesting_level++; + i += 2; + continue; + } + + if (c == RBRACE) + { + nesting_level--; + if (nesting_level == 0) + break; + i++; + continue; + } + + /* Pass the contents of old-style command substitutions through + verbatim. */ + if (c == '`') + { + si = i + 1; + t = string_extract (string, &si, "`", flags|SX_NOALLOC); + i = si + 1; + continue; + } + + /* Pass the contents of new-style command substitutions and + arithmetic substitutions through verbatim. */ + if (string[i] == '$' && string[i+1] == LPAREN) + { + si = i + 2; + t = extract_command_subst (string, &si, flags|SX_NOALLOC); + i = si + 1; + continue; + } + +#if 0 + /* Pass the contents of single-quoted and double-quoted strings + through verbatim. */ + if (c == '\'' || c == '"') + { + si = i + 1; + i = (c == '\'') ? skip_single_quoted (string, slen, si) + : skip_double_quoted (string, slen, si); + /* skip_XXX_quoted leaves index one past close quote */ + continue; + } +#else /* XXX - bash-4.2 */ + /* Pass the contents of double-quoted strings through verbatim. */ + if (c == '"') + { + si = i + 1; + i = skip_double_quoted (string, slen, si); + /* skip_XXX_quoted leaves index one past close quote */ + continue; + } + + if (c == '\'') + { +/*itrace("extract_dollar_brace_string: c == single quote flags = %d quoted = %d dolbrace_state = %d", flags, quoted, dolbrace_state);*/ + if (posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + ADVANCE_CHAR (string, slen, i); + else + { + si = i + 1; + i = skip_single_quoted (string, slen, si); + } + + continue; + } +#endif + + /* move past this character, which was not special. */ + ADVANCE_CHAR (string, slen, i); + + /* This logic must agree with parse.y:parse_matched_pair, since they + share the same defines. */ + if (dolbrace_state == DOLBRACE_PARAM && c == '%' && (i - *sindex) > 1) + dolbrace_state = DOLBRACE_QUOTE; + else if (dolbrace_state == DOLBRACE_PARAM && c == '#' && (i - *sindex) > 1) + dolbrace_state = DOLBRACE_QUOTE; + else if (dolbrace_state == DOLBRACE_PARAM && c == '/' && (i - *sindex) > 1) + dolbrace_state = DOLBRACE_QUOTE; + else if (dolbrace_state == DOLBRACE_PARAM && c == '^' && (i - *sindex) > 1) + dolbrace_state = DOLBRACE_QUOTE; + else if (dolbrace_state == DOLBRACE_PARAM && c == ',' && (i - *sindex) > 1) + dolbrace_state = DOLBRACE_QUOTE; + else if (dolbrace_state == DOLBRACE_PARAM && strchr ("#%^,~:-=?+/", c) != 0) + dolbrace_state = DOLBRACE_OP; + else if (dolbrace_state == DOLBRACE_OP && strchr ("#%^,~:-=?+/", c) == 0) + dolbrace_state = DOLBRACE_WORD; + } + + if (c == 0 && nesting_level) + { + if (no_longjmp_on_fatal_error == 0) + { /* { */ + last_command_exit_value = EXECUTION_FAILURE; + report_error (_("bad substitution: no closing `%s' in %s"), "}", string); + exp_jump_to_top_level (DISCARD); + } + else + { + *sindex = i; + return ((char *)NULL); + } + } + + result = (flags & SX_NOALLOC) ? (char *)NULL : substring (string, *sindex, i); + *sindex = i; + + return (result); +} + +/* Remove backslashes which are quoting backquotes from STRING. Modifies + STRING, and returns a pointer to it. */ +char * +de_backslash (string) + char *string; +{ + register size_t slen; + register int i, j, prev_i; + DECLARE_MBSTATE; + + slen = strlen (string); + i = j = 0; + + /* Loop copying string[i] to string[j], i >= j. */ + while (i < slen) + { + if (string[i] == '\\' && (string[i + 1] == '`' || string[i + 1] == '\\' || + string[i + 1] == '$')) + i++; + prev_i = i; + ADVANCE_CHAR (string, slen, i); + if (j < prev_i) + do string[j++] = string[prev_i++]; while (prev_i < i); + else + j = i; + } + string[j] = '\0'; + + return (string); +} + +#if 0 +/*UNUSED*/ +/* Replace instances of \! in a string with !. */ +void +unquote_bang (string) + char *string; +{ + register int i, j; + register char *temp; + + temp = (char *)xmalloc (1 + strlen (string)); + + for (i = 0, j = 0; (temp[j] = string[i]); i++, j++) + { + if (string[i] == '\\' && string[i + 1] == '!') + { + temp[j] = '!'; + i++; + } + } + strcpy (string, temp); + free (temp); +} +#endif + +#define CQ_RETURN(x) do { no_longjmp_on_fatal_error = 0; return (x); } while (0) + +/* This function assumes s[i] == open; returns with s[ret] == close; used to + parse array subscripts. FLAGS & 1 means to not attempt to skip over + matched pairs of quotes or backquotes, or skip word expansions; it is + intended to be used after expansion has been performed and during final + assignment parsing (see arrayfunc.c:assign_compound_array_list()). */ +static int +skip_matched_pair (string, start, open, close, flags) + const char *string; + int start, open, close, flags; +{ + int i, pass_next, backq, si, c, count; + size_t slen; + char *temp, *ss; + DECLARE_MBSTATE; + + slen = strlen (string + start) + start; + no_longjmp_on_fatal_error = 1; + + i = start + 1; /* skip over leading bracket */ + count = 1; + pass_next = backq = 0; + ss = (char *)string; + while (c = string[i]) + { + if (pass_next) + { + pass_next = 0; + if (c == 0) + CQ_RETURN(i); + ADVANCE_CHAR (string, slen, i); + continue; + } + else if (c == '\\') + { + pass_next = 1; + i++; + continue; + } + else if (backq) + { + if (c == '`') + backq = 0; + ADVANCE_CHAR (string, slen, i); + continue; + } + else if ((flags & 1) == 0 && c == '`') + { + backq = 1; + i++; + continue; + } + else if ((flags & 1) == 0 && c == open) + { + count++; + i++; + continue; + } + else if (c == close) + { + count--; + if (count == 0) + break; + i++; + continue; + } + else if ((flags & 1) == 0 && (c == '\'' || c == '"')) + { + i = (c == '\'') ? skip_single_quoted (ss, slen, ++i) + : skip_double_quoted (ss, slen, ++i); + /* no increment, the skip functions increment past the closing quote. */ + } + else if ((flags&1) == 0 && c == '$' && (string[i+1] == LPAREN || string[i+1] == LBRACE)) + { + si = i + 2; + if (string[si] == '\0') + CQ_RETURN(si); + + if (string[i+1] == LPAREN) + temp = extract_delimited_string (ss, &si, "$(", "(", ")", SX_NOALLOC|SX_COMMAND); /* ) */ + else + temp = extract_dollar_brace_string (ss, &si, 0, SX_NOALLOC); + i = si; + if (string[i] == '\0') /* don't increment i past EOS in loop */ + break; + i++; + continue; + } + else + ADVANCE_CHAR (string, slen, i); + } + + CQ_RETURN(i); +} + +#if defined (ARRAY_VARS) +int +skipsubscript (string, start, flags) + const char *string; + int start, flags; +{ + return (skip_matched_pair (string, start, '[', ']', flags)); +} +#endif + +/* Skip characters in STRING until we find a character in DELIMS, and return + the index of that character. START is the index into string at which we + begin. This is similar in spirit to strpbrk, but it returns an index into + STRING and takes a starting index. This little piece of code knows quite + a lot of shell syntax. It's very similar to skip_double_quoted and other + functions of that ilk. */ +int +skip_to_delim (string, start, delims, flags) + char *string; + int start; + char *delims; + int flags; +{ + int i, pass_next, backq, si, c, invert, skipquote, skipcmd; + size_t slen; + char *temp, open[3]; + DECLARE_MBSTATE; + + slen = strlen (string + start) + start; + if (flags & SD_NOJMP) + no_longjmp_on_fatal_error = 1; + invert = (flags & SD_INVERT); + skipcmd = (flags & SD_NOSKIPCMD) == 0; + + i = start; + pass_next = backq = 0; + while (c = string[i]) + { + /* If this is non-zero, we should not let quote characters be delimiters + and the current character is a single or double quote. We should not + test whether or not it's a delimiter until after we skip single- or + double-quoted strings. */ + skipquote = ((flags & SD_NOQUOTEDELIM) && (c == '\'' || c =='"')); + if (pass_next) + { + pass_next = 0; + if (c == 0) + CQ_RETURN(i); + ADVANCE_CHAR (string, slen, i); + continue; + } + else if (c == '\\') + { + pass_next = 1; + i++; + continue; + } + else if (backq) + { + if (c == '`') + backq = 0; + ADVANCE_CHAR (string, slen, i); + continue; + } + else if (c == '`') + { + backq = 1; + i++; + continue; + } + else if (skipquote == 0 && invert == 0 && member (c, delims)) + break; + else if (c == '\'' || c == '"') + { + i = (c == '\'') ? skip_single_quoted (string, slen, ++i) + : skip_double_quoted (string, slen, ++i); + /* no increment, the skip functions increment past the closing quote. */ + } + else if (c == '$' && ((skipcmd && string[i+1] == LPAREN) || string[i+1] == LBRACE)) + { + si = i + 2; + if (string[si] == '\0') + CQ_RETURN(si); + + if (string[i+1] == LPAREN) + temp = extract_delimited_string (string, &si, "$(", "(", ")", SX_NOALLOC|SX_COMMAND); /* ) */ + else + temp = extract_dollar_brace_string (string, &si, 0, SX_NOALLOC); + i = si; + if (string[i] == '\0') /* don't increment i past EOS in loop */ + break; + i++; + continue; + } +#if defined (PROCESS_SUBSTITUTION) + else if (skipcmd && (c == '<' || c == '>') && string[i+1] == LPAREN) + { + si = i + 2; + if (string[si] == '\0') + CQ_RETURN(si); + temp = extract_process_subst (string, (c == '<') ? "<(" : ">(", &si); + free (temp); /* no SX_ALLOC here */ + i = si; + if (string[i] == '\0') + break; + i++; + continue; + } +#endif /* PROCESS_SUBSTITUTION */ +#if defined (EXTENDED_GLOB) + else if ((flags & SD_EXTGLOB) && extended_glob && string[i+1] == LPAREN && member (c, "?*+!@")) + { + si = i + 2; + if (string[si] == '\0') + CQ_RETURN(si); + + open[0] = c; + open[1] = LPAREN; + open[2] = '\0'; + temp = extract_delimited_string (string, &si, open, "(", ")", SX_NOALLOC); /* ) */ + + i = si; + if (string[i] == '\0') /* don't increment i past EOS in loop */ + break; + i++; + continue; + } +#endif + else if ((skipquote || invert) && (member (c, delims) == 0)) + break; + else + ADVANCE_CHAR (string, slen, i); + } + + CQ_RETURN(i); +} + +#if defined (READLINE) +/* Return 1 if the portion of STRING ending at EINDEX is quoted (there is + an unclosed quoted string), or if the character at EINDEX is quoted + by a backslash. NO_LONGJMP_ON_FATAL_ERROR is used to flag that the various + single and double-quoted string parsing functions should not return an + error if there are unclosed quotes or braces. The characters that this + recognizes need to be the same as the contents of + rl_completer_quote_characters. */ + +int +char_is_quoted (string, eindex) + char *string; + int eindex; +{ + int i, pass_next, c; + size_t slen; + DECLARE_MBSTATE; + + slen = strlen (string); + no_longjmp_on_fatal_error = 1; + i = pass_next = 0; + while (i <= eindex) + { + c = string[i]; + + if (pass_next) + { + pass_next = 0; + if (i >= eindex) /* XXX was if (i >= eindex - 1) */ + CQ_RETURN(1); + ADVANCE_CHAR (string, slen, i); + continue; + } + else if (c == '\\') + { + pass_next = 1; + i++; + continue; + } + else if (c == '\'' || c == '"') + { + i = (c == '\'') ? skip_single_quoted (string, slen, ++i) + : skip_double_quoted (string, slen, ++i); + if (i > eindex) + CQ_RETURN(1); + /* no increment, the skip_xxx functions go one past end */ + } + else + ADVANCE_CHAR (string, slen, i); + } + + CQ_RETURN(0); +} + +int +unclosed_pair (string, eindex, openstr) + char *string; + int eindex; + char *openstr; +{ + int i, pass_next, openc, olen; + size_t slen; + DECLARE_MBSTATE; + + slen = strlen (string); + olen = strlen (openstr); + i = pass_next = openc = 0; + while (i <= eindex) + { + if (pass_next) + { + pass_next = 0; + if (i >= eindex) /* XXX was if (i >= eindex - 1) */ + return 0; + ADVANCE_CHAR (string, slen, i); + continue; + } + else if (string[i] == '\\') + { + pass_next = 1; + i++; + continue; + } + else if (STREQN (string + i, openstr, olen)) + { + openc = 1 - openc; + i += olen; + } + else if (string[i] == '\'' || string[i] == '"') + { + i = (string[i] == '\'') ? skip_single_quoted (string, slen, i) + : skip_double_quoted (string, slen, i); + if (i > eindex) + return 0; + } + else + ADVANCE_CHAR (string, slen, i); + } + return (openc); +} + +/* Split STRING (length SLEN) at DELIMS, and return a WORD_LIST with the + individual words. If DELIMS is NULL, the current value of $IFS is used + to split the string, and the function follows the shell field splitting + rules. SENTINEL is an index to look for. NWP, if non-NULL, + gets the number of words in the returned list. CWP, if non-NULL, gets + the index of the word containing SENTINEL. Non-whitespace chars in + DELIMS delimit separate fields. */ +WORD_LIST * +split_at_delims (string, slen, delims, sentinel, flags, nwp, cwp) + char *string; + int slen; + char *delims; + int sentinel, flags; + int *nwp, *cwp; +{ + int ts, te, i, nw, cw, ifs_split, dflags; + char *token, *d, *d2; + WORD_LIST *ret, *tl; + + if (string == 0 || *string == '\0') + { + if (nwp) + *nwp = 0; + if (cwp) + *cwp = 0; + return ((WORD_LIST *)NULL); + } + + d = (delims == 0) ? ifs_value : delims; + ifs_split = delims == 0; + + /* Make d2 the non-whitespace characters in delims */ + d2 = 0; + if (delims) + { + size_t slength; +#if defined (HANDLE_MULTIBYTE) + size_t mblength = 1; +#endif + DECLARE_MBSTATE; + + slength = strlen (delims); + d2 = (char *)xmalloc (slength + 1); + i = ts = 0; + while (delims[i]) + { +#if defined (HANDLE_MULTIBYTE) + mbstate_t state_bak; + state_bak = state; + mblength = MBRLEN (delims + i, slength, &state); + if (MB_INVALIDCH (mblength)) + state = state_bak; + else if (mblength > 1) + { + memcpy (d2 + ts, delims + i, mblength); + ts += mblength; + i += mblength; + slength -= mblength; + continue; + } +#endif + if (whitespace (delims[i]) == 0) + d2[ts++] = delims[i]; + + i++; + slength--; + } + d2[ts] = '\0'; + } + + ret = (WORD_LIST *)NULL; + + /* Remove sequences of whitespace characters at the start of the string, as + long as those characters are delimiters. */ + for (i = 0; member (string[i], d) && spctabnl (string[i]); i++) + ; + if (string[i] == '\0') + return (ret); + + ts = i; + nw = 0; + cw = -1; + dflags = flags|SD_NOJMP; + while (1) + { + te = skip_to_delim (string, ts, d, dflags); + + /* If we have a non-whitespace delimiter character, use it to make a + separate field. This is just about what $IFS splitting does and + is closer to the behavior of the shell parser. */ + if (ts == te && d2 && member (string[ts], d2)) + { + te = ts + 1; + /* If we're using IFS splitting, the non-whitespace delimiter char + and any additional IFS whitespace delimits a field. */ + if (ifs_split) + while (member (string[te], d) && spctabnl (string[te])) + te++; + else + while (member (string[te], d2)) + te++; + } + + token = substring (string, ts, te); + + ret = add_string_to_list (token, ret); + free (token); + nw++; + + if (sentinel >= ts && sentinel <= te) + cw = nw; + + /* If the cursor is at whitespace just before word start, set the + sentinel word to the current word. */ + if (cwp && cw == -1 && sentinel == ts-1) + cw = nw; + + /* If the cursor is at whitespace between two words, make a new, empty + word, add it before (well, after, since the list is in reverse order) + the word we just added, and set the current word to that one. */ + if (cwp && cw == -1 && sentinel < ts) + { + tl = make_word_list (make_word (""), ret->next); + ret->next = tl; + cw = nw; + nw++; + } + + if (string[te] == 0) + break; + + i = te; + while (member (string[i], d) && (ifs_split || spctabnl(string[i]))) + i++; + + if (string[i]) + ts = i; + else + break; + } + + /* Special case for SENTINEL at the end of STRING. If we haven't found + the word containing SENTINEL yet, and the index we're looking for is at + the end of STRING (or past the end of the previously-found token, + possible if the end of the line is composed solely of IFS whitespace) + add an additional null argument and set the current word pointer to that. */ + if (cwp && cw == -1 && (sentinel >= slen || sentinel >= te)) + { + if (whitespace (string[sentinel - 1])) + { + token = ""; + ret = add_string_to_list (token, ret); + nw++; + } + cw = nw; + } + + if (nwp) + *nwp = nw; + if (cwp) + *cwp = cw; + + FREE (d2); + + return (REVERSE_LIST (ret, WORD_LIST *)); +} +#endif /* READLINE */ + +#if 0 +/* UNUSED */ +/* Extract the name of the variable to bind to from the assignment string. */ +char * +assignment_name (string) + char *string; +{ + int offset; + char *temp; + + offset = assignment (string, 0); + if (offset == 0) + return (char *)NULL; + temp = substring (string, 0, offset); + return (temp); +} +#endif + +/* **************************************************************** */ +/* */ +/* Functions to convert strings to WORD_LISTs and vice versa */ +/* */ +/* **************************************************************** */ + +/* Return a single string of all the words in LIST. SEP is the separator + to put between individual elements of LIST in the output string. */ +char * +string_list_internal (list, sep) + WORD_LIST *list; + char *sep; +{ + register WORD_LIST *t; + char *result, *r; + int word_len, sep_len, result_size; + + if (list == 0) + return ((char *)NULL); + + /* Short-circuit quickly if we don't need to separate anything. */ + if (list->next == 0) + return (savestring (list->word->word)); + + /* This is nearly always called with either sep[0] == 0 or sep[1] == 0. */ + sep_len = STRLEN (sep); + result_size = 0; + + for (t = list; t; t = t->next) + { + if (t != list) + result_size += sep_len; + result_size += strlen (t->word->word); + } + + r = result = (char *)xmalloc (result_size + 1); + + for (t = list; t; t = t->next) + { + if (t != list && sep_len) + { + if (sep_len > 1) + { + FASTCOPY (sep, r, sep_len); + r += sep_len; + } + else + *r++ = sep[0]; + } + + word_len = strlen (t->word->word); + FASTCOPY (t->word->word, r, word_len); + r += word_len; + } + + *r = '\0'; + return (result); +} + +/* Return a single string of all the words present in LIST, separating + each word with a space. */ +char * +string_list (list) + WORD_LIST *list; +{ + return (string_list_internal (list, " ")); +} + +/* An external interface that can be used by the rest of the shell to + obtain a string containing the first character in $IFS. Handles all + the multibyte complications. If LENP is non-null, it is set to the + length of the returned string. */ +char * +ifs_firstchar (lenp) + int *lenp; +{ + char *ret; + int len; + + ret = xmalloc (MB_LEN_MAX + 1); +#if defined (HANDLE_MULTIBYTE) + if (ifs_firstc_len == 1) + { + ret[0] = ifs_firstc[0]; + ret[1] = '\0'; + len = ret[0] ? 1 : 0; + } + else + { + memcpy (ret, ifs_firstc, ifs_firstc_len); + ret[len = ifs_firstc_len] = '\0'; + } +#else + ret[0] = ifs_firstc; + ret[1] = '\0'; + len = ret[0] ? 0 : 1; +#endif + + if (lenp) + *lenp = len; + + return ret; +} + +/* Return a single string of all the words present in LIST, obeying the + quoting rules for "$*", to wit: (P1003.2, draft 11, 3.5.2) "If the + expansion [of $*] appears within a double quoted string, it expands + to a single field with the value of each parameter separated by the + first character of the IFS variable, or by a if IFS is unset." */ +char * +string_list_dollar_star (list) + WORD_LIST *list; +{ + char *ret; +#if defined (HANDLE_MULTIBYTE) +# if defined (__GNUC__) + char sep[MB_CUR_MAX + 1]; +# else + char *sep = 0; +# endif +#else + char sep[2]; +#endif + +#if defined (HANDLE_MULTIBYTE) +# if !defined (__GNUC__) + sep = (char *)xmalloc (MB_CUR_MAX + 1); +# endif /* !__GNUC__ */ + if (ifs_firstc_len == 1) + { + sep[0] = ifs_firstc[0]; + sep[1] = '\0'; + } + else + { + memcpy (sep, ifs_firstc, ifs_firstc_len); + sep[ifs_firstc_len] = '\0'; + } +#else + sep[0] = ifs_firstc; + sep[1] = '\0'; +#endif + + ret = string_list_internal (list, sep); +#if defined (HANDLE_MULTIBYTE) && !defined (__GNUC__) + free (sep); +#endif + return ret; +} + +/* Turn $@ into a string. If (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + is non-zero, the $@ appears within double quotes, and we should quote + the list before converting it into a string. If IFS is unset, and the + word is not quoted, we just need to quote CTLESC and CTLNUL characters + in the words in the list, because the default value of $IFS is + , IFS characters in the words in the list should + also be split. If IFS is null, and the word is not quoted, we need + to quote the words in the list to preserve the positional parameters + exactly. */ +char * +string_list_dollar_at (list, quoted) + WORD_LIST *list; + int quoted; +{ + char *ifs, *ret; +#if defined (HANDLE_MULTIBYTE) +# if defined (__GNUC__) + char sep[MB_CUR_MAX + 1]; +# else + char *sep = 0; +# endif /* !__GNUC__ */ +#else + char sep[2]; +#endif + WORD_LIST *tlist; + + /* XXX this could just be ifs = ifs_value; */ + ifs = ifs_var ? value_cell (ifs_var) : (char *)0; + +#if defined (HANDLE_MULTIBYTE) +# if !defined (__GNUC__) + sep = (char *)xmalloc (MB_CUR_MAX + 1); +# endif /* !__GNUC__ */ + if (ifs && *ifs) + { + if (ifs_firstc_len == 1) + { + sep[0] = ifs_firstc[0]; + sep[1] = '\0'; + } + else + { + memcpy (sep, ifs_firstc, ifs_firstc_len); + sep[ifs_firstc_len] = '\0'; + } + } + else + { + sep[0] = ' '; + sep[1] = '\0'; + } +#else + sep[0] = (ifs == 0 || *ifs == 0) ? ' ' : *ifs; + sep[1] = '\0'; +#endif + + /* XXX -- why call quote_list if ifs == 0? we can get away without doing + it now that quote_escapes quotes spaces */ + tlist = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES|Q_PATQUOTE)) + ? quote_list (list) + : list_quote_escapes (list); + + ret = string_list_internal (tlist, sep); +#if defined (HANDLE_MULTIBYTE) && !defined (__GNUC__) + free (sep); +#endif + return ret; +} + +/* Turn the positional paramters into a string, understanding quoting and + the various subtleties of using the first character of $IFS as the + separator. Calls string_list_dollar_at, string_list_dollar_star, and + string_list as appropriate. */ +char * +string_list_pos_params (pchar, list, quoted) + int pchar; + WORD_LIST *list; + int quoted; +{ + char *ret; + WORD_LIST *tlist; + + if (pchar == '*' && (quoted & Q_DOUBLE_QUOTES)) + { + tlist = quote_list (list); + word_list_remove_quoted_nulls (tlist); + ret = string_list_dollar_star (tlist); + } + else if (pchar == '*' && (quoted & Q_HERE_DOCUMENT)) + { + tlist = quote_list (list); + word_list_remove_quoted_nulls (tlist); + ret = string_list (tlist); + } + else if (pchar == '*') + { + /* Even when unquoted, string_list_dollar_star does the right thing + making sure that the first character of $IFS is used as the + separator. */ + ret = string_list_dollar_star (list); + } + else if (pchar == '@' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + /* We use string_list_dollar_at, but only if the string is quoted, since + that quotes the escapes if it's not, which we don't want. We could + use string_list (the old code did), but that doesn't do the right + thing if the first character of $IFS is not a space. We use + string_list_dollar_star if the string is unquoted so we make sure that + the elements of $@ are separated by the first character of $IFS for + later splitting. */ + ret = string_list_dollar_at (list, quoted); + else if (pchar == '@') + ret = string_list_dollar_star (list); + else + ret = string_list ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) ? quote_list (list) : list); + + return ret; +} + +/* Return the list of words present in STRING. Separate the string into + words at any of the characters found in SEPARATORS. If QUOTED is + non-zero then word in the list will have its quoted flag set, otherwise + the quoted flag is left as make_word () deemed fit. + + This obeys the P1003.2 word splitting semantics. If `separators' is + exactly , then the splitting algorithm is that of + the Bourne shell, which treats any sequence of characters from `separators' + as a delimiter. If IFS is unset, which results in `separators' being set + to "", no splitting occurs. If separators has some other value, the + following rules are applied (`IFS white space' means zero or more + occurrences of , , or , as long as those characters + are in `separators'): + + 1) IFS white space is ignored at the start and the end of the + string. + 2) Each occurrence of a character in `separators' that is not + IFS white space, along with any adjacent occurrences of + IFS white space delimits a field. + 3) Any nonzero-length sequence of IFS white space delimits a field. + */ + +/* BEWARE! list_string strips null arguments. Don't call it twice and + expect to have "" preserved! */ + +/* This performs word splitting and quoted null character removal on + STRING. */ +#define issep(c) \ + (((separators)[0]) ? ((separators)[1] ? isifs(c) \ + : (c) == (separators)[0]) \ + : 0) + +WORD_LIST * +list_string (string, separators, quoted) + register char *string, *separators; + int quoted; +{ + WORD_LIST *result; + WORD_DESC *t; + char *current_word, *s; + int sindex, sh_style_split, whitesep, xflags; + size_t slen; + + if (!string || !*string) + return ((WORD_LIST *)NULL); + + sh_style_split = separators && separators[0] == ' ' && + separators[1] == '\t' && + separators[2] == '\n' && + separators[3] == '\0'; + for (xflags = 0, s = ifs_value; s && *s; s++) + { + if (*s == CTLESC) xflags |= SX_NOCTLESC; + else if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL; + } + + slen = 0; + /* Remove sequences of whitespace at the beginning of STRING, as + long as those characters appear in IFS. Do not do this if + STRING is quoted or if there are no separator characters. */ + if (!quoted || !separators || !*separators) + { + for (s = string; *s && spctabnl (*s) && issep (*s); s++); + + if (!*s) + return ((WORD_LIST *)NULL); + + string = s; + } + + /* OK, now STRING points to a word that does not begin with white space. + The splitting algorithm is: + extract a word, stopping at a separator + skip sequences of spc, tab, or nl as long as they are separators + This obeys the field splitting rules in Posix.2. */ + slen = (MB_CUR_MAX > 1) ? strlen (string) : 1; + for (result = (WORD_LIST *)NULL, sindex = 0; string[sindex]; ) + { + /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim + unless multibyte chars are possible. */ + current_word = string_extract_verbatim (string, slen, &sindex, separators, xflags); + if (current_word == 0) + break; + + /* If we have a quoted empty string, add a quoted null argument. We + want to preserve the quoted null character iff this is a quoted + empty string; otherwise the quoted null characters are removed + below. */ + if (QUOTED_NULL (current_word)) + { + t = alloc_word_desc (); + t->word = make_quoted_char ('\0'); + t->flags |= W_QUOTED|W_HASQUOTEDNULL; + result = make_word_list (t, result); + } + else if (current_word[0] != '\0') + { + /* If we have something, then add it regardless. However, + perform quoted null character removal on the current word. */ + remove_quoted_nulls (current_word); + result = add_string_to_list (current_word, result); + result->word->flags &= ~W_HASQUOTEDNULL; /* just to be sure */ + if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) + result->word->flags |= W_QUOTED; + } + + /* If we're not doing sequences of separators in the traditional + Bourne shell style, then add a quoted null argument. */ + else if (!sh_style_split && !spctabnl (string[sindex])) + { + t = alloc_word_desc (); + t->word = make_quoted_char ('\0'); + t->flags |= W_QUOTED|W_HASQUOTEDNULL; + result = make_word_list (t, result); + } + + free (current_word); + + /* Note whether or not the separator is IFS whitespace, used later. */ + whitesep = string[sindex] && spctabnl (string[sindex]); + + /* Move past the current separator character. */ + if (string[sindex]) + { + DECLARE_MBSTATE; + ADVANCE_CHAR (string, slen, sindex); + } + + /* Now skip sequences of space, tab, or newline characters if they are + in the list of separators. */ + while (string[sindex] && spctabnl (string[sindex]) && issep (string[sindex])) + sindex++; + + /* If the first separator was IFS whitespace and the current character + is a non-whitespace IFS character, it should be part of the current + field delimiter, not a separate delimiter that would result in an + empty field. Look at POSIX.2, 3.6.5, (3)(b). */ + if (string[sindex] && whitesep && issep (string[sindex]) && !spctabnl (string[sindex])) + { + sindex++; + /* An IFS character that is not IFS white space, along with any + adjacent IFS white space, shall delimit a field. (SUSv3) */ + while (string[sindex] && spctabnl (string[sindex]) && isifs (string[sindex])) + sindex++; + } + } + return (REVERSE_LIST (result, WORD_LIST *)); +} + +/* Parse a single word from STRING, using SEPARATORS to separate fields. + ENDPTR is set to the first character after the word. This is used by + the `read' builtin. This is never called with SEPARATORS != $IFS; + it should be simplified. + + XXX - this function is very similar to list_string; they should be + combined - XXX */ +char * +get_word_from_string (stringp, separators, endptr) + char **stringp, *separators, **endptr; +{ + register char *s; + char *current_word; + int sindex, sh_style_split, whitesep, xflags; + size_t slen; + + if (!stringp || !*stringp || !**stringp) + return ((char *)NULL); + + sh_style_split = separators && separators[0] == ' ' && + separators[1] == '\t' && + separators[2] == '\n' && + separators[3] == '\0'; + for (xflags = 0, s = ifs_value; s && *s; s++) + { + if (*s == CTLESC) xflags |= SX_NOCTLESC; + if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL; + } + + s = *stringp; + slen = 0; + + /* Remove sequences of whitespace at the beginning of STRING, as + long as those characters appear in IFS. */ + if (sh_style_split || !separators || !*separators) + { + for (; *s && spctabnl (*s) && isifs (*s); s++); + + /* If the string is nothing but whitespace, update it and return. */ + if (!*s) + { + *stringp = s; + if (endptr) + *endptr = s; + return ((char *)NULL); + } + } + + /* OK, S points to a word that does not begin with white space. + Now extract a word, stopping at a separator, save a pointer to + the first character after the word, then skip sequences of spc, + tab, or nl as long as they are separators. + + This obeys the field splitting rules in Posix.2. */ + sindex = 0; + /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim + unless multibyte chars are possible. */ + slen = (MB_CUR_MAX > 1) ? strlen (s) : 1; + current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags); + + /* Set ENDPTR to the first character after the end of the word. */ + if (endptr) + *endptr = s + sindex; + + /* Note whether or not the separator is IFS whitespace, used later. */ + whitesep = s[sindex] && spctabnl (s[sindex]); + + /* Move past the current separator character. */ + if (s[sindex]) + { + DECLARE_MBSTATE; + ADVANCE_CHAR (s, slen, sindex); + } + + /* Now skip sequences of space, tab, or newline characters if they are + in the list of separators. */ + while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex])) + sindex++; + + /* If the first separator was IFS whitespace and the current character is + a non-whitespace IFS character, it should be part of the current field + delimiter, not a separate delimiter that would result in an empty field. + Look at POSIX.2, 3.6.5, (3)(b). */ + if (s[sindex] && whitesep && isifs (s[sindex]) && !spctabnl (s[sindex])) + { + sindex++; + /* An IFS character that is not IFS white space, along with any adjacent + IFS white space, shall delimit a field. */ + while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex])) + sindex++; + } + + /* Update STRING to point to the next field. */ + *stringp = s + sindex; + return (current_word); +} + +/* Remove IFS white space at the end of STRING. Start at the end + of the string and walk backwards until the beginning of the string + or we find a character that's not IFS white space and not CTLESC. + Only let CTLESC escape a white space character if SAW_ESCAPE is + non-zero. */ +char * +strip_trailing_ifs_whitespace (string, separators, saw_escape) + char *string, *separators; + int saw_escape; +{ + char *s; + + s = string + STRLEN (string) - 1; + while (s > string && ((spctabnl (*s) && isifs (*s)) || + (saw_escape && *s == CTLESC && spctabnl (s[1])))) + s--; + *++s = '\0'; + return string; +} + +#if 0 +/* UNUSED */ +/* Split STRING into words at whitespace. Obeys shell-style quoting with + backslashes, single and double quotes. */ +WORD_LIST * +list_string_with_quotes (string) + char *string; +{ + WORD_LIST *list; + char *token, *s; + size_t s_len; + int c, i, tokstart, len; + + for (s = string; s && *s && spctabnl (*s); s++) + ; + if (s == 0 || *s == 0) + return ((WORD_LIST *)NULL); + + s_len = strlen (s); + tokstart = i = 0; + list = (WORD_LIST *)NULL; + while (1) + { + c = s[i]; + if (c == '\\') + { + i++; + if (s[i]) + i++; + } + else if (c == '\'') + i = skip_single_quoted (s, s_len, ++i); + else if (c == '"') + i = skip_double_quoted (s, s_len, ++i); + else if (c == 0 || spctabnl (c)) + { + /* We have found the end of a token. Make a word out of it and + add it to the word list. */ + token = substring (s, tokstart, i); + list = add_string_to_list (token, list); + free (token); + while (spctabnl (s[i])) + i++; + if (s[i]) + tokstart = i; + else + break; + } + else + i++; /* normal character */ + } + return (REVERSE_LIST (list, WORD_LIST *)); +} +#endif + +/********************************************************/ +/* */ +/* Functions to perform assignment statements */ +/* */ +/********************************************************/ + +#if defined (ARRAY_VARS) +static SHELL_VAR * +do_compound_assignment (name, value, flags) + char *name, *value; + int flags; +{ + SHELL_VAR *v; + int mklocal, mkassoc; + WORD_LIST *list; + + mklocal = flags & ASS_MKLOCAL; + mkassoc = flags & ASS_MKASSOC; + + if (mklocal && variable_context) + { + v = find_variable (name); + list = expand_compound_array_assignment (v, value, flags); + if (mkassoc) + v = make_local_assoc_variable (name); + else if (v == 0 || (array_p (v) == 0 && assoc_p (v) == 0) || v->context != variable_context) + v = make_local_array_variable (name, 0); + assign_compound_array_list (v, list, flags); + } + else + v = assign_array_from_string (name, value, flags); + + return (v); +} +#endif + +/* Given STRING, an assignment string, get the value of the right side + of the `=', and bind it to the left side. If EXPAND is true, then + perform parameter expansion, command substitution, and arithmetic + expansion on the right-hand side. Perform tilde expansion in any + case. Do not perform word splitting on the result of expansion. */ +static int +do_assignment_internal (word, expand) + const WORD_DESC *word; + int expand; +{ + int offset, appendop, assign_list, aflags, retval; + char *name, *value, *temp; + SHELL_VAR *entry; +#if defined (ARRAY_VARS) + char *t; + int ni; +#endif + const char *string; + + if (word == 0 || word->word == 0) + return 0; + + appendop = assign_list = aflags = 0; + string = word->word; + offset = assignment (string, 0); + name = savestring (string); + value = (char *)NULL; + + if (name[offset] == '=') + { + if (name[offset - 1] == '+') + { + appendop = 1; + name[offset - 1] = '\0'; + } + + name[offset] = 0; /* might need this set later */ + temp = name + offset + 1; + +#if defined (ARRAY_VARS) + if (expand && (word->flags & W_COMPASSIGN)) + { + assign_list = ni = 1; + value = extract_array_assignment_list (temp, &ni); + } + else +#endif + if (expand && temp[0]) + value = expand_string_if_necessary (temp, 0, expand_string_assignment); + else + value = savestring (temp); + } + + if (value == 0) + { + value = (char *)xmalloc (1); + value[0] = '\0'; + } + + if (echo_command_at_execute) + { + if (appendop) + name[offset - 1] = '+'; + xtrace_print_assignment (name, value, assign_list, 1); + if (appendop) + name[offset - 1] = '\0'; + } + +#define ASSIGN_RETURN(r) do { FREE (value); free (name); return (r); } while (0) + + if (appendop) + aflags |= ASS_APPEND; + +#if defined (ARRAY_VARS) + if (t = mbschr (name, '[')) /*]*/ + { + if (assign_list) + { + report_error (_("%s: cannot assign list to array member"), name); + ASSIGN_RETURN (0); + } + entry = assign_array_element (name, value, aflags); + if (entry == 0) + ASSIGN_RETURN (0); + } + else if (assign_list) + { + if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0) + aflags |= ASS_MKLOCAL; + if (word->flags & W_ASSIGNASSOC) + aflags |= ASS_MKASSOC; + entry = do_compound_assignment (name, value, aflags); + } + else +#endif /* ARRAY_VARS */ + entry = bind_variable (name, value, aflags); + + stupidly_hack_special_variables (name); + + /* Return 1 if the assignment seems to have been performed correctly. */ + if (entry == 0 || readonly_p (entry)) + retval = 0; /* assignment failure */ + else if (noassign_p (entry)) + { + last_command_exit_value = EXECUTION_FAILURE; + retval = 1; /* error status, but not assignment failure */ + } + else + retval = 1; + + if (entry && retval != 0 && noassign_p (entry) == 0) + VUNSETATTR (entry, att_invisible); + + ASSIGN_RETURN (retval); +} + +/* Perform the assignment statement in STRING, and expand the + right side by doing tilde, command and parameter expansion. */ +int +do_assignment (string) + char *string; +{ + WORD_DESC td; + + td.flags = W_ASSIGNMENT; + td.word = string; + + return do_assignment_internal (&td, 1); +} + +int +do_word_assignment (word, flags) + WORD_DESC *word; + int flags; +{ + return do_assignment_internal (word, 1); +} + +/* Given STRING, an assignment string, get the value of the right side + of the `=', and bind it to the left side. Do not perform any word + expansions on the right hand side. */ +int +do_assignment_no_expand (string) + char *string; +{ + WORD_DESC td; + + td.flags = W_ASSIGNMENT; + td.word = string; + + return (do_assignment_internal (&td, 0)); +} + +/*************************************************** + * * + * Functions to manage the positional parameters * + * * + ***************************************************/ + +/* Return the word list that corresponds to `$*'. */ +WORD_LIST * +list_rest_of_args () +{ + register WORD_LIST *list, *args; + int i; + + /* Break out of the loop as soon as one of the dollar variables is null. */ + for (i = 1, list = (WORD_LIST *)NULL; i < 10 && dollar_vars[i]; i++) + list = make_word_list (make_bare_word (dollar_vars[i]), list); + + for (args = rest_of_args; args; args = args->next) + list = make_word_list (make_bare_word (args->word->word), list); + + return (REVERSE_LIST (list, WORD_LIST *)); +} + +int +number_of_args () +{ + register WORD_LIST *list; + int n; + + for (n = 0; n < 9 && dollar_vars[n+1]; n++) + ; + for (list = rest_of_args; list; list = list->next) + n++; + return n; +} + +/* Return the value of a positional parameter. This handles values > 10. */ +char * +get_dollar_var_value (ind) + intmax_t ind; +{ + char *temp; + WORD_LIST *p; + + if (ind < 10) + temp = dollar_vars[ind] ? savestring (dollar_vars[ind]) : (char *)NULL; + else /* We want something like ${11} */ + { + ind -= 10; + for (p = rest_of_args; p && ind--; p = p->next) + ; + temp = p ? savestring (p->word->word) : (char *)NULL; + } + return (temp); +} + +/* Make a single large string out of the dollar digit variables, + and the rest_of_args. If DOLLAR_STAR is 1, then obey the special + case of "$*" with respect to IFS. */ +char * +string_rest_of_args (dollar_star) + int dollar_star; +{ + register WORD_LIST *list; + char *string; + + list = list_rest_of_args (); + string = dollar_star ? string_list_dollar_star (list) : string_list (list); + dispose_words (list); + return (string); +} + +/* Return a string containing the positional parameters from START to + END, inclusive. If STRING[0] == '*', we obey the rules for $*, + which only makes a difference if QUOTED is non-zero. If QUOTED includes + Q_HERE_DOCUMENT or Q_DOUBLE_QUOTES, this returns a quoted list, otherwise + no quoting chars are added. */ +static char * +pos_params (string, start, end, quoted) + char *string; + int start, end, quoted; +{ + WORD_LIST *save, *params, *h, *t; + char *ret; + int i; + + /* see if we can short-circuit. if start == end, we want 0 parameters. */ + if (start == end) + return ((char *)NULL); + + save = params = list_rest_of_args (); + if (save == 0) + return ((char *)NULL); + + if (start == 0) /* handle ${@:0[:x]} specially */ + { + t = make_word_list (make_word (dollar_vars[0]), params); + save = params = t; + } + + for (i = start ? 1 : 0; params && i < start; i++) + params = params->next; + if (params == 0) + return ((char *)NULL); + for (h = t = params; params && i < end; i++) + { + t = params; + params = params->next; + } + + t->next = (WORD_LIST *)NULL; + + ret = string_list_pos_params (string[0], h, quoted); + + if (t != params) + t->next = params; + + dispose_words (save); + return (ret); +} + +/******************************************************************/ +/* */ +/* Functions to expand strings to strings or WORD_LISTs */ +/* */ +/******************************************************************/ + +#if defined (PROCESS_SUBSTITUTION) +#define EXP_CHAR(s) (s == '$' || s == '`' || s == '<' || s == '>' || s == CTLESC || s == '~') +#else +#define EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~') +#endif + +/* If there are any characters in STRING that require full expansion, + then call FUNC to expand STRING; otherwise just perform quote + removal if necessary. This returns a new string. */ +static char * +expand_string_if_necessary (string, quoted, func) + char *string; + int quoted; + EXPFUNC *func; +{ + WORD_LIST *list; + size_t slen; + int i, saw_quote; + char *ret; + DECLARE_MBSTATE; + + /* Don't need string length for ADVANCE_CHAR unless multibyte chars possible. */ + slen = (MB_CUR_MAX > 1) ? strlen (string) : 0; + i = saw_quote = 0; + while (string[i]) + { + if (EXP_CHAR (string[i])) + break; + else if (string[i] == '\'' || string[i] == '\\' || string[i] == '"') + saw_quote = 1; + ADVANCE_CHAR (string, slen, i); + } + + if (string[i]) + { + list = (*func) (string, quoted); + if (list) + { + ret = string_list (list); + dispose_words (list); + } + else + ret = (char *)NULL; + } + else if (saw_quote && ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0)) + ret = string_quote_removal (string, quoted); + else + ret = savestring (string); + + return ret; +} + +static inline char * +expand_string_to_string_internal (string, quoted, func) + char *string; + int quoted; + EXPFUNC *func; +{ + WORD_LIST *list; + char *ret; + + if (string == 0 || *string == '\0') + return ((char *)NULL); + + list = (*func) (string, quoted); + if (list) + { + ret = string_list (list); + dispose_words (list); + } + else + ret = (char *)NULL; + + return (ret); +} + +char * +expand_string_to_string (string, quoted) + char *string; + int quoted; +{ + return (expand_string_to_string_internal (string, quoted, expand_string)); +} + +char * +expand_string_unsplit_to_string (string, quoted) + char *string; + int quoted; +{ + return (expand_string_to_string_internal (string, quoted, expand_string_unsplit)); +} + +char * +expand_assignment_string_to_string (string, quoted) + char *string; + int quoted; +{ + return (expand_string_to_string_internal (string, quoted, expand_string_assignment)); +} + +char * +expand_arith_string (string, quoted) + char *string; + int quoted; +{ + return (expand_string_if_necessary (string, quoted, expand_string)); +} + +#if defined (COND_COMMAND) +/* Just remove backslashes in STRING. Returns a new string. */ +char * +remove_backslashes (string) + char *string; +{ + char *r, *ret, *s; + + r = ret = (char *)xmalloc (strlen (string) + 1); + for (s = string; s && *s; ) + { + if (*s == '\\') + s++; + if (*s == 0) + break; + *r++ = *s++; + } + *r = '\0'; + return ret; +} + +/* This needs better error handling. */ +/* Expand W for use as an argument to a unary or binary operator in a + [[...]] expression. If SPECIAL is 1, this is the rhs argument + to the != or == operator, and should be treated as a pattern. In + this case, we quote the string specially for the globbing code. If + SPECIAL is 2, this is an rhs argument for the =~ operator, and should + be quoted appropriately for regcomp/regexec. The caller is responsible + for removing the backslashes if the unquoted word is needed later. */ +char * +cond_expand_word (w, special) + WORD_DESC *w; + int special; +{ + char *r, *p; + WORD_LIST *l; + int qflags; + + if (w->word == 0 || w->word[0] == '\0') + return ((char *)NULL); + + w->flags |= W_NOSPLIT2; + l = call_expand_word_internal (w, 0, 0, (int *)0, (int *)0); + if (l) + { + if (special == 0) + { + dequote_list (l); + r = string_list (l); + } + else + { + qflags = QGLOB_CVTNULL; + if (special == 2) + qflags |= QGLOB_REGEXP; + p = string_list (l); + r = quote_string_for_globbing (p, qflags); + free (p); + } + dispose_words (l); + } + else + r = (char *)NULL; + + return r; +} +#endif + +/* Call expand_word_internal to expand W and handle error returns. + A convenience function for functions that don't want to handle + any errors or free any memory before aborting. */ +static WORD_LIST * +call_expand_word_internal (w, q, i, c, e) + WORD_DESC *w; + int q, i, *c, *e; +{ + WORD_LIST *result; + + result = expand_word_internal (w, q, i, c, e); + if (result == &expand_word_error || result == &expand_word_fatal) + { + /* By convention, each time this error is returned, w->word has + already been freed (it sometimes may not be in the fatal case, + but that doesn't result in a memory leak because we're going + to exit in most cases). */ + w->word = (char *)NULL; + last_command_exit_value = EXECUTION_FAILURE; + exp_jump_to_top_level ((result == &expand_word_error) ? DISCARD : FORCE_EOF); + /* NOTREACHED */ + } + else + return (result); +} + +/* Perform parameter expansion, command substitution, and arithmetic + expansion on STRING, as if it were a word. Leave the result quoted. + Since this does not perform word splitting, it leaves quoted nulls + in the result. */ +static WORD_LIST * +expand_string_internal (string, quoted) + char *string; + int quoted; +{ + WORD_DESC td; + WORD_LIST *tresult; + + if (string == 0 || *string == 0) + return ((WORD_LIST *)NULL); + + td.flags = 0; + td.word = savestring (string); + + tresult = call_expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL); + + FREE (td.word); + return (tresult); +} + +/* Expand STRING by performing parameter expansion, command substitution, + and arithmetic expansion. Dequote the resulting WORD_LIST before + returning it, but do not perform word splitting. The call to + remove_quoted_nulls () is in here because word splitting normally + takes care of quote removal. */ +WORD_LIST * +expand_string_unsplit (string, quoted) + char *string; + int quoted; +{ + WORD_LIST *value; + + if (string == 0 || *string == '\0') + return ((WORD_LIST *)NULL); + + expand_no_split_dollar_star = 1; + value = expand_string_internal (string, quoted); + expand_no_split_dollar_star = 0; + + if (value) + { + if (value->word) + { + remove_quoted_nulls (value->word->word); + value->word->flags &= ~W_HASQUOTEDNULL; + } + dequote_list (value); + } + return (value); +} + +/* Expand the rhs of an assignment statement */ +WORD_LIST * +expand_string_assignment (string, quoted) + char *string; + int quoted; +{ + WORD_DESC td; + WORD_LIST *value; + + if (string == 0 || *string == '\0') + return ((WORD_LIST *)NULL); + + expand_no_split_dollar_star = 1; + + td.flags = W_ASSIGNRHS; + td.word = savestring (string); + value = call_expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL); + FREE (td.word); + + expand_no_split_dollar_star = 0; + + if (value) + { + if (value->word) + { + remove_quoted_nulls (value->word->word); + value->word->flags &= ~W_HASQUOTEDNULL; + } + dequote_list (value); + } + return (value); +} + + +/* Expand one of the PS? prompt strings. This is a sort of combination of + expand_string_unsplit and expand_string_internal, but returns the + passed string when an error occurs. Might want to trap other calls + to jump_to_top_level here so we don't endlessly loop. */ +WORD_LIST * +expand_prompt_string (string, quoted, wflags) + char *string; + int quoted; + int wflags; +{ + WORD_LIST *value; + WORD_DESC td; + + if (string == 0 || *string == 0) + return ((WORD_LIST *)NULL); + + td.flags = wflags; + td.word = savestring (string); + + no_longjmp_on_fatal_error = 1; + value = expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL); + no_longjmp_on_fatal_error = 0; + + if (value == &expand_word_error || value == &expand_word_fatal) + { + value = make_word_list (make_bare_word (string), (WORD_LIST *)NULL); + return value; + } + FREE (td.word); + if (value) + { + if (value->word) + { + remove_quoted_nulls (value->word->word); + value->word->flags &= ~W_HASQUOTEDNULL; + } + dequote_list (value); + } + return (value); +} + +/* Expand STRING just as if you were expanding a word, but do not dequote + the resultant WORD_LIST. This is called only from within this file, + and is used to correctly preserve quoted characters when expanding + things like ${1+"$@"}. This does parameter expansion, command + substitution, arithmetic expansion, and word splitting. */ +static WORD_LIST * +expand_string_leave_quoted (string, quoted) + char *string; + int quoted; +{ + WORD_LIST *tlist; + WORD_LIST *tresult; + + if (string == 0 || *string == '\0') + return ((WORD_LIST *)NULL); + + tlist = expand_string_internal (string, quoted); + + if (tlist) + { + tresult = word_list_split (tlist); + dispose_words (tlist); + return (tresult); + } + return ((WORD_LIST *)NULL); +} + +/* This does not perform word splitting or dequote the WORD_LIST + it returns. */ +static WORD_LIST * +expand_string_for_rhs (string, quoted, dollar_at_p, has_dollar_at) + char *string; + int quoted, *dollar_at_p, *has_dollar_at; +{ + WORD_DESC td; + WORD_LIST *tresult; + + if (string == 0 || *string == '\0') + return (WORD_LIST *)NULL; + + td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */ + td.word = string; + tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at); + return (tresult); +} + +/* Expand STRING just as if you were expanding a word. This also returns + a list of words. Note that filename globbing is *NOT* done for word + or string expansion, just when the shell is expanding a command. This + does parameter expansion, command substitution, arithmetic expansion, + and word splitting. Dequote the resultant WORD_LIST before returning. */ +WORD_LIST * +expand_string (string, quoted) + char *string; + int quoted; +{ + WORD_LIST *result; + + if (string == 0 || *string == '\0') + return ((WORD_LIST *)NULL); + + result = expand_string_leave_quoted (string, quoted); + return (result ? dequote_list (result) : result); +} + +/*************************************************** + * * + * Functions to handle quoting chars * + * * + ***************************************************/ + +/* Conventions: + + A string with s[0] == CTLNUL && s[1] == 0 is a quoted null string. + The parser passes CTLNUL as CTLESC CTLNUL. */ + +/* Quote escape characters in string s, but no other characters. This is + used to protect CTLESC and CTLNUL in variable values from the rest of + the word expansion process after the variable is expanded (word splitting + and filename generation). If IFS is null, we quote spaces as well, just + in case we split on spaces later (in the case of unquoted $@, we will + eventually attempt to split the entire word on spaces). Corresponding + code exists in dequote_escapes. Even if we don't end up splitting on + spaces, quoting spaces is not a problem. This should never be called on + a string that is quoted with single or double quotes or part of a here + document (effectively double-quoted). */ +char * +quote_escapes (string) + char *string; +{ + register char *s, *t; + size_t slen; + char *result, *send; + int quote_spaces, skip_ctlesc, skip_ctlnul; + DECLARE_MBSTATE; + + slen = strlen (string); + send = string + slen; + + quote_spaces = (ifs_value && *ifs_value == 0); + + for (skip_ctlesc = skip_ctlnul = 0, s = ifs_value; s && *s; s++) + skip_ctlesc |= *s == CTLESC, skip_ctlnul |= *s == CTLNUL; + + t = result = (char *)xmalloc ((slen * 2) + 1); + s = string; + + while (*s) + { + if ((skip_ctlesc == 0 && *s == CTLESC) || (skip_ctlnul == 0 && *s == CTLNUL) || (quote_spaces && *s == ' ')) + *t++ = CTLESC; + COPY_CHAR_P (t, s, send); + } + *t = '\0'; + return (result); +} + +static WORD_LIST * +list_quote_escapes (list) + WORD_LIST *list; +{ + register WORD_LIST *w; + char *t; + + for (w = list; w; w = w->next) + { + t = w->word->word; + w->word->word = quote_escapes (t); + free (t); + } + return list; +} + +/* Inverse of quote_escapes; remove CTLESC protecting CTLESC or CTLNUL. + + The parser passes us CTLESC as CTLESC CTLESC and CTLNUL as CTLESC CTLNUL. + This is necessary to make unquoted CTLESC and CTLNUL characters in the + data stream pass through properly. + + We need to remove doubled CTLESC characters inside quoted strings before + quoting the entire string, so we do not double the number of CTLESC + characters. + + Also used by parts of the pattern substitution code. */ +char * +dequote_escapes (string) + char *string; +{ + register char *s, *t, *s1; + size_t slen; + char *result, *send; + int quote_spaces; + DECLARE_MBSTATE; + + if (string == 0) + return string; + + slen = strlen (string); + send = string + slen; + + t = result = (char *)xmalloc (slen + 1); + + if (strchr (string, CTLESC) == 0) + return (strcpy (result, string)); + + quote_spaces = (ifs_value && *ifs_value == 0); + + s = string; + while (*s) + { + if (*s == CTLESC && (s[1] == CTLESC || s[1] == CTLNUL || (quote_spaces && s[1] == ' '))) + { + s++; + if (*s == '\0') + break; + } + COPY_CHAR_P (t, s, send); + } + *t = '\0'; + return result; +} + +/* Return a new string with the quoted representation of character C. + This turns "" into QUOTED_NULL, so the W_HASQUOTEDNULL flag needs to be + set in any resultant WORD_DESC where this value is the word. */ +static char * +make_quoted_char (c) + int c; +{ + char *temp; + + temp = (char *)xmalloc (3); + if (c == 0) + { + temp[0] = CTLNUL; + temp[1] = '\0'; + } + else + { + temp[0] = CTLESC; + temp[1] = c; + temp[2] = '\0'; + } + return (temp); +} + +/* Quote STRING, returning a new string. This turns "" into QUOTED_NULL, so + the W_HASQUOTEDNULL flag needs to be set in any resultant WORD_DESC where + this value is the word. */ +char * +quote_string (string) + char *string; +{ + register char *t; + size_t slen; + char *result, *send; + + if (*string == 0) + { + result = (char *)xmalloc (2); + result[0] = CTLNUL; + result[1] = '\0'; + } + else + { + DECLARE_MBSTATE; + + slen = strlen (string); + send = string + slen; + + result = (char *)xmalloc ((slen * 2) + 1); + + for (t = result; string < send; ) + { + *t++ = CTLESC; + COPY_CHAR_P (t, string, send); + } + *t = '\0'; + } + return (result); +} + +/* De-quote quoted characters in STRING. */ +char * +dequote_string (string) + char *string; +{ + register char *s, *t; + size_t slen; + char *result, *send; + DECLARE_MBSTATE; + + slen = strlen (string); + + t = result = (char *)xmalloc (slen + 1); + + if (QUOTED_NULL (string)) + { + result[0] = '\0'; + return (result); + } + + /* If no character in the string can be quoted, don't bother examining + each character. Just return a copy of the string passed to us. */ + if (strchr (string, CTLESC) == NULL) + return (strcpy (result, string)); + + send = string + slen; + s = string; + while (*s) + { + if (*s == CTLESC) + { + s++; + if (*s == '\0') + break; + } + COPY_CHAR_P (t, s, send); + } + + *t = '\0'; + return (result); +} + +/* Quote the entire WORD_LIST list. */ +static WORD_LIST * +quote_list (list) + WORD_LIST *list; +{ + register WORD_LIST *w; + char *t; + + for (w = list; w; w = w->next) + { + t = w->word->word; + w->word->word = quote_string (t); + if (*t == 0) + w->word->flags |= W_HASQUOTEDNULL; /* XXX - turn on W_HASQUOTEDNULL here? */ + w->word->flags |= W_QUOTED; + free (t); + } + return list; +} + +/* De-quote quoted characters in each word in LIST. */ +WORD_LIST * +dequote_list (list) + WORD_LIST *list; +{ + register char *s; + register WORD_LIST *tlist; + + for (tlist = list; tlist; tlist = tlist->next) + { + s = dequote_string (tlist->word->word); + if (QUOTED_NULL (tlist->word->word)) + tlist->word->flags &= ~W_HASQUOTEDNULL; + free (tlist->word->word); + tlist->word->word = s; + } + return list; +} + +/* Remove CTLESC protecting a CTLESC or CTLNUL in place. Return the passed + string. */ +char * +remove_quoted_escapes (string) + char *string; +{ + char *t; + + if (string) + { + t = dequote_escapes (string); + strcpy (string, t); + free (t); + } + + return (string); +} + +/* Perform quoted null character removal on STRING. We don't allow any + quoted null characters in the middle or at the ends of strings because + of how expand_word_internal works. remove_quoted_nulls () turns + STRING into an empty string iff it only consists of a quoted null, + and removes all unquoted CTLNUL characters. */ +char * +remove_quoted_nulls (string) + char *string; +{ + register size_t slen; + register int i, j, prev_i; + DECLARE_MBSTATE; + + if (strchr (string, CTLNUL) == 0) /* XXX */ + return string; /* XXX */ + + slen = strlen (string); + i = j = 0; + + while (i < slen) + { + if (string[i] == CTLESC) + { + /* Old code had j++, but we cannot assume that i == j at this + point -- what if a CTLNUL has already been removed from the + string? We don't want to drop the CTLESC or recopy characters + that we've already copied down. */ + i++; string[j++] = CTLESC; + if (i == slen) + break; + } + else if (string[i] == CTLNUL) + { + i++; + continue; + } + + prev_i = i; + ADVANCE_CHAR (string, slen, i); + if (j < prev_i) + { + do string[j++] = string[prev_i++]; while (prev_i < i); + } + else + j = i; + } + string[j] = '\0'; + + return (string); +} + +/* Perform quoted null character removal on each element of LIST. + This modifies LIST. */ +void +word_list_remove_quoted_nulls (list) + WORD_LIST *list; +{ + register WORD_LIST *t; + + for (t = list; t; t = t->next) + { + remove_quoted_nulls (t->word->word); + t->word->flags &= ~W_HASQUOTEDNULL; + } +} + +/* **************************************************************** */ +/* */ +/* Functions for Matching and Removing Patterns */ +/* */ +/* **************************************************************** */ + +#if defined (HANDLE_MULTIBYTE) +#if 0 /* Currently unused */ +static unsigned char * +mb_getcharlens (string, len) + char *string; + int len; +{ + int i, offset, last; + unsigned char *ret; + char *p; + DECLARE_MBSTATE; + + i = offset = 0; + last = 0; + ret = (unsigned char *)xmalloc (len); + memset (ret, 0, len); + while (string[last]) + { + ADVANCE_CHAR (string, len, offset); + ret[last] = offset - last; + last = offset; + } + return ret; +} +#endif +#endif + +/* Remove the portion of PARAM matched by PATTERN according to OP, where OP + can have one of 4 values: + RP_LONG_LEFT remove longest matching portion at start of PARAM + RP_SHORT_LEFT remove shortest matching portion at start of PARAM + RP_LONG_RIGHT remove longest matching portion at end of PARAM + RP_SHORT_RIGHT remove shortest matching portion at end of PARAM +*/ + +#define RP_LONG_LEFT 1 +#define RP_SHORT_LEFT 2 +#define RP_LONG_RIGHT 3 +#define RP_SHORT_RIGHT 4 + +/* Returns its first argument if nothing matched; new memory otherwise */ +static char * +remove_upattern (param, pattern, op) + char *param, *pattern; + int op; +{ + register int len; + register char *end; + register char *p, *ret, c; + + len = STRLEN (param); + end = param + len; + + switch (op) + { + case RP_LONG_LEFT: /* remove longest match at start */ + for (p = end; p >= param; p--) + { + c = *p; *p = '\0'; + if (strmatch (pattern, param, FNMATCH_EXTFLAG) != FNM_NOMATCH) + { + *p = c; + return (savestring (p)); + } + *p = c; + + } + break; + + case RP_SHORT_LEFT: /* remove shortest match at start */ + for (p = param; p <= end; p++) + { + c = *p; *p = '\0'; + if (strmatch (pattern, param, FNMATCH_EXTFLAG) != FNM_NOMATCH) + { + *p = c; + return (savestring (p)); + } + *p = c; + } + break; + + case RP_LONG_RIGHT: /* remove longest match at end */ + for (p = param; p <= end; p++) + { + if (strmatch (pattern, p, FNMATCH_EXTFLAG) != FNM_NOMATCH) + { + c = *p; *p = '\0'; + ret = savestring (param); + *p = c; + return (ret); + } + } + break; + + case RP_SHORT_RIGHT: /* remove shortest match at end */ + for (p = end; p >= param; p--) + { + if (strmatch (pattern, p, FNMATCH_EXTFLAG) != FNM_NOMATCH) + { + c = *p; *p = '\0'; + ret = savestring (param); + *p = c; + return (ret); + } + } + break; + } + + return (param); /* no match, return original string */ +} + +#if defined (HANDLE_MULTIBYTE) +/* Returns its first argument if nothing matched; new memory otherwise */ +static wchar_t * +remove_wpattern (wparam, wstrlen, wpattern, op) + wchar_t *wparam; + size_t wstrlen; + wchar_t *wpattern; + int op; +{ + wchar_t wc, *ret; + int n; + + switch (op) + { + case RP_LONG_LEFT: /* remove longest match at start */ + for (n = wstrlen; n >= 0; n--) + { + wc = wparam[n]; wparam[n] = L'\0'; + if (wcsmatch (wpattern, wparam, FNMATCH_EXTFLAG) != FNM_NOMATCH) + { + wparam[n] = wc; + return (wcsdup (wparam + n)); + } + wparam[n] = wc; + } + break; + + case RP_SHORT_LEFT: /* remove shortest match at start */ + for (n = 0; n <= wstrlen; n++) + { + wc = wparam[n]; wparam[n] = L'\0'; + if (wcsmatch (wpattern, wparam, FNMATCH_EXTFLAG) != FNM_NOMATCH) + { + wparam[n] = wc; + return (wcsdup (wparam + n)); + } + wparam[n] = wc; + } + break; + + case RP_LONG_RIGHT: /* remove longest match at end */ + for (n = 0; n <= wstrlen; n++) + { + if (wcsmatch (wpattern, wparam + n, FNMATCH_EXTFLAG) != FNM_NOMATCH) + { + wc = wparam[n]; wparam[n] = L'\0'; + ret = wcsdup (wparam); + wparam[n] = wc; + return (ret); + } + } + break; + + case RP_SHORT_RIGHT: /* remove shortest match at end */ + for (n = wstrlen; n >= 0; n--) + { + if (wcsmatch (wpattern, wparam + n, FNMATCH_EXTFLAG) != FNM_NOMATCH) + { + wc = wparam[n]; wparam[n] = L'\0'; + ret = wcsdup (wparam); + wparam[n] = wc; + return (ret); + } + } + break; + } + + return (wparam); /* no match, return original string */ +} +#endif /* HANDLE_MULTIBYTE */ + +static char * +remove_pattern (param, pattern, op) + char *param, *pattern; + int op; +{ + char *xret; + + if (param == NULL) + return (param); + if (*param == '\0' || pattern == NULL || *pattern == '\0') /* minor optimization */ + return (savestring (param)); + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1) + { + wchar_t *ret, *oret; + size_t n; + wchar_t *wparam, *wpattern; + mbstate_t ps; + + n = xdupmbstowcs (&wpattern, NULL, pattern); + if (n == (size_t)-1) + { + xret = remove_upattern (param, pattern, op); + return ((xret == param) ? savestring (param) : xret); + } + n = xdupmbstowcs (&wparam, NULL, param); + if (n == (size_t)-1) + { + free (wpattern); + xret = remove_upattern (param, pattern, op); + return ((xret == param) ? savestring (param) : xret); + } + oret = ret = remove_wpattern (wparam, n, wpattern, op); + /* Don't bother to convert wparam back to multibyte string if nothing + matched; just return copy of original string */ + if (ret == wparam) + { + free (wparam); + free (wpattern); + return (savestring (param)); + } + + free (wparam); + free (wpattern); + + n = strlen (param); + xret = (char *)xmalloc (n + 1); + memset (&ps, '\0', sizeof (mbstate_t)); + n = wcsrtombs (xret, (const wchar_t **)&ret, n, &ps); + xret[n] = '\0'; /* just to make sure */ + free (oret); + return xret; + } + else +#endif + { + xret = remove_upattern (param, pattern, op); + return ((xret == param) ? savestring (param) : xret); + } +} + +/* Match PAT anywhere in STRING and return the match boundaries. + This returns 1 in case of a successful match, 0 otherwise. SP + and EP are pointers into the string where the match begins and + ends, respectively. MTYPE controls what kind of match is attempted. + MATCH_BEG and MATCH_END anchor the match at the beginning and end + of the string, respectively. The longest match is returned. */ +static int +match_upattern (string, pat, mtype, sp, ep) + char *string, *pat; + int mtype; + char **sp, **ep; +{ + int c, len, mlen; + register char *p, *p1, *npat; + char *end; + int n1; + + /* If the pattern doesn't match anywhere in the string, go ahead and + short-circuit right away. A minor optimization, saves a bunch of + unnecessary calls to strmatch (up to N calls for a string of N + characters) if the match is unsuccessful. To preserve the semantics + of the substring matches below, we make sure that the pattern has + `*' as first and last character, making a new pattern if necessary. */ + /* XXX - check this later if I ever implement `**' with special meaning, + since this will potentially result in `**' at the beginning or end */ + len = STRLEN (pat); + if (pat[0] != '*' || (pat[0] == '*' && pat[1] == LPAREN && extended_glob) || pat[len - 1] != '*') + { + p = npat = (char *)xmalloc (len + 3); + p1 = pat; + if (*p1 != '*' || (*p1 == '*' && p1[1] == LPAREN && extended_glob)) + *p++ = '*'; + while (*p1) + *p++ = *p1++; + if (p1[-1] != '*' || p[-2] == '\\') + *p++ = '*'; + *p = '\0'; + } + else + npat = pat; + c = strmatch (npat, string, FNMATCH_EXTFLAG); + if (npat != pat) + free (npat); + if (c == FNM_NOMATCH) + return (0); + + len = STRLEN (string); + end = string + len; + + mlen = umatchlen (pat, len); + + switch (mtype) + { + case MATCH_ANY: + for (p = string; p <= end; p++) + { + if (match_pattern_char (pat, p)) + { +#if 0 + for (p1 = end; p1 >= p; p1--) +#else + p1 = (mlen == -1) ? end : p + mlen; + /* p1 - p = length of portion of string to be considered + p = current position in string + mlen = number of characters consumed by match (-1 for entire string) + end = end of string + we want to break immediately if the potential match len + is greater than the number of characters remaining in the + string + */ + if (p1 > end) + break; + for ( ; p1 >= p; p1--) +#endif + { + c = *p1; *p1 = '\0'; + if (strmatch (pat, p, FNMATCH_EXTFLAG) == 0) + { + *p1 = c; + *sp = p; + *ep = p1; + return 1; + } + *p1 = c; +#if 1 + /* If MLEN != -1, we have a fixed length pattern. */ + if (mlen != -1) + break; +#endif + } + } + } + + return (0); + + case MATCH_BEG: + if (match_pattern_char (pat, string) == 0) + return (0); + +#if 0 + for (p = end; p >= string; p--) +#else + for (p = (mlen == -1) ? end : string + mlen; p >= string; p--) +#endif + { + c = *p; *p = '\0'; + if (strmatch (pat, string, FNMATCH_EXTFLAG) == 0) + { + *p = c; + *sp = string; + *ep = p; + return 1; + } + *p = c; +#if 1 + /* If MLEN != -1, we have a fixed length pattern. */ + if (mlen != -1) + break; +#endif + } + + return (0); + + case MATCH_END: +#if 0 + for (p = string; p <= end; p++) +#else + for (p = end - ((mlen == -1) ? len : mlen); p <= end; p++) +#endif + { + if (strmatch (pat, p, FNMATCH_EXTFLAG) == 0) + { + *sp = p; + *ep = end; + return 1; + } +#if 1 + /* If MLEN != -1, we have a fixed length pattern. */ + if (mlen != -1) + break; +#endif + } + + return (0); + } + + return (0); +} + +#if defined (HANDLE_MULTIBYTE) +/* Match WPAT anywhere in WSTRING and return the match boundaries. + This returns 1 in case of a successful match, 0 otherwise. Wide + character version. */ +static int +match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep) + wchar_t *wstring; + char **indices; + size_t wstrlen; + wchar_t *wpat; + int mtype; + char **sp, **ep; +{ + wchar_t wc, *wp, *nwpat, *wp1; + size_t len; + int mlen; + int n, n1, n2, simple; + + simple = (wpat[0] != L'\\' && wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'['); +#if defined (EXTENDED_GLOB) + if (extended_glob) + simple &= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/ +#endif + + /* If the pattern doesn't match anywhere in the string, go ahead and + short-circuit right away. A minor optimization, saves a bunch of + unnecessary calls to strmatch (up to N calls for a string of N + characters) if the match is unsuccessful. To preserve the semantics + of the substring matches below, we make sure that the pattern has + `*' as first and last character, making a new pattern if necessary. */ + len = wcslen (wpat); + if (wpat[0] != L'*' || (wpat[0] == L'*' && wpat[1] == WLPAREN && extended_glob) || wpat[len - 1] != L'*') + { + wp = nwpat = (wchar_t *)xmalloc ((len + 3) * sizeof (wchar_t)); + wp1 = wpat; + if (*wp1 != L'*' || (*wp1 == '*' && wp1[1] == WLPAREN && extended_glob)) + *wp++ = L'*'; + while (*wp1 != L'\0') + *wp++ = *wp1++; + if (wp1[-1] != L'*' || wp1[-2] == L'\\') + *wp++ = L'*'; + *wp = '\0'; + } + else + nwpat = wpat; + len = wcsmatch (nwpat, wstring, FNMATCH_EXTFLAG); + if (nwpat != wpat) + free (nwpat); + if (len == FNM_NOMATCH) + return (0); + + mlen = wmatchlen (wpat, wstrlen); + +/* itrace("wmatchlen (%ls) -> %d", wpat, mlen); */ + switch (mtype) + { + case MATCH_ANY: + for (n = 0; n <= wstrlen; n++) + { +#if 1 + n2 = simple ? (*wpat == wstring[n]) : match_pattern_wchar (wpat, wstring + n); +#else + n2 = match_pattern_wchar (wpat, wstring + n); +#endif + if (n2) + { +#if 0 + for (n1 = wstrlen; n1 >= n; n1--) +#else + n1 = (mlen == -1) ? wstrlen : n + mlen; + if (n1 > wstrlen) + break; + + for ( ; n1 >= n; n1--) +#endif + { + wc = wstring[n1]; wstring[n1] = L'\0'; + if (wcsmatch (wpat, wstring + n, FNMATCH_EXTFLAG) == 0) + { + wstring[n1] = wc; + *sp = indices[n]; + *ep = indices[n1]; + return 1; + } + wstring[n1] = wc; +#if 1 + /* If MLEN != -1, we have a fixed length pattern. */ + if (mlen != -1) + break; +#endif + } + } + } + + return (0); + + case MATCH_BEG: + if (match_pattern_wchar (wpat, wstring) == 0) + return (0); + +#if 0 + for (n = wstrlen; n >= 0; n--) +#else + for (n = (mlen == -1) ? wstrlen : mlen; n >= 0; n--) +#endif + { + wc = wstring[n]; wstring[n] = L'\0'; + if (wcsmatch (wpat, wstring, FNMATCH_EXTFLAG) == 0) + { + wstring[n] = wc; + *sp = indices[0]; + *ep = indices[n]; + return 1; + } + wstring[n] = wc; +#if 1 + /* If MLEN != -1, we have a fixed length pattern. */ + if (mlen != -1) + break; +#endif + } + + return (0); + + case MATCH_END: +#if 0 + for (n = 0; n <= wstrlen; n++) +#else + for (n = wstrlen - ((mlen == -1) ? wstrlen : mlen); n <= wstrlen; n++) +#endif + { + if (wcsmatch (wpat, wstring + n, FNMATCH_EXTFLAG) == 0) + { + *sp = indices[n]; + *ep = indices[wstrlen]; + return 1; + } +#if 1 + /* If MLEN != -1, we have a fixed length pattern. */ + if (mlen != -1) + break; +#endif + } + + return (0); + } + + return (0); +} +#endif /* HANDLE_MULTIBYTE */ + +static int +match_pattern (string, pat, mtype, sp, ep) + char *string, *pat; + int mtype; + char **sp, **ep; +{ +#if defined (HANDLE_MULTIBYTE) + int ret; + size_t n; + wchar_t *wstring, *wpat; + char **indices; + size_t slen, plen, mslen, mplen; +#endif + + if (string == 0 || *string == 0 || pat == 0 || *pat == 0) + return (0); + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1) + { +#if 0 + slen = STRLEN (string); + mslen = MBSLEN (string); + plen = STRLEN (pat); + mplen = MBSLEN (pat); + if (slen == mslen && plen == mplen) +#else + if (mbsmbchar (string) == 0 && mbsmbchar (pat) == 0) +#endif + return (match_upattern (string, pat, mtype, sp, ep)); + + n = xdupmbstowcs (&wpat, NULL, pat); + if (n == (size_t)-1) + return (match_upattern (string, pat, mtype, sp, ep)); + n = xdupmbstowcs (&wstring, &indices, string); + if (n == (size_t)-1) + { + free (wpat); + return (match_upattern (string, pat, mtype, sp, ep)); + } + ret = match_wpattern (wstring, indices, n, wpat, mtype, sp, ep); + + free (wpat); + free (wstring); + free (indices); + + return (ret); + } + else +#endif + return (match_upattern (string, pat, mtype, sp, ep)); +} + +static int +getpatspec (c, value) + int c; + char *value; +{ + if (c == '#') + return ((*value == '#') ? RP_LONG_LEFT : RP_SHORT_LEFT); + else /* c == '%' */ + return ((*value == '%') ? RP_LONG_RIGHT : RP_SHORT_RIGHT); +} + +/* Posix.2 says that the WORD should be run through tilde expansion, + parameter expansion, command substitution and arithmetic expansion. + This leaves the result quoted, so quote_string_for_globbing () has + to be called to fix it up for strmatch (). If QUOTED is non-zero, + it means that the entire expression was enclosed in double quotes. + This means that quoting characters in the pattern do not make any + special pattern characters quoted. For example, the `*' in the + following retains its special meaning: "${foo#'*'}". */ +static char * +getpattern (value, quoted, expandpat) + char *value; + int quoted, expandpat; +{ + char *pat, *tword; + WORD_LIST *l; +#if 0 + int i; +#endif + /* There is a problem here: how to handle single or double quotes in the + pattern string when the whole expression is between double quotes? + POSIX.2 says that enclosing double quotes do not cause the pattern to + be quoted, but does that leave us a problem with @ and array[@] and their + expansions inside a pattern? */ +#if 0 + if (expandpat && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && *tword) + { + i = 0; + pat = string_extract_double_quoted (tword, &i, 1); + free (tword); + tword = pat; + } +#endif + + /* expand_string_for_rhs () leaves WORD quoted and does not perform + word splitting. */ + l = *value ? expand_string_for_rhs (value, + (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) ? Q_PATQUOTE : quoted, + (int *)NULL, (int *)NULL) + : (WORD_LIST *)0; + pat = string_list (l); + dispose_words (l); + if (pat) + { + tword = quote_string_for_globbing (pat, QGLOB_CVTNULL); + free (pat); + pat = tword; + } + return (pat); +} + +#if 0 +/* Handle removing a pattern from a string as a result of ${name%[%]value} + or ${name#[#]value}. */ +static char * +variable_remove_pattern (value, pattern, patspec, quoted) + char *value, *pattern; + int patspec, quoted; +{ + char *tword; + + tword = remove_pattern (value, pattern, patspec); + + return (tword); +} +#endif + +static char * +list_remove_pattern (list, pattern, patspec, itype, quoted) + WORD_LIST *list; + char *pattern; + int patspec, itype, quoted; +{ + WORD_LIST *new, *l; + WORD_DESC *w; + char *tword; + + for (new = (WORD_LIST *)NULL, l = list; l; l = l->next) + { + tword = remove_pattern (l->word->word, pattern, patspec); + w = alloc_word_desc (); + w->word = tword ? tword : savestring (""); + new = make_word_list (w, new); + } + + l = REVERSE_LIST (new, WORD_LIST *); + tword = string_list_pos_params (itype, l, quoted); + dispose_words (l); + + return (tword); +} + +static char * +parameter_list_remove_pattern (itype, pattern, patspec, quoted) + int itype; + char *pattern; + int patspec, quoted; +{ + char *ret; + WORD_LIST *list; + + list = list_rest_of_args (); + if (list == 0) + return ((char *)NULL); + ret = list_remove_pattern (list, pattern, patspec, itype, quoted); + dispose_words (list); + return (ret); +} + +#if defined (ARRAY_VARS) +static char * +array_remove_pattern (var, pattern, patspec, varname, quoted) + SHELL_VAR *var; + char *pattern; + int patspec; + char *varname; /* so we can figure out how it's indexed */ + int quoted; +{ + ARRAY *a; + HASH_TABLE *h; + int itype; + char *ret; + WORD_LIST *list; + SHELL_VAR *v; + + /* compute itype from varname here */ + v = array_variable_part (varname, &ret, 0); + itype = ret[0]; + + a = (v && array_p (v)) ? array_cell (v) : 0; + h = (v && assoc_p (v)) ? assoc_cell (v) : 0; + + list = a ? array_to_word_list (a) : (h ? assoc_to_word_list (h) : 0); + if (list == 0) + return ((char *)NULL); + ret = list_remove_pattern (list, pattern, patspec, itype, quoted); + dispose_words (list); + + return ret; +} +#endif /* ARRAY_VARS */ + +static char * +parameter_brace_remove_pattern (varname, value, ind, patstr, rtype, quoted, flags) + char *varname, *value; + int ind; + char *patstr; + int rtype, quoted, flags; +{ + int vtype, patspec, starsub; + char *temp1, *val, *pattern; + SHELL_VAR *v; + + if (value == 0) + return ((char *)NULL); + + this_command_name = varname; + + vtype = get_var_and_type (varname, value, ind, quoted, flags, &v, &val); + if (vtype == -1) + return ((char *)NULL); + + starsub = vtype & VT_STARSUB; + vtype &= ~VT_STARSUB; + + patspec = getpatspec (rtype, patstr); + if (patspec == RP_LONG_LEFT || patspec == RP_LONG_RIGHT) + patstr++; + + /* Need to pass getpattern newly-allocated memory in case of expansion -- + the expansion code will free the passed string on an error. */ + temp1 = savestring (patstr); + pattern = getpattern (temp1, quoted, 1); + free (temp1); + + temp1 = (char *)NULL; /* shut up gcc */ + switch (vtype) + { + case VT_VARIABLE: + case VT_ARRAYMEMBER: + temp1 = remove_pattern (val, pattern, patspec); + if (vtype == VT_VARIABLE) + FREE (val); + if (temp1) + { + val = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + ? quote_string (temp1) + : quote_escapes (temp1); + free (temp1); + temp1 = val; + } + break; +#if defined (ARRAY_VARS) + case VT_ARRAYVAR: + temp1 = array_remove_pattern (v, pattern, patspec, varname, quoted); + if (temp1 && ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0)) + { + val = quote_escapes (temp1); + free (temp1); + temp1 = val; + } + break; +#endif + case VT_POSPARMS: + temp1 = parameter_list_remove_pattern (varname[0], pattern, patspec, quoted); + if (temp1 && ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0)) + { + val = quote_escapes (temp1); + free (temp1); + temp1 = val; + } + break; + } + + FREE (pattern); + return temp1; +} + +/******************************************* + * * + * Functions to expand WORD_DESCs * + * * + *******************************************/ + +/* Expand WORD, performing word splitting on the result. This does + parameter expansion, command substitution, arithmetic expansion, + word splitting, and quote removal. */ + +WORD_LIST * +expand_word (word, quoted) + WORD_DESC *word; + int quoted; +{ + WORD_LIST *result, *tresult; + + tresult = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL); + result = word_list_split (tresult); + dispose_words (tresult); + return (result ? dequote_list (result) : result); +} + +/* Expand WORD, but do not perform word splitting on the result. This + does parameter expansion, command substitution, arithmetic expansion, + and quote removal. */ +WORD_LIST * +expand_word_unsplit (word, quoted) + WORD_DESC *word; + int quoted; +{ + WORD_LIST *result; + + expand_no_split_dollar_star = 1; +#if defined (HANDLE_MULTIBYTE) + if (ifs_firstc[0] == 0) +#else + if (ifs_firstc == 0) +#endif + word->flags |= W_NOSPLIT; + word->flags |= W_NOSPLIT2; + result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL); + expand_no_split_dollar_star = 0; + + return (result ? dequote_list (result) : result); +} + +/* Perform shell expansions on WORD, but do not perform word splitting or + quote removal on the result. Virtually identical to expand_word_unsplit; + could be combined if implementations don't diverge. */ +WORD_LIST * +expand_word_leave_quoted (word, quoted) + WORD_DESC *word; + int quoted; +{ + WORD_LIST *result; + + expand_no_split_dollar_star = 1; +#if defined (HANDLE_MULTIBYTE) + if (ifs_firstc[0] == 0) +#else + if (ifs_firstc == 0) +#endif + word->flags |= W_NOSPLIT; + word->flags |= W_NOSPLIT2; + result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL); + expand_no_split_dollar_star = 0; + + return result; +} + +#if defined (PROCESS_SUBSTITUTION) + +/*****************************************************************/ +/* */ +/* Hacking Process Substitution */ +/* */ +/*****************************************************************/ + +#if !defined (HAVE_DEV_FD) +/* Named pipes must be removed explicitly with `unlink'. This keeps a list + of FIFOs the shell has open. unlink_fifo_list will walk the list and + unlink all of them. add_fifo_list adds the name of an open FIFO to the + list. NFIFO is a count of the number of FIFOs in the list. */ +#define FIFO_INCR 20 + +struct temp_fifo { + char *file; + pid_t proc; +}; + +static struct temp_fifo *fifo_list = (struct temp_fifo *)NULL; +static int nfifo; +static int fifo_list_size; + +char * +copy_fifo_list (sizep) + int *sizep; +{ + if (sizep) + *sizep = 0; + return (char *)NULL; +} + +static void +add_fifo_list (pathname) + char *pathname; +{ + if (nfifo >= fifo_list_size - 1) + { + fifo_list_size += FIFO_INCR; + fifo_list = (struct temp_fifo *)xrealloc (fifo_list, + fifo_list_size * sizeof (struct temp_fifo)); + } + + fifo_list[nfifo].file = savestring (pathname); + nfifo++; +} + +void +unlink_fifo (i) + int i; +{ + if ((fifo_list[i].proc == -1) || (kill(fifo_list[i].proc, 0) == -1)) + { + unlink (fifo_list[i].file); + free (fifo_list[i].file); + fifo_list[i].file = (char *)NULL; + fifo_list[i].proc = -1; + } +} + +void +unlink_fifo_list () +{ + int saved, i, j; + + if (nfifo == 0) + return; + + for (i = saved = 0; i < nfifo; i++) + { + if ((fifo_list[i].proc == -1) || (kill(fifo_list[i].proc, 0) == -1)) + { + unlink (fifo_list[i].file); + free (fifo_list[i].file); + fifo_list[i].file = (char *)NULL; + fifo_list[i].proc = -1; + } + else + saved++; + } + + /* If we didn't remove some of the FIFOs, compact the list. */ + if (saved) + { + for (i = j = 0; i < nfifo; i++) + if (fifo_list[i].file) + { + fifo_list[j].file = fifo_list[i].file; + fifo_list[j].proc = fifo_list[i].proc; + j++; + } + nfifo = j; + } + else + nfifo = 0; +} + +/* Take LIST, which is a bitmap denoting active FIFOs in fifo_list + from some point in the past, and close all open FIFOs in fifo_list + that are not marked as active in LIST. If LIST is NULL, close + everything in fifo_list. LSIZE is the number of elements in LIST, in + case it's larger than fifo_list_size (size of fifo_list). */ +void +close_new_fifos (list, lsize) + char *list; + int lsize; +{ + int i; + + if (list == 0) + { + unlink_fifo_list (); + return; + } + + for (i = 0; i < lsize; i++) + if (list[i] == 0 && i < fifo_list_size && fifo_list[i].proc != -1) + unlink_fifo (i); + + for (i = lsize; i < fifo_list_size; i++) + unlink_fifo (i); +} + +int +fifos_pending () +{ + return nfifo; +} + +int +num_fifos () +{ + return nfifo; +} + +static char * +make_named_pipe () +{ + char *tname; + + tname = sh_mktmpname ("sh-np", MT_USERANDOM|MT_USETMPDIR); + if (mkfifo (tname, 0600) < 0) + { + free (tname); + return ((char *)NULL); + } + + add_fifo_list (tname); + return (tname); +} + +#else /* HAVE_DEV_FD */ + +/* DEV_FD_LIST is a bitmap of file descriptors attached to pipes the shell + has open to children. NFDS is a count of the number of bits currently + set in DEV_FD_LIST. TOTFDS is a count of the highest possible number + of open files. */ +static char *dev_fd_list = (char *)NULL; +static int nfds; +static int totfds; /* The highest possible number of open files. */ + +char * +copy_fifo_list (sizep) + int *sizep; +{ + char *ret; + + if (nfds == 0 || totfds == 0) + { + if (sizep) + *sizep = 0; + return (char *)NULL; + } + + if (sizep) + *sizep = totfds; + ret = (char *)xmalloc (totfds); + return (memcpy (ret, dev_fd_list, totfds)); +} + +static void +add_fifo_list (fd) + int fd; +{ + if (dev_fd_list == 0 || fd >= totfds) + { + int ofds; + + ofds = totfds; + totfds = getdtablesize (); + if (totfds < 0 || totfds > 256) + totfds = 256; + if (fd >= totfds) + totfds = fd + 2; + + dev_fd_list = (char *)xrealloc (dev_fd_list, totfds); + memset (dev_fd_list + ofds, '\0', totfds - ofds); + } + + dev_fd_list[fd] = 1; + nfds++; +} + +int +fifos_pending () +{ + return 0; /* used for cleanup; not needed with /dev/fd */ +} + +int +num_fifos () +{ + return nfds; +} + +void +unlink_fifo (fd) + int fd; +{ + if (dev_fd_list[fd]) + { + close (fd); + dev_fd_list[fd] = 0; + nfds--; + } +} + +void +unlink_fifo_list () +{ + register int i; + + if (nfds == 0) + return; + + for (i = 0; nfds && i < totfds; i++) + unlink_fifo (i); + + nfds = 0; +} + +/* Take LIST, which is a snapshot copy of dev_fd_list from some point in + the past, and close all open fds in dev_fd_list that are not marked + as open in LIST. If LIST is NULL, close everything in dev_fd_list. + LSIZE is the number of elements in LIST, in case it's larger than + totfds (size of dev_fd_list). */ +void +close_new_fifos (list, lsize) + char *list; + int lsize; +{ + int i; + + if (list == 0) + { + unlink_fifo_list (); + return; + } + + for (i = 0; i < lsize; i++) + if (list[i] == 0 && i < totfds && dev_fd_list[i]) + unlink_fifo (i); + + for (i = lsize; i < totfds; i++) + unlink_fifo (i); +} + +#if defined (NOTDEF) +print_dev_fd_list () +{ + register int i; + + fprintf (stderr, "pid %ld: dev_fd_list:", (long)getpid ()); + fflush (stderr); + + for (i = 0; i < totfds; i++) + { + if (dev_fd_list[i]) + fprintf (stderr, " %d", i); + } + fprintf (stderr, "\n"); +} +#endif /* NOTDEF */ + +static char * +make_dev_fd_filename (fd) + int fd; +{ + char *ret, intbuf[INT_STRLEN_BOUND (int) + 1], *p; + + ret = (char *)xmalloc (sizeof (DEV_FD_PREFIX) + 8); + + strcpy (ret, DEV_FD_PREFIX); + p = inttostr (fd, intbuf, sizeof (intbuf)); + strcpy (ret + sizeof (DEV_FD_PREFIX) - 1, p); + + add_fifo_list (fd); + return (ret); +} + +#endif /* HAVE_DEV_FD */ + +/* Return a filename that will open a connection to the process defined by + executing STRING. HAVE_DEV_FD, if defined, means open a pipe and return + a filename in /dev/fd corresponding to a descriptor that is one of the + ends of the pipe. If not defined, we use named pipes on systems that have + them. Systems without /dev/fd and named pipes are out of luck. + + OPEN_FOR_READ_IN_CHILD, if 1, means open the named pipe for reading or + use the read end of the pipe and dup that file descriptor to fd 0 in + the child. If OPEN_FOR_READ_IN_CHILD is 0, we open the named pipe for + writing or use the write end of the pipe in the child, and dup that + file descriptor to fd 1 in the child. The parent does the opposite. */ + +static char * +process_substitute (string, open_for_read_in_child) + char *string; + int open_for_read_in_child; +{ + char *pathname; + int fd, result; + pid_t old_pid, pid; +#if defined (HAVE_DEV_FD) + int parent_pipe_fd, child_pipe_fd; + int fildes[2]; +#endif /* HAVE_DEV_FD */ +#if defined (JOB_CONTROL) + pid_t old_pipeline_pgrp; +#endif + + if (!string || !*string || wordexp_only) + return ((char *)NULL); + +#if !defined (HAVE_DEV_FD) + pathname = make_named_pipe (); +#else /* HAVE_DEV_FD */ + if (pipe (fildes) < 0) + { + sys_error (_("cannot make pipe for process substitution")); + return ((char *)NULL); + } + /* If OPEN_FOR_READ_IN_CHILD == 1, we want to use the write end of + the pipe in the parent, otherwise the read end. */ + parent_pipe_fd = fildes[open_for_read_in_child]; + child_pipe_fd = fildes[1 - open_for_read_in_child]; + /* Move the parent end of the pipe to some high file descriptor, to + avoid clashes with FDs used by the script. */ + parent_pipe_fd = move_to_high_fd (parent_pipe_fd, 1, 64); + + pathname = make_dev_fd_filename (parent_pipe_fd); +#endif /* HAVE_DEV_FD */ + + if (pathname == 0) + { + sys_error (_("cannot make pipe for process substitution")); + return ((char *)NULL); + } + + old_pid = last_made_pid; + +#if defined (JOB_CONTROL) + old_pipeline_pgrp = pipeline_pgrp; + pipeline_pgrp = shell_pgrp; + save_pipeline (1); +#endif /* JOB_CONTROL */ + + pid = make_child ((char *)NULL, 1); + if (pid == 0) + { + reset_terminating_signals (); /* XXX */ + free_pushed_string_input (); + /* Cancel traps, in trap.c. */ + restore_original_signals (); /* XXX - what about special builtins? bash-4.2 */ + setup_async_signals (); + subshell_environment |= SUBSHELL_COMSUB|SUBSHELL_PROCSUB; + } + +#if defined (JOB_CONTROL) + set_sigchld_handler (); + stop_making_children (); + /* XXX - should we only do this in the parent? (as in command subst) */ + pipeline_pgrp = old_pipeline_pgrp; +#endif /* JOB_CONTROL */ + + if (pid < 0) + { + sys_error (_("cannot make child for process substitution")); + free (pathname); +#if defined (HAVE_DEV_FD) + close (parent_pipe_fd); + close (child_pipe_fd); +#endif /* HAVE_DEV_FD */ + return ((char *)NULL); + } + + if (pid > 0) + { +#if defined (JOB_CONTROL) + restore_pipeline (1); +#endif + +#if !defined (HAVE_DEV_FD) + fifo_list[nfifo-1].proc = pid; +#endif + + last_made_pid = old_pid; + +#if defined (JOB_CONTROL) && defined (PGRP_PIPE) + close_pgrp_pipe (); +#endif /* JOB_CONTROL && PGRP_PIPE */ + +#if defined (HAVE_DEV_FD) + close (child_pipe_fd); +#endif /* HAVE_DEV_FD */ + + return (pathname); + } + + set_sigint_handler (); + +#if defined (JOB_CONTROL) + set_job_control (0); +#endif /* JOB_CONTROL */ + +#if !defined (HAVE_DEV_FD) + /* Open the named pipe in the child. */ + fd = open (pathname, open_for_read_in_child ? O_RDONLY|O_NONBLOCK : O_WRONLY); + if (fd < 0) + { + /* Two separate strings for ease of translation. */ + if (open_for_read_in_child) + sys_error (_("cannot open named pipe %s for reading"), pathname); + else + sys_error (_("cannot open named pipe %s for writing"), pathname); + + exit (127); + } + if (open_for_read_in_child) + { + if (sh_unset_nodelay_mode (fd) < 0) + { + sys_error (_("cannot reset nodelay mode for fd %d"), fd); + exit (127); + } + } +#else /* HAVE_DEV_FD */ + fd = child_pipe_fd; +#endif /* HAVE_DEV_FD */ + + if (dup2 (fd, open_for_read_in_child ? 0 : 1) < 0) + { + sys_error (_("cannot duplicate named pipe %s as fd %d"), pathname, + open_for_read_in_child ? 0 : 1); + exit (127); + } + + if (fd != (open_for_read_in_child ? 0 : 1)) + close (fd); + + /* Need to close any files that this process has open to pipes inherited + from its parent. */ + if (current_fds_to_close) + { + close_fd_bitmap (current_fds_to_close); + current_fds_to_close = (struct fd_bitmap *)NULL; + } + +#if defined (HAVE_DEV_FD) + /* Make sure we close the parent's end of the pipe and clear the slot + in the fd list so it is not closed later, if reallocated by, for + instance, pipe(2). */ + close (parent_pipe_fd); + dev_fd_list[parent_pipe_fd] = 0; +#endif /* HAVE_DEV_FD */ + + /* subshells shouldn't have this flag, which controls using the temporary + environment for variable lookups. */ + expanding_redir = 0; + + result = parse_and_execute (string, "process substitution", (SEVAL_NONINT|SEVAL_NOHIST)); + +#if !defined (HAVE_DEV_FD) + /* Make sure we close the named pipe in the child before we exit. */ + close (open_for_read_in_child ? 0 : 1); +#endif /* !HAVE_DEV_FD */ + + exit (result); + /*NOTREACHED*/ +} +#endif /* PROCESS_SUBSTITUTION */ + +/***********************************/ +/* */ +/* Command Substitution */ +/* */ +/***********************************/ + +static char * +read_comsub (fd, quoted, rflag) + int fd, quoted; + int *rflag; +{ + char *istring, buf[128], *bufp, *s; + int istring_index, istring_size, c, tflag, skip_ctlesc, skip_ctlnul; + ssize_t bufn; + + istring = (char *)NULL; + istring_index = istring_size = bufn = tflag = 0; + + for (skip_ctlesc = skip_ctlnul = 0, s = ifs_value; s && *s; s++) + skip_ctlesc |= *s == CTLESC, skip_ctlnul |= *s == CTLNUL; + + /* Read the output of the command through the pipe. This may need to be + changed to understand multibyte characters in the future. */ + while (1) + { + if (fd < 0) + break; + if (--bufn <= 0) + { + bufn = zread (fd, buf, sizeof (buf)); + if (bufn <= 0) + break; + bufp = buf; + } + c = *bufp++; + + if (c == 0) + { +#if 0 + internal_warning ("read_comsub: ignored null byte in input"); +#endif + continue; + } + + /* Add the character to ISTRING, possibly after resizing it. */ + RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size, DEFAULT_ARRAY_SIZE); + + /* This is essentially quote_string inline */ + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) /* || c == CTLESC || c == CTLNUL */) + istring[istring_index++] = CTLESC; + /* Escape CTLESC and CTLNUL in the output to protect those characters + from the rest of the word expansions (word splitting and globbing.) + This is essentially quote_escapes inline. */ + else if (skip_ctlesc == 0 && c == CTLESC) + { + tflag |= W_HASCTLESC; + istring[istring_index++] = CTLESC; + } + else if ((skip_ctlnul == 0 && c == CTLNUL) || (c == ' ' && (ifs_value && *ifs_value == 0))) + istring[istring_index++] = CTLESC; + + istring[istring_index++] = c; + +#if 0 +#if defined (__CYGWIN__) + if (c == '\n' && istring_index > 1 && istring[istring_index - 2] == '\r') + { + istring_index--; + istring[istring_index - 1] = '\n'; + } +#endif +#endif + } + + if (istring) + istring[istring_index] = '\0'; + + /* If we read no output, just return now and save ourselves some + trouble. */ + if (istring_index == 0) + { + FREE (istring); + if (rflag) + *rflag = tflag; + return (char *)NULL; + } + + /* Strip trailing newlines from the output of the command. */ + if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + { + while (istring_index > 0) + { + if (istring[istring_index - 1] == '\n') + { + --istring_index; + + /* If the newline was quoted, remove the quoting char. */ + if (istring[istring_index - 1] == CTLESC) + --istring_index; + } + else + break; + } + istring[istring_index] = '\0'; + } + else + strip_trailing (istring, istring_index - 1, 1); + + if (rflag) + *rflag = tflag; + return istring; +} + +/* Perform command substitution on STRING. This returns a WORD_DESC * with the + contained string possibly quoted. */ +WORD_DESC * +command_substitute (string, quoted) + char *string; + int quoted; +{ + pid_t pid, old_pid, old_pipeline_pgrp, old_async_pid; + char *istring; + int result, fildes[2], function_value, pflags, rc, tflag; + WORD_DESC *ret; + + istring = (char *)NULL; + + /* Don't fork () if there is no need to. In the case of no command to + run, just return NULL. */ + if (!string || !*string || (string[0] == '\n' && !string[1])) + return ((WORD_DESC *)NULL); + + if (wordexp_only && read_but_dont_execute) + { + last_command_exit_value = EX_WEXPCOMSUB; + jump_to_top_level (EXITPROG); + } + + /* We're making the assumption here that the command substitution will + eventually run a command from the file system. Since we'll run + maybe_make_export_env in this subshell before executing that command, + the parent shell and any other shells it starts will have to remake + the environment. If we make it before we fork, other shells won't + have to. Don't bother if we have any temporary variable assignments, + though, because the export environment will be remade after this + command completes anyway, but do it if all the words to be expanded + are variable assignments. */ + if (subst_assign_varlist == 0 || garglist == 0) + maybe_make_export_env (); /* XXX */ + + /* Flags to pass to parse_and_execute() */ + pflags = (interactive && sourcelevel == 0) ? SEVAL_RESETLINE : 0; + + /* Pipe the output of executing STRING into the current shell. */ + if (pipe (fildes) < 0) + { + sys_error (_("cannot make pipe for command substitution")); + goto error_exit; + } + + old_pid = last_made_pid; +#if defined (JOB_CONTROL) + old_pipeline_pgrp = pipeline_pgrp; + /* Don't reset the pipeline pgrp if we're already a subshell in a pipeline. */ + if ((subshell_environment & SUBSHELL_PIPE) == 0) + pipeline_pgrp = shell_pgrp; + cleanup_the_pipeline (); +#endif /* JOB_CONTROL */ + + old_async_pid = last_asynchronous_pid; + pid = make_child ((char *)NULL, subshell_environment&SUBSHELL_ASYNC); + last_asynchronous_pid = old_async_pid; + + if (pid == 0) + { + /* Reset the signal handlers in the child, but don't free the + trap strings. Set a flag noting that we have to free the + trap strings if we run trap to change a signal disposition. */ + reset_signal_handlers (); + subshell_environment |= SUBSHELL_RESETTRAP; + } + +#if defined (JOB_CONTROL) + /* XXX DO THIS ONLY IN PARENT ? XXX */ + set_sigchld_handler (); + stop_making_children (); + if (pid != 0) + pipeline_pgrp = old_pipeline_pgrp; +#else + stop_making_children (); +#endif /* JOB_CONTROL */ + + if (pid < 0) + { + sys_error (_("cannot make child for command substitution")); + error_exit: + + last_made_pid = old_pid; + + FREE (istring); + close (fildes[0]); + close (fildes[1]); + return ((WORD_DESC *)NULL); + } + + if (pid == 0) + { + set_sigint_handler (); /* XXX */ + + free_pushed_string_input (); + + if (dup2 (fildes[1], 1) < 0) + { + sys_error (_("command_substitute: cannot duplicate pipe as fd 1")); + exit (EXECUTION_FAILURE); + } + + /* If standard output is closed in the parent shell + (such as after `exec >&-'), file descriptor 1 will be + the lowest available file descriptor, and end up in + fildes[0]. This can happen for stdin and stderr as well, + but stdout is more important -- it will cause no output + to be generated from this command. */ + if ((fildes[1] != fileno (stdin)) && + (fildes[1] != fileno (stdout)) && + (fildes[1] != fileno (stderr))) + close (fildes[1]); + + if ((fildes[0] != fileno (stdin)) && + (fildes[0] != fileno (stdout)) && + (fildes[0] != fileno (stderr))) + close (fildes[0]); + +#ifdef __CYGWIN__ + /* Let stdio know the fd may have changed from text to binary mode, and + make sure to preserve stdout line buffering. */ + freopen (NULL, "w", stdout); + sh_setlinebuf (stdout); +#endif /* __CYGWIN__ */ + + /* The currently executing shell is not interactive. */ + interactive = 0; + + /* This is a subshell environment. */ + subshell_environment |= SUBSHELL_COMSUB; + + /* When not in POSIX mode, command substitution does not inherit + the -e flag. */ + if (posixly_correct == 0) + { + builtin_ignoring_errexit = 0; + change_flag ('e', FLAG_OFF); + set_shellopts (); + } + + remove_quoted_escapes (string); + + startup_state = 2; /* see if we can avoid a fork */ + /* Give command substitution a place to jump back to on failure, + so we don't go back up to main (). */ + result = setjmp (top_level); + + /* If we're running a command substitution inside a shell function, + trap `return' so we don't return from the function in the subshell + and go off to never-never land. */ + if (result == 0 && return_catch_flag) + function_value = setjmp (return_catch); + else + function_value = 0; + + if (result == ERREXIT) + rc = last_command_exit_value; + else if (result == EXITPROG) + rc = last_command_exit_value; + else if (result) + rc = EXECUTION_FAILURE; + else if (function_value) + rc = return_catch_value; + else + { + subshell_level++; + rc = parse_and_execute (string, "command substitution", pflags|SEVAL_NOHIST); + subshell_level--; + } + + last_command_exit_value = rc; + rc = run_exit_trap (); +#if defined (PROCESS_SUBSTITUTION) + unlink_fifo_list (); +#endif + exit (rc); + } + else + { +#if defined (JOB_CONTROL) && defined (PGRP_PIPE) + close_pgrp_pipe (); +#endif /* JOB_CONTROL && PGRP_PIPE */ + + close (fildes[1]); + + tflag = 0; + istring = read_comsub (fildes[0], quoted, &tflag); + + close (fildes[0]); + + current_command_subst_pid = pid; + last_command_exit_value = wait_for (pid); + last_command_subst_pid = pid; + last_made_pid = old_pid; + +#if defined (JOB_CONTROL) + /* If last_command_exit_value > 128, then the substituted command + was terminated by a signal. If that signal was SIGINT, then send + SIGINT to ourselves. This will break out of loops, for instance. */ + if (last_command_exit_value == (128 + SIGINT) && last_command_exit_signal == SIGINT) + kill (getpid (), SIGINT); + + /* wait_for gives the terminal back to shell_pgrp. If some other + process group should have it, give it away to that group here. + pipeline_pgrp is non-zero only while we are constructing a + pipline, so what we are concerned about is whether or not that + pipeline was started in the background. A pipeline started in + the background should never get the tty back here. */ + if (interactive && pipeline_pgrp != (pid_t)0 && (subshell_environment & SUBSHELL_ASYNC) == 0) + give_terminal_to (pipeline_pgrp, 0); +#endif /* JOB_CONTROL */ + + ret = alloc_word_desc (); + ret->word = istring; + ret->flags = tflag; + + return ret; + } +} + +/******************************************************** + * * + * Utility functions for parameter expansion * + * * + ********************************************************/ + +#if defined (ARRAY_VARS) + +static arrayind_t +array_length_reference (s) + char *s; +{ + int len; + arrayind_t ind; + char *akey; + char *t, c; + ARRAY *array; + HASH_TABLE *h; + SHELL_VAR *var; + + var = array_variable_part (s, &t, &len); + + /* If unbound variables should generate an error, report one and return + failure. */ + if ((var == 0 || (assoc_p (var) == 0 && array_p (var) == 0)) && unbound_vars_is_error) + { + c = *--t; + *t = '\0'; + last_command_exit_value = EXECUTION_FAILURE; + err_unboundvar (s); + *t = c; + return (-1); + } + else if (var == 0) + return 0; + + /* We support a couple of expansions for variables that are not arrays. + We'll return the length of the value for v[0], and 1 for v[@] or + v[*]. Return 0 for everything else. */ + + array = array_p (var) ? array_cell (var) : (ARRAY *)NULL; + h = assoc_p (var) ? assoc_cell (var) : (HASH_TABLE *)NULL; + + if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']') + { + if (assoc_p (var)) + return (h ? assoc_num_elements (h) : 0); + else if (array_p (var)) + return (array ? array_num_elements (array) : 0); + else + return (var_isset (var) ? 1 : 0); + } + + if (assoc_p (var)) + { + t[len - 1] = '\0'; + akey = expand_assignment_string_to_string (t, 0); /* [ */ + t[len - 1] = ']'; + if (akey == 0 || *akey == 0) + { + err_badarraysub (t); + FREE (akey); + return (-1); + } + t = assoc_reference (assoc_cell (var), akey); + free (akey); + } + else + { + ind = array_expand_index (var, t, len); + /* negative subscripts to indexed arrays count back from end */ + if (var && array_p (var) && ind < 0) + ind = array_max_index (array_cell (var)) + 1 + ind; + if (ind < 0) + { + err_badarraysub (t); + return (-1); + } + if (array_p (var)) + t = array_reference (array, ind); + else + t = (ind == 0) ? value_cell (var) : (char *)NULL; + } + + len = MB_STRLEN (t); + return (len); +} +#endif /* ARRAY_VARS */ + +static int +valid_brace_expansion_word (name, var_is_special) + char *name; + int var_is_special; +{ + if (DIGIT (*name) && all_digits (name)) + return 1; + else if (var_is_special) + return 1; +#if defined (ARRAY_VARS) + else if (valid_array_reference (name)) + return 1; +#endif /* ARRAY_VARS */ + else if (legal_identifier (name)) + return 1; + else + return 0; +} + +static int +chk_atstar (name, quoted, quoted_dollar_atp, contains_dollar_at) + char *name; + int quoted; + int *quoted_dollar_atp, *contains_dollar_at; +{ + char *temp1; + + if (name == 0) + { + if (quoted_dollar_atp) + *quoted_dollar_atp = 0; + if (contains_dollar_at) + *contains_dollar_at = 0; + return 0; + } + + /* check for $@ and $* */ + if (name[0] == '@' && name[1] == 0) + { + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp) + *quoted_dollar_atp = 1; + if (contains_dollar_at) + *contains_dollar_at = 1; + return 1; + } + else if (name[0] == '*' && name[1] == '\0' && quoted == 0) + { + if (contains_dollar_at) + *contains_dollar_at = 1; + return 1; + } + + /* Now check for ${array[@]} and ${array[*]} */ +#if defined (ARRAY_VARS) + else if (valid_array_reference (name)) + { + temp1 = mbschr (name, '['); + if (temp1 && temp1[1] == '@' && temp1[2] == ']') + { + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp) + *quoted_dollar_atp = 1; + if (contains_dollar_at) + *contains_dollar_at = 1; + return 1; + } /* [ */ + /* ${array[*]}, when unquoted, should be treated like ${array[@]}, + which should result in separate words even when IFS is unset. */ + if (temp1 && temp1[1] == '*' && temp1[2] == ']' && quoted == 0) + { + if (contains_dollar_at) + *contains_dollar_at = 1; + return 1; + } + } +#endif + return 0; +} + +/* Parameter expand NAME, and return a new string which is the expansion, + or NULL if there was no expansion. + VAR_IS_SPECIAL is non-zero if NAME is one of the special variables in + the shell, e.g., "@", "$", "*", etc. QUOTED, if non-zero, means that + NAME was found inside of a double-quoted expression. */ +static WORD_DESC * +parameter_brace_expand_word (name, var_is_special, quoted, pflags, indp) + char *name; + int var_is_special, quoted, pflags; + arrayind_t *indp; +{ + WORD_DESC *ret; + char *temp, *tt; + intmax_t arg_index; + SHELL_VAR *var; + int atype, rflags; + arrayind_t ind; + + ret = 0; + temp = 0; + rflags = 0; + + if (indp) + *indp = INTMAX_MIN; + + /* Handle multiple digit arguments, as in ${11}. */ + if (legal_number (name, &arg_index)) + { + tt = get_dollar_var_value (arg_index); + if (tt) + temp = (*tt && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) + ? quote_string (tt) + : quote_escapes (tt); + else + temp = (char *)NULL; + FREE (tt); + } + else if (var_is_special) /* ${@} */ + { + int sindex; + tt = (char *)xmalloc (2 + strlen (name)); + tt[sindex = 0] = '$'; + strcpy (tt + 1, name); + + ret = param_expand (tt, &sindex, quoted, (int *)NULL, (int *)NULL, + (int *)NULL, (int *)NULL, pflags); + free (tt); + } +#if defined (ARRAY_VARS) + else if (valid_array_reference (name)) + { +expand_arrayref: + /* XXX - does this leak if name[@] or name[*]? */ + temp = array_value (name, quoted, 0, &atype, &ind); + if (atype == 0 && temp) + { + temp = (*temp && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) + ? quote_string (temp) + : quote_escapes (temp); + rflags |= W_ARRAYIND; + if (indp) + *indp = ind; + } + else if (atype == 1 && temp && QUOTED_NULL (temp) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) + rflags |= W_HASQUOTEDNULL; + } +#endif + else if (var = find_variable (name)) + { + if (var_isset (var) && invisible_p (var) == 0) + { +#if defined (ARRAY_VARS) + if (assoc_p (var)) + temp = assoc_reference (assoc_cell (var), "0"); + else if (array_p (var)) + temp = array_reference (array_cell (var), 0); + else + temp = value_cell (var); +#else + temp = value_cell (var); +#endif + + if (temp) + temp = (*temp && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) + ? quote_string (temp) + : quote_escapes (temp); + } + else + temp = (char *)NULL; + } + else if (var = find_variable_last_nameref (name)) + { + temp = nameref_cell (var); +#if defined (ARRAY_VARS) + /* Handle expanding nameref whose value is x[n] */ + if (temp && *temp && valid_array_reference (temp)) + { + name = temp; + goto expand_arrayref; + } +#endif + /* y=2 ; typeset -n x=y; echo ${x} is not the same as echo ${2} in ksh */ + else if (temp && *temp && legal_identifier (temp) == 0) + { + last_command_exit_value = EXECUTION_FAILURE; + report_error (_("%s: invalid variable name for name reference"), temp); + temp = &expand_param_error; + } + else + temp = (char *)NULL; + } + else + temp = (char *)NULL; + + if (ret == 0) + { + ret = alloc_word_desc (); + ret->word = temp; + ret->flags |= rflags; + } + return ret; +} + +/* Expand an indirect reference to a variable: ${!NAME} expands to the + value of the variable whose name is the value of NAME. */ +static WORD_DESC * +parameter_brace_expand_indir (name, var_is_special, quoted, quoted_dollar_atp, contains_dollar_at) + char *name; + int var_is_special, quoted; + int *quoted_dollar_atp, *contains_dollar_at; +{ + char *temp, *t; + WORD_DESC *w; + SHELL_VAR *v; + + /* See if it's a nameref first, behave in ksh93-compatible fashion. + There is at least one incompatibility: given ${!foo[0]} where foo=bar, + bash performs an indirect lookup on foo[0] and expands the result; + ksh93 expands bar[0]. We could do that here -- there are enough usable + primitives to do that -- but do not at this point. */ + if (var_is_special == 0 && (v = find_variable_last_nameref (name))) + { + if (nameref_p (v) && (t = nameref_cell (v)) && *t) + { + w = alloc_word_desc (); + w->word = savestring (t); + w->flags = 0; + return w; + } + } + + /* If var_is_special == 0, and name is not an array reference, this does + more expansion than necessary. It should really look up the variable's + value and not try to expand it. */ + w = parameter_brace_expand_word (name, var_is_special, quoted, PF_IGNUNBOUND, 0); + t = w->word; + /* Have to dequote here if necessary */ + if (t) + { + temp = (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) + ? dequote_string (t) + : dequote_escapes (t); + free (t); + t = temp; + } + dispose_word_desc (w); + + chk_atstar (t, quoted, quoted_dollar_atp, contains_dollar_at); + if (t == 0) + return (WORD_DESC *)NULL; + + w = parameter_brace_expand_word (t, SPECIAL_VAR(t, 0), quoted, 0, 0); + free (t); + + return w; +} + +/* Expand the right side of a parameter expansion of the form ${NAMEcVALUE}, + depending on the value of C, the separating character. C can be one of + "-", "+", or "=". QUOTED is true if the entire brace expression occurs + between double quotes. */ +static WORD_DESC * +parameter_brace_expand_rhs (name, value, c, quoted, qdollaratp, hasdollarat) + char *name, *value; + int c, quoted, *qdollaratp, *hasdollarat; +{ + WORD_DESC *w; + WORD_LIST *l; + char *t, *t1, *temp; + int hasdol; + + /* If the entire expression is between double quotes, we want to treat + the value as a double-quoted string, with the exception that we strip + embedded unescaped double quotes (for sh backwards compatibility). */ + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && *value) + { + hasdol = 0; + temp = string_extract_double_quoted (value, &hasdol, 1); + } + else + temp = value; + + w = alloc_word_desc (); + hasdol = 0; + /* XXX was 0 not quoted */ + l = *temp ? expand_string_for_rhs (temp, quoted, &hasdol, (int *)NULL) + : (WORD_LIST *)0; + if (hasdollarat) + *hasdollarat = hasdol || (l && l->next); + if (temp != value) + free (temp); + if (l) + { + /* The expansion of TEMP returned something. We need to treat things + slightly differently if HASDOL is non-zero. If we have "$@", the + individual words have already been quoted. We need to turn them + into a string with the words separated by the first character of + $IFS without any additional quoting, so string_list_dollar_at won't + do the right thing. We use string_list_dollar_star instead. */ + temp = (hasdol || l->next) ? string_list_dollar_star (l) : string_list (l); + + /* If l->next is not null, we know that TEMP contained "$@", since that + is the only expansion that creates more than one word. */ + if (qdollaratp && ((hasdol && quoted) || l->next)) + *qdollaratp = 1; + /* If we have a quoted null result (QUOTED_NULL(temp)) and the word is + a quoted null (l->next == 0 && QUOTED_NULL(l->word->word)), the + flags indicate it (l->word->flags & W_HASQUOTEDNULL), and the + expansion is quoted (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + (which is more paranoia than anything else), we need to return the + quoted null string and set the flags to indicate it. */ + if (l->next == 0 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL (temp) && QUOTED_NULL (l->word->word) && (l->word->flags & W_HASQUOTEDNULL)) + { + w->flags |= W_HASQUOTEDNULL; + } + dispose_words (l); + } + else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && hasdol) + { + /* The brace expansion occurred between double quotes and there was + a $@ in TEMP. It does not matter if the $@ is quoted, as long as + it does not expand to anything. In this case, we want to return + a quoted empty string. */ + temp = make_quoted_char ('\0'); + w->flags |= W_HASQUOTEDNULL; + } + else + temp = (char *)NULL; + + if (c == '-' || c == '+') + { + w->word = temp; + return w; + } + + /* c == '=' */ + t = temp ? savestring (temp) : savestring (""); + t1 = dequote_string (t); + free (t); +#if defined (ARRAY_VARS) + if (valid_array_reference (name)) + assign_array_element (name, t1, 0); + else +#endif /* ARRAY_VARS */ + bind_variable (name, t1, 0); + + /* From Posix group discussion Feb-March 2010. Issue 7 0000221 */ + free (temp); + + w->word = t1; + return w; +} + +/* Deal with the right hand side of a ${name:?value} expansion in the case + that NAME is null or not set. If VALUE is non-null it is expanded and + used as the error message to print, otherwise a standard message is + printed. */ +static void +parameter_brace_expand_error (name, value) + char *name, *value; +{ + WORD_LIST *l; + char *temp; + + last_command_exit_value = EXECUTION_FAILURE; /* ensure it's non-zero */ + if (value && *value) + { + l = expand_string (value, 0); + temp = string_list (l); + report_error ("%s: %s", name, temp ? temp : ""); /* XXX was value not "" */ + FREE (temp); + dispose_words (l); + } + else + report_error (_("%s: parameter null or not set"), name); + + /* Free the data we have allocated during this expansion, since we + are about to longjmp out. */ + free (name); + FREE (value); +} + +/* Return 1 if NAME is something for which parameter_brace_expand_length is + OK to do. */ +static int +valid_length_expression (name) + char *name; +{ + return (name[1] == '\0' || /* ${#} */ + ((sh_syntaxtab[(unsigned char) name[1]] & CSPECVAR) && name[2] == '\0') || /* special param */ + (DIGIT (name[1]) && all_digits (name + 1)) || /* ${#11} */ +#if defined (ARRAY_VARS) + valid_array_reference (name + 1) || /* ${#a[7]} */ +#endif + legal_identifier (name + 1)); /* ${#PS1} */ +} + +/* Handle the parameter brace expansion that requires us to return the + length of a parameter. */ +static intmax_t +parameter_brace_expand_length (name) + char *name; +{ + char *t, *newname; + intmax_t number, arg_index; + WORD_LIST *list; +#if defined (ARRAY_VARS) + SHELL_VAR *var; +#endif + + if (name[1] == '\0') /* ${#} */ + number = number_of_args (); + else if ((name[1] == '@' || name[1] == '*') && name[2] == '\0') /* ${#@}, ${#*} */ + number = number_of_args (); + else if ((sh_syntaxtab[(unsigned char) name[1]] & CSPECVAR) && name[2] == '\0') + { + /* Take the lengths of some of the shell's special parameters. */ + switch (name[1]) + { + case '-': + t = which_set_flags (); + break; + case '?': + t = itos (last_command_exit_value); + break; + case '$': + t = itos (dollar_dollar_pid); + break; + case '!': + if (last_asynchronous_pid == NO_PID) + t = (char *)NULL; /* XXX - error if set -u set? */ + else + t = itos (last_asynchronous_pid); + break; + case '#': + t = itos (number_of_args ()); + break; + } + number = STRLEN (t); + FREE (t); + } +#if defined (ARRAY_VARS) + else if (valid_array_reference (name + 1)) + number = array_length_reference (name + 1); +#endif /* ARRAY_VARS */ + else + { + number = 0; + + if (legal_number (name + 1, &arg_index)) /* ${#1} */ + { + t = get_dollar_var_value (arg_index); + if (t == 0 && unbound_vars_is_error) + return INTMAX_MIN; + number = MB_STRLEN (t); + FREE (t); + } +#if defined (ARRAY_VARS) + else if ((var = find_variable (name + 1)) && (invisible_p (var) == 0) && (array_p (var) || assoc_p (var))) + { + if (assoc_p (var)) + t = assoc_reference (assoc_cell (var), "0"); + else + t = array_reference (array_cell (var), 0); + if (t == 0 && unbound_vars_is_error) + return INTMAX_MIN; + number = MB_STRLEN (t); + } +#endif + else /* ${#PS1} */ + { + newname = savestring (name); + newname[0] = '$'; + list = expand_string (newname, Q_DOUBLE_QUOTES); + t = list ? string_list (list) : (char *)NULL; + free (newname); + if (list) + dispose_words (list); + + number = t ? MB_STRLEN (t) : 0; + FREE (t); + } + } + + return (number); +} + +/* Skip characters in SUBSTR until DELIM. SUBSTR is an arithmetic expression, + so we do some ad-hoc parsing of an arithmetic expression to find + the first DELIM, instead of using strchr(3). Two rules: + 1. If the substring contains a `(', read until closing `)'. + 2. If the substring contains a `?', read past one `:' for each `?'. +*/ + +static char * +skiparith (substr, delim) + char *substr; + int delim; +{ + size_t sublen; + int skipcol, pcount, i; + DECLARE_MBSTATE; + + sublen = strlen (substr); + i = skipcol = pcount = 0; + while (substr[i]) + { + /* Balance parens */ + if (substr[i] == LPAREN) + { + pcount++; + i++; + continue; + } + if (substr[i] == RPAREN && pcount) + { + pcount--; + i++; + continue; + } + if (pcount) + { + ADVANCE_CHAR (substr, sublen, i); + continue; + } + + /* Skip one `:' for each `?' */ + if (substr[i] == ':' && skipcol) + { + skipcol--; + i++; + continue; + } + if (substr[i] == delim) + break; + if (substr[i] == '?') + { + skipcol++; + i++; + continue; + } + ADVANCE_CHAR (substr, sublen, i); + } + + return (substr + i); +} + +/* Verify and limit the start and end of the desired substring. If + VTYPE == 0, a regular shell variable is being used; if it is 1, + then the positional parameters are being used; if it is 2, then + VALUE is really a pointer to an array variable that should be used. + Return value is 1 if both values were OK, 0 if there was a problem + with an invalid expression, or -1 if the values were out of range. */ +static int +verify_substring_values (v, value, substr, vtype, e1p, e2p) + SHELL_VAR *v; + char *value, *substr; + int vtype; + intmax_t *e1p, *e2p; +{ + char *t, *temp1, *temp2; + arrayind_t len; + int expok; +#if defined (ARRAY_VARS) + ARRAY *a; + HASH_TABLE *h; +#endif + + /* duplicate behavior of strchr(3) */ + t = skiparith (substr, ':'); + if (*t && *t == ':') + *t = '\0'; + else + t = (char *)0; + + temp1 = expand_arith_string (substr, Q_DOUBLE_QUOTES); + *e1p = evalexp (temp1, &expok); + free (temp1); + if (expok == 0) + return (0); + + len = -1; /* paranoia */ + switch (vtype) + { + case VT_VARIABLE: + case VT_ARRAYMEMBER: + len = MB_STRLEN (value); + break; + case VT_POSPARMS: + len = number_of_args () + 1; + if (*e1p == 0) + len++; /* add one arg if counting from $0 */ + break; +#if defined (ARRAY_VARS) + case VT_ARRAYVAR: + /* For arrays, the first value deals with array indices. Negative + offsets count from one past the array's maximum index. Associative + arrays treat the number of elements as the maximum index. */ + if (assoc_p (v)) + { + h = assoc_cell (v); + len = assoc_num_elements (h) + (*e1p < 0); + } + else + { + a = (ARRAY *)value; + len = array_max_index (a) + (*e1p < 0); /* arrays index from 0 to n - 1 */ + } + break; +#endif + } + + if (len == -1) /* paranoia */ + return -1; + + if (*e1p < 0) /* negative offsets count from end */ + *e1p += len; + + if (*e1p > len || *e1p < 0) + return (-1); + +#if defined (ARRAY_VARS) + /* For arrays, the second offset deals with the number of elements. */ + if (vtype == VT_ARRAYVAR) + len = assoc_p (v) ? assoc_num_elements (h) : array_num_elements (a); +#endif + + if (t) + { + t++; + temp2 = savestring (t); + temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES); + free (temp2); + t[-1] = ':'; + *e2p = evalexp (temp1, &expok); + free (temp1); + if (expok == 0) + return (0); +#if 1 + if ((vtype == VT_ARRAYVAR || vtype == VT_POSPARMS) && *e2p < 0) +#else + /* bash-4.3: allow positional parameter length < 0 to count backwards + from end of positional parameters */ + if (vtype == VT_ARRAYVAR && *e2p < 0) +#endif + { + internal_error (_("%s: substring expression < 0"), t); + return (0); + } +#if defined (ARRAY_VARS) + /* In order to deal with sparse arrays, push the intelligence about how + to deal with the number of elements desired down to the array- + specific functions. */ + if (vtype != VT_ARRAYVAR) +#endif + { + if (*e2p < 0) + { + *e2p += len; + if (*e2p < 0 || *e2p < *e1p) + { + internal_error (_("%s: substring expression < 0"), t); + return (0); + } + } + else + *e2p += *e1p; /* want E2 chars starting at E1 */ + if (*e2p > len) + *e2p = len; + } + } + else + *e2p = len; + + return (1); +} + +/* Return the type of variable specified by VARNAME (simple variable, + positional param, or array variable). Also return the value specified + by VARNAME (value of a variable or a reference to an array element). + QUOTED is the standard description of quoting state, using Q_* defines. + FLAGS is currently a set of flags to pass to array_value. If IND is + non-null and not INTMAX_MIN, and FLAGS includes AV_USEIND, IND is + passed to array_value so the array index is not computed again. + If this returns VT_VARIABLE, the caller assumes that CTLESC and CTLNUL + characters in the value are quoted with CTLESC and takes appropriate + steps. For convenience, *VALP is set to the dequoted VALUE. */ +static int +get_var_and_type (varname, value, ind, quoted, flags, varp, valp) + char *varname, *value; + arrayind_t ind; + int quoted, flags; + SHELL_VAR **varp; + char **valp; +{ + int vtype; + char *temp; +#if defined (ARRAY_VARS) + SHELL_VAR *v; +#endif + arrayind_t lind; + + /* This sets vtype to VT_VARIABLE or VT_POSPARMS */ + vtype = (varname[0] == '@' || varname[0] == '*') && varname[1] == '\0'; + if (vtype == VT_POSPARMS && varname[0] == '*') + vtype |= VT_STARSUB; + *varp = (SHELL_VAR *)NULL; + +#if defined (ARRAY_VARS) + if (valid_array_reference (varname)) + { + v = array_variable_part (varname, &temp, (int *)0); + /* If we want to signal array_value to use an already-computed index, + set LIND to that index */ + lind = (ind != INTMAX_MIN && (flags & AV_USEIND)) ? ind : 0; + if (v && (array_p (v) || assoc_p (v))) + { /* [ */ + if (ALL_ELEMENT_SUB (temp[0]) && temp[1] == ']') + { + /* Callers have to differentiate betwen indexed and associative */ + vtype = VT_ARRAYVAR; + if (temp[0] == '*') + vtype |= VT_STARSUB; + *valp = array_p (v) ? (char *)array_cell (v) : (char *)assoc_cell (v); + } + else + { + vtype = VT_ARRAYMEMBER; + *valp = array_value (varname, Q_DOUBLE_QUOTES, flags, (int *)NULL, &lind); + } + *varp = v; + } + else if (v && (ALL_ELEMENT_SUB (temp[0]) && temp[1] == ']')) + { + vtype = VT_VARIABLE; + *varp = v; + if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) + *valp = dequote_string (value); + else + *valp = dequote_escapes (value); + } + else + { + vtype = VT_ARRAYMEMBER; + *varp = v; + *valp = array_value (varname, Q_DOUBLE_QUOTES, flags, (int *)NULL, &lind); + } + } + else if ((v = find_variable (varname)) && (invisible_p (v) == 0) && (assoc_p (v) || array_p (v))) + { + vtype = VT_ARRAYMEMBER; + *varp = v; + *valp = assoc_p (v) ? assoc_reference (assoc_cell (v), "0") : array_reference (array_cell (v), 0); + } + else +#endif + { + if (value && vtype == VT_VARIABLE) + { + if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) + *valp = dequote_string (value); + else + *valp = dequote_escapes (value); + } + else + *valp = value; + } + + return vtype; +} + +/******************************************************/ +/* */ +/* Functions to extract substrings of variable values */ +/* */ +/******************************************************/ + +#if defined (HANDLE_MULTIBYTE) +/* Character-oriented rather than strictly byte-oriented substrings. S and + E, rather being strict indices into STRING, indicate character (possibly + multibyte character) positions that require calculation. + Used by the ${param:offset[:length]} expansion. */ +static char * +mb_substring (string, s, e) + char *string; + int s, e; +{ + char *tt; + int start, stop, i, slen; + DECLARE_MBSTATE; + + start = 0; + /* Don't need string length in ADVANCE_CHAR unless multibyte chars possible. */ + slen = (MB_CUR_MAX > 1) ? STRLEN (string) : 0; + + i = s; + while (string[start] && i--) + ADVANCE_CHAR (string, slen, start); + stop = start; + i = e - s; + while (string[stop] && i--) + ADVANCE_CHAR (string, slen, stop); + tt = substring (string, start, stop); + return tt; +} +#endif + +/* Process a variable substring expansion: ${name:e1[:e2]}. If VARNAME + is `@', use the positional parameters; otherwise, use the value of + VARNAME. If VARNAME is an array variable, use the array elements. */ + +static char * +parameter_brace_substring (varname, value, ind, substr, quoted, flags) + char *varname, *value; + int ind; + char *substr; + int quoted, flags; +{ + intmax_t e1, e2; + int vtype, r, starsub; + char *temp, *val, *tt, *oname; + SHELL_VAR *v; + + if (value == 0) + return ((char *)NULL); + + oname = this_command_name; + this_command_name = varname; + + vtype = get_var_and_type (varname, value, ind, quoted, flags, &v, &val); + if (vtype == -1) + { + this_command_name = oname; + return ((char *)NULL); + } + + starsub = vtype & VT_STARSUB; + vtype &= ~VT_STARSUB; + + r = verify_substring_values (v, val, substr, vtype, &e1, &e2); + this_command_name = oname; + if (r <= 0) + { + if (vtype == VT_VARIABLE) + FREE (val); + return ((r == 0) ? &expand_param_error : (char *)NULL); + } + + switch (vtype) + { + case VT_VARIABLE: + case VT_ARRAYMEMBER: +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1) + tt = mb_substring (val, e1, e2); + else +#endif + tt = substring (val, e1, e2); + + if (vtype == VT_VARIABLE) + FREE (val); + if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) + temp = quote_string (tt); + else + temp = tt ? quote_escapes (tt) : (char *)NULL; + FREE (tt); + break; + case VT_POSPARMS: + tt = pos_params (varname, e1, e2, quoted); + if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) == 0) + { + temp = tt ? quote_escapes (tt) : (char *)NULL; + FREE (tt); + } + else + temp = tt; + break; +#if defined (ARRAY_VARS) + case VT_ARRAYVAR: + if (assoc_p (v)) + /* we convert to list and take first e2 elements starting at e1th + element -- officially undefined for now */ + temp = assoc_subrange (assoc_cell (v), e1, e2, starsub, quoted); + else + /* We want E2 to be the number of elements desired (arrays can be sparse, + so verify_substring_values just returns the numbers specified and we + rely on array_subrange to understand how to deal with them). */ + temp = array_subrange (array_cell (v), e1, e2, starsub, quoted); + /* array_subrange now calls array_quote_escapes as appropriate, so the + caller no longer needs to. */ + break; +#endif + default: + temp = (char *)NULL; + } + + return temp; +} + +/****************************************************************/ +/* */ +/* Functions to perform pattern substitution on variable values */ +/* */ +/****************************************************************/ + +static int +shouldexp_replacement (s) + char *s; +{ + register char *p; + + for (p = s; p && *p; p++) + { + if (*p == '\\') + p++; + else if (*p == '&') + return 1; + } + return 0; +} + +char * +pat_subst (string, pat, rep, mflags) + char *string, *pat, *rep; + int mflags; +{ + char *ret, *s, *e, *str, *rstr, *mstr; + int rsize, rptr, l, replen, mtype, rxpand, rslen, mlen; + + if (string == 0) + return (savestring ("")); + + mtype = mflags & MATCH_TYPEMASK; + +#if 0 /* bash-4.2 ? */ + rxpand = (rep && *rep) ? shouldexp_replacement (rep) : 0; +#else + rxpand = 0; +#endif + + /* Special cases: + * 1. A null pattern with mtype == MATCH_BEG means to prefix STRING + * with REP and return the result. + * 2. A null pattern with mtype == MATCH_END means to append REP to + * STRING and return the result. + * These don't understand or process `&' in the replacement string. + */ + if ((pat == 0 || *pat == 0) && (mtype == MATCH_BEG || mtype == MATCH_END)) + { + replen = STRLEN (rep); + l = STRLEN (string); + ret = (char *)xmalloc (replen + l + 2); + if (replen == 0) + strcpy (ret, string); + else if (mtype == MATCH_BEG) + { + strcpy (ret, rep); + strcpy (ret + replen, string); + } + else + { + strcpy (ret, string); + strcpy (ret + l, rep); + } + return (ret); + } + + ret = (char *)xmalloc (rsize = 64); + ret[0] = '\0'; + + for (replen = STRLEN (rep), rptr = 0, str = string;;) + { + if (match_pattern (str, pat, mtype, &s, &e) == 0) + break; + l = s - str; + + if (rxpand) + { + int x; + mlen = e - s; + mstr = xmalloc (mlen + 1); + for (x = 0; x < mlen; x++) + mstr[x] = s[x]; + mstr[mlen] = '\0'; + rstr = strcreplace (rep, '&', mstr, 0); + rslen = strlen (rstr); + } + else + { + rstr = rep; + rslen = replen; + } + + RESIZE_MALLOCED_BUFFER (ret, rptr, (l + rslen), rsize, 64); + + /* OK, now copy the leading unmatched portion of the string (from + str to s) to ret starting at rptr (the current offset). Then copy + the replacement string at ret + rptr + (s - str). Increment + rptr (if necessary) and str and go on. */ + if (l) + { + strncpy (ret + rptr, str, l); + rptr += l; + } + if (replen) + { + strncpy (ret + rptr, rstr, rslen); + rptr += rslen; + } + str = e; /* e == end of match */ + + if (rstr != rep) + free (rstr); + + if (((mflags & MATCH_GLOBREP) == 0) || mtype != MATCH_ANY) + break; + + if (s == e) + { + /* On a zero-length match, make sure we copy one character, since + we increment one character to avoid infinite recursion. */ + RESIZE_MALLOCED_BUFFER (ret, rptr, 1, rsize, 64); + ret[rptr++] = *str++; + e++; /* avoid infinite recursion on zero-length match */ + } + } + + /* Now copy the unmatched portion of the input string */ + if (str && *str) + { + RESIZE_MALLOCED_BUFFER (ret, rptr, STRLEN(str) + 1, rsize, 64); + strcpy (ret + rptr, str); + } + else + ret[rptr] = '\0'; + + return ret; +} + +/* Do pattern match and replacement on the positional parameters. */ +static char * +pos_params_pat_subst (string, pat, rep, mflags) + char *string, *pat, *rep; + int mflags; +{ + WORD_LIST *save, *params; + WORD_DESC *w; + char *ret; + int pchar, qflags; + + save = params = list_rest_of_args (); + if (save == 0) + return ((char *)NULL); + + for ( ; params; params = params->next) + { + ret = pat_subst (params->word->word, pat, rep, mflags); + w = alloc_word_desc (); + w->word = ret ? ret : savestring (""); + dispose_word (params->word); + params->word = w; + } + + pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@'; + qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0; + +#if 0 + if ((mflags & (MATCH_QUOTED|MATCH_STARSUB)) == (MATCH_QUOTED|MATCH_STARSUB)) + ret = string_list_dollar_star (quote_list (save)); + else if ((mflags & MATCH_STARSUB) == MATCH_STARSUB) + ret = string_list_dollar_star (save); + else if ((mflags & MATCH_QUOTED) == MATCH_QUOTED) + ret = string_list_dollar_at (save, qflags); + else + ret = string_list_dollar_star (save); +#else + ret = string_list_pos_params (pchar, save, qflags); +#endif + + dispose_words (save); + + return (ret); +} + +/* Perform pattern substitution on VALUE, which is the expansion of + VARNAME. PATSUB is an expression supplying the pattern to match + and the string to substitute. QUOTED is a flags word containing + the type of quoting currently in effect. */ +static char * +parameter_brace_patsub (varname, value, ind, patsub, quoted, flags) + char *varname, *value; + int ind; + char *patsub; + int quoted, flags; +{ + int vtype, mflags, starsub, delim; + char *val, *temp, *pat, *rep, *p, *lpatsub, *tt; + SHELL_VAR *v; + + if (value == 0) + return ((char *)NULL); + + this_command_name = varname; + + vtype = get_var_and_type (varname, value, ind, quoted, flags, &v, &val); + if (vtype == -1) + return ((char *)NULL); + + starsub = vtype & VT_STARSUB; + vtype &= ~VT_STARSUB; + + mflags = 0; + /* PATSUB is never NULL when this is called. */ + if (*patsub == '/') + { + mflags |= MATCH_GLOBREP; + patsub++; + } + + /* Malloc this because expand_string_if_necessary or one of the expansion + functions in its call chain may free it on a substitution error. */ + lpatsub = savestring (patsub); + + if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + mflags |= MATCH_QUOTED; + + if (starsub) + mflags |= MATCH_STARSUB; + + /* If the pattern starts with a `/', make sure we skip over it when looking + for the replacement delimiter. */ + delim = skip_to_delim (lpatsub, ((*patsub == '/') ? 1 : 0), "/", 0); + if (lpatsub[delim] == '/') + { + lpatsub[delim] = 0; + rep = lpatsub + delim + 1; + } + else + rep = (char *)NULL; + + if (rep && *rep == '\0') + rep = (char *)NULL; + + /* Perform the same expansions on the pattern as performed by the + pattern removal expansions. */ + pat = getpattern (lpatsub, quoted, 1); + + if (rep) + /* We want to perform quote removal on the expanded replacement even if + the entire expansion is double-quoted because the parser and string + extraction functions treated quotes in the replacement string as + special. */ + rep = expand_string_if_necessary (rep, quoted & ~(Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT), expand_string_unsplit); + + /* ksh93 doesn't allow the match specifier to be a part of the expanded + pattern. This is an extension. Make sure we don't anchor the pattern + at the beginning or end of the string if we're doing global replacement, + though. */ + p = pat; + if (mflags & MATCH_GLOBREP) + mflags |= MATCH_ANY; + else if (pat && pat[0] == '#') + { + mflags |= MATCH_BEG; + p++; + } + else if (pat && pat[0] == '%') + { + mflags |= MATCH_END; + p++; + } + else + mflags |= MATCH_ANY; + + /* OK, we now want to substitute REP for PAT in VAL. If + flags & MATCH_GLOBREP is non-zero, the substitution is done + everywhere, otherwise only the first occurrence of PAT is + replaced. The pattern matching code doesn't understand + CTLESC quoting CTLESC and CTLNUL so we use the dequoted variable + values passed in (VT_VARIABLE) so the pattern substitution + code works right. We need to requote special chars after + we're done for VT_VARIABLE and VT_ARRAYMEMBER, and for the + other cases if QUOTED == 0, since the posparams and arrays + indexed by * or @ do special things when QUOTED != 0. */ + + switch (vtype) + { + case VT_VARIABLE: + case VT_ARRAYMEMBER: + temp = pat_subst (val, p, rep, mflags); + if (vtype == VT_VARIABLE) + FREE (val); + if (temp) + { + tt = (mflags & MATCH_QUOTED) ? quote_string (temp) : quote_escapes (temp); + free (temp); + temp = tt; + } + break; + case VT_POSPARMS: + temp = pos_params_pat_subst (val, p, rep, mflags); + if (temp && (mflags & MATCH_QUOTED) == 0) + { + tt = quote_escapes (temp); + free (temp); + temp = tt; + } + break; +#if defined (ARRAY_VARS) + case VT_ARRAYVAR: + temp = assoc_p (v) ? assoc_patsub (assoc_cell (v), p, rep, mflags) + : array_patsub (array_cell (v), p, rep, mflags); + /* Don't call quote_escapes anymore; array_patsub calls + array_quote_escapes as appropriate before adding the + space separators; ditto for assoc_patsub. */ + break; +#endif + } + + FREE (pat); + FREE (rep); + free (lpatsub); + + return temp; +} + +/****************************************************************/ +/* */ +/* Functions to perform case modification on variable values */ +/* */ +/****************************************************************/ + +/* Do case modification on the positional parameters. */ + +static char * +pos_params_modcase (string, pat, modop, mflags) + char *string, *pat; + int modop; + int mflags; +{ + WORD_LIST *save, *params; + WORD_DESC *w; + char *ret; + int pchar, qflags; + + save = params = list_rest_of_args (); + if (save == 0) + return ((char *)NULL); + + for ( ; params; params = params->next) + { + ret = sh_modcase (params->word->word, pat, modop); + w = alloc_word_desc (); + w->word = ret ? ret : savestring (""); + dispose_word (params->word); + params->word = w; + } + + pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@'; + qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0; + + ret = string_list_pos_params (pchar, save, qflags); + dispose_words (save); + + return (ret); +} + +/* Perform case modification on VALUE, which is the expansion of + VARNAME. MODSPEC is an expression supplying the type of modification + to perform. QUOTED is a flags word containing the type of quoting + currently in effect. */ +static char * +parameter_brace_casemod (varname, value, ind, modspec, patspec, quoted, flags) + char *varname, *value; + int ind, modspec; + char *patspec; + int quoted, flags; +{ + int vtype, starsub, modop, mflags, x; + char *val, *temp, *pat, *p, *lpat, *tt; + SHELL_VAR *v; + + if (value == 0) + return ((char *)NULL); + + this_command_name = varname; + + vtype = get_var_and_type (varname, value, ind, quoted, flags, &v, &val); + if (vtype == -1) + return ((char *)NULL); + + starsub = vtype & VT_STARSUB; + vtype &= ~VT_STARSUB; + + modop = 0; + mflags = 0; + if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + mflags |= MATCH_QUOTED; + if (starsub) + mflags |= MATCH_STARSUB; + + p = patspec; + if (modspec == '^') + { + x = p && p[0] == modspec; + modop = x ? CASE_UPPER : CASE_UPFIRST; + p += x; + } + else if (modspec == ',') + { + x = p && p[0] == modspec; + modop = x ? CASE_LOWER : CASE_LOWFIRST; + p += x; + } + else if (modspec == '~') + { + x = p && p[0] == modspec; + modop = x ? CASE_TOGGLEALL : CASE_TOGGLE; + p += x; + } + + lpat = p ? savestring (p) : 0; + /* Perform the same expansions on the pattern as performed by the + pattern removal expansions. FOR LATER */ + pat = lpat ? getpattern (lpat, quoted, 1) : 0; + + /* OK, now we do the case modification. */ + switch (vtype) + { + case VT_VARIABLE: + case VT_ARRAYMEMBER: + temp = sh_modcase (val, pat, modop); + if (vtype == VT_VARIABLE) + FREE (val); + if (temp) + { + tt = (mflags & MATCH_QUOTED) ? quote_string (temp) : quote_escapes (temp); + free (temp); + temp = tt; + } + break; + + case VT_POSPARMS: + temp = pos_params_modcase (val, pat, modop, mflags); + if (temp && (mflags & MATCH_QUOTED) == 0) + { + tt = quote_escapes (temp); + free (temp); + temp = tt; + } + break; + +#if defined (ARRAY_VARS) + case VT_ARRAYVAR: + temp = assoc_p (v) ? assoc_modcase (assoc_cell (v), pat, modop, mflags) + : array_modcase (array_cell (v), pat, modop, mflags); + /* Don't call quote_escapes; array_modcase calls array_quote_escapes + as appropriate before adding the space separators; ditto for + assoc_modcase. */ + break; +#endif + } + + FREE (pat); + free (lpat); + + return temp; +} + +/* Check for unbalanced parens in S, which is the contents of $(( ... )). If + any occur, this must be a nested command substitution, so return 0. + Otherwise, return 1. A valid arithmetic expression must always have a + ( before a matching ), so any cases where there are more right parens + means that this must not be an arithmetic expression, though the parser + will not accept it without a balanced total number of parens. */ +static int +chk_arithsub (s, len) + const char *s; + int len; +{ + int i, count; + DECLARE_MBSTATE; + + i = count = 0; + while (i < len) + { + if (s[i] == LPAREN) + count++; + else if (s[i] == RPAREN) + { + count--; + if (count < 0) + return 0; + } + + switch (s[i]) + { + default: + ADVANCE_CHAR (s, len, i); + break; + + case '\\': + i++; + if (s[i]) + ADVANCE_CHAR (s, len, i); + break; + + case '\'': + i = skip_single_quoted (s, len, ++i); + break; + + case '"': + i = skip_double_quoted ((char *)s, len, ++i); + break; + } + } + + return (count == 0); +} + +/****************************************************************/ +/* */ +/* Functions to perform parameter expansion on a string */ +/* */ +/****************************************************************/ + +/* ${[#][!]name[[:][^[^]][,[,]]#[#]%[%]-=?+[word][:e1[:e2]]]} */ +static WORD_DESC * +parameter_brace_expand (string, indexp, quoted, pflags, quoted_dollar_atp, contains_dollar_at) + char *string; + int *indexp, quoted, *quoted_dollar_atp, *contains_dollar_at, pflags; +{ + int check_nullness, var_is_set, var_is_null, var_is_special; + int want_substring, want_indir, want_patsub, want_casemod; + char *name, *value, *temp, *temp1; + WORD_DESC *tdesc, *ret; + int t_index, sindex, c, tflag, modspec; + intmax_t number; + arrayind_t ind; + + temp = temp1 = value = (char *)NULL; + var_is_set = var_is_null = var_is_special = check_nullness = 0; + want_substring = want_indir = want_patsub = want_casemod = 0; + + sindex = *indexp; + t_index = ++sindex; + /* ${#var} doesn't have any of the other parameter expansions on it. */ + if (string[t_index] == '#' && legal_variable_starter (string[t_index+1])) /* {{ */ + name = string_extract (string, &t_index, "}", SX_VARNAME); + else +#if defined (CASEMOD_EXPANSIONS) + /* To enable case-toggling expansions using the `~' operator character + change the 1 to 0. */ +# if defined (CASEMOD_CAPCASE) + name = string_extract (string, &t_index, "#%^,~:-=?+/}", SX_VARNAME); +# else + name = string_extract (string, &t_index, "#%^,:-=?+/}", SX_VARNAME); +# endif /* CASEMOD_CAPCASE */ +#else + name = string_extract (string, &t_index, "#%:-=?+/}", SX_VARNAME); +#endif /* CASEMOD_EXPANSIONS */ + + ret = 0; + tflag = 0; + + ind = INTMAX_MIN; + + /* If the name really consists of a special variable, then make sure + that we have the entire name. We don't allow indirect references + to special variables except `#', `?', `@' and `*'. */ + if ((sindex == t_index && VALID_SPECIAL_LENGTH_PARAM (string[t_index])) || + (sindex == t_index - 1 && string[sindex] == '!' && VALID_INDIR_PARAM (string[t_index]))) + { + t_index++; + temp1 = string_extract (string, &t_index, "#%:-=?+/}", 0); + name = (char *)xrealloc (name, 3 + (strlen (temp1))); + *name = string[sindex]; + if (string[sindex] == '!') + { + /* indirect reference of $#, $?, $@, or $* */ + name[1] = string[sindex + 1]; + strcpy (name + 2, temp1); + } + else + strcpy (name + 1, temp1); + free (temp1); + } + sindex = t_index; + + /* Find out what character ended the variable name. Then + do the appropriate thing. */ + if (c = string[sindex]) + sindex++; + + /* If c is followed by one of the valid parameter expansion + characters, move past it as normal. If not, assume that + a substring specification is being given, and do not move + past it. */ + if (c == ':' && VALID_PARAM_EXPAND_CHAR (string[sindex])) + { + check_nullness++; + if (c = string[sindex]) + sindex++; + } + else if (c == ':' && string[sindex] != RBRACE) + want_substring = 1; + else if (c == '/' /* && string[sindex] != RBRACE */) /* XXX */ + want_patsub = 1; +#if defined (CASEMOD_EXPANSIONS) + else if (c == '^' || c == ',' || c == '~') + { + modspec = c; + want_casemod = 1; + } +#endif + + /* Catch the valid and invalid brace expressions that made it through the + tests above. */ + /* ${#-} is a valid expansion and means to take the length of $-. + Similarly for ${#?} and ${##}... */ + if (name[0] == '#' && name[1] == '\0' && check_nullness == 0 && + VALID_SPECIAL_LENGTH_PARAM (c) && string[sindex] == RBRACE) + { + name = (char *)xrealloc (name, 3); + name[1] = c; + name[2] = '\0'; + c = string[sindex++]; + } + + /* ...but ${#%}, ${#:}, ${#=}, ${#+}, and ${#/} are errors. */ + if (name[0] == '#' && name[1] == '\0' && check_nullness == 0 && + member (c, "%:=+/") && string[sindex] == RBRACE) + { + temp = (char *)NULL; + goto bad_substitution; + } + + /* Indirect expansion begins with a `!'. A valid indirect expansion is + either a variable name, one of the positional parameters or a special + variable that expands to one of the positional parameters. */ + want_indir = *name == '!' && + (legal_variable_starter ((unsigned char)name[1]) || DIGIT (name[1]) + || VALID_INDIR_PARAM (name[1])); + + /* Determine the value of this variable. */ + + /* Check for special variables, directly referenced. */ + if (SPECIAL_VAR (name, want_indir)) + var_is_special++; + + /* Check for special expansion things, like the length of a parameter */ + if (*name == '#' && name[1]) + { + /* If we are not pointing at the character just after the + closing brace, then we haven't gotten all of the name. + Since it begins with a special character, this is a bad + substitution. Also check NAME for validity before trying + to go on. */ + if (string[sindex - 1] != RBRACE || (valid_length_expression (name) == 0)) + { + temp = (char *)NULL; + goto bad_substitution; + } + + number = parameter_brace_expand_length (name); + if (number == INTMAX_MIN && unbound_vars_is_error) + { + last_command_exit_value = EXECUTION_FAILURE; + err_unboundvar (name+1); + free (name); + return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal); + } + free (name); + + *indexp = sindex; + if (number < 0) + return (&expand_wdesc_error); + else + { + ret = alloc_word_desc (); + ret->word = itos (number); + return ret; + } + } + + /* ${@} is identical to $@. */ + if (name[0] == '@' && name[1] == '\0') + { + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp) + *quoted_dollar_atp = 1; + + if (contains_dollar_at) + *contains_dollar_at = 1; + + tflag |= W_DOLLARAT; + } + + /* Process ${!PREFIX*} expansion. */ + if (want_indir && string[sindex - 1] == RBRACE && + (string[sindex - 2] == '*' || string[sindex - 2] == '@') && + legal_variable_starter ((unsigned char) name[1])) + { + char **x; + WORD_LIST *xlist; + + temp1 = savestring (name + 1); + number = strlen (temp1); + temp1[number - 1] = '\0'; + x = all_variables_matching_prefix (temp1); + xlist = strvec_to_word_list (x, 0, 0); + if (string[sindex - 2] == '*') + temp = string_list_dollar_star (xlist); + else + { + temp = string_list_dollar_at (xlist, quoted); + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp) + *quoted_dollar_atp = 1; + if (contains_dollar_at) + *contains_dollar_at = 1; + + tflag |= W_DOLLARAT; + } + free (x); + dispose_words (xlist); + free (temp1); + *indexp = sindex; + + free (name); + + ret = alloc_word_desc (); + ret->word = temp; + ret->flags = tflag; /* XXX */ + return ret; + } + +#if defined (ARRAY_VARS) + /* Process ${!ARRAY[@]} and ${!ARRAY[*]} expansion. */ /* [ */ + if (want_indir && string[sindex - 1] == RBRACE && + string[sindex - 2] == ']' && valid_array_reference (name+1)) + { + char *x, *x1; + + temp1 = savestring (name + 1); + x = array_variable_name (temp1, &x1, (int *)0); /* [ */ + FREE (x); + if (ALL_ELEMENT_SUB (x1[0]) && x1[1] == ']') + { + temp = array_keys (temp1, quoted); /* handles assoc vars too */ + if (x1[0] == '@') + { + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp) + *quoted_dollar_atp = 1; + if (contains_dollar_at) + *contains_dollar_at = 1; + + tflag |= W_DOLLARAT; + } + + free (temp1); + *indexp = sindex; + + ret = alloc_word_desc (); + ret->word = temp; + ret->flags = tflag; /* XXX */ + return ret; + } + + free (temp1); + } +#endif /* ARRAY_VARS */ + + /* Make sure that NAME is valid before trying to go on. */ + if (valid_brace_expansion_word (want_indir ? name + 1 : name, + var_is_special) == 0) + { + temp = (char *)NULL; + goto bad_substitution; + } + + if (want_indir) + tdesc = parameter_brace_expand_indir (name + 1, var_is_special, quoted, quoted_dollar_atp, contains_dollar_at); + else + tdesc = parameter_brace_expand_word (name, var_is_special, quoted, PF_IGNUNBOUND|(pflags&PF_NOSPLIT2), &ind); + + if (tdesc) + { + temp = tdesc->word; + tflag = tdesc->flags; + dispose_word_desc (tdesc); + } + else + temp = (char *)0; + + if (temp == &expand_param_error || temp == &expand_param_fatal) + { + FREE (name); + FREE (value); + return (temp == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal); + } + +#if defined (ARRAY_VARS) + if (valid_array_reference (name)) + chk_atstar (name, quoted, quoted_dollar_atp, contains_dollar_at); +#endif + + var_is_set = temp != (char *)0; + var_is_null = check_nullness && (var_is_set == 0 || *temp == 0); + /* XXX - this may not need to be restricted to special variables */ + if (check_nullness) + var_is_null |= var_is_set && var_is_special && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL (temp); + + /* Get the rest of the stuff inside the braces. */ + if (c && c != RBRACE) + { + /* Extract the contents of the ${ ... } expansion + according to the Posix.2 rules. */ + value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD); + if (string[sindex] == RBRACE) + sindex++; + else + goto bad_substitution; + } + else + value = (char *)NULL; + + *indexp = sindex; + + /* All the cases where an expansion can possibly generate an unbound + variable error. */ + if (want_substring || want_patsub || want_casemod || c == '#' || c == '%' || c == RBRACE) + { + if (var_is_set == 0 && unbound_vars_is_error && ((name[0] != '@' && name[0] != '*') || name[1])) + { + last_command_exit_value = EXECUTION_FAILURE; + err_unboundvar (name); + FREE (value); + FREE (temp); + free (name); + return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal); + } + } + + /* If this is a substring spec, process it and add the result. */ + if (want_substring) + { + temp1 = parameter_brace_substring (name, temp, ind, value, quoted, (tflag & W_ARRAYIND) ? AV_USEIND : 0); + FREE (name); + FREE (value); + FREE (temp); + + if (temp1 == &expand_param_error) + return (&expand_wdesc_error); + else if (temp1 == &expand_param_fatal) + return (&expand_wdesc_fatal); + + ret = alloc_word_desc (); + ret->word = temp1; + if (temp1 && QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + ret->flags |= W_QUOTED|W_HASQUOTEDNULL; + return ret; + } + else if (want_patsub) + { + temp1 = parameter_brace_patsub (name, temp, ind, value, quoted, (tflag & W_ARRAYIND) ? AV_USEIND : 0); + FREE (name); + FREE (value); + FREE (temp); + + if (temp1 == &expand_param_error) + return (&expand_wdesc_error); + else if (temp1 == &expand_param_fatal) + return (&expand_wdesc_fatal); + + ret = alloc_word_desc (); + ret->word = temp1; + if (temp1 && QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + ret->flags |= W_QUOTED|W_HASQUOTEDNULL; + return ret; + } +#if defined (CASEMOD_EXPANSIONS) + else if (want_casemod) + { + temp1 = parameter_brace_casemod (name, temp, ind, modspec, value, quoted, (tflag & W_ARRAYIND) ? AV_USEIND : 0); + FREE (name); + FREE (value); + FREE (temp); + + if (temp1 == &expand_param_error) + return (&expand_wdesc_error); + else if (temp1 == &expand_param_fatal) + return (&expand_wdesc_fatal); + + ret = alloc_word_desc (); + ret->word = temp1; + if (temp1 && QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + ret->flags |= W_QUOTED|W_HASQUOTEDNULL; + return ret; + } +#endif + + /* Do the right thing based on which character ended the variable name. */ + switch (c) + { + default: + case '\0': + bad_substitution: + last_command_exit_value = EXECUTION_FAILURE; + report_error (_("%s: bad substitution"), string ? string : "??"); + FREE (value); + FREE (temp); + free (name); + return &expand_wdesc_error; + + case RBRACE: + break; + + case '#': /* ${param#[#]pattern} */ + case '%': /* ${param%[%]pattern} */ + if (value == 0 || *value == '\0' || temp == 0 || *temp == '\0') + { + FREE (value); + break; + } + temp1 = parameter_brace_remove_pattern (name, temp, ind, value, c, quoted, (tflag & W_ARRAYIND) ? AV_USEIND : 0); + free (temp); + free (value); + free (name); + + ret = alloc_word_desc (); + ret->word = temp1; + if (temp1 && QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + ret->flags |= W_QUOTED|W_HASQUOTEDNULL; + return ret; + + case '-': + case '=': + case '?': + case '+': + if (var_is_set && var_is_null == 0) + { + /* If the operator is `+', we don't want the value of the named + variable for anything, just the value of the right hand side. */ + if (c == '+') + { + /* XXX -- if we're double-quoted and the named variable is "$@", + we want to turn off any special handling of "$@" -- + we're not using it, so whatever is on the rhs applies. */ + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp) + *quoted_dollar_atp = 0; + if (contains_dollar_at) + *contains_dollar_at = 0; + + FREE (temp); + if (value) + { + /* From Posix discussion on austin-group list. Issue 221 + requires that backslashes escaping `}' inside + double-quoted ${...} be removed. */ + if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + quoted |= Q_DOLBRACE; + ret = parameter_brace_expand_rhs (name, value, c, + quoted, + quoted_dollar_atp, + contains_dollar_at); + /* XXX - fix up later, esp. noting presence of + W_HASQUOTEDNULL in ret->flags */ + free (value); + } + else + temp = (char *)NULL; + } + else + { + FREE (value); + } + /* Otherwise do nothing; just use the value in TEMP. */ + } + else /* VAR not set or VAR is NULL. */ + { + FREE (temp); + temp = (char *)NULL; + if (c == '=' && var_is_special) + { + last_command_exit_value = EXECUTION_FAILURE; + report_error (_("$%s: cannot assign in this way"), name); + free (name); + free (value); + return &expand_wdesc_error; + } + else if (c == '?') + { + parameter_brace_expand_error (name, value); + return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal); + } + else if (c != '+') + { + /* XXX -- if we're double-quoted and the named variable is "$@", + we want to turn off any special handling of "$@" -- + we're not using it, so whatever is on the rhs applies. */ + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp) + *quoted_dollar_atp = 0; + if (contains_dollar_at) + *contains_dollar_at = 0; + + /* From Posix discussion on austin-group list. Issue 221 requires + that backslashes escaping `}' inside double-quoted ${...} be + removed. */ + if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + quoted |= Q_DOLBRACE; + ret = parameter_brace_expand_rhs (name, value, c, quoted, + quoted_dollar_atp, + contains_dollar_at); + /* XXX - fix up later, esp. noting presence of + W_HASQUOTEDNULL in tdesc->flags */ + } + free (value); + } + + break; + } + free (name); + + if (ret == 0) + { + ret = alloc_word_desc (); + ret->flags = tflag; + ret->word = temp; + } + return (ret); +} + +/* Expand a single ${xxx} expansion. The braces are optional. When + the braces are used, parameter_brace_expand() does the work, + possibly calling param_expand recursively. */ +static WORD_DESC * +param_expand (string, sindex, quoted, expanded_something, + contains_dollar_at, quoted_dollar_at_p, had_quoted_null_p, + pflags) + char *string; + int *sindex, quoted, *expanded_something, *contains_dollar_at; + int *quoted_dollar_at_p, *had_quoted_null_p, pflags; +{ + char *temp, *temp1, uerror[3]; + int zindex, t_index, expok; + unsigned char c; + intmax_t number; + SHELL_VAR *var; + WORD_LIST *list; + WORD_DESC *tdesc, *ret; + int tflag; + + zindex = *sindex; + c = string[++zindex]; + + temp = (char *)NULL; + ret = tdesc = (WORD_DESC *)NULL; + tflag = 0; + + /* Do simple cases first. Switch on what follows '$'. */ + switch (c) + { + /* $0 .. $9? */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + temp1 = dollar_vars[TODIGIT (c)]; + if (unbound_vars_is_error && temp1 == (char *)NULL) + { + uerror[0] = '$'; + uerror[1] = c; + uerror[2] = '\0'; + last_command_exit_value = EXECUTION_FAILURE; + err_unboundvar (uerror); + return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal); + } + if (temp1) + temp = (*temp1 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + ? quote_string (temp1) + : quote_escapes (temp1); + else + temp = (char *)NULL; + + break; + + /* $$ -- pid of the invoking shell. */ + case '$': + temp = itos (dollar_dollar_pid); + break; + + /* $# -- number of positional parameters. */ + case '#': + temp = itos (number_of_args ()); + break; + + /* $? -- return value of the last synchronous command. */ + case '?': + temp = itos (last_command_exit_value); + break; + + /* $- -- flags supplied to the shell on invocation or by `set'. */ + case '-': + temp = which_set_flags (); + break; + + /* $! -- Pid of the last asynchronous command. */ + case '!': + /* If no asynchronous pids have been created, expand to nothing. + If `set -u' has been executed, and no async processes have + been created, this is an expansion error. */ + if (last_asynchronous_pid == NO_PID) + { + if (expanded_something) + *expanded_something = 0; + temp = (char *)NULL; + if (unbound_vars_is_error) + { + uerror[0] = '$'; + uerror[1] = c; + uerror[2] = '\0'; + last_command_exit_value = EXECUTION_FAILURE; + err_unboundvar (uerror); + return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal); + } + } + else + temp = itos (last_asynchronous_pid); + break; + + /* The only difference between this and $@ is when the arg is quoted. */ + case '*': /* `$*' */ + list = list_rest_of_args (); + +#if 0 + /* According to austin-group posix proposal by Geoff Clare in + <20090505091501.GA10097@squonk.masqnet> of 5 May 2009: + + "The shell shall write a message to standard error and + immediately exit when it tries to expand an unset parameter + other than the '@' and '*' special parameters." + */ + + if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0) + { + uerror[0] = '$'; + uerror[1] = '*'; + uerror[2] = '\0'; + last_command_exit_value = EXECUTION_FAILURE; + err_unboundvar (uerror); + return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal); + } +#endif + + /* If there are no command-line arguments, this should just + disappear if there are other characters in the expansion, + even if it's quoted. */ + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && list == 0) + temp = (char *)NULL; + else if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES|Q_PATQUOTE)) + { + /* If we have "$*" we want to make a string of the positional + parameters, separated by the first character of $IFS, and + quote the whole string, including the separators. If IFS + is unset, the parameters are separated by ' '; if $IFS is + null, the parameters are concatenated. */ + temp = (quoted & (Q_DOUBLE_QUOTES|Q_PATQUOTE)) ? string_list_dollar_star (list) : string_list (list); + if (temp) + { + temp1 = quote_string (temp); + if (*temp == 0) + tflag |= W_HASQUOTEDNULL; + free (temp); + temp = temp1; + } + } + else + { + /* We check whether or not we're eventually going to split $* here, + for example when IFS is empty and we are processing the rhs of + an assignment statement. In that case, we don't separate the + arguments at all. Otherwise, if the $* is not quoted it is + identical to $@ */ +#if 1 +# if defined (HANDLE_MULTIBYTE) + if (expand_no_split_dollar_star && ifs_firstc[0] == 0) +# else + if (expand_no_split_dollar_star && ifs_firstc == 0) +# endif + temp = string_list_dollar_star (list); + else + temp = string_list_dollar_at (list, quoted); +#else + temp = string_list_dollar_at (list, quoted); +#endif + if (expand_no_split_dollar_star == 0 && contains_dollar_at) + *contains_dollar_at = 1; + } + + dispose_words (list); + break; + + /* When we have "$@" what we want is "$1" "$2" "$3" ... This + means that we have to turn quoting off after we split into + the individually quoted arguments so that the final split + on the first character of $IFS is still done. */ + case '@': /* `$@' */ + list = list_rest_of_args (); + +#if 0 + /* According to austin-group posix proposal by Geoff Clare in + <20090505091501.GA10097@squonk.masqnet> of 5 May 2009: + + "The shell shall write a message to standard error and + immediately exit when it tries to expand an unset parameter + other than the '@' and '*' special parameters." + */ + + if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0) + { + uerror[0] = '$'; + uerror[1] = '@'; + uerror[2] = '\0'; + last_command_exit_value = EXECUTION_FAILURE; + err_unboundvar (uerror); + return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal); + } +#endif + + /* We want to flag the fact that we saw this. We can't turn + off quoting entirely, because other characters in the + string might need it (consider "\"$@\""), but we need some + way to signal that the final split on the first character + of $IFS should be done, even though QUOTED is 1. */ + /* XXX - should this test include Q_PATQUOTE? */ + if (quoted_dollar_at_p && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + *quoted_dollar_at_p = 1; + if (contains_dollar_at) + *contains_dollar_at = 1; + + /* We want to separate the positional parameters with the first + character of $IFS in case $IFS is something other than a space. + We also want to make sure that splitting is done no matter what -- + according to POSIX.2, this expands to a list of the positional + parameters no matter what IFS is set to. */ + temp = string_list_dollar_at (list, (pflags & PF_ASSIGNRHS) ? (quoted|Q_DOUBLE_QUOTES) : quoted); + + tflag |= W_DOLLARAT; + dispose_words (list); + break; + + case LBRACE: + tdesc = parameter_brace_expand (string, &zindex, quoted, pflags, + quoted_dollar_at_p, + contains_dollar_at); + + if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal) + return (tdesc); + temp = tdesc ? tdesc->word : (char *)0; + + /* XXX */ + /* Quoted nulls should be removed if there is anything else + in the string. */ + /* Note that we saw the quoted null so we can add one back at + the end of this function if there are no other characters + in the string, discard TEMP, and go on. The exception to + this is when we have "${@}" and $1 is '', since $@ needs + special handling. */ + if (tdesc && tdesc->word && (tdesc->flags & W_HASQUOTEDNULL) && QUOTED_NULL (temp)) + { + if (had_quoted_null_p) + *had_quoted_null_p = 1; + if (*quoted_dollar_at_p == 0) + { + free (temp); + tdesc->word = temp = (char *)NULL; + } + + } + + ret = tdesc; + goto return0; + + /* Do command or arithmetic substitution. */ + case LPAREN: + /* We have to extract the contents of this paren substitution. */ + t_index = zindex + 1; + temp = extract_command_subst (string, &t_index, 0); + zindex = t_index; + + /* For Posix.2-style `$(( ))' arithmetic substitution, + extract the expression and pass it to the evaluator. */ + if (temp && *temp == LPAREN) + { + char *temp2; + temp1 = temp + 1; + temp2 = savestring (temp1); + t_index = strlen (temp2) - 1; + + if (temp2[t_index] != RPAREN) + { + free (temp2); + goto comsub; + } + + /* Cut off ending `)' */ + temp2[t_index] = '\0'; + + if (chk_arithsub (temp2, t_index) == 0) + { + free (temp2); +#if 0 + internal_warning (_("future versions of the shell will force evaluation as an arithmetic substitution")); +#endif + goto comsub; + } + + /* Expand variables found inside the expression. */ + temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES); + free (temp2); + +arithsub: + /* No error messages. */ + this_command_name = (char *)NULL; + number = evalexp (temp1, &expok); + free (temp); + free (temp1); + if (expok == 0) + { + if (interactive_shell == 0 && posixly_correct) + { + last_command_exit_value = EXECUTION_FAILURE; + return (&expand_wdesc_fatal); + } + else + return (&expand_wdesc_error); + } + temp = itos (number); + break; + } + +comsub: + if (pflags & PF_NOCOMSUB) + /* we need zindex+1 because string[zindex] == RPAREN */ + temp1 = substring (string, *sindex, zindex+1); + else + { + tdesc = command_substitute (temp, quoted); + temp1 = tdesc ? tdesc->word : (char *)NULL; + if (tdesc) + dispose_word_desc (tdesc); + } + FREE (temp); + temp = temp1; + break; + + /* Do POSIX.2d9-style arithmetic substitution. This will probably go + away in a future bash release. */ + case '[': + /* Extract the contents of this arithmetic substitution. */ + t_index = zindex + 1; + temp = extract_arithmetic_subst (string, &t_index); + zindex = t_index; + if (temp == 0) + { + temp = savestring (string); + if (expanded_something) + *expanded_something = 0; + goto return0; + } + + /* Do initial variable expansion. */ + temp1 = expand_arith_string (temp, Q_DOUBLE_QUOTES); + + goto arithsub; + + default: + /* Find the variable in VARIABLE_LIST. */ + temp = (char *)NULL; + + for (t_index = zindex; (c = string[zindex]) && legal_variable_char (c); zindex++) + ; + temp1 = (zindex > t_index) ? substring (string, t_index, zindex) : (char *)NULL; + + /* If this isn't a variable name, then just output the `$'. */ + if (temp1 == 0 || *temp1 == '\0') + { + FREE (temp1); + temp = (char *)xmalloc (2); + temp[0] = '$'; + temp[1] = '\0'; + if (expanded_something) + *expanded_something = 0; + goto return0; + } + + /* If the variable exists, return its value cell. */ + var = find_variable (temp1); + + if (var && invisible_p (var) == 0 && var_isset (var)) + { +#if defined (ARRAY_VARS) + if (assoc_p (var) || array_p (var)) + { + temp = array_p (var) ? array_reference (array_cell (var), 0) + : assoc_reference (assoc_cell (var), "0"); + if (temp) + temp = (*temp && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + ? quote_string (temp) + : quote_escapes (temp); + else if (unbound_vars_is_error) + goto unbound_variable; + } + else +#endif + { + temp = value_cell (var); + + temp = (*temp && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))) + ? quote_string (temp) + : quote_escapes (temp); + } + + free (temp1); + + goto return0; + } + else if (var = find_variable_last_nameref (temp1)) + { + temp = nameref_cell (var); +#if defined (ARRAY_VARS) + if (temp && *temp && valid_array_reference (temp)) + { + tdesc = parameter_brace_expand_word (temp, SPECIAL_VAR (temp, 0), quoted, pflags, (arrayind_t *)NULL); + if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal) + return (tdesc); + ret = tdesc; + goto return0; + } + else +#endif + /* y=2 ; typeset -n x=y; echo $x is not the same as echo $2 in ksh */ + if (temp && *temp && legal_identifier (temp) == 0) + { + last_command_exit_value = EXECUTION_FAILURE; + report_error (_("%s: invalid variable name for name reference"), temp); + return (&expand_wdesc_error); /* XXX */ + } + else + temp = (char *)NULL; + } + + temp = (char *)NULL; + +unbound_variable: + if (unbound_vars_is_error) + { + last_command_exit_value = EXECUTION_FAILURE; + err_unboundvar (temp1); + } + else + { + free (temp1); + goto return0; + } + + free (temp1); + last_command_exit_value = EXECUTION_FAILURE; + return ((unbound_vars_is_error && interactive_shell == 0) + ? &expand_wdesc_fatal + : &expand_wdesc_error); + } + + if (string[zindex]) + zindex++; + +return0: + *sindex = zindex; + + if (ret == 0) + { + ret = alloc_word_desc (); + ret->flags = tflag; /* XXX */ + ret->word = temp; + } + return ret; +} + +/* Make a word list which is the result of parameter and variable + expansion, command substitution, arithmetic substitution, and + quote removal of WORD. Return a pointer to a WORD_LIST which is + the result of the expansion. If WORD contains a null word, the + word list returned is also null. + + QUOTED contains flag values defined in shell.h. + + ISEXP is used to tell expand_word_internal that the word should be + treated as the result of an expansion. This has implications for + how IFS characters in the word are treated. + + CONTAINS_DOLLAR_AT and EXPANDED_SOMETHING are return values; when non-null + they point to an integer value which receives information about expansion. + CONTAINS_DOLLAR_AT gets non-zero if WORD contained "$@", else zero. + EXPANDED_SOMETHING get non-zero if WORD contained any parameter expansions, + else zero. + + This only does word splitting in the case of $@ expansion. In that + case, we split on ' '. */ + +/* Values for the local variable quoted_state. */ +#define UNQUOTED 0 +#define PARTIALLY_QUOTED 1 +#define WHOLLY_QUOTED 2 + +static WORD_LIST * +expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_something) + WORD_DESC *word; + int quoted, isexp; + int *contains_dollar_at; + int *expanded_something; +{ + WORD_LIST *list; + WORD_DESC *tword; + + /* The intermediate string that we build while expanding. */ + char *istring; + + /* The current size of the above object. */ + int istring_size; + + /* Index into ISTRING. */ + int istring_index; + + /* Temporary string storage. */ + char *temp, *temp1; + + /* The text of WORD. */ + register char *string; + + /* The size of STRING. */ + size_t string_size; + + /* The index into STRING. */ + int sindex; + + /* This gets 1 if we see a $@ while quoted. */ + int quoted_dollar_at; + + /* One of UNQUOTED, PARTIALLY_QUOTED, or WHOLLY_QUOTED, depending on + whether WORD contains no quoting characters, a partially quoted + string (e.g., "xx"ab), or is fully quoted (e.g., "xxab"). */ + int quoted_state; + + /* State flags */ + int had_quoted_null; + int has_dollar_at, temp_has_dollar_at; + int tflag; + int pflags; /* flags passed to param_expand */ + + int assignoff; /* If assignment, offset of `=' */ + + register unsigned char c; /* Current character. */ + int t_index; /* For calls to string_extract_xxx. */ + + char twochars[2]; + + DECLARE_MBSTATE; + + istring = (char *)xmalloc (istring_size = DEFAULT_INITIAL_ARRAY_SIZE); + istring[istring_index = 0] = '\0'; + quoted_dollar_at = had_quoted_null = has_dollar_at = 0; + quoted_state = UNQUOTED; + + string = word->word; + if (string == 0) + goto finished_with_string; + /* Don't need the string length for the SADD... and COPY_ macros unless + multibyte characters are possible. */ + string_size = (MB_CUR_MAX > 1) ? strlen (string) : 1; + + if (contains_dollar_at) + *contains_dollar_at = 0; + + assignoff = -1; + + /* Begin the expansion. */ + + for (sindex = 0; ;) + { + c = string[sindex]; + + /* Case on toplevel character. */ + switch (c) + { + case '\0': + goto finished_with_string; + + case CTLESC: + sindex++; +#if HANDLE_MULTIBYTE + if (MB_CUR_MAX > 1 && string[sindex]) + { + SADD_MBQCHAR_BODY(temp, string, sindex, string_size); + } + else +#endif + { + temp = (char *)xmalloc (3); + temp[0] = CTLESC; + temp[1] = c = string[sindex]; + temp[2] = '\0'; + } + +dollar_add_string: + if (string[sindex]) + sindex++; + +add_string: + if (temp) + { + istring = sub_append_string (temp, istring, &istring_index, &istring_size); + temp = (char *)0; + } + + break; + +#if defined (PROCESS_SUBSTITUTION) + /* Process substitution. */ + case '<': + case '>': + { + if (string[++sindex] != LPAREN || (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || (word->flags & (W_DQUOTE|W_NOPROCSUB)) || posixly_correct) + { + sindex--; /* add_character: label increments sindex */ + goto add_character; + } + else + t_index = sindex + 1; /* skip past both '<' and LPAREN */ + + temp1 = extract_process_subst (string, (c == '<') ? "<(" : ">(", &t_index); /*))*/ + sindex = t_index; + + /* If the process substitution specification is `<()', we want to + open the pipe for writing in the child and produce output; if + it is `>()', we want to open the pipe for reading in the child + and consume input. */ + temp = temp1 ? process_substitute (temp1, (c == '>')) : (char *)0; + + FREE (temp1); + + goto dollar_add_string; + } +#endif /* PROCESS_SUBSTITUTION */ + + case '=': + /* Posix.2 section 3.6.1 says that tildes following `=' in words + which are not assignment statements are not expanded. If the + shell isn't in posix mode, though, we perform tilde expansion + on `likely candidate' unquoted assignment statements (flags + include W_ASSIGNMENT but not W_QUOTED). A likely candidate + contains an unquoted :~ or =~. Something to think about: we + now have a flag that says to perform tilde expansion on arguments + to `assignment builtins' like declare and export that look like + assignment statements. We now do tilde expansion on such words + even in POSIX mode. */ + if (word->flags & (W_ASSIGNRHS|W_NOTILDE)) + { + if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c)) + goto add_ifs_character; + else + goto add_character; + } + /* If we're not in posix mode or forcing assignment-statement tilde + expansion, note where the `=' appears in the word and prepare to + do tilde expansion following the first `='. */ + if ((word->flags & W_ASSIGNMENT) && + (posixly_correct == 0 || (word->flags & W_TILDEEXP)) && + assignoff == -1 && sindex > 0) + assignoff = sindex; + if (sindex == assignoff && string[sindex+1] == '~') /* XXX */ + word->flags |= W_ITILDE; +#if 0 + else if ((word->flags & W_ASSIGNMENT) && + (posixly_correct == 0 || (word->flags & W_TILDEEXP)) && + string[sindex+1] == '~') + word->flags |= W_ITILDE; +#endif + if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c)) + goto add_ifs_character; + else + goto add_character; + + case ':': + if (word->flags & W_NOTILDE) + { + if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c)) + goto add_ifs_character; + else + goto add_character; + } + + if ((word->flags & (W_ASSIGNMENT|W_ASSIGNRHS|W_TILDEEXP)) && + string[sindex+1] == '~') + word->flags |= W_ITILDE; + + if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c)) + goto add_ifs_character; + else + goto add_character; + + case '~': + /* If the word isn't supposed to be tilde expanded, or we're not + at the start of a word or after an unquoted : or = in an + assignment statement, we don't do tilde expansion. */ + if ((word->flags & (W_NOTILDE|W_DQUOTE)) || + (sindex > 0 && ((word->flags & W_ITILDE) == 0)) || + (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) + { + word->flags &= ~W_ITILDE; + if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) == 0) + goto add_ifs_character; + else + goto add_character; + } + + if (word->flags & W_ASSIGNRHS) + tflag = 2; + else if (word->flags & (W_ASSIGNMENT|W_TILDEEXP)) + tflag = 1; + else + tflag = 0; + + temp = bash_tilde_find_word (string + sindex, tflag, &t_index); + + word->flags &= ~W_ITILDE; + + if (temp && *temp && t_index > 0) + { + temp1 = bash_tilde_expand (temp, tflag); + if (temp1 && *temp1 == '~' && STREQ (temp, temp1)) + { + FREE (temp); + FREE (temp1); + goto add_character; /* tilde expansion failed */ + } + free (temp); + temp = temp1; + sindex += t_index; + goto add_quoted_string; /* XXX was add_string */ + } + else + { + FREE (temp); + goto add_character; + } + + case '$': + if (expanded_something) + *expanded_something = 1; + + temp_has_dollar_at = 0; + pflags = (word->flags & W_NOCOMSUB) ? PF_NOCOMSUB : 0; + if (word->flags & W_NOSPLIT2) + pflags |= PF_NOSPLIT2; + if (word->flags & W_ASSIGNRHS) + pflags |= PF_ASSIGNRHS; + tword = param_expand (string, &sindex, quoted, expanded_something, + &temp_has_dollar_at, "ed_dollar_at, + &had_quoted_null, pflags); + has_dollar_at += temp_has_dollar_at; + + if (tword == &expand_wdesc_error || tword == &expand_wdesc_fatal) + { + free (string); + free (istring); + return ((tword == &expand_wdesc_error) ? &expand_word_error + : &expand_word_fatal); + } + if (contains_dollar_at && has_dollar_at) + *contains_dollar_at = 1; + + if (tword && (tword->flags & W_HASQUOTEDNULL)) + had_quoted_null = 1; + + temp = tword ? tword->word : (char *)NULL; + dispose_word_desc (tword); + + /* Kill quoted nulls; we will add them back at the end of + expand_word_internal if nothing else in the string */ + if (had_quoted_null && temp && QUOTED_NULL (temp)) + { + FREE (temp); + temp = (char *)NULL; + } + + goto add_string; + break; + + case '`': /* Backquoted command substitution. */ + { + t_index = sindex++; + + temp = string_extract (string, &sindex, "`", SX_REQMATCH); + /* The test of sindex against t_index is to allow bare instances of + ` to pass through, for backwards compatibility. */ + if (temp == &extract_string_error || temp == &extract_string_fatal) + { + if (sindex - 1 == t_index) + { + sindex = t_index; + goto add_character; + } + last_command_exit_value = EXECUTION_FAILURE; + report_error (_("bad substitution: no closing \"`\" in %s") , string+t_index); + free (string); + free (istring); + return ((temp == &extract_string_error) ? &expand_word_error + : &expand_word_fatal); + } + + if (expanded_something) + *expanded_something = 1; + + if (word->flags & W_NOCOMSUB) + /* sindex + 1 because string[sindex] == '`' */ + temp1 = substring (string, t_index, sindex + 1); + else + { + de_backslash (temp); + tword = command_substitute (temp, quoted); + temp1 = tword ? tword->word : (char *)NULL; + if (tword) + dispose_word_desc (tword); + } + FREE (temp); + temp = temp1; + goto dollar_add_string; + } + + case '\\': + if (string[sindex + 1] == '\n') + { + sindex += 2; + continue; + } + + c = string[++sindex]; + + if (quoted & Q_HERE_DOCUMENT) + tflag = CBSHDOC; + else if (quoted & Q_DOUBLE_QUOTES) + tflag = CBSDQUOTE; + else + tflag = 0; + + /* From Posix discussion on austin-group list: Backslash escaping + a } in ${...} is removed. Issue 0000221 */ + if ((quoted & Q_DOLBRACE) && c == RBRACE) + { + SCOPY_CHAR_I (twochars, CTLESC, c, string, sindex, string_size); + } + else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && ((sh_syntaxtab[c] & tflag) == 0)) + { + SCOPY_CHAR_I (twochars, '\\', c, string, sindex, string_size); + } + else if (c == 0) + { + c = CTLNUL; + sindex--; /* add_character: label increments sindex */ + goto add_character; + } + else + { + SCOPY_CHAR_I (twochars, CTLESC, c, string, sindex, string_size); + } + + sindex++; +add_twochars: + /* BEFORE jumping here, we need to increment sindex if appropriate */ + RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size, + DEFAULT_ARRAY_SIZE); + istring[istring_index++] = twochars[0]; + istring[istring_index++] = twochars[1]; + istring[istring_index] = '\0'; + + break; + + case '"': +#if 0 + if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (word->flags & W_DQUOTE)) +#else + if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) +#endif + goto add_character; + + t_index = ++sindex; + temp = string_extract_double_quoted (string, &sindex, 0); + + /* If the quotes surrounded the entire string, then the + whole word was quoted. */ + quoted_state = (t_index == 1 && string[sindex] == '\0') + ? WHOLLY_QUOTED + : PARTIALLY_QUOTED; + + if (temp && *temp) + { + tword = alloc_word_desc (); + tword->word = temp; + + temp = (char *)NULL; + + temp_has_dollar_at = 0; /* XXX */ + /* Need to get W_HASQUOTEDNULL flag through this function. */ + list = expand_word_internal (tword, Q_DOUBLE_QUOTES, 0, &temp_has_dollar_at, (int *)NULL); + has_dollar_at += temp_has_dollar_at; + + if (list == &expand_word_error || list == &expand_word_fatal) + { + free (istring); + free (string); + /* expand_word_internal has already freed temp_word->word + for us because of the way it prints error messages. */ + tword->word = (char *)NULL; + dispose_word (tword); + return list; + } + + dispose_word (tword); + + /* "$@" (a double-quoted dollar-at) expands into nothing, + not even a NULL word, when there are no positional + parameters. */ + if (list == 0 && has_dollar_at) + { + quoted_dollar_at++; + break; + } + + /* If we get "$@", we know we have expanded something, so we + need to remember it for the final split on $IFS. This is + a special case; it's the only case where a quoted string + can expand into more than one word. It's going to come back + from the above call to expand_word_internal as a list with + a single word, in which all characters are quoted and + separated by blanks. What we want to do is to turn it back + into a list for the next piece of code. */ + if (list) + dequote_list (list); + + if (list && list->word && (list->word->flags & W_HASQUOTEDNULL)) + had_quoted_null = 1; /* XXX */ + + if (has_dollar_at) + { + quoted_dollar_at++; + if (contains_dollar_at) + *contains_dollar_at = 1; + if (expanded_something) + *expanded_something = 1; + } + } + else + { + /* What we have is "". This is a minor optimization. */ + FREE (temp); + list = (WORD_LIST *)NULL; + } + + /* The code above *might* return a list (consider the case of "$@", + where it returns "$1", "$2", etc.). We can't throw away the + rest of the list, and we have to make sure each word gets added + as quoted. We test on tresult->next: if it is non-NULL, we + quote the whole list, save it to a string with string_list, and + add that string. We don't need to quote the results of this + (and it would be wrong, since that would quote the separators + as well), so we go directly to add_string. */ + if (list) + { + if (list->next) + { +#if 0 + if (quoted_dollar_at && (word->flags & W_NOSPLIT2)) + temp = string_list_internal (quote_list (list), " "); + else +#endif + /* Testing quoted_dollar_at makes sure that "$@" is + split correctly when $IFS does not contain a space. */ + temp = quoted_dollar_at + ? string_list_dollar_at (list, Q_DOUBLE_QUOTES) + : string_list (quote_list (list)); + dispose_words (list); + goto add_string; + } + else + { + temp = savestring (list->word->word); + tflag = list->word->flags; + dispose_words (list); + + /* If the string is not a quoted null string, we want + to remove any embedded unquoted CTLNUL characters. + We do not want to turn quoted null strings back into + the empty string, though. We do this because we + want to remove any quoted nulls from expansions that + contain other characters. For example, if we have + x"$*"y or "x$*y" and there are no positional parameters, + the $* should expand into nothing. */ + /* We use the W_HASQUOTEDNULL flag to differentiate the + cases: a quoted null character as above and when + CTLNUL is contained in the (non-null) expansion + of some variable. We use the had_quoted_null flag to + pass the value through this function to its caller. */ + if ((tflag & W_HASQUOTEDNULL) && QUOTED_NULL (temp) == 0) + remove_quoted_nulls (temp); /* XXX */ + } + } + else + temp = (char *)NULL; + + /* We do not want to add quoted nulls to strings that are only + partially quoted; we can throw them away. The exception to + this is when we are going to be performing word splitting, + since we have to preserve a null argument if the next character + will cause word splitting. */ + if (temp == 0 && quoted_state == PARTIALLY_QUOTED && (word->flags & (W_NOSPLIT|W_NOSPLIT2))) + continue; + + add_quoted_string: + + if (temp) + { + temp1 = temp; + temp = quote_string (temp); + free (temp1); + goto add_string; + } + else + { + /* Add NULL arg. */ + c = CTLNUL; + sindex--; /* add_character: label increments sindex */ + goto add_character; + } + + /* break; */ + + case '\'': +#if 0 + if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (word->flags & W_DQUOTE)) +#else + if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) +#endif + goto add_character; + + t_index = ++sindex; + temp = string_extract_single_quoted (string, &sindex); + + /* If the entire STRING was surrounded by single quotes, + then the string is wholly quoted. */ + quoted_state = (t_index == 1 && string[sindex] == '\0') + ? WHOLLY_QUOTED + : PARTIALLY_QUOTED; + + /* If all we had was '', it is a null expansion. */ + if (*temp == '\0') + { + free (temp); + temp = (char *)NULL; + } + else + remove_quoted_escapes (temp); /* ??? */ + + /* We do not want to add quoted nulls to strings that are only + partially quoted; such nulls are discarded. */ + if (temp == 0 && (quoted_state == PARTIALLY_QUOTED)) + continue; + + /* If we have a quoted null expansion, add a quoted NULL to istring. */ + if (temp == 0) + { + c = CTLNUL; + sindex--; /* add_character: label increments sindex */ + goto add_character; + } + else + goto add_quoted_string; + + /* break; */ + + default: + /* This is the fix for " $@ " */ + add_ifs_character: + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || (isexp == 0 && isifs (c))) + { + if (string[sindex]) /* from old goto dollar_add_string */ + sindex++; + if (c == 0) + { + c = CTLNUL; + goto add_character; + } + else + { +#if HANDLE_MULTIBYTE + if (MB_CUR_MAX > 1) + sindex--; + + if (MB_CUR_MAX > 1) + { + SADD_MBQCHAR_BODY(temp, string, sindex, string_size); + } + else +#endif + { + twochars[0] = CTLESC; + twochars[1] = c; + goto add_twochars; + } + } + } + + SADD_MBCHAR (temp, string, sindex, string_size); + + add_character: + RESIZE_MALLOCED_BUFFER (istring, istring_index, 1, istring_size, + DEFAULT_ARRAY_SIZE); + istring[istring_index++] = c; + istring[istring_index] = '\0'; + + /* Next character. */ + sindex++; + } + } + +finished_with_string: + /* OK, we're ready to return. If we have a quoted string, and + quoted_dollar_at is not set, we do no splitting at all; otherwise + we split on ' '. The routines that call this will handle what to + do if nothing has been expanded. */ + + /* Partially and wholly quoted strings which expand to the empty + string are retained as an empty arguments. Unquoted strings + which expand to the empty string are discarded. The single + exception is the case of expanding "$@" when there are no + positional parameters. In that case, we discard the expansion. */ + + /* Because of how the code that handles "" and '' in partially + quoted strings works, we need to make ISTRING into a QUOTED_NULL + if we saw quoting characters, but the expansion was empty. + "" and '' are tossed away before we get to this point when + processing partially quoted strings. This makes "" and $xxx"" + equivalent when xxx is unset. We also look to see whether we + saw a quoted null from a ${} expansion and add one back if we + need to. */ + + /* If we expand to nothing and there were no single or double quotes + in the word, we throw it away. Otherwise, we return a NULL word. + The single exception is for $@ surrounded by double quotes when + there are no positional parameters. In that case, we also throw + the word away. */ + + if (*istring == '\0') + { + if (quoted_dollar_at == 0 && (had_quoted_null || quoted_state == PARTIALLY_QUOTED)) + { + istring[0] = CTLNUL; + istring[1] = '\0'; + tword = make_bare_word (istring); + tword->flags |= W_HASQUOTEDNULL; /* XXX */ + list = make_word_list (tword, (WORD_LIST *)NULL); + if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + tword->flags |= W_QUOTED; + } + /* According to sh, ksh, and Posix.2, if a word expands into nothing + and a double-quoted "$@" appears anywhere in it, then the entire + word is removed. */ + else if (quoted_state == UNQUOTED || quoted_dollar_at) + list = (WORD_LIST *)NULL; +#if 0 + else + { + tword = make_bare_word (istring); + if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + tword->flags |= W_QUOTED; + list = make_word_list (tword, (WORD_LIST *)NULL); + } +#else + else + list = (WORD_LIST *)NULL; +#endif + } + else if (word->flags & W_NOSPLIT) + { + tword = make_bare_word (istring); + if (word->flags & W_ASSIGNMENT) + tword->flags |= W_ASSIGNMENT; /* XXX */ + if (word->flags & W_COMPASSIGN) + tword->flags |= W_COMPASSIGN; /* XXX */ + if (word->flags & W_NOGLOB) + tword->flags |= W_NOGLOB; /* XXX */ + if (word->flags & W_NOBRACE) + tword->flags |= W_NOBRACE; /* XXX */ + if (word->flags & W_NOEXPAND) + tword->flags |= W_NOEXPAND; /* XXX */ + if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) + tword->flags |= W_QUOTED; + if (had_quoted_null && QUOTED_NULL (istring)) + tword->flags |= W_HASQUOTEDNULL; + list = make_word_list (tword, (WORD_LIST *)NULL); + } + else + { + char *ifs_chars; + + ifs_chars = (quoted_dollar_at || has_dollar_at) ? ifs_value : (char *)NULL; + + /* If we have $@, we need to split the results no matter what. If + IFS is unset or NULL, string_list_dollar_at has separated the + positional parameters with a space, so we split on space (we have + set ifs_chars to " \t\n" above if ifs is unset). If IFS is set, + string_list_dollar_at has separated the positional parameters + with the first character of $IFS, so we split on $IFS. */ + if (has_dollar_at && ifs_chars) + list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1); + else + { + tword = make_bare_word (istring); + if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (quoted_state == WHOLLY_QUOTED)) + tword->flags |= W_QUOTED; + if (word->flags & W_ASSIGNMENT) + tword->flags |= W_ASSIGNMENT; + if (word->flags & W_COMPASSIGN) + tword->flags |= W_COMPASSIGN; + if (word->flags & W_NOGLOB) + tword->flags |= W_NOGLOB; + if (word->flags & W_NOBRACE) + tword->flags |= W_NOBRACE; + if (word->flags & W_NOEXPAND) + tword->flags |= W_NOEXPAND; + if (had_quoted_null && QUOTED_NULL (istring)) + tword->flags |= W_HASQUOTEDNULL; /* XXX */ + list = make_word_list (tword, (WORD_LIST *)NULL); + } + } + + free (istring); + return (list); +} + +/* **************************************************************** */ +/* */ +/* Functions for Quote Removal */ +/* */ +/* **************************************************************** */ + +/* Perform quote removal on STRING. If QUOTED > 0, assume we are obeying the + backslash quoting rules for within double quotes or a here document. */ +char * +string_quote_removal (string, quoted) + char *string; + int quoted; +{ + size_t slen; + char *r, *result_string, *temp, *send; + int sindex, tindex, dquote; + unsigned char c; + DECLARE_MBSTATE; + + /* The result can be no longer than the original string. */ + slen = strlen (string); + send = string + slen; + + r = result_string = (char *)xmalloc (slen + 1); + + for (dquote = sindex = 0; c = string[sindex];) + { + switch (c) + { + case '\\': + c = string[++sindex]; + if (c == 0) + { + *r++ = '\\'; + break; + } + if (((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || dquote) && (sh_syntaxtab[c] & CBSDQUOTE) == 0) + *r++ = '\\'; + /* FALLTHROUGH */ + + default: + SCOPY_CHAR_M (r, string, send, sindex); + break; + + case '\'': + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || dquote) + { + *r++ = c; + sindex++; + break; + } + tindex = sindex + 1; + temp = string_extract_single_quoted (string, &tindex); + if (temp) + { + strcpy (r, temp); + r += strlen (r); + free (temp); + } + sindex = tindex; + break; + + case '"': + dquote = 1 - dquote; + sindex++; + break; + } + } + *r = '\0'; + return (result_string); +} + +#if 0 +/* UNUSED */ +/* Perform quote removal on word WORD. This allocates and returns a new + WORD_DESC *. */ +WORD_DESC * +word_quote_removal (word, quoted) + WORD_DESC *word; + int quoted; +{ + WORD_DESC *w; + char *t; + + t = string_quote_removal (word->word, quoted); + w = alloc_word_desc (); + w->word = t ? t : savestring (""); + return (w); +} + +/* Perform quote removal on all words in LIST. If QUOTED is non-zero, + the members of the list are treated as if they are surrounded by + double quotes. Return a new list, or NULL if LIST is NULL. */ +WORD_LIST * +word_list_quote_removal (list, quoted) + WORD_LIST *list; + int quoted; +{ + WORD_LIST *result, *t, *tresult, *e; + + for (t = list, result = (WORD_LIST *)NULL; t; t = t->next) + { + tresult = make_word_list (word_quote_removal (t->word, quoted), (WORD_LIST *)NULL); +#if 0 + result = (WORD_LIST *) list_append (result, tresult); +#else + if (result == 0) + result = e = tresult; + else + { + e->next = tresult; + while (e->next) + e = e->next; + } +#endif + } + return (result); +} +#endif + +/******************************************* + * * + * Functions to perform word splitting * + * * + *******************************************/ + +void +setifs (v) + SHELL_VAR *v; +{ + char *t; + unsigned char uc; + + ifs_var = v; + ifs_value = (v && value_cell (v)) ? value_cell (v) : " \t\n"; + + /* Should really merge ifs_cmap with sh_syntaxtab. XXX - doesn't yet + handle multibyte chars in IFS */ + memset (ifs_cmap, '\0', sizeof (ifs_cmap)); + for (t = ifs_value ; t && *t; t++) + { + uc = *t; + ifs_cmap[uc] = 1; + } + +#if defined (HANDLE_MULTIBYTE) + if (ifs_value == 0) + { + ifs_firstc[0] = '\0'; + ifs_firstc_len = 1; + } + else + { + size_t ifs_len; + ifs_len = strnlen (ifs_value, MB_CUR_MAX); + ifs_firstc_len = MBLEN (ifs_value, ifs_len); + if (ifs_firstc_len == 1 || ifs_firstc_len == 0 || MB_INVALIDCH (ifs_firstc_len)) + { + ifs_firstc[0] = ifs_value[0]; + ifs_firstc[1] = '\0'; + ifs_firstc_len = 1; + } + else + memcpy (ifs_firstc, ifs_value, ifs_firstc_len); + } +#else + ifs_firstc = ifs_value ? *ifs_value : 0; +#endif +} + +char * +getifs () +{ + return ifs_value; +} + +/* This splits a single word into a WORD LIST on $IFS, but only if the word + is not quoted. list_string () performs quote removal for us, even if we + don't do any splitting. */ +WORD_LIST * +word_split (w, ifs_chars) + WORD_DESC *w; + char *ifs_chars; +{ + WORD_LIST *result; + + if (w) + { + char *xifs; + + xifs = ((w->flags & W_QUOTED) || ifs_chars == 0) ? "" : ifs_chars; + result = list_string (w->word, xifs, w->flags & W_QUOTED); + } + else + result = (WORD_LIST *)NULL; + + return (result); +} + +/* Perform word splitting on LIST and return the RESULT. It is possible + to return (WORD_LIST *)NULL. */ +static WORD_LIST * +word_list_split (list) + WORD_LIST *list; +{ + WORD_LIST *result, *t, *tresult, *e; + + for (t = list, result = (WORD_LIST *)NULL; t; t = t->next) + { + tresult = word_split (t->word, ifs_value); + if (result == 0) + result = e = tresult; + else + { + e->next = tresult; + while (e->next) + e = e->next; + } + } + return (result); +} + +/************************************************** + * * + * Functions to expand an entire WORD_LIST * + * * + **************************************************/ + +/* Do any word-expansion-specific cleanup and jump to top_level */ +static void +exp_jump_to_top_level (v) + int v; +{ + set_pipestatus_from_exit (last_command_exit_value); + + /* Cleanup code goes here. */ + expand_no_split_dollar_star = 0; /* XXX */ + expanding_redir = 0; + assigning_in_environment = 0; + + if (parse_and_execute_level == 0) + top_level_cleanup (); /* from sig.c */ + + jump_to_top_level (v); +} + +/* Put NLIST (which is a WORD_LIST * of only one element) at the front of + ELIST, and set ELIST to the new list. */ +#define PREPEND_LIST(nlist, elist) \ + do { nlist->next = elist; elist = nlist; } while (0) + +/* Separate out any initial variable assignments from TLIST. If set -k has + been executed, remove all assignment statements from TLIST. Initial + variable assignments and other environment assignments are placed + on SUBST_ASSIGN_VARLIST. */ +static WORD_LIST * +separate_out_assignments (tlist) + WORD_LIST *tlist; +{ + register WORD_LIST *vp, *lp; + + if (tlist == 0) + return ((WORD_LIST *)NULL); + + if (subst_assign_varlist) + dispose_words (subst_assign_varlist); /* Clean up after previous error */ + + subst_assign_varlist = (WORD_LIST *)NULL; + vp = lp = tlist; + + /* Separate out variable assignments at the start of the command. + Loop invariant: vp->next == lp + Loop postcondition: + lp = list of words left after assignment statements skipped + tlist = original list of words + */ + while (lp && (lp->word->flags & W_ASSIGNMENT)) + { + vp = lp; + lp = lp->next; + } + + /* If lp != tlist, we have some initial assignment statements. + We make SUBST_ASSIGN_VARLIST point to the list of assignment + words and TLIST point to the remaining words. */ + if (lp != tlist) + { + subst_assign_varlist = tlist; + /* ASSERT(vp->next == lp); */ + vp->next = (WORD_LIST *)NULL; /* terminate variable list */ + tlist = lp; /* remainder of word list */ + } + + /* vp == end of variable list */ + /* tlist == remainder of original word list without variable assignments */ + if (!tlist) + /* All the words in tlist were assignment statements */ + return ((WORD_LIST *)NULL); + + /* ASSERT(tlist != NULL); */ + /* ASSERT((tlist->word->flags & W_ASSIGNMENT) == 0); */ + + /* If the -k option is in effect, we need to go through the remaining + words, separate out the assignment words, and place them on + SUBST_ASSIGN_VARLIST. */ + if (place_keywords_in_env) + { + WORD_LIST *tp; /* tp == running pointer into tlist */ + + tp = tlist; + lp = tlist->next; + + /* Loop Invariant: tp->next == lp */ + /* Loop postcondition: tlist == word list without assignment statements */ + while (lp) + { + if (lp->word->flags & W_ASSIGNMENT) + { + /* Found an assignment statement, add this word to end of + subst_assign_varlist (vp). */ + if (!subst_assign_varlist) + subst_assign_varlist = vp = lp; + else + { + vp->next = lp; + vp = lp; + } + + /* Remove the word pointed to by LP from TLIST. */ + tp->next = lp->next; + /* ASSERT(vp == lp); */ + lp->next = (WORD_LIST *)NULL; + lp = tp->next; + } + else + { + tp = lp; + lp = lp->next; + } + } + } + return (tlist); +} + +#define WEXP_VARASSIGN 0x001 +#define WEXP_BRACEEXP 0x002 +#define WEXP_TILDEEXP 0x004 +#define WEXP_PARAMEXP 0x008 +#define WEXP_PATHEXP 0x010 + +/* All of the expansions, including variable assignments at the start of + the list. */ +#define WEXP_ALL (WEXP_VARASSIGN|WEXP_BRACEEXP|WEXP_TILDEEXP|WEXP_PARAMEXP|WEXP_PATHEXP) + +/* All of the expansions except variable assignments at the start of + the list. */ +#define WEXP_NOVARS (WEXP_BRACEEXP|WEXP_TILDEEXP|WEXP_PARAMEXP|WEXP_PATHEXP) + +/* All of the `shell expansions': brace expansion, tilde expansion, parameter + expansion, command substitution, arithmetic expansion, word splitting, and + quote removal. */ +#define WEXP_SHELLEXP (WEXP_BRACEEXP|WEXP_TILDEEXP|WEXP_PARAMEXP) + +/* Take the list of words in LIST and do the various substitutions. Return + a new list of words which is the expanded list, and without things like + variable assignments. */ + +WORD_LIST * +expand_words (list) + WORD_LIST *list; +{ + return (expand_word_list_internal (list, WEXP_ALL)); +} + +/* Same as expand_words (), but doesn't hack variable or environment + variables. */ +WORD_LIST * +expand_words_no_vars (list) + WORD_LIST *list; +{ + return (expand_word_list_internal (list, WEXP_NOVARS)); +} + +WORD_LIST * +expand_words_shellexp (list) + WORD_LIST *list; +{ + return (expand_word_list_internal (list, WEXP_SHELLEXP)); +} + +static WORD_LIST * +glob_expand_word_list (tlist, eflags) + WORD_LIST *tlist; + int eflags; +{ + char **glob_array, *temp_string; + register int glob_index; + WORD_LIST *glob_list, *output_list, *disposables, *next; + WORD_DESC *tword; + + output_list = disposables = (WORD_LIST *)NULL; + glob_array = (char **)NULL; + while (tlist) + { + /* For each word, either globbing is attempted or the word is + added to orig_list. If globbing succeeds, the results are + added to orig_list and the word (tlist) is added to the list + of disposable words. If globbing fails and failed glob + expansions are left unchanged (the shell default), the + original word is added to orig_list. If globbing fails and + failed glob expansions are removed, the original word is + added to the list of disposable words. orig_list ends up + in reverse order and requires a call to REVERSE_LIST to + be set right. After all words are examined, the disposable + words are freed. */ + next = tlist->next; + + /* If the word isn't an assignment and contains an unquoted + pattern matching character, then glob it. */ + if ((tlist->word->flags & W_NOGLOB) == 0 && + unquoted_glob_pattern_p (tlist->word->word)) + { + glob_array = shell_glob_filename (tlist->word->word); + + /* Handle error cases. + I don't think we should report errors like "No such file + or directory". However, I would like to report errors + like "Read failed". */ + + if (glob_array == 0 || GLOB_FAILED (glob_array)) + { + glob_array = (char **)xmalloc (sizeof (char *)); + glob_array[0] = (char *)NULL; + } + + /* Dequote the current word in case we have to use it. */ + if (glob_array[0] == NULL) + { + temp_string = dequote_string (tlist->word->word); + free (tlist->word->word); + tlist->word->word = temp_string; + } + + /* Make the array into a word list. */ + glob_list = (WORD_LIST *)NULL; + for (glob_index = 0; glob_array[glob_index]; glob_index++) + { + tword = make_bare_word (glob_array[glob_index]); + tword->flags |= W_GLOBEXP; /* XXX */ + glob_list = make_word_list (tword, glob_list); + } + + if (glob_list) + { + output_list = (WORD_LIST *)list_append (glob_list, output_list); + PREPEND_LIST (tlist, disposables); + } + else if (fail_glob_expansion != 0) + { + last_command_exit_value = EXECUTION_FAILURE; + report_error (_("no match: %s"), tlist->word->word); + exp_jump_to_top_level (DISCARD); + } + else if (allow_null_glob_expansion == 0) + { + /* Failed glob expressions are left unchanged. */ + PREPEND_LIST (tlist, output_list); + } + else + { + /* Failed glob expressions are removed. */ + PREPEND_LIST (tlist, disposables); + } + } + else + { + /* Dequote the string. */ + temp_string = dequote_string (tlist->word->word); + free (tlist->word->word); + tlist->word->word = temp_string; + PREPEND_LIST (tlist, output_list); + } + + strvec_dispose (glob_array); + glob_array = (char **)NULL; + + tlist = next; + } + + if (disposables) + dispose_words (disposables); + + if (output_list) + output_list = REVERSE_LIST (output_list, WORD_LIST *); + + return (output_list); +} + +#if defined (BRACE_EXPANSION) +static WORD_LIST * +brace_expand_word_list (tlist, eflags) + WORD_LIST *tlist; + int eflags; +{ + register char **expansions; + char *temp_string; + WORD_LIST *disposables, *output_list, *next; + WORD_DESC *w; + int eindex; + + for (disposables = output_list = (WORD_LIST *)NULL; tlist; tlist = next) + { + next = tlist->next; + + if (tlist->word->flags & W_NOBRACE) + { +/*itrace("brace_expand_word_list: %s: W_NOBRACE", tlist->word->word);*/ + PREPEND_LIST (tlist, output_list); + continue; + } + + if ((tlist->word->flags & (W_COMPASSIGN|W_ASSIGNARG)) == (W_COMPASSIGN|W_ASSIGNARG)) + { +/*itrace("brace_expand_word_list: %s: W_COMPASSIGN|W_ASSIGNARG", tlist->word->word);*/ + PREPEND_LIST (tlist, output_list); + continue; + } + + /* Only do brace expansion if the word has a brace character. If + not, just add the word list element to BRACES and continue. In + the common case, at least when running shell scripts, this will + degenerate to a bunch of calls to `mbschr', and then what is + basically a reversal of TLIST into BRACES, which is corrected + by a call to REVERSE_LIST () on BRACES when the end of TLIST + is reached. */ + if (mbschr (tlist->word->word, LBRACE)) + { + expansions = brace_expand (tlist->word->word); + + for (eindex = 0; temp_string = expansions[eindex]; eindex++) + { + w = alloc_word_desc (); + w->word = temp_string; + + /* If brace expansion didn't change the word, preserve + the flags. We may want to preserve the flags + unconditionally someday -- XXX */ + if (STREQ (temp_string, tlist->word->word)) + w->flags = tlist->word->flags; + else + w = make_word_flags (w, temp_string); + + output_list = make_word_list (w, output_list); + } + free (expansions); + + /* Add TLIST to the list of words to be freed after brace + expansion has been performed. */ + PREPEND_LIST (tlist, disposables); + } + else + PREPEND_LIST (tlist, output_list); + } + + if (disposables) + dispose_words (disposables); + + if (output_list) + output_list = REVERSE_LIST (output_list, WORD_LIST *); + + return (output_list); +} +#endif + +#if defined (ARRAY_VARS) +/* Take WORD, a compound associative array assignment, and internally run + 'declare -A w', where W is the variable name portion of WORD. */ +static int +make_internal_declare (word, option) + char *word; + char *option; +{ + int t; + WORD_LIST *wl; + WORD_DESC *w; + + w = make_word (word); + + t = assignment (w->word, 0); + w->word[t] = '\0'; + + wl = make_word_list (w, (WORD_LIST *)NULL); + wl = make_word_list (make_word (option), wl); + + return (declare_builtin (wl)); +} +#endif + +static WORD_LIST * +shell_expand_word_list (tlist, eflags) + WORD_LIST *tlist; + int eflags; +{ + WORD_LIST *expanded, *orig_list, *new_list, *next, *temp_list; + int expanded_something, has_dollar_at; + char *temp_string; + + /* We do tilde expansion all the time. This is what 1003.2 says. */ + new_list = (WORD_LIST *)NULL; + for (orig_list = tlist; tlist; tlist = next) + { + temp_string = tlist->word->word; + + next = tlist->next; + +#if defined (ARRAY_VARS) + /* If this is a compound array assignment to a builtin that accepts + such assignments (e.g., `declare'), take the assignment and perform + it separately, handling the semantics of declarations inside shell + functions. This avoids the double-evaluation of such arguments, + because `declare' does some evaluation of compound assignments on + its own. */ + if ((tlist->word->flags & (W_COMPASSIGN|W_ASSIGNARG)) == (W_COMPASSIGN|W_ASSIGNARG)) + { + int t; + + if ((tlist->word->flags & (W_ASSIGNASSOC|W_ASSNGLOBAL)) == (W_ASSIGNASSOC|W_ASSNGLOBAL)) + make_internal_declare (tlist->word->word, "-gA"); + else if (tlist->word->flags & W_ASSIGNASSOC) + make_internal_declare (tlist->word->word, "-A"); + else if (tlist->word->flags & W_ASSNGLOBAL) + make_internal_declare (tlist->word->word, "-g"); + + t = do_word_assignment (tlist->word, 0); + if (t == 0) + { + last_command_exit_value = EXECUTION_FAILURE; + exp_jump_to_top_level (DISCARD); + } + + /* Now transform the word as ksh93 appears to do and go on */ + t = assignment (tlist->word->word, 0); + tlist->word->word[t] = '\0'; + tlist->word->flags &= ~(W_ASSIGNMENT|W_NOSPLIT|W_COMPASSIGN|W_ASSIGNARG|W_ASSIGNASSOC); + } +#endif + + expanded_something = 0; + expanded = expand_word_internal + (tlist->word, 0, 0, &has_dollar_at, &expanded_something); + + if (expanded == &expand_word_error || expanded == &expand_word_fatal) + { + /* By convention, each time this error is returned, + tlist->word->word has already been freed. */ + tlist->word->word = (char *)NULL; + + /* Dispose our copy of the original list. */ + dispose_words (orig_list); + /* Dispose the new list we're building. */ + dispose_words (new_list); + + last_command_exit_value = EXECUTION_FAILURE; + if (expanded == &expand_word_error) + exp_jump_to_top_level (DISCARD); + else + exp_jump_to_top_level (FORCE_EOF); + } + + /* Don't split words marked W_NOSPLIT. */ + if (expanded_something && (tlist->word->flags & W_NOSPLIT) == 0) + { + temp_list = word_list_split (expanded); + dispose_words (expanded); + } + else + { + /* If no parameter expansion, command substitution, process + substitution, or arithmetic substitution took place, then + do not do word splitting. We still have to remove quoted + null characters from the result. */ + word_list_remove_quoted_nulls (expanded); + temp_list = expanded; + } + + expanded = REVERSE_LIST (temp_list, WORD_LIST *); + new_list = (WORD_LIST *)list_append (expanded, new_list); + } + + if (orig_list) + dispose_words (orig_list); + + if (new_list) + new_list = REVERSE_LIST (new_list, WORD_LIST *); + + return (new_list); +} + +/* The workhorse for expand_words () and expand_words_no_vars (). + First arg is LIST, a WORD_LIST of words. + Second arg EFLAGS is a flags word controlling which expansions are + performed. + + This does all of the substitutions: brace expansion, tilde expansion, + parameter expansion, command substitution, arithmetic expansion, + process substitution, word splitting, and pathname expansion, according + to the bits set in EFLAGS. Words with the W_QUOTED or W_NOSPLIT bits + set, or for which no expansion is done, do not undergo word splitting. + Words with the W_NOGLOB bit set do not undergo pathname expansion; words + with W_NOBRACE set do not undergo brace expansion (see + brace_expand_word_list above). */ +static WORD_LIST * +expand_word_list_internal (list, eflags) + WORD_LIST *list; + int eflags; +{ + WORD_LIST *new_list, *temp_list; + int tint; + + if (list == 0) + return ((WORD_LIST *)NULL); + + garglist = new_list = copy_word_list (list); + if (eflags & WEXP_VARASSIGN) + { + garglist = new_list = separate_out_assignments (new_list); + if (new_list == 0) + { + if (subst_assign_varlist) + { + /* All the words were variable assignments, so they are placed + into the shell's environment. */ + for (temp_list = subst_assign_varlist; temp_list; temp_list = temp_list->next) + { + this_command_name = (char *)NULL; /* no arithmetic errors */ + tint = do_word_assignment (temp_list->word, 0); + /* Variable assignment errors in non-interactive shells + running in Posix.2 mode cause the shell to exit. */ + if (tint == 0) + { + last_command_exit_value = EXECUTION_FAILURE; + if (interactive_shell == 0 && posixly_correct) + exp_jump_to_top_level (FORCE_EOF); + else + exp_jump_to_top_level (DISCARD); + } + } + dispose_words (subst_assign_varlist); + subst_assign_varlist = (WORD_LIST *)NULL; + } + return ((WORD_LIST *)NULL); + } + } + + /* Begin expanding the words that remain. The expansions take place on + things that aren't really variable assignments. */ + +#if defined (BRACE_EXPANSION) + /* Do brace expansion on this word if there are any brace characters + in the string. */ + if ((eflags & WEXP_BRACEEXP) && brace_expansion && new_list) + new_list = brace_expand_word_list (new_list, eflags); +#endif /* BRACE_EXPANSION */ + + /* Perform the `normal' shell expansions: tilde expansion, parameter and + variable substitution, command substitution, arithmetic expansion, + and word splitting. */ + new_list = shell_expand_word_list (new_list, eflags); + + /* Okay, we're almost done. Now let's just do some filename + globbing. */ + if (new_list) + { + if ((eflags & WEXP_PATHEXP) && disallow_filename_globbing == 0) + /* Glob expand the word list unless globbing has been disabled. */ + new_list = glob_expand_word_list (new_list, eflags); + else + /* Dequote the words, because we're not performing globbing. */ + new_list = dequote_list (new_list); + } + + if ((eflags & WEXP_VARASSIGN) && subst_assign_varlist) + { + sh_wassign_func_t *assign_func; + int is_special_builtin, is_builtin_or_func; + + /* If the remainder of the words expand to nothing, Posix.2 requires + that the variable and environment assignments affect the shell's + environment. */ + assign_func = new_list ? assign_in_env : do_word_assignment; + tempenv_assign_error = 0; + + is_builtin_or_func = (new_list && new_list->word && (find_shell_builtin (new_list->word->word) || find_function (new_list->word->word))); + /* Posix says that special builtins exit if a variable assignment error + occurs in an assignment preceding it. */ + is_special_builtin = (posixly_correct && new_list && new_list->word && find_special_builtin (new_list->word->word)); + + for (temp_list = subst_assign_varlist; temp_list; temp_list = temp_list->next) + { + this_command_name = (char *)NULL; + assigning_in_environment = (assign_func == assign_in_env); + tint = (*assign_func) (temp_list->word, is_builtin_or_func); + assigning_in_environment = 0; + /* Variable assignment errors in non-interactive shells running + in Posix.2 mode cause the shell to exit. */ + if (tint == 0) + { + if (assign_func == do_word_assignment) + { + last_command_exit_value = EXECUTION_FAILURE; + if (interactive_shell == 0 && posixly_correct && is_special_builtin) + exp_jump_to_top_level (FORCE_EOF); + else + exp_jump_to_top_level (DISCARD); + } + else + tempenv_assign_error++; + } + } + + dispose_words (subst_assign_varlist); + subst_assign_varlist = (WORD_LIST *)NULL; + } + +#if 0 + tint = list_length (new_list) + 1; + RESIZE_MALLOCED_BUFFER (glob_argv_flags, 0, tint, glob_argv_flags_size, 16); + for (tint = 0, temp_list = new_list; temp_list; temp_list = temp_list->next) + glob_argv_flags[tint++] = (temp_list->word->flags & W_GLOBEXP) ? '1' : '0'; + glob_argv_flags[tint] = '\0'; +#endif + + return (new_list); +} diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 72ec06a2c..3efcf32d6 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -1,4 +1,4 @@ -BUILD_DIR=/usr/local/build/bash/bash-current +BUILD_DIR=/usr/local/build/chet/bash/bash-current THIS_SH=$BUILD_DIR/bash PATH=$PATH:$BUILD_DIR