📄 ash.1
字号:
2036(has)S2195(a)S2265(higher)S2547(priority)S2874(than)S3072(``||'')S3273(or)S3382(``&&''.)S6936 V1080(An)S10 I1228(if)S10 R1309(command)S(looks)217 1730 A1972(like)S7176 V10 B1480(if)S10 R1567(list)S7296 V10 B1480(then)S10 R1840(list)S7416 V1421([)S10 B1480(elif)S10 R1640(list)S7536 V10 B1530(then)S10 R1840(list)S1988(])S(...)75 2047 A7903 V720(Page)S941(1)S2654(\()S2696(March)S2984(7,)S(1991)200 3084 A3292(\))S4455(September)S4911(13,)S(1996)200 5061 A8143 VEP%%Page: 2 2BP/slant 0 def/height 0 def480 V10 R720(SH)S857(\()S899(1)S957(\))S2696(Eighth)S(Edition)296 2989 A4990(SH)S5127(\()S5169(1)S5227(\))S960 V1421([)S10 B1480(else)S10 R1781(list)S1929(])S1080 V10 B1480(\256)S1368 V10 R1080(A)S10 I1178(while)S10 R1421(command)S(looks)217 1842 A2084(like)S1608 V10 B1480(while)S10 R1735(list)S1728 V10 B1480(do)S10 R1840(list)S1848 V10 B1480(done)S2088 V10 R1080(The)S1263(two)S1440(lists)S1628(are)S1778(executed)S2162(repeatedly)S2608(while)S2858(the)S3007(exit)S3184(status)S3439(of)S3549(the)S3698(\256rst)S3881(list)S4031(is)S4125(zero.)S4376(The)S10 I(until)184 4560 A10 R4771(command)S5194(is)S2208 V1080(similar,)S1410(but)S1563(has)S1722(the)S1870(word)S10 B2102(until)S10 R2329(in)S(place)213 2432 A2670(of)S10 B2779(while)S2328 V10 R1105(repeats)S(until)184 1416 A1625(the)S1773(exit)S1949(status)S2203(of)S2312(the)S2460(\256rst)S2642(list)S2790(is)S2882(zero.)S2496 V1080(The)S10 I1262(for)S10 R1404(command)S(looks)217 1825 A2067(like)S2736 V10 B1480(for)S10 R1634(variable)S10 B1984(in)S10 R(word...)282 2093 A2856 V10 B1480(do)S10 R1840(list)S2976 V10 B1480(done)S3216 V10 R1080(The)S1267(words)S1543(are)S1697(expanded,)S2137(and)S2312(then)S2515(the)S2668(list)S2821(is)S2918(executed)S3306(repeatedly)S3757(with)S3967(the)S4121(variable)S4477(set)S4620(to)S(each)185 4729 A4945(word)S5183(in)S3336 V1080(turn.)S10 B1317(do)S10 R1448(and)S10 B1618(done)S10 R1850(may)S2048(be)S(replaced)342 2168 A2535(with)S2739(``{'')S2948(and)S3118(``}''.)S3504 V1080(The)S10 I1262(break)S10 R1516(and)S10 I1686(continue)S10 R2057(commands)S(look)178 2517 A2720(like)S3744 V10 B1480(break)S10 R1757([)S1816(num)S2019(])S3864 V10 B1480(continue)S10 R1875([)S1934(num)S2137(])S4104 V10 I1080(Break)S10 R1353(terminates)S1805(the)S10 I1960(num)S10 R2165(innermost)S10 I2599(for)S10 R2748(or)S10 I2864(while)S10 R(loops.)242 3115 A10 I3415(Continue)S10 R3816(continues)S4234(with)S4446(the)S4602(next)S4808(iteration)S5177(of)S4224 V1080(the)S10 I1228(num'th)S10 R1538(innermost)S(loop.)203 1965 A2218(These)S2484(are)S2633(implemented)S3183(as)S(builtin)262 3292 A3579(commands.)S4392 V1080(The)S10 I1262(case)S10 R1466(command)S(looks)217 1887 A2129(like)S4632 V10 B1480(case)S10 R1684(word)S10 B1916(in)S4752 V10 R1480(pattern)S10 B1760(\))S10 R1819(list)S10 B1967(;;)S4872 V10 R(...)75 1480 A4992 V10 B1480(esac)S5232 V10 R1080(The)S1262(pattern)S1567(can)S1732(actually)S2076(be)S2196(one)S2366(or)S2475(more)S2707(patterns)S3051(\(see)S10 I3239(Patterns)S10 R3605(below\),)S3935(separated)S4341(by)S4466(``|'')S4647(characters.)S5400 V1080(Commands)S1562(may)S1760(be)S(grouped)329 1880 A2234(by)S(writing)291 2359 A2675(either)S5640 V10 B1480(\()S10 R1514(list)S10 B1637(\))S5880 V10 R1080(or)S6120 V10 B1480({)S10 R1545(list;)S10 B1721(})S6360 V10 R1080(The)S1262(\256rst)S1444(of)S1553(these)S1785(executes)S2157(the)S2305(commands)S2765(in)S2868(a)S2938(subshell.)S6528 V1080(A)S1178(function)S(de\256nition)385 1538 A(looks)217 1948 A2190(like)S6768 V1480(name)S10 B1723(\()S1782(\))S10 R1841(command)S7008 V1080(A)S1182(function)S(de\256nition)385 1546 A1960(is)S2056(an)S2180(executable)S2640(statement;)S3083(when)S3330(executed)S3717(it)S3802(installs)S4116(a)S4190(function)S4554(named)S10 B4851(name)S10 R5116(and)S7128 V1080(returns)S1385(an)S1505(exit)S1681(status)S1935(of)S2044(zero.)S2293(The)S2475(command)S2896(is)S2988(normally)S3376(a)S3446(list)S3594(enclosed)S3971(between)S4332(``{'')S4541(and)S4711(``}''.)S7296 V1080(Variables)S1497(may)S1700(be)S1825(declared)S2197(to)S2305(be)S2430(local)S2656(to)S2764(a)S2839(function)S3205(by)S3336(using)S3584(a)S10 I3660(local)S10 R3892(command.)S4369(This)S(should)267 4579 A4877(appear)S5177(as)S7416 V1080(the)S1228(\256rst)S1410(staement)S1793(of)S1902(a)S1972(function,)S2357(and)S(looks)217 2527 A2769(like)S7903 V720(September)S1176(13,)S(1996)200 1326 A2654(\()S2696(March)S2984(7,)S(1991)200 3084 A3292(\))S4990(Page)S5211(2)S8143 VEP%%Page: 3 3BP/slant 0 def/height 0 def480 V10 R720(SH)S857(\()S899(1)S957(\))S2696(Eighth)S(Edition)296 2989 A4990(SH)S5127(\()S5169(1)S5227(\))S960 V10 B1480(local)S10 R1706([)S1765(variable)S2115(|)S10 B2160(-)S10 R2219(])S(...)75 2278 A1200 V10 I1080(Local)S10 R1334(is)S1426(implemented)S1976(as)S2085(a)S(builtin)262 2155 A2442(command.)S1368 V1080(When)S1356(a)S1438(variable)S1800(is)S1904(made)S2159(local,)S2417(it)S2510(inherits)S2849(the)S(initial)235 3009 A3281(value)S3536(and)S(exported)352 3718 A4107(and)S(readonly)352 4289 A4678(\257ags)S4905(from)S5138(the)S1488 V1080(variable)S1439(with)S1652(the)S1809(same)S2050(name)S2302(in)S2414(the)S(surrounding)485 2571 A3089(scope,)S3376(if)S3471(there)S3706(is)S3806(one.)S4034(Otherwise,)S4507(the)S4663(variable)S5021(is)S5121(ini-)S1608 V1080(tially)S1321(unset.)S10 I1617(Ash)S10 R1802(uses)S(dynamic)346 2009 A2389(scoping,)S2760(so)S2883(that)S3068(if)S(you)150 3164 A3349(make)S3602(the)S3760(variable)S10 B4120(x)S10 R4205(local)S4436(to)S4549(function)S10 I4919(f)S10 R4955(,)S5015(which)S1728 V1080(then)S1289(calls)S1510(function)S10 I1881(g)S10 R1939(,)S2000(references)S2452(to)S2566(the)S2725(variable)S10 B3086(x)S10 R3171(made)S3424(inside)S10 I3699(g)S10 R(will)157 3784 A3976(refer)S4203(to)S4316(the)S4474(variable)S10 B4834(x)S10 R4919(declared)S1848 V1080(inside)S10 I1345(f)S10 R1381(,)S1431(not)S1584(to)S1687(the)S1835(global)S2111(variable)S2461(named)S10 B2754(x)S10 R2804(.)S2016 V1080(The)S1263(only)S1467(special)S1773(parameter)S2203(than)S2402(can)S2568(be)S2689(made)S2933(local)S3155(is)S3248(``)S10 B3316(-)S10 R3350(''.)S3494(Making)S3832(``)S10 B3900(-)S10 R3934('')S4028(local)S4250(any)S4421(shell)S4637(options)S4959(that)S5137(are)S2136 V1080(changed)S1445(via)S1598(the)S10 I1751(set)S10 R1893(command)S2319(inside)S2589(the)S2742(function)S3107(to)S3215(be)S3340(restored)S3695(to)S3803(their)S4018(original)S4361(values)S4648(when)S4896(the)S5048(func-)S2256 V1080(tion)S1261(returns.)S2424 V1080(The)S10 I1262(return)S10 R1538(command)S(looks)217 1959 A2201(like)S2664 V10 B1480(return)S10 R1786([)S1845(exitstatus)S2250(])S2904 V1080(It)S1167(terminates)S1612(the)S1760(currently)S2149(executing)S2565(function.)S10 I2975(Return)S10 R3274(is)S3366(implemented)S3916(as)S4025(a)S(builtin)262 4095 A4382(command.)S3144 V10 B864(Simple)S1186(Commands)S3312 V10 R1080(A)S1182(simple)S1479(command)S1904(is)S2000(a)S2074(sequence)S2472(of)S2585(words.)S2911(The)S3098(execution)S3519(of)S3633(a)S3708(simple)S4006(command)S(proceeds)358 4432 A4820(as)S4934(follows.)S3432 V1080(First,)S1317(the)S1467(leading)S1790(words)S2063(of)S2174(the)S2324(form)S2547(``name=value'')S3203(are)S3353(stripped)S3703(off)S3847(and)S4018(assigned)S4390(to)S4494(the)S4643(environment)S5177(of)S3552 V1080(the)S1235(command.)S(Second,)321 1713 A2066(the)S2221(words)S2499(are)S2655(expanded.)S3122(Third,)S3403(the)S3559(\256rst)S3749(remaining)S4190(word)S4430(is)S4530(taken)S4781(as)S4898(the)S5054(com-)S3672 V1080(mand)S1337(name)S1589(that)S1774(command)S2204(is)S2305(located.)S2680(Fourth,)S3007(any)S3186(redirections)S3695(are)S3852(performed.)S4355(Fifth,)S4609(the)S4765(command)S5194(is)S3792 V1080(executed.)S1513(We)S(look)178 1678 A1881(at)S1979(these)S2211(operations)S2655(in)S2758(reverse)S3075(order.)S3960 V1080(The)S1265(execution)S1685(of)S1798(the)S1950(command)S2375(varies)S2645(with)S2853(the)S3005(type)S3207(of)S3320(command.)S3795(There)S4060(are)S4213(three)S4444(types)S4685(of)S4798(commands:)S4080 V1080(shell)S1295(functions,)S(builtin)262 1719 A2006(commands,)S2491(and)S2661(normal)S2971(programs.)S4248 V1080(When)S1359(a)S1443(shell)S1672(function)S2047(is)S2154(executed,)S2577(all)S2718(of)S2842(the)S3005(shell)S(positional)396 3235 A3671(parameters)S4154(\(except)S4491($0,)S4656(which)S4942(remains)S4368 V1080(unchanged\))S1577(are)S1729(set)S1869(to)S1975(the)S2126(parameters)S2597(to)S2703(the)S2854(shell)S3072(function.)S3485(The)S3670(variables)S4062(which)S4335(are)S(explicitly)380 4486 A(placed)263 4893 A5183(in)S4488 V1080(the)S1232(environment)S1769(of)S1882(the)S2034(command)S2459(\(by)S2622(placing)S2947(assignments)S3467(to)S3574(them)S3804(before)S4091(the)S4243(function)S4607(name\))S4889(are)S5043(made)S4608 V1080(local)S1306(to)S1413(the)S1565(function)S1929(and)S2103(are)S2256(set)S2397(to)S2504(values)S2790(given.)S3092(Then)S3328(the)S3480(command)S3905(given)S4157(in)S4264(the)S4416(function)S(de\256nition)385 4780 A5194(is)S4728 V1080(executed.)S1513(The)S(positional)396 1695 A2116(parameters)S2584(are)S2733(restored)S3083(to)S3186(their)S3396(original)S3734(values)S4016(when)S4259(the)S4407(command)S4828(completes.)S4896 V1080(Shell)S(builtins)301 1312 A1638(are)S1787(executed)S2170(internally)S2581(to)S2684(the)S2832(shell,)S(without)307 3072 A3404(spawning)S3814(a)S3884(new)S4077(process.)S5064 V1080(When)S1367(a)S1459(normal)S1791(program)S2179(is)S2293(executed,)S2723(the)S2893(shell)S3130(runs)S3350(the)S3520(program,)S3934(passing)S4283(the)S4454(parameters)S4945(and)S5138(the)S5184 V1080(environment)S1616(to)S1722(the)S1873(program.)S2292(If)S2388(the)S2539(program)S2907(is)S3001(a)S3073(shell)S3290(procedure,)S3745(the)S3895(shell)S(will)157 4112 A4296(interpret)S4665(the)S4815(program)S5183(in)S5304 V1080(a)S1156(subshell.)S1566(The)S1754(shell)S(will)157 1975 A(reinitialize)432 2163 A2626(itself)S2859(in)S2968(this)S3144(case,)S3374(so)S3494(that)S3676(the)S3830(effect)S(will)157 4092 A4280(be)S4407(as)S4523(if)S4617(a)S4694(new)S4894(shell)S5116(had)S5424 V1080(been)S(invoked)323 1299 A1651(to)S1758(handle)S2055(the)S2207(shell)S2426(procedure,)S2883(except)S3175(that)S3355(the)S3506(location)S3858(of)S3970(commands)S4433(located)S4752(in)S4858(the)S5009(parent)S5544 V1080(shell)S(will)157 1300 A1487(be)S1612(remembered)S2146(by)S2276(the)S2429(child.)S2710(If)S2808(the)S2961(program)S3332(is)S3429(a)S3505(\256le)S3665(beginning)S4097(with)S(``#!'',)245 4307 A4583(the)S4737(remainder)S5177(of)S5664 V1080(the)S1233(\256rst)S1420(line)S1601(speci\256es)S1978(an)S2103(interpreter)S2554(for)S2702(the)S2855(program.)S3276(The)S3463(shell)S3683(\(or)S3831(the)S3984(operating)S4394(system,)S(under)229 4728 A4986(Berke-)S5784 V1080(ley)S1239(UNIX\))S(will)157 1562 A1755(run)S1926(the)S2086(interpreter)S2544(in)S2659(this)S2841(case.)S3102(The)S3296(arguments)S3752(to)S3867(the)S4027(interpreter)S(will)157 4485 A4679(consist)S4995(of)S5116(any)S5904 V1080(arguments)S1526(given)S1776(on)S
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -