📄 bash.0
字号:
BASH(1) BASH(1)NNAAMMEE bash - GNU Bourne-Again SHellSSYYNNOOPPSSIISS bbaasshh [options] [file]CCOOPPYYRRIIGGHHTT Bash is Copyright (C) 1989-2010 by the Free Software Foundation, Inc.DDEESSCCRRIIPPTTIIOONN BBaasshh is an sshh-compatible command language interpreter that executes commands read from the standard input or from a file. BBaasshh also incor- porates useful features from the _K_o_r_n and _C shells (kksshh and ccsshh). BBaasshh is intended to be a conformant implementation of the Shell and Utilities portion of the IEEE POSIX specification (IEEE Standard 1003.1). BBaasshh can be configured to be POSIX-conformant by default.OOPPTTIIOONNSS All of the single-character shell options documented in the descrip- tion of the sseett builtin command can be used as options when the shell is invoked. In addition, bbaasshh interprets the following options when it is invoked: --cc _s_t_r_i_n_g If the --cc option is present, then commands are read from _s_t_r_i_n_g. If there are arguments after the _s_t_r_i_n_g, they are assigned to the positional parameters, starting with $$00. --ii If the --ii option is present, the shell is _i_n_t_e_r_a_c_t_i_v_e. --ll Make bbaasshh act as if it had been invoked as a login shell (see IINNVVOOCCAATTIIOONN below). --rr If the --rr option is present, the shell becomes _r_e_s_t_r_i_c_t_e_d (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). --ss If the --ss 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. --DD A list of all double-quoted strings preceded by $$ is printed on the standard output. These are the strings that are sub- ject to language translation when the current locale is not CC or PPOOSSIIXX. This implies the --nn option; no commands will be executed. [[--++]]OO [[_s_h_o_p_t___o_p_t_i_o_n]] _s_h_o_p_t___o_p_t_i_o_n is one of the shell options accepted by the sshhoopptt builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). If _s_h_o_p_t___o_p_t_i_o_n is present, --OO sets the value of that option; ++OO unsets it. If _s_h_o_p_t___o_p_t_i_o_n is not supplied, the names and values of the shell options accepted by sshhoopptt are printed on the standard output. If the invocation option is ++OO, the output is displayed in a format that may be reused as input. ---- A ---- signals the end of options and disables further option processing. Any arguments after the ---- are treated as file- names and arguments. An argument of -- is equivalent to ----. BBaasshh also interprets a number of multi-character options. These options must appear on the command line before the single-character options to be recognized. ----ddeebbuuggggeerr Arrange for the debugger profile to be executed before the shell starts. Turns on extended debugging mode (see the description of the eexxttddeebbuugg option to the sshhoopptt builtin below). ----dduummpp--ppoo--ssttrriinnggss Equivalent to --DD, but the output is in the GNU _g_e_t_t_e_x_t ppoo (por- table object) file format. ----dduummpp--ssttrriinnggss Equivalent to --DD. ----hheellpp Display a usage message on standard output and exit success- fully. ----iinniitt--ffiillee _f_i_l_e ----rrccffiillee _f_i_l_e Execute commands from _f_i_l_e instead of the standard personal ini- tialization file _~_/_._b_a_s_h_r_c if the shell is interactive (see IINNVVOOCCAATTIIOONN below). ----llooggiinn Equivalent to --ll. ----nnooeeddiittiinngg Do not use the GNU rreeaaddlliinnee library to read command lines when the shell is interactive. ----nnoopprrooffiillee Do not read either the system-wide startup file _/_e_t_c_/_p_r_o_f_i_l_e or any of the personal initialization files _~_/_._b_a_s_h___p_r_o_f_i_l_e, _~_/_._b_a_s_h___l_o_g_i_n, or _~_/_._p_r_o_f_i_l_e. By default, bbaasshh reads these files when it is invoked as a login shell (see IINNVVOOCCAATTIIOONN below). ----nnoorrcc Do not read and execute the personal initialization file _~_/_._b_a_s_h_r_c if the shell is interactive. This option is on by default if the shell is invoked as sshh. ----ppoossiixx Change the behavior of bbaasshh where the default operation differs from the POSIX standard to match the standard (_p_o_s_i_x _m_o_d_e). ----rreessttrriicctteedd The shell becomes restricted (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). ----vveerrbboossee Equivalent to --vv. ----vveerrssiioonn Show version information for this instance of bbaasshh on the stan- dard output and exit successfully.AARRGGUUMMEENNTTSS If arguments remain after option processing, and neither the --cc nor the --ss option has been supplied, the first argument is assumed to be the name of a file containing shell commands. If bbaasshh is invoked in this fashion, $$00 is set to the name of the file, and the positional parame- ters are set to the remaining arguments. BBaasshh reads and executes com- mands from this file, then exits. BBaasshh's exit status is the exit sta- tus 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 PPAATTHH for the script.IINNVVOOCCAATTIIOONN A _l_o_g_i_n _s_h_e_l_l is one whose first character of argument zero is a --, or one started with the ----llooggiinn option. An _i_n_t_e_r_a_c_t_i_v_e shell is one started without non-option arguments and without the --cc option whose standard input and error are both connected to terminals (as determined by _i_s_a_t_t_y(3)), or one started with the --ii option. PPSS11 is set and $$-- includes ii if bbaasshh is interactive, allowing a shell script or a startup file to test this state. The following paragraphs describe how bbaasshh executes its startup files. If any of the files exist but cannot be read, bbaasshh reports an error. Tildes are expanded in file names as described below under TTiillddee EExxppaann-- ssiioonn in the EEXXPPAANNSSIIOONN section. When bbaasshh is invoked as an interactive login shell, or as a non-inter- active shell with the ----llooggiinn option, it first reads and executes com- mands from the file _/_e_t_c_/_p_r_o_f_i_l_e, if that file exists. After reading that file, it looks for _~_/_._b_a_s_h___p_r_o_f_i_l_e, _~_/_._b_a_s_h___l_o_g_i_n, and _~_/_._p_r_o_f_i_l_e, in that order, and reads and executes commands from the first one that exists and is readable. The ----nnoopprrooffiillee option may be used when the shell is started to inhibit this behavior. When a login shell exits, bbaasshh reads and executes commands from the file _~_/_._b_a_s_h___l_o_g_o_u_t, if it exists. When an interactive shell that is not a login shell is started, bbaasshh reads and executes commands from _~_/_._b_a_s_h_r_c, if that file exists. This may be inhibited by using the ----nnoorrcc option. The ----rrccffiillee _f_i_l_e option will force bbaasshh to read and execute commands from _f_i_l_e instead of _~_/_._b_a_s_h_r_c. When bbaasshh is started non-interactively, to run a shell script, for example, it looks for the variable BBAASSHH__EENNVV 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. BBaasshh behaves as if the following com- mand were executed: if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi but the value of the PPAATTHH variable is not used to search for the file name. If bbaasshh is invoked with the name sshh, it tries to mimic the startup behavior of historical versions of sshh as closely as possible, while conforming to the POSIX standard as well. When invoked as an interac- tive login shell, or a non-interactive shell with the ----llooggiinn option, it first attempts to read and execute commands from _/_e_t_c_/_p_r_o_f_i_l_e and _~_/_._p_r_o_f_i_l_e, in that order. The ----nnoopprrooffiillee option may be used to inhibit this behavior. When invoked as an interactive shell with the name sshh, bbaasshh looks for the variable EENNVV, 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 sshh does not attempt to read and exe- cute commands from any other startup files, the ----rrccffiillee option has no effect. A non-interactive shell invoked with the name sshh does not attempt to read any other startup files. When invoked as sshh, bbaasshh enters _p_o_s_i_x mode after the startup files are read. When bbaasshh is started in _p_o_s_i_x mode, as with the ----ppoossiixx command line option, it follows the POSIX standard for startup files. In this mode, interactive shells expand the EENNVV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read. BBaasshh 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 _r_s_h_d, or the secure shell daemon _s_s_h_d. If bbaasshh deter- mines it is being run in this fashion, it reads and executes commands from _~_/_._b_a_s_h_r_c, if that file exists and is readable. It will not do this if invoked as sshh. The ----nnoorrcc option may be used to inhibit this behavior, and the ----rrccffiillee option may be used to force another file to be read, but _r_s_h_d does not generally invoke the shell with those options or allow them to be specified. If the shell is started with the effective user (group) id not equal to the real user (group) id, and the --pp option is not supplied, no startup
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -