/usr/bin/bash: Difference between revisions
Line 1,995: | Line 1,995: | ||
;<nowiki>complete [-abcdefgjksuv] [-o comp-option] [-DEI] [-A action] [-G globpat] [-W wordlist]</nowiki> | ;<nowiki>complete [-abcdefgjksuv] [-o comp-option] [-DEI] [-A action] [-G globpat] [-W wordlist]</nowiki> | ||
:;<nowiki>[-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] name [name ...]</nowiki> | |||
;<nowiki>complete -pr [-DEI] [name ...]</nowiki> | ;<nowiki>complete -pr [-DEI] [name ...]</nowiki> | ||
Specify how arguments to each name should be completed. If the -p 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 -r option removes a completion specification for each name, or, if no names are supplied, all completion specifications. The -D option indicates that other supplied options and actions should apply to the ``default'' command completion; that is, completion attempted on a command for which no completion has previously been defined. The -E option indicates that other supplied options and actions should apply to ``empty'' command completion; that is, completion attempted on a blank line. The -I option indicates that other supplied options and actions should apply to completion on the initial non-assignment word on the line, or after a command delimiter such as ; or |, which is usually command name completion. If multiple options are supplied, the -D option takes precedence over -E, and both take precedence over -I. If any of -D, -E, or -I are supplied, any other name arguments are ignored; these completions only apply to the case specified by the option. | Specify how arguments to each name should be completed. If the -p 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 -r option removes a completion specification for each name, or, if no names are supplied, all completion specifications. The -D option indicates that other supplied options and actions should apply to the ``default'' command completion; that is, completion attempted on a command for which no completion has previously been defined. The -E option indicates that other supplied options and actions should apply to ``empty'' command completion; that is, completion attempted on a blank line. The -I option indicates that other supplied options and actions should apply to completion on the initial non-assignment word on the line, or after a command delimiter such as ; or |, which is usually command name completion. If multiple options are supplied, the -D option takes precedence over -E, and both take precedence over -I. If any of -D, -E, or -I are supplied, any other name arguments are ignored; these completions only apply to the case specified by the option. | ||
Line 2,002: | Line 2,002: | ||
Other options, if specified, have the following meanings. The arguments to the -G, -W, and -X options (and, if necessary, the -P and -S options) should be quoted to protect them from expansion before the complete builtin is invoked. | Other options, if specified, have the following meanings. The arguments to the -G, -W, and -X options (and, if necessary, the -P and -S options) should be quoted to protect them from expansion before the complete builtin is invoked. | ||
:;-o comp-option | |||
::The comp-option controls several aspects of the compspec's behavior beyond the simple generation of completions. comp-option may be one of: | ::The comp-option controls several aspects of the compspec's behavior beyond the simple generation of completions. comp-option may be one of: | ||
:::bashdefault | :::bashdefault | ||
Line 2,020: | Line 2,020: | ||
:::plusdirs | :::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. | ::::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. | ||
:;-A action | |||
::The action may be one of the following to generate a list of possible completions: | ::The action may be one of the following to generate a list of possible completions: | ||
:::alias | :::alias | ||
Line 2,070: | Line 2,070: | ||
:::variable | :::variable | ||
::::Names of all shell variables. May also be specified as -v. | ::::Names of all shell variables. May also be specified as -v. | ||
:;-C command | |||
::command is executed in a subshell environment, and its output is used as the possible completions. | ::command is executed in a subshell environment, and its output is used as the possible completions. | ||
:;-F function | |||
::The shell function function is executed in the current shell environment. When the function is executed, the first argument ($1) is the name of the command whose arguments are being completed, the second argument ($2) is the word being completed, and the third argument ($3) 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 COMPREPLY array variable. | ::The shell function function is executed in the current shell environment. When the function is executed, the first argument ($1) is the name of the command whose arguments are being completed, the second argument ($2) is the word being completed, and the third argument ($3) 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 COMPREPLY array variable. | ||
:;-G globpat | |||
::The pathname expansion pattern globpat is expanded to generate the possible completions. | ::The pathname expansion pattern globpat is expanded to generate the possible completions. | ||
:;-P prefix | |||
::prefix is added at the beginning of each possible completion after all other options have been applied. | ::prefix is added at the beginning of each possible completion after all other options have been applied. | ||
:;-S suffix | |||
::suffix is appended to each possible completion after all other options have been applied. | ::suffix is appended to each possible completion after all other options have been applied. | ||
:;-W wordlist | |||
::The wordlist is split using the characters in the IFS special variable as delimiters, and each resultant word is expanded. Shell quoting is honored within wordlist, in order to provide a mechanism for the words to contain shell metacharacters or characters in the value of IFS. The possible completions are the members of the resultant list which match the word being completed. | ::The wordlist is split using the characters in the IFS special variable as delimiters, and each resultant word is expanded. Shell quoting is honored within wordlist, in order to provide a mechanism for the words to contain shell metacharacters or characters in the value of IFS. The possible completions are the members of the resultant list which match the word being completed. | ||
:;-X filterpat | |||
::filterpat is a pattern as used for pathname expansion. It is applied to the list of possible completions generated by the preceding options and arguments, and each completion matching filterpat is removed from the list. A leading ! in filterpat negates the pattern; in this case, any completion not matching filterpat is removed. | ::filterpat is a pattern as used for pathname expansion. It is applied to the list of possible completions generated by the preceding options and arguments, and each completion matching filterpat is removed from the list. A leading ! in filterpat negates the pattern; in this case, any completion not matching filterpat is removed. | ||
Line 2,098: | Line 2,098: | ||
;<nowiki>typeset [-aAfFgiIlnrtux] [-p] [name[=value] ...]</nowiki> | ;<nowiki>typeset [-aAfFgiIlnrtux] [-p] [name[=value] ...]</nowiki> | ||
Declare variables and/or give them attributes. If no names are given then display the values of variables. The -p option will display the attributes and values of each name. When -p is used with name arguments, additional options, other than -f and -F, are ignored. When -p is supplied without name 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 -p, declare will display the attributes and values of all shell variables. The -f option will restrict the display to shell functions. The -F option inhibits the display of function definitions; only the function name and attributes are printed. If the extdebug shell option is enabled using shopt, the source file name and line number where each name is defined are displayed as well. The -F option implies -f. The -g option forces variables to be created or modified at the global scope, even when declare is executed in a shell function. It is ignored in all other cases. The -I option causes local variables to inherit the attributes (except the nameref attribute) and value of any existing variable with the same name at a surrounding scope. If there is no existing variable, the local variable is initially unset. The following options can be used to restrict output to variables with the specified attribute or to give variables attributes: | Declare variables and/or give them attributes. If no names are given then display the values of variables. The -p option will display the attributes and values of each name. When -p is used with name arguments, additional options, other than -f and -F, are ignored. When -p is supplied without name 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 -p, declare will display the attributes and values of all shell variables. The -f option will restrict the display to shell functions. The -F option inhibits the display of function definitions; only the function name and attributes are printed. If the extdebug shell option is enabled using shopt, the source file name and line number where each name is defined are displayed as well. The -F option implies -f. The -g option forces variables to be created or modified at the global scope, even when declare is executed in a shell function. It is ignored in all other cases. The -I option causes local variables to inherit the attributes (except the nameref attribute) and value of any existing variable with the same name at a surrounding scope. If there is no existing variable, the local variable is initially unset. The following options can be used to restrict output to variables with the specified attribute or to give variables attributes: | ||
:;-a | |||
:::Each name is an indexed array variable (see Arrays above). | :::Each name is an indexed array variable (see Arrays above). | ||
:;-A | |||
::Each name is an associative array variable (see Arrays above). | ::Each name is an associative array variable (see Arrays above). | ||
:;-f | |||
::Use function names only. | ::Use function names only. | ||
:;-i | |||
::The variable is treated as an integer; arithmetic evaluation (see ARITHMETIC EVALUATION above) is performed when the variable is assigned a value. | ::The variable is treated as an integer; arithmetic evaluation (see ARITHMETIC EVALUATION above) is performed when the variable is assigned a value. | ||
:;-l | |||
::When the variable is assigned a value, all upper-case characters are converted to lower-case. The upper-case attribute is disabled. | ::When the variable is assigned a value, all upper-case characters are converted to lower-case. The upper-case attribute is disabled. | ||
:;-n | |||
::Give each name the nameref attribute, making it a name reference to another variable. That other variable is defined by the value of name. All references, assignments, and attribute modifications to name, except those using or changing the -n attribute itself, are performed on the variable referenced by name's value. The nameref attribute cannot be applied to array variables. | ::Give each name the nameref attribute, making it a name reference to another variable. That other variable is defined by the value of name. All references, assignments, and attribute modifications to name, except those using or changing the -n attribute itself, are performed on the variable referenced by name's value. The nameref attribute cannot be applied to array variables. | ||
:;-r | |||
::Make names readonly. These names cannot then be assigned values by subsequent assignment statements or unset. | ::Make names readonly. These names cannot then be assigned values by subsequent assignment statements or unset. | ||
:;-t | |||
::Give each name the trace attribute. Traced functions inherit the DEBUG and RETURN traps from the calling shell. The trace attribute has no special meaning for variables. | ::Give each name the trace attribute. Traced functions inherit the DEBUG and RETURN traps from the calling shell. The trace attribute has no special meaning for variables. | ||
:;-u | |||
::When the variable is assigned a value, all lower-case characters are converted to upper-case. The lower-case attribute is disabled. | ::When the variable is assigned a value, all lower-case characters are converted to upper-case. The lower-case attribute is disabled. | ||
:;-x | |||
::Mark names for export to subsequent commands via the environment. | ::Mark names for export to subsequent commands via the environment. | ||
Line 2,123: | Line 2,123: | ||
;<nowiki>dirs [-clpv] [+n] [-n]</nowiki> | ;<nowiki>dirs [-clpv] [+n] [-n]</nowiki> | ||
: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 pushd command; the popd command removes entries from the list. The current directory is always the first directory in the stack. | :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 pushd command; the popd command removes entries from the list. The current directory is always the first directory in the stack. | ||
:;-c | |||
::Clears the directory stack by deleting all of the entries. | ::Clears the directory stack by deleting all of the entries. | ||
:;-l | |||
::Produces a listing using full pathnames; the default listing format uses a tilde to denote the home directory. | ::Produces a listing using full pathnames; the default listing format uses a tilde to denote the home directory. | ||
:;-p | |||
::Print the directory stack with one entry per line. | ::Print the directory stack with one entry per line. | ||
:;-v | |||
::Print the directory stack with one entry per line, prefixing each entry with its index in the stack. | ::Print the directory stack with one entry per line, prefixing each entry with its index in the stack. | ||
:;+n | |||
::Displays the nth entry counting from the left of the list shown by dirs when invoked without options, starting with zero. | ::Displays the nth entry counting from the left of the list shown by dirs when invoked without options, starting with zero. | ||
:;-n | |||
::Displays the nth entry counting from the right of the list shown by dirs when invoked without options, starting with zero. | ::Displays the nth entry counting from the right of the list shown by dirs when invoked without options, starting with zero. | ||
Line 2,143: | Line 2,143: | ||
;<nowiki>echo [-neE] [arg ...]</nowiki> | ;<nowiki>echo [-neE] [arg ...]</nowiki> | ||
:Output the args, separated by spaces, followed by a newline. The return status is 0 unless a write error occurs. If -n is specified, the trailing newline is suppressed. If the -e option is given, interpretation of the following backslash-escaped characters is enabled. The -E option disables the interpretation of these escape characters, even on systems where they are interpreted by default. The xpg_echo shell option may be used to dynamically determine whether or not echo expands these escape characters by default. echo does not interpret -- to mean the end of options. echo interprets the following escape sequences: | :Output the args, separated by spaces, followed by a newline. The return status is 0 unless a write error occurs. If -n is specified, the trailing newline is suppressed. If the -e option is given, interpretation of the following backslash-escaped characters is enabled. The -E option disables the interpretation of these escape characters, even on systems where they are interpreted by default. The xpg_echo shell option may be used to dynamically determine whether or not echo expands these escape characters by default. echo does not interpret -- to mean the end of options. echo interprets the following escape sequences: | ||
:;\a | |||
::alert (bell) | ::alert (bell) | ||
:;\b | |||
::backspace | ::backspace | ||
:;\c | |||
::suppress further output | ::suppress further output | ||
:;\e | |||
:;\E | |||
::an escape character | ::an escape character | ||
:;\f | |||
::form feed | ::form feed | ||
:;\n | |||
::new line | ::new line | ||
:;\r | |||
::carriage return | ::carriage return | ||
:;\t | |||
::horizontal tab | ::horizontal tab | ||
:;\v | |||
::vertical tab | ::vertical tab | ||
:;\\ | |||
::backslash | ::backslash | ||
:;\0nnn | |||
::the eight-bit character whose value is the octal value nnn (zero to three octal digits) | ::the eight-bit character whose value is the octal value nnn (zero to three octal digits) | ||
:;\xHH | |||
::the eight-bit character whose value is the hexadecimal value HH (one or two hex digits) | ::the eight-bit character whose value is the hexadecimal value HH (one or two hex digits) | ||
:;\uHHHH | |||
::the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value HHHH (one to four hex digits) | ::the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value HHHH (one to four hex digits) | ||
:;\UHHHHHHHH | |||
::the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value HHHHHHHH (one to eight hex digits) | ::the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value HHHHHHHH (one to eight hex digits) | ||
Line 2,222: | Line 2,222: | ||
;<nowiki>help [-dms] [pattern]</nowiki> | ;<nowiki>help [-dms] [pattern]</nowiki> | ||
:Display helpful information about builtin commands. If pattern is specified, help gives detailed help on all commands matching pattern; otherwise help for all the builtins and shell control structures is printed. | :Display helpful information about builtin commands. If pattern is specified, help gives detailed help on all commands matching pattern; otherwise help for all the builtins and shell control structures is printed. | ||
:;-d | |||
::Display a short description of each pattern | ::Display a short description of each pattern | ||
:;-m | |||
::Display the description of each pattern in a manpage-like format | ::Display the description of each pattern in a manpage-like format | ||
:;-s | |||
::Display only a short usage synopsis for each pattern | ::Display only a short usage synopsis for each pattern | ||
Line 2,263: | Line 2,263: | ||
;<nowiki>jobs -x command [ args ... ]</nowiki> | ;<nowiki>jobs -x command [ args ... ]</nowiki> | ||
:The first form lists the active jobs. The options have the following meanings: | :The first form lists the active jobs. The options have the following meanings: | ||
:;-l | |||
::List process IDs in addition to the normal information. | ::List process IDs in addition to the normal information. | ||
:;-n | |||
::Display information only about jobs that have changed status since the user was last notified of their status. | ::Display information only about jobs that have changed status since the user was last notified of their status. | ||
:;-p | |||
::List only the process ID of the job's process group leader. | ::List only the process ID of the job's process group leader. | ||
:;-r | |||
::Display only running jobs. | ::Display only running jobs. | ||
:;-s | |||
::Display only stopped jobs. | ::Display only stopped jobs. | ||
Line 2,294: | Line 2,294: | ||
;<nowiki>readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]</nowiki> | ;<nowiki>readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]</nowiki> | ||
:Read lines from the standard input into the indexed array variable array, or from file descriptor fd if the -u option is supplied. The variable MAPFILE is the default array. Options, if supplied, have the following meanings: | :Read lines from the standard input into the indexed array variable array, or from file descriptor fd if the -u option is supplied. The variable MAPFILE is the default array. Options, if supplied, have the following meanings: | ||
:;-d | |||
::The first character of delim is used to terminate each input line, rather than newline. If delim is the empty string, mapfile will terminate a line when it reads a NUL character. | ::The first character of delim is used to terminate each input line, rather than newline. If delim is the empty string, mapfile will terminate a line when it reads a NUL character. | ||
:;-n | |||
::Copy at most count lines. If count is 0, all lines are copied. | ::Copy at most count lines. If count is 0, all lines are copied. | ||
:;-O | |||
::Begin assigning to array at index origin. The default index is 0. | ::Begin assigning to array at index origin. The default index is 0. | ||
:;-s | |||
::Discard the first count lines read. | ::Discard the first count lines read. | ||
:;-t | |||
::Remove a trailing delim (default newline) from each line read. | ::Remove a trailing delim (default newline) from each line read. | ||
:;-u | |||
::Read lines from file descriptor fd instead of the standard input. | ::Read lines from file descriptor fd instead of the standard input. | ||
:;-C | |||
::Evaluate callback each time quantum lines are read. The -c option specifies quantum. | ::Evaluate callback each time quantum lines are read. The -c option specifies quantum. | ||
:;-c | |||
::Specify the number of lines read between each call to callback. | ::Specify the number of lines read between each call to callback. | ||
Line 2,319: | Line 2,319: | ||
;<nowiki>popd [-n] [+n] [-n]</nowiki> | ;<nowiki>popd [-n] [+n] [-n]</nowiki> | ||
:Removes entries from the directory stack. With no arguments, removes the top directory from the stack, and performs a cd to the new top directory. Arguments, if supplied, have the following meanings: | :Removes entries from the directory stack. With no arguments, removes the top directory from the stack, and performs a cd to the new top directory. Arguments, if supplied, have the following meanings: | ||
:;-n | |||
::Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated. | ::Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated. | ||
:;+n | |||
::Removes the nth entry counting from the left of the list shown by dirs, starting with zero. For example: ``popd +0'' removes the first directory, ``popd +1'' the second. | ::Removes the nth entry counting from the left of the list shown by dirs, starting with zero. For example: ``popd +0'' removes the first directory, ``popd +1'' the second. | ||
:;-n | |||
::Removes the nth entry counting from the right of the list shown by dirs, starting with zero. For example: ``popd -0'' removes the last directory, ``popd -1'' the next to last. | ::Removes the nth entry counting from the right of the list shown by dirs, starting with zero. For example: ``popd -0'' removes the last directory, ``popd -1'' the next to last. | ||
Line 2,332: | Line 2,332: | ||
:The 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 argument. In addition to the standard printf(1) format specifications, printf interprets the following extensions: | :The 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 argument. In addition to the standard printf(1) format specifications, printf interprets the following extensions: | ||
:;%b | |||
::causes printf to expand backslash escape sequences in the corresponding argument in the same way as echo -e. | ::causes printf to expand backslash escape sequences in the corresponding argument in the same way as echo -e. | ||
:;%q | |||
::causes printf to output the corresponding argument in a format that can be reused as shell input. | ::causes printf to output the corresponding argument in a format that can be reused as shell input. | ||
:;%(datefmt)T | |||
::causes printf to output the date-time string resulting from using datefmt as a format string for strftime(3). The corresponding 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 printf behavior. | ::causes printf to output the date-time string resulting from using datefmt as a format string for strftime(3). The corresponding 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 printf behavior. | ||
Line 2,348: | Line 2,348: | ||
;<nowiki>pushd [-n] [dir]</nowiki> | ;<nowiki>pushd [-n] [dir]</nowiki> | ||
: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, pushd exchanges the top two directories and returns 0, unless the directory stack is empty. Arguments, if supplied, have the following meanings: | :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, pushd exchanges the top two directories and returns 0, unless the directory stack is empty. Arguments, if supplied, have the following meanings: | ||
:;-n | |||
::Suppresses the normal change of directory when rotating or adding directories to the stack, so that only the stack is manipulated. | ::Suppresses the normal change of directory when rotating or adding directories to the stack, so that only the stack is manipulated. | ||
:;+n | |||
::Rotates the stack so that the nth directory (counting from the left of the list shown by dirs, starting with zero) is at the top. | ::Rotates the stack so that the nth directory (counting from the left of the list shown by dirs, starting with zero) is at the top. | ||
:;-n | |||
::Rotates the stack so that the nth directory (counting from the right of the list shown by dirs, starting with zero) is at the top. | ::Rotates the stack so that the nth directory (counting from the right of the list shown by dirs, starting with zero) is at the top. | ||
:;dir | |||
::Adds dir to the directory stack at the top, making it the new current working di‐ | ::Adds dir to the directory stack at the top, making it the new current working di‐ | ||
rectory as if it had been supplied as the argument to the cd builtin. | rectory as if it had been supplied as the argument to the cd builtin. | ||
Line 2,365: | Line 2,365: | ||
;<nowiki>read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]</nowiki> | ;<nowiki>read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]</nowiki> | ||
:One line is read from the standard input, or from the file descriptor fd supplied as an argument to the -u option, split into words as described above under Word Splitting, and the first word is assigned to the first name, the second word to the second name, and so on. If there are more words than names, the remaining words and their intervening delimiters are assigned to the last name. If there are fewer words read from the input stream than names, the remaining names are assigned empty values. The characters in IFS are used to split the line into words using the same rules the shell uses for expansion (described above under Word Splitting). The backslash character (\) may be used to remove any special meaning for the next character read and for line continuation. Options, if supplied, have the following meanings: | :One line is read from the standard input, or from the file descriptor fd supplied as an argument to the -u option, split into words as described above under Word Splitting, and the first word is assigned to the first name, the second word to the second name, and so on. If there are more words than names, the remaining words and their intervening delimiters are assigned to the last name. If there are fewer words read from the input stream than names, the remaining names are assigned empty values. The characters in IFS are used to split the line into words using the same rules the shell uses for expansion (described above under Word Splitting). The backslash character (\) may be used to remove any special meaning for the next character read and for line continuation. Options, if supplied, have the following meanings: | ||
:;-a aname | |||
::The words are assigned to sequential indices of the array variable aname, starting at 0. aname is unset before any new values are assigned. Other name arguments are ignored. | ::The words are assigned to sequential indices of the array variable aname, starting at 0. aname is unset before any new values are assigned. Other name arguments are ignored. | ||
:;-d delim | |||
::The first character of delim is used to terminate the input line, rather than newline. If delim is the empty string, read will terminate a line when it reads a NUL character. | ::The first character of delim is used to terminate the input line, rather than newline. If delim is the empty string, read will terminate a line when it reads a NUL character. | ||
:;-e | |||
::If the standard input is coming from a terminal, readline (see READLINE above) is used to obtain the line. Readline uses the current (or default, if line editing was not previously active) editing settings, but uses Readline's default filename completion. | ::If the standard input is coming from a terminal, readline (see READLINE above) is used to obtain the line. Readline uses the current (or default, if line editing was not previously active) editing settings, but uses Readline's default filename completion. | ||
:;-i text | |||
::If readline is being used to read the line, text is placed into the editing buffer before editing begins. | ::If readline is being used to read the line, text is placed into the editing buffer before editing begins. | ||
:;-n nchars | |||
::read returns after reading nchars characters rather than waiting for a complete line of input, but honors a delimiter if fewer than nchars characters are read before the delimiter. | ::read returns after reading nchars characters rather than waiting for a complete line of input, but honors a delimiter if fewer than nchars characters are read before the delimiter. | ||
:;-N nchars | |||
::read returns after reading exactly nchars characters rather than waiting for a complete line of input, unless EOF is encountered or read times out. Delimiter characters encountered in the input are not treated specially and do not cause read to return until nchars characters are read. The result is not split on the characters in IFS; the intent is that the variable is assigned exactly the characters read (with the exception of backslash; see the -r option below). | ::read returns after reading exactly nchars characters rather than waiting for a complete line of input, unless EOF is encountered or read times out. Delimiter characters encountered in the input are not treated specially and do not cause read to return until nchars characters are read. The result is not split on the characters in IFS; the intent is that the variable is assigned exactly the characters read (with the exception of backslash; see the -r option below). | ||
:;-p prompt | |||
::Display prompt 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. | ::Display prompt 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. | ||
:;-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 then be used as a line continuation. | ::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 then be used as a line continuation. | ||
:;-s | |||
::Silent mode. If input is coming from a terminal, characters are not echoed. | ::Silent mode. If input is coming from a terminal, characters are not echoed. | ||
:;-t timeout | |||
::Cause read to time out and return failure if a complete line of input (or a specified number of characters) is not read within timeout seconds. timeout may be a decimal number with a fractional portion following the decimal point. This option is only effective if read is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. If read times out, read saves any partial input read into the specified variable name. If timeout is 0, read 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. | ::Cause read to time out and return failure if a complete line of input (or a specified number of characters) is not read within timeout seconds. timeout may be a decimal number with a fractional portion following the decimal point. This option is only effective if read is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. If read times out, read saves any partial input read into the specified variable name. If timeout is 0, read 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. | ||
:;-u fd | |||
::Read input from file descriptor fd. | ::Read input from file descriptor fd. | ||
Line 2,399: | Line 2,399: | ||
;<nowiki>set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]</nowiki> | ;<nowiki>set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]</nowiki> | ||
: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 posix mode, 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 $1, $2, ... $n. Options, if specified, have the following meanings: | :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 posix mode, 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 $1, $2, ... $n. Options, if specified, have the following meanings: | ||
:;-a | |||
::Each variable or function that is created or modified is given the export attribute and marked for export to the environment of subsequent commands. | ::Each variable or function that is created or modified is given the export attribute and marked for export to the environment of subsequent commands. | ||
:;-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. | ::Report the status of terminated background jobs immediately, rather than before the next primary prompt. This is effective only when job control is enabled. | ||
:;-e | |||
::Exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command (see 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 while or until keyword, part of the test following the if or elif reserved words, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted with !. If a compound command other than a subshell returns a non-zero status because a command failed while -e was being ignored, the shell does not exit. A trap on ERR, if set, is executed before the shell exits. This option applies to the shell environment and each subshell environment separately (see COMMAND EXECUTION ENVIRONMENT above), and may cause subshells to exit before executing all the commands in the subshell. | ::Exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command (see 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 while or until keyword, part of the test following the if or elif reserved words, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted with !. If a compound command other than a subshell returns a non-zero status because a command failed while -e was being ignored, the shell does not exit. A trap on ERR, if set, is executed before the shell exits. This option applies to the shell environment and each subshell environment separately (see COMMAND EXECUTION ENVIRONMENT above), and may cause subshells to exit before executing all the commands in the subshell. | ||
::If a compound command or shell function executes in a context where -e is being ignored, none of the commands executed within the compound command or function body will be affected by the -e setting, even if -e is set and a command returns a failure status. If a compound command or shell function sets -e while executing in a context where -e is ignored, that setting will not have any effect until the compound command or the command containing the function call completes. | ::If a compound command or shell function executes in a context where -e is being ignored, none of the commands executed within the compound command or function body will be affected by the -e setting, even if -e is set and a command returns a failure status. If a compound command or shell function sets -e while executing in a context where -e is ignored, that setting will not have any effect until the compound command or the command containing the function call completes. | ||
:;-f | |||
::Disable pathname expansion. | ::Disable pathname expansion. | ||
:;-h | |||
::Remember the location of commands as they are looked up for execution. This is enabled by default. | ::Remember the location of commands as they are looked up for execution. This is enabled by default. | ||
:;-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. | ::All arguments in the form of assignment statements are placed in the environment for a command, not just those that precede the command name. | ||
:;-m | |||
::Monitor mode. Job control is enabled. This option is on by default for interactive shells on systems that support it (see 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. | ::Monitor mode. Job control is enabled. This option is on by default for interactive shells on systems that support it (see 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. | ||
:;-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. | ::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. | ||
:;-o option-name | |||
::The option-name can be one of the following: | ::The option-name can be one of the following: | ||
::allexport | ::allexport | ||
Line 2,474: | Line 2,474: | ||
:::Same as -x. | :::Same as -x. | ||
::If -o is supplied with no option-name, the values of the current options are printed. If +o is supplied with no option-name, a series of set commands to recreate the current option settings is displayed on the standard output. | ::If -o is supplied with no option-name, the values of the current options are printed. If +o is supplied with no option-name, a series of set commands to recreate the current option settings is displayed on the standard output. | ||
:;-p | |||
::Turn on privileged mode. In this mode, the $ENV and $BASH_ENV files are not processed, shell functions are not inherited from the environment, and the SHELLOPTS, BASHOPTS, CDPATH, and 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 -p option is not supplied, these actions are taken and the effective user id is set to the real user id. If the -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. | ::Turn on privileged mode. In this mode, the $ENV and $BASH_ENV files are not processed, shell functions are not inherited from the environment, and the SHELLOPTS, BASHOPTS, CDPATH, and 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 -p option is not supplied, these actions are taken and the effective user id is set to the real user id. If the -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. | ||
:;-t | |||
::Exit after reading and executing one command. | ::Exit after reading and executing one command. | ||
:;-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. | ::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. | ||
:;-v | |||
::Print shell input lines as they are read. | ::Print shell input lines as they are read. | ||
:;-x | |||
::After expanding each simple command, for command, case command, select command, or arithmetic for command, display the expanded value of PS4, followed by the command and its expanded arguments or associated word list. | ::After expanding each simple command, for command, case command, select command, or arithmetic for command, display the expanded value of PS4, followed by the command and its expanded arguments or associated word list. | ||
:;-B | |||
::The shell performs brace expansion (see Brace Expansion above). This is on by default. | ::The shell performs brace expansion (see Brace Expansion above). This is on by default. | ||
:;-C | |||
::If set, bash does not overwrite an existing file with the >, >&, and <> redirection operators. This may be overridden when creating output files by using the redirection operator >| instead of >. | ::If set, bash does not overwrite an existing file with the >, >&, and <> redirection operators. This may be overridden when creating output files by using the redirection operator >| instead of >. | ||
:;-E | |||
::If set, any trap on ERR is inherited by shell functions, command substitutions, and commands executed in a subshell environment. The ERR trap is normally not inherited in such cases. | ::If set, any trap on ERR is inherited by shell functions, command substitutions, and commands executed in a subshell environment. The ERR trap is normally not inherited in such cases. | ||
:;-H | |||
::Enable ! style history substitution. This option is on by default when the shell is interactive. | ::Enable ! style history substitution. This option is on by default when the shell is interactive. | ||
:;-P | |||
::If set, the shell does not resolve symbolic links when executing commands such as cd that change the current working directory. It uses the physical directory structure instead. By default, bash follows the logical chain of directories when performing commands which change the current directory. | ::If set, the shell does not resolve symbolic links when executing commands such as cd that change the current working directory. It uses the physical directory structure instead. By default, bash follows the logical chain of directories when performing commands which change the current directory. | ||
:;-T | |||
::If set, any traps on DEBUG and RETURN are inherited by shell functions, command substitutions, and commands executed in a subshell environment. The DEBUG and RETURN traps are normally not inherited in such cases. | ::If set, any traps on DEBUG and RETURN are inherited by shell functions, command substitutions, and commands executed in a subshell environment. The DEBUG and RETURN traps are normally not inherited in such cases. | ||
:;-- | |||
::If no arguments follow this option, then the positional parameters are unset.Otherwise, the positional parameters are set to the args, even if some of them begin with a -. | ::If no arguments follow this option, then the positional parameters are unset.Otherwise, the positional parameters are set to the args, even if some of them begin with a -. | ||
:;- | |||
::Signal the end of options, cause all remaining args to be assigned to the positional parameters. The -x and -v options are turned off. If there are no args, the positional parameters remain unchanged. | ::Signal the end of options, cause all remaining args to be assigned to the positional parameters. The -x and -v options are turned off. If there are no args, the positional parameters remain unchanged. | ||
Line 2,508: | Line 2,508: | ||
;<nowiki>shopt [-pqsu] [-o] [optname ...]</nowiki> | ;<nowiki>shopt [-pqsu] [-o] [optname ...]</nowiki> | ||
:Toggle the values of settings controlling optional shell behavior. The settings can be either those listed below, or, if the -o option is used, those available with the -o option to the set builtin command. With no options, or with the -p option, a list of all settable options is displayed, with an indication of whether or not each is set; if optnames are supplied, the output is restricted to those options. The -p option causes output to be displayed in a form that may be reused as input. Other options have the following meanings: | :Toggle the values of settings controlling optional shell behavior. The settings can be either those listed below, or, if the -o option is used, those available with the -o option to the set builtin command. With no options, or with the -p option, a list of all settable options is displayed, with an indication of whether or not each is set; if optnames are supplied, the output is restricted to those options. The -p option causes output to be displayed in a form that may be reused as input. Other options have the following meanings: | ||
:;-s | |||
::Enable (set) each optname. | ::Enable (set) each optname. | ||
:;-u | |||
::Disable (unset) each optname. | ::Disable (unset) each optname. | ||
:;-q | |||
::Suppresses normal output (quiet mode); the return status indicates whether the optname is set or unset. If multiple optname arguments are given with -q, the return status is zero if all optnames are enabled; non-zero otherwise. | ::Suppresses normal output (quiet mode); the return status indicates whether the optname is set or unset. If multiple optname arguments are given with -q, the return status is zero if all optnames are enabled; non-zero otherwise. | ||
:;-o | |||
::Restricts the values of optname to be those defined for the -o option to the set builtin. | ::Restricts the values of optname to be those defined for the -o option to the set builtin. | ||
Line 2,521: | Line 2,521: | ||
:The return status when listing options is zero if all optnames are enabled, non-zero otherwise. When setting or unsetting options, the return status is zero unless an optname is not a valid shell option. | :The return status when listing options is zero if all optnames are enabled, non-zero otherwise. When setting or unsetting options, the return status is zero unless an optname is not a valid shell option. | ||
: | :ショップオプションのリストは以下の通り: | ||
:;assoc_expand_once | |||
:: | ::設定されている場合、シェルは、算術式評価中、変数代入を実行できるビルドイン実行中、および配列の再参照を実行するビルドイン実行中に、連想配列添え字の多重評価を抑制する。 | ||
:;autocd | |||
:: | ::設定された場合、ディレクトリ名であるコマンド名は、あたかもcdコマンドの引数であるかのように実行される。 このオプションは対話型シェルでのみ使用される。 | ||
;;cdable_vars | ;;cdable_vars | ||
:: | ::設定された場合、ディレクトリでないcd組み込みコマンドの引数は、変更先のディレクトリを値とする変数名とみなされる。 | ||
:;cdspell | |||
:: | ::設定された場合、cdコマンドのディレクトリ構成要素のスペルにおける軽微なエラーが修正される。 チェックされる誤りは、文字が入れ替わっている、文字が欠けている、 1文字多い、などである。 修正が見つかった場合、修正されたファイル名が表示され、コマンドは続行される。 このオプションは対話型シェルでのみ使用される。 | ||
:;checkhash | |||
:: | ::セットされていると、bashはハッシュ・テーブルで見つかったコマンドを実行しようとする前に、そのコマンドが存在するかどうかをチェックする。 ハッシュ化されたコマンドがもはや存在しない場合は、通常のパス検索が実行される。 | ||
:;checkjobs | |||
:: | ::設定されている場合、bashは対話型シェルを終了する前に、停止中および実行中のジョブのステータスを一覧表示する。 実行中のジョブがある場合、コマンドを介さずに2回目の終了を試みるまで終了が延期される(上記の[[#JOB CONTROL|JOB CONTROL ]]を参照)。 停止中のジョブがある場合、シェルは常に終了を延期する。 | ||
:;checkwinsize | |||
:: | ::このオプションを設定すると、bashは外部(ビルトインでない)コマンドを実行するたびにウィンドウ・サイズをチェックし、必要に応じてLINESとCOLUMNSの値を更新する。 このオプションはデフォルトで有効になっている。 | ||
:;cmdhist | |||
:: | ::これを設定すると、bashは複数行コマンドのすべての行を同じ履歴エントリに保存しようとする。 これにより、複数行コマンドの再編集が容易になる。 このオプションはデフォルトで有効になっているが、上記の「[[#HISTORY|HISTORY ]]」で説明したように、コマンドヒストリが有効になっている場合にのみ効果がある。 | ||
:;compat31 | |||
:;compat32 | |||
:;compat40 | |||
:;compat41 | |||
:;compat42 | |||
:;compat43 | |||
:;compat44 | |||
:: | ::これらは、シェルの互換モードの側面を制御する(以下の「[[#SHELL COMPATIBILITY MODE|SHELL COMPATIBILITY MODE ]]」を参照)。 | ||
:;complete_fullquote | |||
:: | ::設定されている場合、bashは補完を実行するときにファイル名とディレクトリ名に含まれるすべてのシェル・メタ文字を引用符で囲む。 設定されていない場合、補完されるファイル名のシェル変数参照にドル記号のようなメタキャラクタがあると、bashはそのメタキャラクタを引用符で囲む文字から除外する。つまり、ディレクトリに展開される変数名のドル記号は引用されないが、ファイル名に現れるドル記号も引用されない。 これは、bashがバックスラッシュを使って補完されたファイル名を引用している場合にのみ有効である。 この変数はデフォルトで設定されており、これは4.2までのバージョンにおけるbashのデフォルトの動作である。 | ||
:;direxpand | |||
:: | ::これを設定すると、bashはファイル名の補完を実行するときに、ディレクトリ名を単語展開の結果に置き換える。 これにより、readline編集バッファの内容が変更される。 設定されていない場合、bashはユーザーが入力した内容を保持しようとする。 | ||
:;dirspell | |||
:: | ::設定すると、最初に与えられたディレクトリ名が存在しない場合、bashは単語補完時にディレクトリ名のスペル修正を試みる。 | ||
:;dotglob | |||
:: | ::.'で始まるファイル名をパス名の展開結果に含める。 ドットグロブがセットされていても、ファイル名 ``.'' と ``...'' は常に明示的にマッチさせる必要がある。 | ||
:;execfail | |||
:: | ::設定された場合、非対話型シェルは、exec 組み込みコマンドの引数として指定されたファイルを実行できなくても終了しない。 対話型シェルは、exec に失敗しても終了しない。 | ||
:;expand_aliases | |||
:: | ::設定されている場合、エイリアスは上記の ALIASES で説明されているように展開される。 このオプションは対話型シェルではデフォルトで有効になっている。 | ||
:;extdebug | |||
:: | ::シェル起動時、またはシェル起動ファイルに設定すると、 --debuggerオプションと同じように、シェル起動前にデバッガ・プロファイルを実行するようにアレンジする。 起動後に設定すると、デバッガが使用することを意図した動作が有効になる: | ||
:::1. | :::1. declareビルトインの-Fオプションは、引数として与えられた各関数名に対応するソースファイル名と行番号を表示する。 | ||
:::2. | :::2. DEBUGトラップによって実行されたコマンドがゼロ以外の値を返した場合、次のコマンドはスキップされ実行されない。 | ||
:::3. | :::3. DEBUGトラップによって実行されたコマンドが値2を返し、シェルがサブルーチン(シェル関数または.NETやソース・ビルトインによって実行されるシェル・スクリプト)で実行されている場合、シェルはreturnの呼び出しをシミュレートする。 | ||
:::4. | :::4. BASH_ARGCとBASH_ARGVは、上記の説明に従って更新される。 | ||
:::5. | :::5. コマンド置換、シェル関数、および ( コマンド ) で呼び出されるサブシェルは、DEBUG および RETURN トラップを継承する。 | ||
:::6. | :::6. コマンド置換、シェル関数、および ( コマンド ) で呼び出されたサブシェルは、ERR トラップを継承する。 | ||
:;extglob | |||
:: | ::設定すると、上記の「パス名の拡張」で説明した拡張パターンマッチング機能が有効になる。 | ||
:;extquote | |||
:: | ::設定すると、${parameter}を二重引用符で囲んだ展開の中で、$'string'と$"string "の引用符付けが行われる。 このオプションはデフォルトで有効になっている。 | ||
:;failglob | |||
:: | ::設定すると、パス名展開時にファイル名にマッチしないパターンは展開エラーとなる。 | ||
:;force_fignore | |||
:: | ::設定されていると、FIGNOREシェル変数で指定された接尾辞は、単語補完を実行するときに、無視された単語が唯一の可能な補完であっても無視される。 FIGNOREについての説明は上記の[[#SHELL VARIABLES|SHELL VARIABLES ]]を参照のこと。 このオプションはデフォルトで有効になっている。 | ||
:;globasciiranges | |||
:: | ::これを設定すると、パターンマッチングの括弧式で使用される範囲式(上記の [[#Pattern Matching|Pattern Matching ]]を参照)は、比較を実行するときに従来のCロケールのように 動作する。 つまり、現在のロケールの照合順序は考慮されないので、 bはAとBの間で照合されず、大文字と小文字のASCII文字は一緒に照合される。 | ||
:;globstar | |||
:: | ::設定されている場合、パス名展開コンテキストで使われるパターン ** は、すべてのファイルと0個以上のディレクトリとサブディレクトリにマッチする。 パターンの後に/が続くと、ディレクトリとサブディレクトリにのみマッチする。 | ||
:;gnu_errfmt | |||
:: | ::設定すると、シェルのエラーメッセージは標準のGNUエラーメッセージ形式で書かれる。 | ||
:;histappend | |||
:: | ::設定された場合、シェルの終了時に、履歴リストはファイルを上書きするのではなく、HISTFILE変数の値で指定されたファイルに追加される。 | ||
:;histreedit | |||
:: | ::readlineが設定され、かつreadlineが使用されている場合、失敗した履歴の置換を再編集する機会がユーザーに与えられる。 | ||
:;histverify | |||
:: | ::セットされていてreadlineが使用されている場合、ヒストリ置換の結果はすぐにシェル・パーサーに渡されない。 その代わりに、結果の行がreadline編集バッファにロードされ、さらに修正できるようになる。 | ||
:;hostcomplete | |||
:: | ::readlineが使用されている場合、@を含む単語が補完されると、bashはホスト名の補完を試みる(上記のREADLINEでの補完を参照)。 これはデフォルトで有効になっている。 | ||
:;huponexit | |||
:: | ::設定すると、対話型ログイン・シェルが終了したときに、bashはすべてのジョブにSIGHUPを送信する。 | ||
:;inherit_errexit | |||
:: | ::このオプションを設定すると、サブシェル環境でerrexitオプショ ンを設定解除する代わりに、コマンド置換がerrexitオプションの値を継承する。 このオプションは、posixモードが有効な場合に有効になる。 | ||
:;interactive_comments | |||
:: | ::このオプションが設定されている場合、#で始まる単語を許可すると、その単語とその行の残りのすべての文字が対話型シェルで無視される(上記の[[#COMMENTS|COMMENTS ]]を参照)。このオプションはデフォルトで有効になっている。 | ||
:;lastpipe | |||
:: | ::設定され、ジョブ制御がアクティブでない場合、シェルは、現在のシェル環境でバックグラウンドで実行されていないパイプラインの最後のコマンドを実行する。 | ||
:;lithist | |||
:: | ::cmdhist オプションが有効な場合、複数行のコマンドは可能な限りセミコロン区切りではなく、改行を埋め込んで履歴に保存される。 | ||
:;localvar_inherit | |||
:: | ::設定されている場合、ローカル変数は、新しい値が代入される前に、前のスコープに存在する同名の変数の値と属性を継承する。 nameref属性は継承されない。 | ||
:;localvar_unset | |||
:: | ::セットされている場合、以前の関数スコープにあるローカル変数に対してunsetを呼び出すと、その関数が返されるまでの間、後続のルックアップでunsetが見つかるようにマークされる。これは、現在の関数スコープでローカル変数をアンセットしたときの動作と同じである。 | ||
:;login_shell | |||
:: | ::シェルは、ログイン・シェルとして起動する場合、このオプションを設定する(上記の[[#INVOCATION|INVOCATION ]]を参照)。 この値は変更できない。 | ||
:;mailwarn | |||
:: | ::もしセットされていて、bashがメールをチェックしているファイルが前回チェックしたときからアクセスされていた場合、``The mailfile has been read''というメッセージが表示される。 | ||
:;no_empty_cmd_completion | |||
:: | ::readlineが使用されている場合、空の行で補完を試みても、PATHを検索して補完を試みることはない。 | ||
:;nocaseglob | |||
:: | ::設定すると、bashはパス名展開(上記の[[#Pathname Expansion|Pathname Expansion ]]を参照)の際に、大文字と小文字を区別せずにファイル名をマッチングする。 | ||
:;nocasematch | |||
:: | ::設定されていると、bashは大文字小文字を区別せずにパターンをマッチングする。大文字小文字や<nowiki>[[</nowiki> 条件付きコマンドの実行中にマッチングを行う場合、パターン置換の単語展開を行う場合、プログラム可能な補完の一部として可能な補完をフィルタリングする場合などである。 | ||
:;nullglob | |||
:: | ::これを設定すると、bashはマッチするファイルがないパターン(上記の[[#Pathname Expansion|Pathname Expansion ]]を参照)を、それ自身ではなくNULL文字列に展開することができる。 | ||
:;progcomp | |||
:: | ::設定されている場合、プログラマブル補完機能(上記の[[#Programmable Completion|Programmable Completion ]]を参照)が有効になる。 このオプションはデフォルトで有効になっている。 | ||
:;progcomp_alias | |||
:: | ::設定され、プログラム可能な補完が有効になっている場合、bashは補完を持たないコマンド名をエイリアスの可能性があるものとして扱い、エイリアスの展開を試みる。エイリアスを持っている場合、bashは展開されたエイリアスの結果のコマンドワードを使用してプログラマブル補完を試みる。 | ||
:;promptvars | |||
:: | ::設定されている場合、プロンプト文字列は、上記のPROMPTINGで説明されているように 展開された後に、パラメータ展開、コマンド置換、算術展開、引用符除去を受ける。 このオプションはデフォルトで有効になっている。 | ||
:;restricted_shell | |||
:: | ::シェルが制限付きモードで起動した場合、このオプションが設定される(下記の[[#RESTRICTED SHELL|RESTRICTED SHELL ]]を参照)。 この値は変更できない。 これは起動ファイルが実行されてもリセットされないので、起動ファイルはシェルが制限されているかどうかを発見することができる。 | ||
:;shift_verbose | |||
:: | ::設定されている場合、シフトカウントが位置パラメーターの数を超えると、shift 組み込み関数はエラーメッセージを表示する。 | ||
:;sourcepath | |||
:: | ::このオプションを設定すると、source (.) 組み込み関数が PATH の値を使用して、 引数として指定されたファイルを含むディレクトリを検索する。 このオプションはデフォルトで有効になっている。 | ||
:;xpg_echo | |||
:: | ::設定すると、echo組み込み関数はデフォルトでバックスラッシュ・エスケープ・シーケンスを展開する。 | ||
;<nowikI>suspend [-f]</nowiki> | ;<nowikI>suspend [-f]</nowiki> | ||
: | :SIGCONT シグナルを受け取るまで、このシェルの実行を一時停止する。 ログインシェルはサスペンドできない。-f オプションを使用すると、これを上書きして強制的にサスペンドできる。シェルがログイン・シェルで -f が指定されていない場合、またはジョブ制御が有効になっていない場合、戻り値は 0 である。 | ||
;test expr | ;test expr | ||
;<nowiki>[ expr ]</nowiki> | ;<nowiki>[ expr ]</nowiki> | ||
: | :条件式exprの評価に応じて、0(真)または1(偽)のステータスを返す。 各演算子とオペランドは別々の引数でなければならない。 testはいかなるオプションも受け付けないし、オプションの終了を意味する--という引数も受け付けず無視する。 | ||
: | :式は以下の演算子を使って組み合わせることができる。 評価は引数の数に依存する。 演算子の優先順位は、引数が5つ以上ある場合に使用される。 | ||
:;! expr | |||
:: | ::exprがfalseなら真。 | ||
:;( expr ) | |||
:: | ::expr の値を返す。 これは、演算子の通常の優先順位を上書きするために使われる。 | ||
:;expr1 -a expr2 | |||
:: | ::expr1とexpr2の両方が真なら真である。 | ||
:;expr1 -o expr2 | |||
:: | ::expr1 または expr2 のどちらかが真なら真。 | ||
: | :testと<nowiki>[</nowiki> は、引数の数に基づく一連のルールを使って条件式を評価する。 | ||
:;0 arguments | |||
:: | ::この表現は偽である。 | ||
:;1 argument | |||
:: | ::この式は、引数がNULLでない場合にのみ真となる。 | ||
:;2 arguments | |||
:: | ::最初の引数が! の場合、式は2番目の引数がNULLの場合のみ真となる。 最初の引数が、上記の「条件式」に列挙された単項条件演算子のいずれかである場合、単項テストが真であれば式は真となる。 最初の引数が有効な単項条件演算子でない場合、式は偽となる。 | ||
:;3 arguments | |||
:: | ::以下の条件は、列挙された順序で適用される。 第2引数が、上記の「条件式」の項に列挙された二項条件演算子の1つである場合、式の結果は、第1引数と第3引数をオペランドとして使用した二項検定の結果となる。 a演算子と-o演算子は、3つの引数がある場合、二項演算子とみなされる。 第1引数が! の場合、値は、第2引数と第3引数を使った2引数テストの否定となる。 第1引数が正確に(かつ第3引数が正確に)である場合、結果は第2引数の1引数テストとなる。 そうでない場合、式は偽となる。 | ||
:;4 arguments | |||
:: | ::最初の引数が!の場合、結果は残りの引数で構成される3つの引数式の否定となる。 そうでない場合、式はパースされ、上に挙げたルールを使って優先順位に従って評価される。 | ||
:;5 or more arguments | |||
:: | ::式はパースされ、上記の規則を用いて優先順位に従って評価される。 | ||
: | :演算子 < と > は、test または [ と一緒に使われると、ASCIIの順序で辞書順にソートされる。 | ||
;times | ;times | ||
: | :シェルおよびシェルから実行されたプロセスの累積ユーザー時間および累積システム時間を表示する。 戻り値は 0 である。 | ||
;<nowiki>trap [-lp] [[arg] sigspec ...]</nowiki> | ;<nowiki>trap [-lp] [[arg] sigspec ...]</nowiki> | ||
: | :コマンド arg は、シェルがシグナル sigspec を受け取ったときに読み込まれ、実行される。 arg が存在しない場合 (sigspec が1つの場合) または - の場合、指定された各シグナルは元の値 (シェルに入ったときの値) にリセットされる。 arg が NULL 文字列の場合、各 sigspec で指定されたシグナルは、シェルおよびシェルが呼び出すコマンドによって無視される。 arg が存在せず、-p が供給された場合、各 sigspec に関連付けられたトラップコマンドが表示される。 引数がない場合、または -p だけが与えられた場合、 trap は各シグナルに関連付けられたコマンドのリストを表示する。 lオプションを指定すると、シェルはシグナル名とそれに対応する番号のリストを表示する。 各sigspecは、<signal.h>で定義されているシグナル名かシグナル番号である。 シグナル名は大文字と小文字を区別せず、接頭辞 SIG はオプションである。 | ||
: | :sigspecがEXIT(0)の場合、コマンドargはシェルからの終了時に実行される。 sigspecがDEBUGの場合、コマンドargは、単純コマンド、forコマンド、caseコマンド、selectコマンド、すべての算術forコマンド、およびシェル関数内で最初のコマンドが実行される前に実行される(上記の[[#SHELL GRAMMAR|SHELL GRAMMAR ]]を参照)。 DEBUGトラップに対する効果の詳細については、shopt組み込みのextdebugオプションの説明を参照のこと。 sigspec が RETURN の場合、.source または source 組み込み関数で実行されたシェル関数またはスクリプトが実行を終了するたびに、コマンド arg が実行される。 | ||
: | :sigspecがERRの場合、パイプライン(単一の単純なコマンドで構成されることもある)、リスト、または複合コマンドが、以下の条件に従って、ゼロ以外の終了ステータスを返すたびに、コマンドargが実行される。 ERR トラップは、失敗したコマンドが while または until キーワードの直後のコマンドリストの一部である場合、if 文のテストの一部である場合、最後の && または || に続くコマンド以外の && または || リストで実行されるコマンドの一部である場合、パイプラインの最後のコマンド以外のコマンドである場合、コマンドの戻り値が ! これらは、errexit (-e)オプションが従う条件と同じである。 | ||
: | :シェルに入ったときに無視されたシグナルは、トラップもリセットもできない。 無視されないトラップされたシグナルは、サブシェルまたはサブシェル環境が作成されると、元の値にリセットされる。 sigspecが無効な場合、戻りステータスはfalseになり、そうでなければtrapはtrueを返す。 | ||
;<nowiki>type [-aftpP] name [name ...]</nowiki> | ;<nowiki>type [-aftpP] name [name ...]</nowiki> | ||
: | :オプションがない場合は、それぞれの名前がコマンド名として使われた場合にどのように解釈されるかを示す。tオプションが使われると、typeは、nameがエイリアス、シェル予約語、関数、組み込み関数、ディスクファイルの場合、それぞれエイリアス、キーワード、関数、組み込み関数、ディスクファイルのいずれかの文字列を表示する。 名前が見つからない場合は何も表示されず、終了ステータスにfalseが返される。 -pオプションが使われた場合、typeはnameがコマンド名として指定された場合 に実行されるディスクファイルの名前を返すか、``type -t name''がfileを返さない場合は何も返さない。 -P オプションをつけると、``type -t name'' が file を返さない場合でも、それぞれの名前に対して PATH を検索する。 コマンドがハッシュ化されている場合、-p と -P はハッシュ化された値を表示するが、必ずしも PATH で最初に表示されるファイルとは限らない。 -aオプションが使われると、nameという名前の実行ファイルを含むすべての場所を表示する。 これには、-pオプションも使用されていない場合に限り、エイリアスや関数も含まれる。 aを使用する場合、ハッシュ化されたコマンドのテーブルは参照されない。 fオプションは、コマンド組み込み関数と同様にシェル関数の検索を抑制する。 typeは、すべての引数が見つかった場合はtrueを返し、見つからなかった場合はfalseを返す。 | ||
;<nowiki>ulimit [-HS] -a</nowiki> | ;<nowiki>ulimit [-HS] -a</nowiki> | ||
;<nowiki>ulimit [-HS] [-bcdefiklmnpqrstuvxPRT [limit]]</nowiki> | ;<nowiki>ulimit [-HS] [-bcdefiklmnpqrstuvxPRT [limit]]</nowiki> | ||
: | :シェルやシェルによって起動されるプロセスが利用可能なリソースを制御する。-Hおよび-Sオプションは、指定されたリソースに対してハードリミットまたはソフトリミットを設定することを指定する。 ハードリミットは、一度設定されると非 root ユーザーが増やすことはできない。 Hも-Sも指定しない場合、ソフトリミットとハードリミットの両方が設定される。 limitの値には、リソースに指定された単位の数値を指定するか、特別な値hard、soft、unlimitedのいずれかを指定する。hardは現在のハードリミット、softは現在のソフトリミット、unlimitedはリミットなしをそれぞれ表す。 limitが省略された場合は、-Hオプションが与えられていない限り、リソースのソフトリミットの現在値が表示される。 複数のリソースを指定した場合は、値の前にリミット名と単位 (適切な場合) が表示される。 その他のオプションは、以下のように解釈される: | ||
:;-a | |||
:: | ::すべての電流制限を報告する。 | ||
:;-b | |||
:: | ::ソケットバッファの最大サイズ | ||
:;-c | |||
:: | ::作成されるコアファイルの最大サイズ | ||
:;-d | |||
: | プロセスのデータセグメントの最大サイズである。 | ||
:;-e | |||
スケジューリング優先度の最大値("nice")。 | |||
:;-f | |||
: | シェルとその子プロセスが書き込むファイルの最大サイズである。 | ||
:;-i | |||
:: | ::pending シグナルの最大数 | ||
:;-k | |||
:: | ::割り当て可能なkキューの最大数 | ||
:;-l | |||
:: | ::メモリにロックできる最大サイズ | ||
:;-m | |||
:: | ::常駐セットの最大サイズ(多くのシステムはこの制限を守らない) | ||
:;-n | |||
:: | ::開いているファイル記述子の最大数(多くのシステムはこの値の設定を許可しない) | ||
:;-p | |||
:: | ::512バイトブロック単位のパイプサイズ(この値は設定できない場合がある) | ||
:;-q | |||
:: | ::POSIXメッセージ・キューの最大バイト数 | ||
:;-r | |||
:: | ::リアルタイム・スケジューリングの最大優先度 | ||
:;-s | |||
:: | ::最大スタックサイズ | ||
:;-t | |||
:: | ::最大CPU時間(秒) | ||
:;-u | |||
:: | ::1ユーザーが利用可能な最大プロセス数 | ||
:;-v | |||
:: | ::シェルと、システムによってはその子シェルが利用可能な仮想メモリの最大量 | ||
:;-x | |||
:: | ::ファイルロックの最大数 | ||
:;-P | |||
:: | ::疑似端末の最大数 | ||
:;-R | |||
:: | ::リアルタイムプロセスがブロックされるまでに実行できる最大時間(マイクロ秒単位 | ||
:;-T | |||
:: | ::スレッドの最大数 | ||
: | :limitが与えられ、-aオプションが使われていない場合、 limitは指定されたリソースの新しい値になる。 オプションが与えられていない場合は、-fが仮定される。 ただし、-tは秒単位、-Rはマイクロ秒単位、-pは512バイトブロック単位、 -P、-T、-b、-k、-n、-uはスケールなし、 posixモードでは-cと-fは512バイト単位である。 無効なオプションや引数が与えられるか、新しいリミット値の設定中にエラーが発生しない限り、戻り値は0である。 | ||
;<nowiki>umask [-p] [-S] [mode]</nowiki> | ;<nowiki>umask [-p] [-S] [mode]</nowiki> | ||
: | :ユーザーファイル作成マスクは mode に設定される。 mode が数字で始まる場合は、8進数として解釈される。そうでない場合は、 chmod(1) が受け付けるものと同様のシンボリック・モード・マスクとして解釈される。 modeが省略された場合、マスクの現在の値が表示される。-Sオプションを指定すると、マスクが記号形式で表示される。 -pオプションが与えられ、modeが省略された場合、入力として再利用可能な形式で出力される。 戻りステータスは、モードの変更に成功した場合、または mode 引数が与えられなかった場合は 0 であり、そうでない場合は false である。 | ||
;<nowiki>unalias [-a] [name ...]</nowiki> | ;<nowiki>unalias [-a] [name ...]</nowiki> | ||
: | :定義されているエイリアスのリストからそれぞれの名前を削除する。 -aを指定すると、すべてのエイリアス定義が削除される。 与えられた名前が定義されたエイリアスでない限り、戻り値は真である。 | ||
;<nowiki>unset [-fv] [-n] [name ...]</nowiki> | ;<nowiki>unset [-fv] [-n] [name ...]</nowiki> | ||
: | :それぞれの名前に対して、対応する変数または関数を削除する。 -vオプションが指定された場合、各名前はシェル変数を参照し、その変数が削除される。 読み取り専用の変数は設定解除できない。-f を指定すると、各名称はシェル関数を指し、その関数定義が削除される。-n オプションが指定され、name が nameref 属性を持つ変数である場合、name は参照先の変数ではなくアンセットされる。 -nオプションは、-fオプションが与えられている場合には何の効果もない。 その名前の変数がない場合、その名前の関数があればアンセットされる。 アンセットされた変数や関数は、後続のコマンドに渡される環境から取り除かれる。 '''BASH_ALIASES'''、'''BASH_ARGV0'''、'''BASH_CMDS'''、'''BASH_COMMAND'''、'''BASH_SUBSHELL'''、'''BASHPID'''、'''COMP_WORDBREAKS'''、'''DIRSTACK'''、'''EPOCHREALTIME'''、'''EPOCHSECONDS'''、'''FUNCNAME'''、'''GROUPS'''、'''HISTCMD'''、'''LINENO'''、'''RANDOM'''、'''SECONDS'''、'''SRANDOM'''のどれかがアンセットされると、たとえその後にリセットされたとしても、特別なプロパティは失われる。 名前が読み取り専用でない限り、終了ステータスは真である。 | ||
;<nowiki>wait [-fn] [-p varname] [id ...]</nowiki> | ;<nowiki>wait [-fn] [-p varname] [id ...]</nowiki> | ||
: | :指定された各子プロセスを待ち、その終了ステータスを返す。 各idは、プロセスIDまたはジョブ指定である。ジョブ指定が与えられた場合、 そのジョブのパイプラインにある全てのプロセスが待たれる。 idが与えられない場合、waitは実行中のすべてのバックグラウンド・ジョブと、 最後に実行されたプロセス置換(そのプロセスidが$! -nオプションが与えられた場合、waitはidのリストから1つのジョブ、またはidが与えられない場合は任意のジョブの完了を待ち、その終了ステータスを返す。与えられた引数のどれもがシェルの子でない場合、または引数が与えられず、シェルに待機していない子がない場合、終了ステータスは127である。 -p オプションが与えられると、終了ステータスが返されたジョブのプロセスまたはジョブ識別子が、 オプション引数で指定された変数 varname に代入される。 この変数は、代入の前に初期状態では設定されていない。 これは、-n オプションが指定されている場合にのみ有効である。 ジョブ制御が有効になっているときに -f オプションを指定すると、id がステータスを変更したときに返すのではなく、id が終了するのを待ってからステータスを返すようになる。 idが存在しないプロセスまたはジョブを指定した場合、返されるステータスは127である。 それ以外の場合は、最後に待機したプロセスまたはジョブの終了ステータスが返される。 | ||
== SHELL COMPATIBILITY MODE == | == SHELL COMPATIBILITY MODE == |