📄 article.txt
字号:
ings. A new history search mode has been implemented: inthis mode, readline searches the history for lines beginningwith the characters between the beginning of the currentline and the cursor. The existing readline incrementalsearch commands no longer match identical lines more thanonce. Filename completion now expands variables in direc-tory names. The history expansion facilities are now nearly October 28, 1994 - 14 -completely csh-compatible: missing modifiers have been addedand history substitution has been extended. Several of the features described earlier, such as _s_e_t-_o _p_o_s_i_x and $_P_O_S_I_X__P_E_D_A_N_T_I_C, are new in version 1.14.There is a new shell variable, _O_S_T_Y_P_E, to which Bash assignsa value that identifies the version of UNIX it's running on(great for putting architecture-specific binary directoriesinto the $PATH). Two variables have been renamed: $_H_I_S_T_C_O_N_-_T_R_O_L replaces $_h_i_s_t_o_r_y__c_o_n_t_r_o_l, and $_H_O_S_T_F_I_L_E replaces$_h_o_s_t_n_a_m_e__c_o_m_p_l_e_t_i_o_n__f_i_l_e. In both cases, the old names areaccepted for backwards compatibility. The ksh _s_e_l_e_c_t con-struct, which allows the generation of simple menus, hasbeen implemented. New capabilities have been added toexisting variables: $_a_u_t_o__r_e_s_u_m_e can now take values of_e_x_a_c_t or _s_u_b_s_t_r_i_n_g, and $_H_I_S_T_C_O_N_T_R_O_L understands the value_i_g_n_o_r_e_b_o_t_h, which combines the two previously acceptablevalues. The _d_i_r_s builtin has acquired options to print outspecific members of the directory stack. The $_n_o_l_i_n_k_s vari-able, which forces a physical view of the file system, hasbeen superseded by the -_P option to the _s_e_t builtin(equivalent to set -o physical); the variable is retainedfor backwards compatibility. The version string containedin $_B_A_S_H__V_E_R_S_I_O_N now includes an indication of the patchlevel as well as the "build version". Some little-usedfeatures have been removed: the _b_y_e synonym for _e_x_i_t andthe $_N_O__P_R_O_M_P_T__V_A_R_S variable are gone. There is now anorganized test suite that can be run as a regression testwhen building a new version of Bash. The documentation has been thoroughly overhauled: thereis a new manual page on the readline library and the _i_n_f_ofile has been updated to reflect the current version. Asalways, as many bugs as possible have been fixed, althoughsome surely remain._5._2. _O_t_h_e_r _F_e_a_t_u_r_e_s There are a few features that I hope to include inlater Bash releases. Some are based on work already done inother shells. In addition to simple variables, a future release ofBash will include one-dimensional arrays, using the kshimplementation of arrays as a model. Additions to the kshsyntax, such as _v_a_r_n_a_m_e=( ... ) to assign a list of wordsdirectly to an array and a mechanism to allow the _r_e_a_d buil-tin to read a list of values directly into an array, wouldbe desirable. Given those extensions, the ksh _s_e_t -_A syntaxmay not be worth supporting (the -_A option assigns a list ofvalues to an array, but is a rather peculiar special case). Some shells include a means of _p_r_o_g_r_a_m_m_a_b_l_e word com-pletion, where the user specifies on a per-command basis how October 28, 1994 - 15 -the arguments of the command are to be treated when comple-tion is attempted: as filenames, hostnames, executablefiles, and so on. The other aspects of the current Bashimplementation could remain as-is; the existing heuristicswould still be valid. Only when completing the arguments toa simple command would the programmable completion be ineffect. It would also be nice to give the user finer-grainedcontrol over which commands are saved onto the history list.One proposal is for a variable, tentatively named _H_I_S_T_I_G_-_N_O_R_E, which would contain a colon-separated list of com-mands. Lines beginning with these commands, after the res-trictions of $_H_I_S_T_C_O_N_T_R_O_L have been applied, would not beplaced onto the history list. The shell pattern-matchingcapabilities could also be available when specifying thecontents of $_H_I_S_T_I_G_N_O_R_E. One thing that newer shells such as _w_k_s_h (also known as_d_t_k_s_h) provide is a command to dynamically load code imple-menting additional builtin commands into a running shell.This new builtin would take an object file or shared libraryimplementing the "body" of the builtin (_x_x_x__b_u_i_l_t_i_n() forthose familiar with Bash internals) and a structure contain-ing the name of the new command, the function to call whenthe new builtin is invoked (presumably defined in the sharedobject specified as an argument), and the documentation tobe printed by the _h_e_l_p command (possibly present in theshared object as well). It would manage the details ofextending the internal table of builtins. A few other builtins would also be desirable: two arethe POSIX.2 _g_e_t_c_o_n_f command, which prints the values of sys-tem configuration variables defined by POSIX.2, and a _d_i_s_o_w_nbuiltin, which causes a shell running with job controlactive to "forget about" one or more background jobs in itsinternal jobs table. Using _g_e_t_c_o_n_f, for example, a usercould retrieve a value for $_P_A_T_H guaranteed to find all ofthe POSIX standard utilities, or find out how long filenamesmay be in the file system containing a specified directory. There are no implementation timetables for any of thesefeatures, nor are there concrete plans to include them. Ifanyone has comments on these proposals, feel free to send meelectronic mail._6. _R_e_f_l_e_c_t_i_o_n_s _a_n_d _L_e_s_s_o_n_s _L_e_a_r_n_e_d The lesson that has been repeated most often duringBash development is that there are dark corners in theBourne shell, and people use all of them. In the originaldescription of the Bourne shell, quoting and the shell gram-mar are both poorly specified and incomplete; subsequentdescriptions have not helped much. The grammar presented in October 28, 1994 - 16 -Bourne's paper describing the shell distributed with theSeventh Edition of UNIX|- is so far off that it does notallow the command who|wc. In fact, as Tom Duff states: Nobody really knows what the Bourne shell's gram- mar is. Even examination of the source code is little help.|=The POSIX.2 standard includes a _y_a_c_c grammar that comesclose to capturing the Bourne shell's behavior, but itdisallows some constructs which sh accepts without complaint- and there are scripts out there that use them. It took afew versions and several bug reports before Bash implementedsh-compatible quoting, and there are still some "legal" shconstructs which Bash flags as syntax errors. Complete shcompatibility is a tough nut. The shell is bigger and slower than I would like,though the current version is substantially faster than pre-viously. The readline library could stand a substantialrewrite. A hand-written parser to replace the current_y_a_c_c-generated one would probably result in a speedup, andwould solve one glaring problem: the shell could parse com-mands in "$(...)" constructs as they are entered, ratherthan reporting errors when the construct is expanded. As always, there is some chaff to go with the wheat.Areas of duplicated functionality need to be cleaned up.There are several cases where Bash treats a variable spe-cially to enable functionality available another way($notify vs. set -o notify and $nolinks vs. set -o physi-cal, for instance); the special treatment of the variablename should probably be removed. A few more things couldstand removal; the $_a_l_l_o_w__n_u_l_l__g_l_o_b__e_x_p_a_n_s_i_o_n and$_g_l_o_b__d_o_t__f_i_l_e_n_a_m_e_s variables are of particularly question-able value. The $[...] arithmetic evaluation syntax isredundant now that the POSIX-mandated $((...)) construct hasbeen implemented, and could be deleted. It would be nice ifthe text output by the _h_e_l_p builtin were external to theshell rather than compiled into it. The behavior enabled by$_c_o_m_m_a_n_d__o_r_i_e_n_t_e_d__h_i_s_t_o_r_y, which causes the shell to attemptto save all lines of a multi-line command in a single his-tory entry, should be made the default and the variableremoved._________________________|-S. R. Bourne, "UNIX Time-Sharing System: The UNIXShell", _B_e_l_l _S_y_s_t_e_m _T_e_c_h_n_i_c_a_l _J_o_u_r_n_a_l, 57(6), July-August, 1978, pp. 1971-1990.|=Tom Duff, "Rc - A Shell for Plan 9 and UNIX systems",_P_r_o_c. _o_f _t_h_e _S_u_m_m_e_r _1_9_9_0 _E_U_U_G _C_o_n_f_e_r_e_n_c_e, London, July,1990, pp. 21-33. October 28, 1994 - 17 -_7. _A_v_a_i_l_a_b_i_l_i_t_y As with all other GNU software, Bash is available foranonymous FTP from _p_r_e_p._a_i._m_i_t._e_d_u:/_p_u_b/_g_n_u and from otherGNU software mirror sites. The current version is in _b_a_s_h-_1._1_4._1._t_a_r._g_z in that directory. Use _a_r_c_h_i_e to find thenearest archive site. The latest version is always avail-able for FTP from _b_a_s_h._C_W_R_U._E_d_u:/_p_u_b/_d_i_s_t. Bash documenta-tion is available for FTP from _b_a_s_h._C_W_R_U._E_d_u:/_p_u_b/_b_a_s_h. The Free Software Foundation sells tapes and CD-ROMscontaining Bash; send electronic mail to gnu@prep.ai.mit.eduor call +1-617-876-3296 for more information. Bash is also distributed with several versions ofUNIX-compatible systems. It is included as /bin/sh and/bin/bash on several Linux distributions (more about thedifference in a moment), and as contributed software inBSDI's BSD/386* and FreeBSD. The Linux distribution deserves special mention. Thereare two configurations included in the standard Bash distri-bution: a "normal" configuration, in which all of the stan-dard features are included, and a "minimal" configuration,which omits job control, aliases, history and command lineediting, the directory stack and _p_u_s_h_d/_p_o_p_d/_d_i_r_s, processsubstitution, prompt string special character decoding, andthe _s_e_l_e_c_t construct. This minimal version is designed tobe a drop-in replacement for the traditional UNIX /bin/sh,and is included as the Linux /bin/sh in several packagings._8. _C_o_n_c_l_u_s_i_o_n Bash is a worthy successor to sh. It is sufficientlyportable to run on nearly every version of UNIX from 4.3 BSDto SVR4.2, and several UNIX workalikes. It is robust enoughto replace sh on most of those systems, and provides morefunctionality. It has several thousand regular users, andtheir feedback has helped to make it as good as it is today- a testament to the benefits of free software._________________________*BSD/386 is a trademark of Berkeley Software Design,Inc. October 28, 1994
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -