📄 article.ps
字号:
.674(as in)-.1 F -.15(ve)-.4 G .674(nted so that shell functions could be).15 F .996(written to replace b)72 135.6 R .996(uiltins; it mak)-.2 F .996(es the capabilities of the b)-.1 F .995(uiltin a)-.2 F -.25(va)-.2 G .995(ilable to the function.).25F .995(The reserv)5.995 F(ed)-.15 E -.1(wo)72 147.6 S 1.731(rd \231!\232 w).1 F 1.731(as added to ne)-.1 F -.05(ga)-.15 G 1.731(te the return v).05 F 1.731(alue of a command or pipeline; it w)-.25 F1.732(as nearly impossible to)-.1 F -.15(ex)72 159.6 S .286(press \231if not x\232 cleanly using the sh language.).15 F .286(There e)5.286 F .286(xist multiple incompatible implementations of the)-.15 F F1(test)72 171.6 Q F0 -.2(bu)3.163 G .663(iltin, which tests \214les for type and other attrib).2 F .664(utes and performs arithmetic and string comparisons.)-.2 F .5(POSIX considered none of these correct, so the standard beha)72 183.6 R.5(vior w)-.2 F .5(as speci\214ed in terms of the number of)-.1 F(ar)72195.6 Q .412(guments to the command.)-.18 F .412(POSIX.2 dictates e)5.412 F .412(xactly what will happen when four or fe)-.15 F .412(wer ar)-.25 F .412(guments are)-.18 F(gi)72 207.6 Q -.15(ve)-.25 G 5.01(nt).15G(o)-5.01 E F1(test)5.01 E F0 5.01(,a)C 2.51(nd lea)-5.01 F -.15(ve)-.2G 5.01(st).15 G 2.51(he beha)-5.01 F 2.51(vior unde\214ned when more ar)-.2 F 2.51(guments are supplied.)-.18 F 2.51(Bash uses the)7.51 F(POSIX.2 algorithm, which w)72 219.6 Q(as concei)-.1 E -.15(ve)-.25 G2.5(db).15 G 2.5(yD)-2.5 G -.2(av)-2.5 G(id K).2 E(orn.)-.35 E F1 2.5(3.1. F)72 243.6 R(eatur)-.25 E(es not in the Bour)-.18 E(ne Shell)-.15E F0 .718(There are a number of minor dif)97 259.2 R .719(ferences between Bash and the v)-.25 F .719(ersion of sh present on most other)-.15 F -.15(ve)72 271.2 S .874(rsions of).15 F/F2 9/Times-Roman@0 SF(UNIX)3.374 E F0 5.873(.T)C .873(he majority of these are due to the POSIX standard, b)-5.873 F .873(ut some are the result of Bash)-.2 F .386(adopting features from other shells.)72 283.2 R -.15(Fo)5.386 G 2.886(ri).15 G .386(nstance, Bash includes the ne)-2.886 F 2.886<7799>-.25 G.386(!\232 reserv)-2.886 F .386(ed w)-.15 F .386(ord, the)-.1 F F1(command)2.886 E F0 -.2(bu)72 295.2 S .116(iltin, the ability of the).2F F1 -.18(re)2.616 G(ad).18 E F0 -.2(bu)2.615 G .115(iltin to correctly return a line ending with a backslash, symbolic ar).2 F(guments)-.18 E .798(to the)72 307.2 R F1(umask)3.298 E F0 -.2(bu)3.298 G .798(iltin, v).2 F .798(ariable substring remo)-.25 F -.25(va)-.15 G .798(l, a w).25 F .799(ay to get the length of a v)-.1 F .799(ariable, and the ne)-.25 F 3.299(wa)-.25 G(lgo-)-3.299 E(rithm for the)72 319.2 Q F1(test)2.5 E F0 -.2(bu)2.5 G(iltin from the POSIX.2 standard, none of which appear in sh.).2 E 1.225(Bash also implements the \231$\(...\)\232 command substitution syntax,\ which supersedes the sh `...` con-)97 334.8 R 2.851(struct. The)72346.8 R .351(\231$\(...\)\232 construct e)2.851 F .351(xpands to the ou\tput of the command contained within the parentheses, with)-.15 F .664(trailing ne)72 358.8 R .664(wlines remo)-.25 F -.15(ve)-.15 G 3.164(d. The).15 F .664(sh syntax is accepted for backw)3.164 F .664(ards compatibility)-.1 F 3.164(,b)-.65 G .664(ut the \231$\(...\)\232 form is)-3.364 F(preferred because its quoting\ rules are much simpler and it is easier to nest.)72 370.8 Q .772(The Bourne shell does not pro)97 386.4 R .772(vide such features as brace e)-.15 F .772(xpansion, the ability to de\214ne a v)-.15 F(ariable)-.25 E .283(and a function with the same name, local v)72 398.4 R .282(ariables in shell functions, the ability to enable and disable indi-)-.25 F .547(vidual b)72 410.4 R .547(uiltins or write a function to replace a b)-.2 F .547(uiltin, or a means to e)-.2 F .547(xport a shell function to a child pro-)-.15 F(cess.)72 422.4 Q .32(Bash has closed a long-standing shell security hole by not using the)97438 R F1($IFS)2.82 E F0 -.25(va)2.82 G .32(riable to split each w).25 F(ord)-.1 E 1.254(read by the shell, b)72 450 R 1.254(ut splitting only the results of e)-.2 F 1.255(xpansion \(ksh and the 4.4 BSD sh ha)-.15 F 1.555 -.15(ve \214)-.2 H-.15(xe).15 G 3.755(dt).15 G 1.255(his as)-3.755 F 2.907(well\). Useful)72 462 R(beha)2.907 E .407(vior such as a means to abort e)-.2 F -.15(xe)-.15 G .407(cution of a script read with the \231.).15 F 2.906<9a63>-.7 G .406(ommand using the)-2.906 F F1 -.18(re)72 474 S(tur).18 E(n)-.15 E F0 -.2(bu)2.742 G .242(iltin or automatically e).2 F .242(xporting v)-.15 F .243(ariables in the shell')-.25 F 2.743(se)-.55 G-.4(nv)-2.743 G .243(ironment to children is also not present).4 F .969(in the Bourne shell.)72 486 R .968(Bash pro)5.968 F .968(vides a much more po)-.15 F .968(werful en)-.25 F .968(vironment for both interacti)-.4 F 1.268 -.15(ve u)-.25 H .968(se and pro-).15 F(gramming.)72 498 Q F1 2.5(4. Bash-speci\214c)72 522 R-.25(Fe)2.5 G(atur).25 E(es)-.18 E F0 .491(This section details a fe)97537.6 R 2.991(wo)-.25 G 2.991(ft)-2.991 G .491(he features which mak)-2.991 F 2.991(eB)-.1 G .491(ash unique.)-2.991 F .492(Most of them pro)5.491 F .492(vide impro)-.15 F -.15(ve)-.15 G(d).15 E(interacti)72 549.6Q 1.182 -.15(ve u)-.25 H .882(se, b).15 F .882(ut a fe)-.2 F 3.382(wp)-.25 G .882(rogramming impro)-3.382 F -.15(ve)-.15 G .882(ments are present as well.).15 F .882(Full descriptions of these fea-)5.882 F(tures can be found in the Bash documentation.)72 561.6 Q F1 2.5(4.1. Startup)72 585.6 R(Files)2.5 E F0 .161(Bash e)97 601.2 R -.15(xe)-.15 G .161(cutes startup \214les dif).15 F .161(ferently than other shells.)-.25 F .162(The Bash beha)5.161 F .162(vior is a compromise between)-.2 F .29(the csh principle of startup \214les with \214x)72 613.2 R .29(ed names e)-.15 F -.15(xe)-.15 G .29(cuted for each shell and the sh \231minimalist\232 beha).15 F(vior)-.2E(.)-.55 E 2.955(An interacti)72 625.2 R 3.255 -.15(ve i)-.25 H 2.955(nstance of Bash started as a login shell reads and e).15 F -.15(xe)-.15G(cutes).15 E/F3 10/Times-Italic@0 SF(~/.bash_pr)5.456 E(o\214le)-.45 EF0 2.956(\(the \214le)5.456 F .954(.bash_pro\214le in the user')72 637.2R 3.454(sh)-.55 G .953(ome directory\), if it e)-3.454 F 3.453(xists. An)-.15 F(interacti)3.453 E 1.253 -.15(ve n)-.25 H .953(on-login shell reads and e).15 F -.15(xe)-.15 G(cutes).15 E F3(~/.bashr)72 649.2 Q(c)-.37 E F0 5.641(.A)C(non-interacti)-2.5 E .942-.15(ve s)-.25 H .642(hell \(one be).15 F .642(gun to e)-.15 F -.15(xe)-.15 G .642(cute a shell script, for e).15 F .642(xample\) reads no \214x)-.15 F .642(ed startup)-.15 F .342(\214le, b)72661.2 R .342(ut uses the v)-.2 F .342(alue of the v)-.25 F(ariable)-.25E F1($ENV)2.842 E F0 2.841(,i)C 2.841(fs)-2.841 G .341(et, as the name of a startup \214le.)-2.841 F .341(The ksh practice of read-)5.341 F(ing)72 673.2 Q F1($ENV)3.114 E F0.614(for e)3.114 F -.15(ve)-.25 G .614(ry shell, with the accompan).15 F.615(ying dif)-.15 F .615(\214culty of de\214ning the proper v)-.25 F.615(ariables and functions)-.25 F .721(for interacti)72 685.2 R 1.021-.15(ve a)-.25 H .721(nd non-interacti).15 F 1.021 -.15(ve s)-.25 H .721(hells or ha).15 F .721(ving the \214le read only for interacti)-.2 F1.02 -.15(ve s)-.25 H .72(hells, w).15 F .72(as considered)-.1 F .158(too comple)72 697.2 R 2.658(x. Ease)-.15 F .158(of use w)2.658 F .158(on out here.)-.1 F(Interestingly)5.158 E 2.658(,t)-.65 G .158(he ne)-2.658 F .159(xt release of ksh will change to reading)-.15 F F1($ENV)2.659 E .32 LW 144 705.2 72 705.2 DL/F4 8/Times-Roman@0 SF .559(\207Bill Jo)72 717 R 1.599 -.52(y, A)-.08 H 2.559(nI).52 G .559(ntroduction to the C Shell,)-2.559 F/F5 8/Times-Italic@0 SF .558(UNIX User')2.558 F 2.558(sS)-.32 G .558(upplementary Documents)-2.558 FF4 2.558(,U)C(ni)-2.558 E -.12(ve)-.2 G .558(rsity of California at).12F(Berk)72 727 Q(ele)-.08 E 1.04 -.52(y, 1)-.12 H(986.).52 E EP%%Page: 4 4%%BeginPageSetupBP%%EndPageSetup/F0 10/Times-Roman@0 SF(-4-)282.17 48 Q(only for interacti)72 84 Q .3-.15(ve s)-.25 H(hells.).15 E/F1 10/Times-Bold@0 SF 2.5(4.2. New)72 108R(Builtin Commands)2.5 E F0 1.02(There are a fe)97 123.6 R 3.52(wb)-.25G 1.02(uiltins which are ne)-3.72 F 3.52(wo)-.25 G 3.52(rh)-3.52 G -2.25-.2(av e)-3.52 H 1.02(been e)3.72 F 1.02(xtended in Bash.)-.15 F(The)6.02 E F1(enable)3.52 E F0 -.2(bu)3.52 G 1.02(iltin allo).2 F(ws)-.25 E-.2(bu)72 135.6 S .824(iltin commands to be turned on and of).2 F 3.324(fa)-.25 G(rbitrarily)-3.324 E 5.824(.T)-.65 G 3.324(ou)-6.624 G .824(se the v)-3.324 F .824(ersion of)-.15 F/F2 10/Times-Italic@0 SF(ec)3.324 E(ho)-.15 E F0 .825(found in a user')3.324 F 3.325(ss)-.55 G(earch)-3.325 E .625(path rather than the Bash b)72 147.6 R(uiltin,)-.2E/F3 10/Courier@0 SF .625(enable -n echo)3.125 F F0(suf)3.125 E 3.125(\214ces. The)-.25 F F1(help)3.124 E F0 -.2(bu)3.124 G .624(iltin pro).2F .624(vides quick synopses)-.15 F .703(of the shell f)72 159.6 R .704(acilities without requiring access to a manual page.)-.1 F F1(Builtin)5.704 E F0 .704(is similar to)3.204 F F1(command)3.204 E F0 .704(in that it)3.204 F .342(bypasses shell functions and directly e)72171.6 R -.15(xe)-.15 G .342(cutes b).15 F .342(uiltin commands.)-.2 F.342(Access to a csh-style stack of directories)5.342 F .072(is pro)72183.6 R .073(vided via the)-.15 F F1(pushd)2.573 E F0(,)A F1(popd)2.573E F0 2.573(,a)C(nd)-2.573 E F1(dirs)2.573 E F0 -.2(bu)2.573 G(iltins.).2E F1(Pushd)5.073 E F0(and)2.573 E F1(popd)2.573 E F0 .073(insert and remo)2.573 F .373 -.15(ve d)-.15 H .073(irectories from the).15 F 2.858(stack, respecti)72 195.6 R -.15(ve)-.25 G(ly).15 E 5.358(,a)-.65 G(nd)-5.358 E F1(dirs)5.358 E F0 2.858(lists the stack contents.)5.358 F 2.858(On systems that allo)7.858 F 5.358<778c>-.25 G 2.857(ne-grained control of)-5.358 F 1.339(resources, the)72 207.6 R F1(ulimit)3.839 E F0 -.2(bu)3.839 G 1.339(iltin can be used to tune these settings.).2 F F1(Ulimit)6.34 E F0(allo)3.84 E 1.34(ws a user to control, among)-.25 F 1.086(other things, whether core dumps are to be generated, ho)72 219.6 R3.586(wm)-.25 G 1.086(uch memory the shell or a child process is)-3.586F(allo)72 231.6 Q .496(wed to allocate, and ho)-.25 F 2.996(wl)-.25 G(ar)-2.996 E .496(ge a \214le created by a child process can gro)-.18 F4.296 -.65(w. T)-.25 H(he).65 E F1(suspend)2.996 E F0 .497(command will)2.997 F .744(stop the shell process when job control is acti)72 243.6 R-.15(ve)-.25 G 3.243(;m).15 G .743(ost other shells do not allo)-3.243 F3.243(wt)-.25 G(hemselv)-3.243 E .743(es to be stopped)-.15 F(lik)72255.6 Q 2.717(et)-.1 G(hat.)-2.717 E F1 -.74(Ty)5.217 G(pe,).74 E F0.217(the Bash answer to)2.717 F F1(which)2.717 E F0(and)2.717 E F1(whence,)2.717 E F0(sho)2.717 E .218(ws what will happen when a w)-.25 F.218(ord is typed as a)-.1 F(command:)72 267.6 Q F3 6($t)97 285.6 S(ype export)-6 E(export is a shell builtin)97 297.6 Q 6($t)97 309.6 S(ype -t export)-6 E(builtin)97 321.6 Q 6($t)97 333.6 S(ype bash)-6 E(bash is /bin/bash)97 345.6 Q 6($t)97 357.6 S(ype cd)-6 E(cd is a function)97 369.6 Q(cd \(\))97 381.6 Q({)97 393.6 Q(builtin cd ${1+"$@"} && xtitle $HOST: $PWD)121 405.6 Q(})97 417.6 Q F0-1.11(Va)72 439.2 S .682(rious modes tell what a command w)1.11 F .681(ord is \(reserv)-.1 F .681(ed w)-.15 F .681(ord, alias, function, b)-.1F .681(uiltin, or \214le\) or which v)-.2 F(er)-.15 E(-)-.2 E 1.15(sion of a command will be e)72 451.2 R -.15(xe)-.15 G 1.15(cuted based on a user').15 F 3.65(ss)-.55 G 1.15(earch path.)-3.65 F1.15(Some of this functionality has been)6.15 F(adopted by POSIX.2 and folded into the)72 463.2 Q F1(command)2.5 E F0(utility)2.5 E(.)-.65 E F1 2.5(4.3. Editing)72 487.2 R(and Completion)2.5 E F0 .682(One area in which Bash shines is command line editing.)97502.8 R .682(Bash uses the)5.682 F F2 -.37(re)3.182 G(adline).37 E F0.681(library to read and)3.181 F .942(edit lines when interacti)72 514.8R -.15(ve)-.25 G 5.942(.R).15 G .942(eadline is a po)-5.942 F .942(werful and \215e)-.25 F .942(xible input f)-.15 F .943(acility that a user can con\214gure to)-.1 F(indi)72 526.8 Q .732(vidual tastes.)-.25 F .732(It allo)5.732 F .732(ws lines to be edited \using either emacs or vi commands, where those commands)-.25 F .2(are appropriate.)72 538.8 R .2(The full capability of emacs is not present \255 there is no w)5.2 F .2(ay to e)-.1 F -.15(xe)-.15 G .2(cute a named command).15 F 1.15(with M-x, for instance \255 b)72 550.8 R 1.15(ut the e)-.2 F 1.149(xisting commands are more than adequate.)-.15 F 1.149(The vi mode is compliant)6.149 F(with the command line editing standardized by POSIX.2.)72 562.8 Q 1.69(Readline is fully customizable.)97 578.4 R 1.691(In addition to the basic commands and k)6.69 F 1.991 -.15(ey b)-.1 H1.691(indings, the library).15 F(allo)72 590.4 Q .028(ws users to de\214ne additional k)-.25 F .327 -.15(ey b)-.1 H .027(indings using a startup \214le.).15 F(The)5.027 E F2(inputr)2.527 E(c)-.37 E F0 .027(\214le, which def)2.527 F .027(aults to the \214le)-.1 FF2(~/.inputr)72 602.4 Q(c)-.37 E F0 3.002(,i)C 3.002(sr)-3.002 G .503(e\ad each time readline initializes, permitting users to maintain a consi\stent interf)-3.002 F .503(ace across a)-.1 F .893(set of programs.)72614.4 R .893(Readline includes an e)5.893 F .893(xtensible interf)-.15 F.892(ace, so each program using the library can add its)-.1 F -.25(ow)72626.4 S 3.56(nb).25 G 1.06(indable commands and program-speci\214c k)-3.56 F 1.361 -.15(ey b)-.1 H 3.561(indings. Bash).15 F 1.061(uses this f)3.561 F 1.061(acility to add bindings that)-.1 F(perform history e)72 638.4 Q(xpansion or shell w)-.15 E(ord e)-.1 E(xpansions on the current input line.)-.15 E .707(Readline interprets a number of v)97 654 R .706(ariables which further tune its beha)-.25 F(vior)-.2 E 5.706(.V)-.55 G.706(ariables e)-6.816 F .706(xist to control)-.15 F .157(whether or not eight-bit characters are directly read as input or con)72 666 R -.15(ve)-.4 G .158(rted to meta-pre\214x).15 F .158(ed k)-.15 F.458 -.15(ey s)-.1 H .158(equences \(a).15 F(meta-pre\214x)72 678 Q .082(ed k)-.15 F .382 -.15(ey s)-.1 H .081(equence consists of the characte\r with the eighth bit zeroed, preceded by the).15 F F2(meta-pr)2.581 E(e\214x)-.37 E F0(character)72 690 Q 3.233(,u)-.4 G .733(sually escape, which selects an alternate k)-3.233 F -.15(ey)-.1 G .734(map\), to decide whether to output characters with).15 F .624(the eighth bit set directly or as a meta-pre\214x)72 702 R .624(ed k)-.15 F .924 -.15(ey s)-.1 H .623(equence, whether or not to wrap to a ne).15 F 3.123(ws)-.25 G .623(creen line)-3.123 F 1.196(when a line being edited is longer than the screen width, the k)72 714R -.15(ey)-.1 G 1.196(map to which subsequent k).15 F 1.496 -.15(ey b)-.1 H(indings).15 E .531(should apply)72 726 R 3.031(,o)-.65 G 3.031(re)-3.031 G -.15(ve)-3.281 G 3.031(nw).15 G .531(hat happens when readline w)-3.031 F .531(ants to ring the terminal')-.1 F 3.03(sb)-.55 G 3.03(ell. All)-3.03 F .53(of these v)3.03 F(ariables)-.25 E EP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -