📄 article.ms
字号:
/usr/local/bin$ pwd/usr/local/bin$ /bin/pwd/net/share/sun4/local/bin$ cd ..$ pwd/usr/local$ /bin/pwd/net/share/sun4/local$ cd ..$ pwd/usr$ /bin/pwd/usr.EE.LPOne problem with this, ofcourse, arises when programs that do not understand the shell's logicalnotion of the file system interpret \*Q..\*U differently. This generallyhappens when Bash completes filenames containing \*Q..\*U according to alogical hierarchy which does not correspond to their physical location. For users who find this troublesome, a corresponding.I physicalview of the file system is available:.SE$ cd /usr/local/bin$ pwd/usr/local/bin$ set -o physical$ pwd/net/share/sun4/local/bin.EE.NH 2Internationalization.PPOne of the most significant improvements in version 1.13 of Bash was thechange to \*Qeight-bit cleanliness\*U. Previous versions used theeighth bit of characters to mark whether or not they werequoted when performing word expansions. While this did not affectthe majority of users, most of whom used only seven-bit ASCII characters,some found it confining. Beginning with version 1.13, Bashimplemented a different quoting mechanism that did not alter theeighth bit of characters. This allowed Bashto manipulate files with \*Qodd\*U characters in their names, butdid nothing to help users enter those names, soversion 1.13 introduced changes to readline thatmade it eight-bit clean as well. Options exist that force readline toattach no special significance to characters with the eighth bit set(the default behavior is to convert these characters to meta-prefixedkey sequences) and to output these characters without conversion tometa-prefixed sequences. These changes, along with the expansion ofkeymaps to a full eight bits, enable readline to work with most of theISO-8859 family of character sets, used by many European countries..NH 2POSIX Mode.PPAlthough Bash is intended to be POSIX.2 conformant, there are areas inwhich the default behavior is not compatible with the standard. Forusers who wish to operate in a strict POSIX.2 environment, Bashimplements a \fIPOSIX mode\fP. When this mode is active, Bash modifiesits default operation where it differs from POSIX.2 to match thestandard. POSIX mode is entered when Bash is started with the.B -posixoption. This feature is also available as an option to the\fBset\fP builtin, \fBset -o posix\fP.For compatibility with other GNU software that attempts to be POSIX.2compliant, Bash also enters POSIX mode if the variable.B $POSIXLY_CORRECTis set when Bash is started or assigned a value during execution..B $POSIX_PEDANTICis accepted as well, to be compatible with some older GNU utilities.When Bash is started in POSIX mode, for example, it sources thefile named by the value of .B $ENVrather than the \*Qnormal\*U startup files, and does not allowreserved words to be aliased..NH 1New Features and Future Plans.PPThere are several features introduced in the currentversion of Bash, version 1.14, and a number under considerationfor future releases. This section will briefly detail the newfeatures in version 1.14 and describe several featuresthat may appear in later versions..NH 2New Features in Bash-1.14.PPThe new features available in Bash-1.14 answer several ofthe most common requests for enhancements. Most notably, thereis a mechanismfor including non-visible character sequences in prompts, such asthose which cause a terminal to print characters in differentcolors or in standout mode. There was nothing preventing the useof these sequences in earlierversions, but the readline redisplay algorithm assumed eachcharacter occupied physical screen space and would wrap linesprematurely..PPReadline has a few newvariables, several new bindable commands, and some additionalemacs mode default key bindings. A new history searchmode has been implemented: in this mode, readline searches thehistory for lines beginning with the characters between thebeginning of the current line and the cursor. The existing readlineincremental search commands no longer match identical lines morethan once.Filename completion now expands variables in directory names.The history expansion facilities are now nearlycompletely csh-compatible: missing modifiers have been added andhistory substitution has been extended..PPSeveral of the features described earlier, such as.B "set -o posix"and.B $POSIX_PEDANTIC ,are new in version 1.14.There is a new shell variable,.B OSTYPE ,to which Bash assigns a value that identifies theversion of \s-1UNIX\s+1 it'srunning on (great for putting architecture-specific binary directoriesinto the \fB$PATH\fP).Two variables have been renamed:.B $HISTCONTROLreplaces.B $history_control ,and.B $HOSTFILEreplaces.B $hostname_completion_file .In both cases, the old names are accepted for backwardscompatibility. The ksh.I selectconstruct, which allows the generation of simple menus,has been implemented. New capabilities have been addedto existing variables:.B $auto_resumecan now take values of.I exactor.I substring ,and.B $HISTCONTROLunderstands the value.I ignoreboth ,which combines the two previously acceptable values. The.B dirsbuiltin has acquired options to print out specific members of thedirectory stack. The.B $nolinksvariable, which forces a physical view of the file system,has been superseded by the.B \-Poption to the.B setbuiltin (equivalent to \fBset -o physical\fP); the variable is retainedfor backwards compatibility. The version string contained in.B $BASH_VERSIONnow includes an indication of the patch level as well as the\*Qbuild version\*U.Some little-used features havebeen removed: the.B byesynonym for.B exitand the.B $NO_PROMPT_VARSvariable are gone. There is now an organized test suite that can berun as a regression test when building a new version of Bash..PPThe documentation has been thoroughly overhauled:there is a new manual page on the readline library and the \fIinfo\fPfile has been updated to reflect the current version.As always, as many bugs as possible have been fixed, although somesurely remain..NH 2Other Features.PPThere are a few features that I hope to include in later Bash releases.Some are based on work already done in other shells..PPIn addition to simple variables, a future release of Bash will includeone-dimensional arrays, using the kshimplementation of arrays as a model. Additions to the ksh syntax,such as \fIvarname\fP=( ... ) to assign a list of words directly toan array and a mechanism to allowthe.B readbuiltin to read a list of values directly into an array, would bedesirable. Given those extensions, the ksh.B "set \-A"syntax may not be worth supporting (the.B \-Aoption assigns a list of values to an array, but is a ratherpeculiar special case)..PPSome shells include a means of \fIprogrammable\fP wordcompletion, where the user specifies on a per-command basis how thearguments of the command are to be treated when completion is attempted:as filenames, hostnames, executable files, and so on. The otheraspects of the current Bash implementation could remain as-is; theexisting heuristics would still be valid. Only when completing thearguments to a simple command would the programmable completion bein effect..PPIt would also be nice to give the user finer-grainedcontrol over which commands are saved onto the history list. Oneproposal is for a variable, tentatively named.B HISTIGNORE ,which would contain a colon-separated list of commands. Lines beginningwith these commands, after the restrictions of.B $HISTCONTROLhave been applied, would not be placed onto the history list. Theshell pattern-matching capabilities could also be available whenspecifying the contents of.B $HISTIGNORE ..PPOne thing that newer shells such as.B wksh(also known as.B dtksh )provide is a command to dynamically load codeimplementing additional builtin commands into a running shell.This new builtin would take an object file or shared libraryimplementing the \*Qbody\*U of thebuiltin (\fIxxx_builtin()\fP for those familiar with Bash internals)and a structure containing the name of the new command, the functionto call when the new builtin is invoked (presumably defined in theshared object specified as an argument), and the documentation to beprinted by the.B helpcommand (possibly present in the shared object as well). It wouldmanage the details of extending the internal table of builtins. .PPA few other builtins would also be desirable: two are the POSIX.2.B getconfcommand, which prints the values of system configuration variablesdefined by POSIX.2, and a.B disownbuiltin, which causes a shell runningwith job control active to \*Qforget about\*U one or morebackground jobs in its internal jobs table. Using.B getconf ,for example, a user could retrieve a value for.B $PATHguaranteed to find all of the POSIX standard utilities, orfind out how long filenames may be in the file system containinga specified directory..PPThere are no implementation timetables for any of these features, norare there concrete plans to include them. If anyone has comments onthese proposals, feel free to send me electronic mail..NH 1Reflections and Lessons Learned.PPThe lesson that has been repeated most often during Bashdevelopment is that there are dark corners in the Bourne shell,and people use all of them. In the original description of theBourne shell, quoting and the shell grammar are both poorlyspecified and incomplete; subsequent descriptions have not helpedmuch. The grammar presented in Bourne's paper describingthe shell distributed with the Seventh Edition of \s-1UNIX\s+1\(dgis so far off that it does not allow the command \f(CWwho|wc\fP.In fact, as Tom Duff states:.QPNobody really knows what theBourne shell's grammar is. Even examination of the source code islittle help.\(dd.FS\(dgS. R. Bourne, \*QUNIX Time-Sharing System: The UNIX Shell\*U,\fIBell System Technical Journal\fP, 57(6), July-August, 1978, pp. 1971-1990..FE.FS\(ddTom Duff, \*QRc \- A Shell for Plan 9 and \s-1UNIX\s+1 systems\*U,\fIProc. of the Summer 1990 EUUG Conference\fP, London, July, 1990,pp. 21-33..FE.LPThe POSIX.2 standard includes a \fIyacc\fP grammar that comes closeto capturing the Bourne shell's behavior, but it disallows someconstructs which sh accepts without complaint \- and there arescripts out there that use them. It took a few versions andseveral bug reports before Bash implemented sh-compatible quoting,and there are still some \*Qlegal\*U sh constructs which Bash flags assyntax errors. Complete sh compatibility is a tough nut..PPThe shell is bigger and slower than I would like, though the currentversion is substantially faster than previously. The readline librarycould stand a substantial rewrite. A hand-written parser to replacethe current \fIyacc\fP-generated one would probably result in a speedup,and would solve one glaring problem: the shell could parsecommands in \*Q$(...)\*U constructsas they are entered, rather than reporting errors when the constructis expanded..PPAs always, there is some chaff to go with the wheat.Areas of duplicated functionality need to be cleanedup. There are several cases where Bash treats a variable specially toenable functionality available another way (\fB$notify\fP vs.\fBset -o notify\fP and \fB$nolinks\fP vs. \fBset -o physical\fP, forinstance); the special treatment of the variable name should probablybe removed. A few more things could stand removal; the.B $allow_null_glob_expansionand.B $glob_dot_filenamesvariables are of particularly questionable value.The \fB$[...]\fP arithmetic evaluation syntax is redundant now thatthe POSIX-mandated \fB$((...))\fP construct has been implemented,and could be deleted.It would be nice if the text output by the.B helpbuiltin were external to the shell rather than compiled into it.The behavior enabled by.B $command_oriented_history ,which causes the shell to attempt to save all lines of a multi-linecommand in a single history entry, should be made the default andthe variable removed..NH 1Availability.PPAs with all otherGNU software, Bash is available for anonymous FTP from.I prep.ai.mit.edu:/pub/gnuand from other GNU software mirror sites. The current version is in.I bash-1.14.1.tar.gzin that directory. Use.I archieto find the nearest archive site. Thelatest version is always available for FTP from.I bash.CWRU.Edu:/pub/dist.Bash documentation is available for FTP from.I bash.CWRU.Edu:/pub/bash..PPThe Free Software Foundation sells tapes and CD-ROMscontaining Bash; send electronic mail to\f(CRgnu@prep.ai.mit.edu\fP or call \f(CR+1-617-876-3296\fPfor more information..PPBash is also distributed with several versions of \s-1UNIX\s+1-compatiblesystems. It is included as /bin/sh and /bin/bash on several Linuxdistributions (more about the difference in a moment), and as contributedsoftware in BSDI's BSD/386* and FreeBSD..FS*BSD/386 is a trademark of Berkeley Software Design, Inc..FE.PPThe Linux distribution deserves special mention. There are twoconfigurations included in the standard Bash distribution: a\*Qnormal\*U configuration, in which all of the standard featuresare included, and a \*Qminimal\*U configuration, which omits jobcontrol, aliases, history and command line editing, the directorystack and.B pushd/popd/dirs,process substitution, prompt string special character decoding, and the.I selectconstruct. This minimal version is designed to be a drop-in replacementfor the traditional \s-1UNIX\s+1 /bin/sh, and is included as the Linux/bin/sh in several packagings..NH 1Conclusion.PPBash is a worthy successor to sh.It is sufficiently portableto run on nearly every version of \s-1UNIX\s+1 from4.3 BSD to SVR4.2, and several \s-1UNIX\s+1 workalikes.It is robust enough to replace sh on most of those systems,and provides more functionality. It has several thousand regular users,and their feedback has helped to make it as good as it is today \- atestament to the benefits of free software.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -