1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
|
.ds OK [\|
.ds CK \|]
.ds ' \s+4\v@.3m@\'\v@-.3m@\s-4
.ds ` \s+4\v@.3m@\`\v@-.3m@\s-4
.de P
.br
..
.TH KSH 1
.SH NAME
ksh \- Korn shell, the not standard command programming language
.SH SYNOPSIS
.B ksh
[
.B \-acefhikmnorstuvx
] [
.B \-o
option ] .\|.\|.
[ arg .\|.\|. ]
.br
.SH DESCRIPTION
.I Ksh\^
is a command programming language
that executes commands read from a terminal
or a file.
.I Rsh\^
is a restricted version of the standard command interpreter
.IR sh ;
it is used to set up login names and execution environments whose
capabilities are more controlled than those of the standard shell.
See
.I Invocation\^
below
for the meaning of arguments to the shell.
.SS Definitions.
A
.I metacharacter\^
is one of the following characters:
.RS
.PP
\f3; & ( ) \(bv < > new-line space tab\fP
.RE
.PP
A
.I blank\^
is a
.B tab
or a
.BR space .
An
.I identifier\^
is a sequence of letters, digits, or underscores
starting with a letter or underscore.
Identifiers are used as names for
.IR aliases ,
.IR functions ,
and
.IR "named parameters" .
A
.I word\^
is a sequence of
.I characters\^
separated by one or more non-quoted
.IR metacharacters .
.SS Commands.
A
.I simple-command\^
is a sequence of
.I blank\^
separated words
which may be preceded by a parameter assignment list.
(See
.I Environment\^
below).
The first word specifies the name of the command to
be executed.
Except as specified below,
the remaining words are passed as arguments
to the invoked command.
The command name is passed as argument 0
(see
.IR exec (2)).
The
.I value\^
of a simple-command is its exit status
if it terminates normally, or (octal) 200+\f2status\^\fP if
it terminates abnormally (see
.IR signal (2)
for a list of
status values).
.PP
A
.I pipeline\^
is a sequence of one or more
.I commands\^
separated by
.BR \(bv .
The standard output of each command but the last
is connected by a
.IR pipe (2)
to the standard input of the next command.
Each command is run as a separate process;
the shell waits for the last command to terminate.
The exit status of a pipeline is the exit
status of the last command.
.PP
A
.I list\^
is a sequence of one or more
pipelines
separated by
.BR ; ,
.BR & ,
.BR && ,
or
.BR \(bv\|\(bv ,
and optionally terminated by
.BR ; ,
.BR & ,
or
.BR \(bv& .
Of these five symbols,
.BR ; ,
.BR & ,
and
.BR \(bv&
have equal precedence,
which is lower than that of
.B &&
and
.BR \(bv\|\(bv .
The symbols
.B &&
and
.B \(bv\|\(bv
also have equal precedence.
A semicolon
.RB ( ; )
causes sequential execution of the preceding pipeline; an ampersand
.RB ( & )
causes asynchronous execution of the preceding pipeline (i.e., the shell does
.I not\^
wait for that pipeline to finish).
The symbol
.B \(bv&
causes asynchronous execution of the preceding command or pipeline
with a two-way pipe established to the parent shell.
The standard input and output of the spawned command
can be written to and read from by the parent Shell
using the
.B \-p
option of
the special commands
.B read
and
.B print\^
described later.
Only one such command can be active
at any given time.
The symbol
.B &&
.RB (\| \(bv\|\(bv \^)
causes the
.I list\^
following it to be executed only if the preceding
pipeline
returns a zero (non-zero) value.
An arbitrary number of new-lines may appear in a
.I list,\^
instead of semicolons,
to delimit commands.
.PP
A
.I command\^
is either a simple-command
or one of the following.
Unless otherwise stated,
the value returned by a command is that of the
last simple-command executed in the command.
.TP
\f3for\fP \f2identifier\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3do\fP \f2list\^\fP \f3done\fP
Each time a
.B for
command is executed,
.I identifier\^
is set to the next
.I word\^
taken from the
.B in
.I word\^
list.
If
.BI in " word\^"
\&.\|.\|.
is omitted, then
the
.B for
command executes the \f3do\fP \f2list\^\fP once for each positional parameter
that is set
(see
.I "Parameter Substitution\^"
below).
Execution ends when there are no more words in the list.
.TP
\f3select\fP \f2identifier\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3do\fP \f2list\^\fP \f3done\fP
A
.B select
command prints on standard error (file descriptor 2), the set of
.IR word s,
each preceded by a number.
If
.BI in " word\^"
\&.\|.\|.
is omitted, then
the
positional parameters
are used instead
(see
.I "Parameter Substitution\^"
below).
The
.SM
.B PS3
prompt is printed
and a line is read from the standard input.
If this line consists of the number
of one of the listed
.BR word s,
then the value of the parameter
.I identifier\^
is set to the
.I word\^
corresponding to this number.
If this line is empty the selection list is
printed again.
Otherwise the value of the parameter
.I identifier\^
is set to
.BR null .
The contents of the line read from standard input is
saved in
the parameter
.SM
.BR REPLY.
The
.I list\^
is executed for each selection until a
.B break\^
or
.I end-of-file\^
is encountered.
.TP
\f3case\fP \f2word\^\fP \f3in\fP \*(OK \f2pattern\^\fP \*(OK \(bv \
\f2pattern\^\fP \*(CK .\|.\|. \f3)\fP \f2list\^\fP \f3;;\fP \*(CK .\|.\|. \f3esac\fP
A
.B case
command executes the
.I list\^
associated with the first
.I pattern\^
that matches
.IR word .
The form of the patterns is
the same as that used for
file-name generation (see
.I "File Name Generation\^"
below).
.TP
\f3if\fP \f2list\^\fP \f3then\fP \f2list\^\fP \*(OK \
\f3elif\fP \f2list\^\fP \f3then\fP \f2list\^\fP \*(CK .\|.\|. \
\*(OK \f3else\fP \f2list\^\fP \*(CK \f3f\&i\fP
The
.I list\^
following \f3if\fP is executed and,
if it
returns a zero exit status, the
.I list\^
following
the first
.B then
is executed.
Otherwise, the
.I list\^
following \f3elif\fP
is executed and, if its value is zero,
the
.I list\^
following
the next
.B then
is executed.
Failing that, the
.B else
.I list\^
is executed.
If no
.B else
.I list\^
or
.B then
.I list\^
is executed, then the
.B if
command returns a zero exit status.
.TP
.PD 0
\f3while\fP \f2list\^\fP \f3do\fP \f2list\^\fP \f3done\fP
.TP
\f3until\fP \f2list\^\fP \f3do\fP \f2list\^\fP \f3done\fP
.PD
A
.B while
command repeatedly executes the
.B while
.I list\^
and, if the exit status of the last command in the list is zero, executes
the
.B do
.IR list ;
otherwise the loop terminates.
If no commands in the
.B do
.I list\^
are executed, then the
.B while
command returns a zero exit status;
.B until
may be used in place of
.B while
to negate
the loop termination test.
.TP
\f3(\fP\f2list\^\fP\f3)\fP
.br
Execute
.I list\^
in a separate environment.
Note, that if two adjacent open parentheses are
needed for nesting, a space must be inserted to avoid
arithmetic evaluation as described below.
.TP
\f3{ \fP\f2list\^\fP\f3;}\fP
.br
.I list\^
is simply executed.
Note that
.B {
is a
.I keyword\^
and requires a blank
in order to be recognized.
.TP
.PD 0
\f3function\fP \f2identifier\^\fP \f3{\fP \f2list\^\fP \f3;}\fP
.TP
\f2identifier\^\fP \f3() {\fP \f2list\^\fP \f3;}\fP
.PD
Define a function which is referenced by
.IR identifier .
The body of the function is the
.I list\^
of commands between
.B {
and
.BR } .
(See
.I Functions\^
below).
.TP
\f3time \fP\f2pipeline\^\fP
.br
The
.I pipeline\^
is executed and the elapsed time as well as
the user and system time are printed on standard error.
.PP
The following keywords
are only recognized as the first word of a command
and when not quoted:
.if t .RS
.PP
.B
.if n if then else elif fi case esac for while until do done { } function select time
.if t if then else elif fi case esac for while until do done { } function select time
.if t .RE
.SS Comments.
A word beginning with
.B #
causes that word and all the following characters up to a new-line
to be ignored.
.SS Aliasing.
The first word of each command is replaced by the text of an
.B alias
if an
.B alias
for this word has been defined.
The
first character of an
.B alias
name can be any printable character,
but the rest of the characters
must be the same as for a valid
.IR identifier .
The replacement string can contain any
valid Shell script
including the metacharacters listed above.
The first word of each command of the
replaced text will not be tested for additional aliases.
If the last character of the alias value is a
.I blank\^
then the word following the alias will also be checked for alias
substitution.
Aliases can be used to redefine special
builtin commands but cannot be used to redefine
the keywords listed above.
Aliases can be created, listed, and exported with the
.B alias
command and can be removed with the
.B unalias
command.
Exported aliases remain in effect for sub-shells
but must be reinitialized for separate invocations
of the Shell (See
.I Invocation\^
below).
.PP
.I Aliasing\^
is performed when
scripts are read,
not while they are executed.
Therefore,
for an alias to take effect
the
.B
alias
command has to be executed before
the command which references the alias is read.
.PP
Aliases are frequently used as a short hand for full path
names.
An option to the aliasing facility allows the value of the alias
to be automatically set to the full pathname of
the corresponding command.
These aliases are called
.I tracked
aliases.
The value of a
.I tracked
alias is defined the first time the identifier
is read and becomes undefined each time
the
.SM
.B PATH
variable is reset.
These aliases remain
.I tracked
so that the next
subsequent reference will redefine the value.
Several tracked aliases are compiled into the shell.
The
.B \-h
option of the
.B set
command makes each command name which is an
.I identifier\^
into a tracked alias.
.PP
The following
.I exported aliases
are compiled into the shell
but can be unset or redefined:
.RS 20
.PD 0
.TP
.B "echo=\(fmprint \-\(fm"
.TP
.B "false=\(fmlet 0\(fm"
.TP
.B "functions=\(fmtypeset \-f\(fm"
.TP
.B "history=\(fmfc \-l\(fm"
.TP
.B "integer=\(fmtypeset \-i\(fm"
.TP
.B "nohup=\(fmnohup \(fm"
.TP
.B "pwd=\(fmprint \- $\s-1PWD\s+1\(fm"
.TP
.B "r=\(fmfc \-e \-\(fm"
.TP
.B "true=\(fm:\(fm"
.TP
.B "type=\(fmwhence \-v\(fm"
.TP
.B "hash=\(fmalias \-t\(fm"
.PD
.RE
.SS Tilde Substitution.
After alias substitution is performed, each word
is checked to see if it begins with an unquoted
.BR \(ap .
If it does, then the word up to a
.B /
is checked to see if it matches a user name in the
.B /etc/passwd
file.
If a match is found, the
.B \(ap
and the matched login name is replaced by the
login directory of the matched user.
This is called a
.I tilde
substitution.
If no match is found, the original text is left unchanged.
A
.B \(ap
by itself, or in front of a
.BR / ,
is replaced by the value of the
.B
.SM HOME
parameter.
A
.B \(ap
followed by a
.B +
or
.B \-
is replaced by the value of
the parameter
.B
.SM PWD
and
.B
.SM OLDPWD
respectively.
.PP
In addition, the value of each
.I "keyword parameter"
is checked to see if it begins with a
.B \(ap
or if a
.B \(ap
appears after a
.BR : .
In either of these cases a
.I tilde
substitution is attempted.
.SS Command Substitution.
The standard output from a command enclosed in
a pair of grave accents (\^\f3\*`\^\*`\fP\^) may be used as part or all
of a word;
trailing new-lines are removed.
The command substitution
\^\f3\*`\^cat file\^\*`\fP\^
can be replaced by the equivalent but faster
\^\f3\*`\^<file\^\*`\fP\^.
Command substitution of most special commands
that do not perform input/output redirection are
carried out without creating a separate process.
.SS Parameter Substitution.
A
.I parameter\^
is an
.IR identifier ,
a digit,
or any of the characters
.BR \(** ,
.BR @ ,
.BR # ,
.BR ? ,
.BR \- ,
.BR $ ,
and
.BR !\\^ .
A
.I named parameter\^
(a parameter denoted by an identifier)
has a
.I value\^
and zero or more
.IR attributes .
.I Named parameters \^
can be assigned
.I values\^
and
.I attributes
by using the
.B typeset\^
special command.
The attributes supported by the Shell are described
later with the
.B typeset\^
special command.
Exported parameters pass values and attributes to
sub-shells but only values to the environment.
.PP
The shell supports a limited one-dimensional array facility.
An element of an array parameter is referenced by a
.IR subscript .
A
.I subscript\^
is denoted by a
.BR [ ,
followed by an
.I arithmetic expression\^
(see Arithmetic evaluation below)
followed by a
.BR ] .
The value of all
subscripts must be in the
range of
0 through 511.
Arrays need not be declared.
Any reference to a named parameter
with a valid subscript is
legal and an array will be created if necessary.
Referencing an array without a subscript
is equivalent to referencing the first element.
.PP
The
.I value\^
of a
.I named parameter\^
may also be assigned by writing:
.RS
.PP
.IB name = value\^\|
\*(OK
.IB name = value\^
\*(CK .\|.\|.
.RE
.PP
.PD 0
If the integer attribute,
.BR \-i ,
is set for
.I name\^
the
.I value\^
is subject to arithmetic evaluation as described below.
.PP
Positional parameters,
parameters denoted by a number,
may be assigned values with the
.B set\^
special command.
Parameter
.B $0
is set from argument zero when the shell
is invoked.
.PP
The character
.B $
is used to introduce substitutable
.IR parameters .
.TP
\f3${\fP\f2parameter\^\fP\f3}\fP
The value, if any, of the parameter is substituted.
The braces are required when
.I parameter\^
is followed by a letter, digit, or underscore
that is not to be interpreted as part of its name
or when a named parameter is subscripted.
If
.I parameter\^
is a digit then it is a positional parameter.
If
.I parameter\^
is
.BR \(**
or
.BR @ ,
then all the positional
parameters, starting with
.BR $1 ,
are substituted
(separated by spaces).
If an array
.I identifier\^
with subscript
.B \(**
or
.B @
is used,
then the value
for each of the
elements
is substituted
(separated by spaces).
.TP
\f3${#\fP\f2parameter\^\fP\f3}\fP
If
.I parameter\^
is not
.BR \(** ,
the length of the value of the
.I parameter\^
is substituted.
Otherwise, the number of positional parameters is substituted.
.TP
\f3${#\fP\f2identifier\fP\f3[*]}\fP
The number of elements in the array
.I identifier\^
is substituted.
.TP
\f3${\fP\f2parameter\^\fP\f3:\-\fP\f2word\^\fP\f3}\fP
If
.I parameter\^
is set and is non-null then substitute its value;
otherwise substitute
.IR word .
.TP
\f3${\fP\f2parameter\^\fP\f3:=\fP\f2word\^\fP\f3}\fP
If
.I parameter\^
is not set or is null then set it to
.IR word ;
the value of the parameter is then substituted.
Positional parameters may not be assigned to
in this way.
.TP
\f3${\fP\f2parameter\^\fP\f3:?\fP\f2word\^\fP\f3}\fP
If
.I parameter\^
is set and is non-null then substitute its value;
otherwise, print
.I word\^
and exit from the shell.
If
.I word\^
is omitted then a standard message is printed.
.TP
\f3${\fP\f2parameter\^\fP\f3:+\fP\f2word\^\fP\f3}\fP
If
.I parameter\^
is set and is non-null then substitute
.IR word ;
otherwise substitute nothing.
.TP
.PD 0
\f3${\fP\f2parameter\^\fP\f3#\fP\f2pattern\^\fP\f3}\fP
.TP
\f3${\fP\f2parameter\^\fP\f3##\fP\f2pattern\^\fP\f3}\fP
.PD
If
the Shell
.I pattern\^
matches the beginning of the value of
.IR parameter ,
then the value of
this substitution is the value of the
.I parameter\^
with the matched portion deleted;
otherwise the value of this
.I parameter\^
is substituted.
In the first form the smallest matching pattern is deleted and in the
latter form the largest matching pattern is deleted.
.TP
.PD 0
\f3${\fP\f2parameter\^\fP\f3%\fP\f2pattern\^\fP\f3}\fP
.TP
\f3${\fP\f2parameter\^\fP\f3%%\fP\f2pattern\^\fP\f3}\fP
.PD
If
the Shell
.I pattern\^
matches the end of the value of
.IR parameter ,
then the value of
.I parameter\^
with the matched part deleted;
otherwise substitute the value of
.IR parameter .
In the first form the smallest matching pattern is deleted and in the
latter form the largest matching pattern is deleted.
.PD
.PP
In the above,
.I word\^
is not evaluated unless it is
to be used as the substituted string,
so that, in the following example,
.B pwd\^
is executed only if
.B d\^
is not set or is null:
.RS
.PP
echo \|${d:\-\^\*`\^pwd\^\*`\^}
.RE
.PP
If the colon (
.B : )
is omitted from the above expressions,
then the shell only checks whether
.I parameter\^
is set or not.
.PP
The following
parameters
are automatically set by the shell:
.RS
.PD 0
.TP
.B #
The number of positional parameters in decimal.
.TP
.B \-
Flags supplied to the shell on invocation or by
the
.B set
command.
.TP
.B ?
The decimal value returned by the last executed command.
.TP
.B $
The process number of this shell.
.TP
.B _
The last argument of the previous command.
This parameter is not set for commands which are asynchronous.
.TP
.B !
The process number of the last background command invoked.
.TP
.B
.SM PPID
The process number of the parent of the shell.
.TP
.B
.SM PWD
The present working directory set by the
.B cd
command.
.TP
.B
.SM OLDPWD
The previous working directory set by the
.B cd
command.
.TP
.B
.SM RANDOM
Each time this parameter is referenced, a random integer is generated.
The sequence of random numbers can be initialized by assigning
a numeric value to
.SM
.BR RANDOM .
.TP
.B
.SM REPLY
This parameter is set by the
.B select
statement and by
the
.B read
special command when no arguments are supplied.
.PD
.RE
.PP
The following
parameters
are used by the shell:
.RS
.PD 0
.TP
.B
.SM CDPATH
The search path for the
.I cd
command.
.TP
.B
.SM COLUMNS
If this variable is set,
the value is used to define the width of the edit window
for the shell edit modes and for printing
.B select
lists.
.TP
.B
.SM EDITOR
If the value of this variable ends in
.IR emacs ,
.IR gmacs ,
or
.I vi
and the
.B
.SM VISUAL
variable is not set,
then the corresponding option
(see Special Command
.B set
below)
will be turned on.
.TP
.SM
.B ENV
If this parameter is set, then
parameter substitution is performed on
the value to generate
the pathname of the script that will be
executed when the
.I shell\^
is invoked.
(See
.I Invocation\^
below.)
This file is typically used for
.I alias
and
.I function
definitions.
.TP
.B
.SM FCEDIT
The default editor name for the
.B fc
command.
.TP
.SM
.B IFS
Internal field separators,
normally
.BR space ,
.BR tab ,
and
.B new-line
that is used to separate command words which result from
command or parameter substitution
and for separating words with the special command
.BR read .
.TP
.SM
.B HISTFILE
If this parameter is set when the shell is invoked, then
the value is the pathname of the file that will be
used to store the command history.
(See
.I "Command re-entry\^"
below.)
.TP
.SM
.B HISTSIZE
If this parameter is set when the shell is invoked, then
the number of previously entered commands that
are accessible by this shell
will be greater than or equal to this number.
The default is 128.
.TP
.B
.SM HOME
The default argument (home directory) for the
.B cd
command.
.TP
.B
.SM MAIL
If this parameter is set to the name of a mail file
.I and\^
the
.B
.SM MAILPATH
parameter is not set,
then the shell informs the user of arrival of mail
in the specified file.
.TP
.B
.SM MAILCHECK
This variable specifies how often (in seconds) the
shell will check for changes in the modification time
of any of the files specified by the
.B
.SM MAILPATH
or
.B
.SM MAIL
parameters.
The default value is 600 seconds.
If set to 0,
the shell will check before each prompt.
.TP
.B
.SM MAILPATH
A colon (
.B :
)
separated list of file names.
If this parameter is set
then the shell informs the user of
any modifications to the specified files
that have occurred within the last
.B
.SM MAILCHECK
seconds.
Each file name can be followed by a
.B ?
and a message that will be printed.
The message will undergo parameter and command substitution
with the parameter,
.B $_
defined as the name of the file that has changed.
The default message is
.I you have mail in $_\^.
.TP
.B
.SM PATH
The search path for commands (see
.I Execution\^
below).
The user may not change
.B \s-1PATH\s+1
if executing under
.I rsh
(except in
.I .profile\^
).
.TP
.SM
.B PS1
The value of this parameter is expanded for paramter
substitution to define the
primary prompt string which by default is
.RB `` "$ \|" ''.
The character
.B !
in the primary prompt string is replaced by the
.I command\^
number (see
.I Command Re-entry
below).
.TP
.SM
.B PS2
Secondary prompt string, by default
.RB `` "> \|" ''.
.TP
.SM
.B PS3
Selection prompt string
used within a
.B select
loop, by default
.RB `` "#? \|" ''.
.TP
.SM
.B SHELL
The pathname of the
.I shell\^
is kept in the environment.
At invocation, if the value of this variable contains an
.B r
in the basename,
then the shell becomes restricted.
.TP
.B
.SM TMOUT
If set to a value greater than zero,
the shell will terminate if a command is not entered within
the prescribed number of seconds.
(Note that the shell can be compiled with a maximum bound
for this value which cannot be exceeded.)
.TP
.B
.SM VISUAL
If the value of this variable ends in
.IR emacs ,
.IR gmacs ,
or
.I vi
then the corresponding option
(see Special Command
.B set
below)
will be turned on.
.PD
.RE
.PP
The shell gives default values to
\f3\s-1PATH\s+1\fP, \f3\s-1PS1\s+1\fP, \f3\s-1PS2\s+1\fP, \f3\s-1MAILCHECK\s+1\fP,
\f3\s-1TMOUT\s+1\fP and \f3\s-1IFS\s+1\fP,
while
.SM
.BR HOME ,
.SM
.B SHELL
.SM
.B ENV
and
.SM
.B MAIL
are
not set at all by the shell (although
.SM
.B HOME
.I is\^
set by
.IR login (1)).
On some systems
.SM
.B MAIL
and
.SM
.B SHELL
are also
set by
.IR login (1)).
.SS Blank Interpretation.
After parameter and command substitution,
the results of substitutions are scanned for the field separator
characters (
those found in
.SM
.B IFS
)
and split into distinct arguments where such characters are found.
Explicit null arguments (\^\f3"\^"\fP or \f3\*\(fm\^\*\(fm\fP\^) are retained.
Implicit null arguments
(those resulting from
.I parameters\^
that have no values) are removed.
.SS File Name Generation.
Following substitution, each command
.I word\^
is scanned for
the characters
.BR \(** ,
.BR ? ,
and
.B \*(OK\^
unless the
.B \-f
option has been
.BR set .
If one of these characters appears
then the word is regarded as a
.IR pattern .
The word is replaced with alphabetically sorted file names that match the pattern.
If no file name is found that matches the pattern, then
the word is left unchanged.
When a
.I pattern\^
is used for file name generation,
the character
.B .
at the start of a file name
or immediately following a
.BR / ,
as well as the character
.B /
itself,
must be matched explicitly.
In other instances of pattern matching the
.B /
and
.B .
are not treated specially.
.PP
.PD 0
.RS
.TP
.B \(**
Matches any string, including the null string.
.TP
.B ?
Matches any single character.
.TP
.BR \*(OK \^.\|.\|.\^ \*(CK
Matches any one of the enclosed characters.
A pair of characters separated by
.B \-
matches any
character lexically between the pair, inclusive.
If the first character following the opening "[ \|"
is a "! \|" then any character not enclosed is matched.
A
.B \-
can be included in the character set by putting it as the
first or last character.
.PD
.RE
.SS Quoting.
Each of the
.I metacharacters\^
listed above (See
.I Definitions
above).
has a special meaning to the shell
and cause termination of a word unless quoted.
A character may be
.I quoted\^
(i.e., made to stand for itself)
by preceding
it with a
.BR \e .
The pair
.B \enew-line
is ignored.
All characters enclosed between a pair of single quote marks (\^\f3\(fm\^\(fm\fP\^),
except a single quote,
are quoted.
Inside double quote marks
(\f3"\^"\fP),
parameter and command substitution occurs and
.B \e
quotes the characters
.BR \e ,
.BR \(fm ,
\f3"\fP,
and
.BR $ .
.B
"$\(**"
is equivalent to
\f3"$1 \|$2\fP \|.\|.\|.\f3"\fP,
whereas
.B
"$@"
is equivalent to
.B
"$1"\|
.B
"$2"\|
\&.\|.\|.\^.
.PP
The special meaning of keywords can be removed by quoting any
character of the keyword.
The recognition of special command names listed below cannot be altered
by quoting them.
.SS Arithmetic Evaluation.
An ability to perform integer arithmetic
is provided with the special command
.BR let .
Evaluations are performed using
.I long\^
arithmetic.
Constants are of the form
\*(OK\f2base\f3#\^\f1\*(CK\f2n\^\fP
where
.I base\^
is a decimal number between two and thirty-six
representing the arithmetic base
and
.I n\^
is a number in that base.
If
.I base\^
is omitted
then base 10 is used.
.PP
An internal integer representation of a
.I named parameter\^
can be specified with the
.B \-i
option of the
.B typeset
special command.
When this attribute is selected
the first assignment to the
parameter determines the arithmetic base
to be used when
parameter substitution occurs.
.PP
Since many of the arithmetic operators require
quoting, an alternative form of the
.B let
command is provided.
For any command which begins with a
.BR (( ,
all the characters until a matching
.B ))
are treated as a quoted expression.
More precisely,
.B ((
\&.\|.\|.
.B ))
is equivalent to
.B let\^
\f3"\fP \|.\|.\|.\f3"\fP.
.SS Prompting.
When used interactively,
the shell prompts with the value of
.SM
.B PS1
before reading a command.
If at any time a new-line is typed and further input is needed
to complete a command, then the secondary prompt
(i.e., the value of
.BR \s-1PS2\s+1 )
is issued.
.SS Input/Output.
Before a command is executed, its input and output
may be redirected using a special notation interpreted by the shell.
The following may appear anywhere in a simple-command
or may precede or follow a
.I command\^
and are
.I not\^
passed on to the invoked command.
Command and parameter substitution occurs before
.I word\^
or
.I digit\^
is used except as noted below.
File name generation
occurs only if the pattern matches a single file
and blank interpretation is not performed.
.TP 14
.BI < word
Use file
.I word\^
as standard input (file descriptor 0).
.TP
.BI > word
Use file
.I word\^
as standard output (file descriptor 1).
If the file does not exist then it is created;
otherwise, it is truncated to zero length.
.TP
.BI >\h@-.3m@> word
Use file
.I word\^
as standard output.
If the file exists then output is appended to it (by first seeking to the end-of-file);
otherwise, the file is created.
.TP
\f3<\h@-.3m@<\fP\*(OK\f3\-\fP\*(CK\f2word\fP
The shell input is read up to a line that is the same as
.IR word ,
or to an end-of-file.
No parameter substitution, command substitution or
file name generation is performed on
.IR word .
The resulting document,
called a
.IR here-document ,
becomes
the standard input.
If any character of
.I word\^
is quoted, then no interpretation
is placed upon the characters of the document;
otherwise, parameter and command substitution occurs,
.B \enew-line
is ignored,
and
.B \e
must be used to quote the characters
.BR \e ,
.BR $ ,
.BR \*` ,
and the first character of
.IR word .
If
.B \-
is appended to
.BR <\h@-.3m@< ,
then all leading tabs are stripped from
.I word\^
and from the document.
.TP
.BI <& digit
The standard input is duplicated from file descriptor
.I digit
(see
.IR dup (2)).
Similarly for the standard output using
.BR >&
.IR digit .
.TP
.B <&\-
The standard input is closed.
Similarly for the standard output using
.BR >&\- .
.PP
If one of the above is preceded by a digit,
then the
file descriptor number referred to is that specified
by the digit
(instead of the default 0 or 1).
For example:
.RS
.PP
\&.\|.\|. \|2>&1
.RE
.PP
means file descriptor 2 is to be opened
for writing as a duplicate
of file descriptor 1.
.PP
The order in which redirections are specified is significant.
The shell evaluates each redirection in terms of the
.RI ( "file descriptor" ", " file )
association at the time of evaluation.
For example:
.RS
.PP
\&.\|.\|. \|1>\f2fname\^\fP 2>&1
.RE
.PP
first associates file descriptor 1 with file
.IR fname\^ .
It then associates file descriptor 2 with the file associated with file
descriptor 1 (i.e.
.IR fname\^ ).
If the order of redirections were reversed, file descriptor 2 would be associated
with the terminal (assuming file descriptor 1 had been) and then file descriptor
1 would be associated with file
.IR fname\^ .
.PP
If a command is followed by
.B &
and job control is not active,
then the default standard input
for the command
is the empty file
.BR /dev/null .
Otherwise, the environment for the execution of a command contains the
file descriptors of the invoking shell as modified by
input/output specifications.
.SS Environment.
The
.I environment\^
(see
.IR environ (7))
is a list of name-value pairs that is passed to
an executed program in the same way as a normal argument list.
The names must be
.I identifiers\^
and the values are character strings.
The shell interacts with the environment in several ways.
On invocation, the shell scans the environment
and creates a
parameter
for each name found,
giving it the corresponding value and marking it
.I export .
Executed commands inherit the environment.
If the user modifies the values of these
parameters
or creates new ones,
using the
.B export
or
.B typeset \-x
commands they become part of the
environment.
The environment seen by any executed command is thus composed
of any name-value pairs originally inherited by the shell,
whose values may be modified by the current shell,
plus any additions
which must be noted in
.B export
or
.B typeset \-x
commands.
.PP
The environment for any
.I simple-command\^
or function
may be augmented by prefixing it with one or more parameter assignments.
A parameter assignment argument is a word of the form
.IR identifier=value .
Thus:
.RS
.PP
\s-1TERM\s+1=450 \|cmd \|args and
.br
(export \|\s-1TERM\s+1; \|\s-1TERM\s+1=450; \|cmd \|args)
.RE
.PP
are equivalent (as far as the above execution of
.I cmd\^
is concerned).
.PP
If the
.B \-k
flag is set,
.I all\^
parameter assignment arguments are placed in the environment,
even if they occur after the command name.
The following
first prints
.B "a=b c"
and then
.BR c:
.PP
.RS
.nf
echo \|a=b \|c
set \|\-k
echo \|a=b \|c
.fi
.RE
.SS Functions.
.PP
The
.B function\^
keyword, described in the
.I Commands
section above,
is used to define shell functions.
Shell functions are read in and stored internally.
Alias names are resolved when the function is read.
Functions are executed like commands with the arguments
passed as positional parameters.
(See
.I Execution
below).
.PP
Functions execute in the same process as the caller and
share all files, traps ( other than
.SM
.B EXIT
and
.SM
.BR ERR )
and present working directory with the
caller.
A trap set on
.SM
.B EXIT
inside a function
is executed after the function completes.
Ordinarily,
variables are shared between the calling program
and the function.
However,
the
.B typeset
special command used within a function
defines local variables whose scope includes
the current function and
all functions it calls.
.PP
The special command
.B return
is used to return
from function calls.
Errors within functions return control to the caller.
.PP
Function identifiers
can be listed with the
.B \-f
option of the
.B typeset
special command.
The text of functions will also
be listed.
Function can be undefined with the
.B \-f
option of the
.B unset
special command.
.PP
Ordinarily,
functions are unset when the shell executes a shell script.
The
.B \-xf
option of the
.B typeset
command allows a function to be exported
to scripts that are executed without a separate
invocation of the shell.
Functions that need to be defined across separate
invocations of the shell should be placed in the
.B
.SM
ENV
file.
.SS Jobs.
.PP
If the
.B monitor
option of the
.B set
command is turned on,
an interactive shell associates a \fIjob\fR with each pipeline. It keeps
a table of current jobs, printed by the
.B jobs
command, and assigns them small integer numbers. When
a job is started asynchronously with
.BR & ,
the shell prints a line which looks
like:
.PP
.DT
[1] 1234
.PP
indicating that the job which was started asynchronously was job number
1 and had one (top-level) process, whose process id was 1234.
.PP
This paragraph and the next require features that are
not in all versions of UNIX and may not apply.
If you are running a job and wish to do something else you may hit the key
\fB^Z\fR (control-Z) which sends a STOP signal to the current job.
The shell will then normally indicate that the job has been `Stopped',
and print another prompt. You can then manipulate the state of this job,
putting it in the background with the
.B bg
command, or run some other
commands and then eventually bring the job back into the foreground with
the foreground command
.BR fg .
A \fB^Z\fR takes effect immediately and
is like an interrupt in that pending output and unread input are discarded
when it is typed.
.PP
A job being run in the background will stop if it tries to read
from the terminal. Background jobs are normally allowed to produce output,
but this can be disabled by giving the command ``stty tostop''.
If you set this
tty option, then background jobs will stop when they try to produce
output like they do when they try to read input.
.PP
There are several ways to refer to jobs in the shell. The character
.B %
introduces a job name. If you wish to refer to job number 1, you can
name it as
.B %1 .
Jobs can also be named by prefixes of the string typed in to
.B kill
or restart them.
Thus, on systems that support job control,
.RB ` fg
.BR %ed '
would normally restart
a suspended
.IR ed (1)
job, if there were a suspended job whose name began with
the string `ed'.
.PP
The shell maintains a notion of the current and previous jobs.
In output pertaining to jobs, the current job is marked with a
.B +
and the previous job with a
.BR \- .
The abbreviation
.B %+
refers
to the current job and
.B %\-
refers to the previous job.
.B %%
is also a synonym for the current job.
.PP
This shell learns immediately whenever a process changes state.
It normally informs you whenever a job becomes blocked so that
no further progress is possible, but only just before it prints
a prompt. This is done so that it does not otherwise disturb your work.
.PP
When you try to leave the shell while jobs are running or stopped, you will
be warned that `You have stopped(running) jobs.' You may use the
.B jobs
command to see what they are. If you do this or immediately try to
exit again, the shell will not warn you a second time, and the stopped
jobs will be terminated.
.SS Signals.
The \s-1INT\s+1 and \s-1QUIT\s+1 signals for an invoked
command are ignored if the command is followed by
.B &
and job
.B monitor
option is not active.
Otherwise, signals have the values
inherited by the shell from its parent,
with the exception of signal 11
(but see also
the
.B trap
command below).
.SS Execution.
Each time a command is executed, the above substitutions
are carried out.
If the command name matches one
of the
.I "Special Commands\^"
listed below,
it is executed within the
current shell process.
Next, the command name is checked to see if
it matches one of the user defined functions.
If it does,
the positional parameters are saved
and then reset to the arguments of the
.I function\^
call.
When the
.I function\^
completes or issues a
.BR return ,
the positional parameter list is restored
and any trap set on
.SM
.B EXIT
within the function is executed.
The value of a
.I function\^
is the value of the last command executed.
A function is also executed in the
current shell process.
If a command name is not a
.I "special command\^"
or a user defined
.IR function ,
a process is created and
an attempt is made to execute the command via
.IR exec (2).
.PP
The shell parameter
.B
.SM PATH
defines the search path for
the directory containing the command.
Alternative directory names are separated by
a colon
.RB ( : ).
The default path is
.B :/bin:/usr/bin
(specifying the current directory,
.BR /bin ,
and
.BR /usr/bin ,
in that order).
Note that the current directory
is specified by a null path name,
which can appear immediately after the
equal sign, between colon delimiters,
or at the end of the path list.
If the command name contains a \f3/\fP then the search path
is not used.
Otherwise, each directory in the path is
searched for an executable file.
If the file has execute permission but is not a
directory or an
.B a.out
file,
it is assumed to be a file containing shell commands.
A sub-shell is spawned to read it.
All non-exported aliases,
functions,
and named parameters are removed in this case.
A parenthesized command is also executed in
a sub-shell.
.SS Command Re-entry.
The text of the last
.B
.SM
HISTSIZE
(default 128)
commands entered from a terminal device
is saved in a
.I history
file.
The file
.B \s-1$HOME\s+1/.history
is used if the
.B
.SM
HISTFILE
variable is not set
or is not writable.
A shell can access the commands of
all
.I interactive
shells which use the same named
.SM
.BR HISTFILE .
The special command
.B fc\^
is used to list or
edit a portion this file.
The portion of the file to be edited or listed can be selected by
number or by giving the first character or
characters of the command.
A single command or range of commands can be specified.
If you do not specify an editor program as
an argument to
.B fc\^
then the value of the parameter
.SM
.B FCEDIT
is used.
If
.SM
.B FCEDIT
is not defined then
.I /bin/ed
is used.
The edited command(s) is printed and re-executed upon
leaving the editor.
The editor name
.B \-
is used to skip the editing phase and
to re-execute the command.
In this case a substitution parameter of the form
\f2old\fP\f3=\fP\f2new\fP
can be used to modify the command before execution.
For example, if
.B r
is aliased to
.B \(fmfc \-e \-\(fm
then typing
`\f3r bad=good c\fP'
will re-execute the most recent command which starts with the letter
.BR c ,
replacing the string
.B bad
with the string
.BR good .
.SS In-line Editing Options
Normally, each command line entered from a terminal device is simply
typed followed by a new-line (`RETURN' or `LINE\ FEED').
If either the
.IR emacs ,
.IR gmacs ,
or
.I vi
option is active, the user can edit the command line.
To be in either of these edit modes
.B set
the corresponding
option.
An editing option is automatically selected each time the
.SM
.B VISUAL
or
.SM
.B EDITOR
variable is assigned a value ending in either of these
option names.
.PP
The editing features require that the user's terminal
accept `RETURN' as carriage return without line feed
and that a space (`\ ' must overwrite the current character on
the screen.
ADM terminal users should set the "space\ -\ advance"
switch to `space'.
Hewlett-Packard series 2621 terminal users should set the straps to
`bcGHxZ\ etX'.
.PP
The editing modes implement a concept where the user is looking through a
window at the current line.
The window width is the value of
.SM
.B COLUMNS
if it is defined, otherwise 80.
If the line is longer than the window width minus two, a mark is
displayed at the end of the window to notify the user.
As the cursor moves and reaches the window boundaries the window will be
centered about the cursor.
The mark is a
.BR > " ("
.BR < ", "
.BR * )
if the line extends on the
right (left, both) side(s) of the window.
.SS Emacs Editing Mode
This mode is entered by enabling either the
.I emacs
or
.I gmacs
option.
The only difference between these two modes is the way
they handle
.BR ^T .
To edit, the user
moves the cursor to the point needing correction and
then inserts or deletes characters or words as needed.
All the editing commands are control characters or escape
sequences.
The notation for control characters is caret (
.B ^
) followed
by the character.
For example,
.B ^F
is the notation for control
.BR F .
This is entered by depressing `f' while holding down the
`CTRL' (control) key.
The `SHIFT' key is
.I not
depressed.
(The notation
.B ^?
indicates the DEL (delete) key.)
.PP
The notation for escape sequences is
.B M-
followed by a
character.
For example,
.B M-f
(pronounced Meta f)
is entered by depressing ESC
(ascii
.B 033
)
followed by `f'.
(
.B M-F
would be the notation for ESC followed by `SHIFT' (capital) `F'.)
.PP
All edit commands
operate from any place on the line
(not just at the beginning).
Neither the "RETURN" nor the "LINE FEED" key is
entered after edit commands except when noted.
.PP
.PD 0
.TP 10
.BI ^F
Move cursor forward (right) one character.
.PP
.TP 10
.BI M-f
Move cursor forward one word.
(The editor's idea of a word is a string of characters
consisting of only letters, digits and underscores.)
.PP
.TP 10
.BI ^B
Move cursor backward (left) one character.
.PP
.TP 10
.BI M-b
Move cursor backward one word.
.PP
.TP 10
.BI ^A
Move cursor to start of line.
.PP
.TP 10
.BI ^E
Move cursor to end of line.
.PP
.TP 10
.BI ^] char
Move cursor to character
.I char
on current line.
.PP
.TP 10
.BI ^X^X
Interchange the cursor and mark.
.PP
.TP 10
.I erase
(User defined erase character as defined
by the stty command, usually
.B ^H
or
.BR # .)
Delete previous character.
.PP
.TP 10
.BI ^D
Delete current character.
.PP
.TP 10
.BI M-d
Delete current word.
.PP
.TP 10
.BI M-^H
(Meta-backspace) Delete previous word.
.PP
.TP 10
.BI M-h
Delete previous word.
.PP
.TP 10
.BI M-^?
(Meta-DEL) Delete previous word (if your interrupt character is
.B ^?
(DEL, the default) then this command will not work).
.PP
.TP 10
.BI ^T
Transpose current character with next character in
.I emacs
mode.
Transpose two previous characters in
.I gmacs
mode.
.PP
.TP 10
.BI ^C
Capitalize current character.
.PP
.TP 10
.BI M-C
Capitalize current word.
.PP
.TP 10
.BI ^K
Kill from the cursor to the end of the line.
If given a parameter of zero then kill from
the start of line to the cursor.
.PP
.TP 10
.BI ^W
Kill from the cursor to the mark.
.PP
.TP 10
.BI M-p
Push the region from the cursor to the mark on the stack.
.PP
.TP 10
.I kill
(User defined kill character as defined
by the stty command, usually
.B ^G
or
.BR @ .)
Kill the entire current line.
If two
.I kill
characters are entered in succession, all
kill characters from then on cause a line feed
(useful when using paper terminals).
.PP
.TP 10
.BI ^Y
Restore last item removed from line. (Yank item back to the line.)
.PP
.TP 10
.BI ^L
Line feed and print current line.
.PP
.TP 10
.BI ^@
(Null character) Set mark.
.PP
.TP 10
.BI M-
(Meta space) Set mark.
.PP
.TP 10
.BI ^J
(New\ line) Execute the current line.
.PP
.TP 10
.BI ^M
(Return) Execute the current line.
.PP
.TP 10
.I eof
End-of-file character,
normally
.BR ^D ,
will terminate the shell
if the current line is null.
.PP
.TP 10
.BI ^P
Fetch previous command.
Each time
.B ^P
is entered
the previous command back in time is accessed.
.PP
.TP 10
.BI M-<
Fetch the least recent (oldest) history line.
.PP
.TP 10
.BI M->
Fetch the most recent (youngest) history line.
.PP
.TP 10
.BI ^N
Fetch next command.
Each time
.B ^N
is entered
the next command forward in time is accessed.
.PP
.TP 10
.BI ^R string
Reverse search history for a previous command line containing
.IR string .
If a parameter of zero is given the search is forward.
.I String
is terminated by a "RETURN" or "NEW\ LINE".
.PP
.TP 10
.B ^O
Operate \- Execute the current line and fetch
the next line relative to current line from the
history file.
.PP
.TP 10
.BI M- digits
(Escape) Define numeric parameter, the digits
are taken as a parameter to the next command.
The commands that accept a parameter are
.BR ^F ,
.BR ^B ,
.IR erase ,
.BR ^D ,
.BR ^K ,
.BR ^R ,
.B ^P
and
.BR ^N .
.PP
.TP 10
.BI M- letter
Soft-key \- Your alias list is searched for an
alias by the name
.BI _ letter
and if an alias of this name is defined, its
value will be inserted on the line.
The
.I letter
must not be one of the above meta-functions.
.PP
.TP 10
.B M-_
The last parameter of the previous command is inserted
on the line.
.PP
.TP 10
.B M-.
The last parameter of the previous command is inserted
on the line.
.PP
.TP 10
.B M-*
Attempt file name generation on the current word.
.PP
.TP 10
.BI ^U
Multiply parameter of next command by 4.
.PP
.TP 10
.BI \e
Escape next character.
Editing characters, the user's erase, kill and
interrupt (normally
.B ^?
)
characters
may be entered
in a command line or in a search string if preceded by a
.BR \e .
The
.B \e
removes the next character's
editing features (if any).
.PP
.TP 10
.BI ^V
Display version of the shell.
.PD
.SS Vi Editing Mode
There are two typing modes.
Initially, when you enter a command you are in the
.I input\^
mode.
To edit, the user enters
.I control\^
mode by typing ESC (
.B 033
) and
moves the cursor to the point needing correction and
then inserts or deletes characters or words as needed.
Most control commands accept an optional repeat
.I count
prior to the command.
.P
When in vi mode on most systems,
canonical processing is initially enabled and the
command will be echoed again if the speed is 1200 baud or greater and it
contains any control characters or less than one second has elapsed
since the prompt was printed.
The ESC character terminates canonical processing for the remainder of the command
and the user can than modify the command line.
This scheme has the advantages of canonical processing with the type-ahead
echoing of raw mode.
.P
If the option
.B viraw\^
is also set, the terminal will always have canonical processing
disabled. This mode is implicit for systems that do not support two
alternate end of line delimiters,
and may be helpful for certain terminals.
.SS "\ \ \ \ \ Input Edit Commands"
.PP
.RS
By default the editor is in input mode.
.PD 0
.TP 10
.I erase
(User defined erase character as defined
by the stty command, usually
.B ^H
or
.BR # .)
Delete previous character.
.TP 10
.BI ^W
Delete the previous blank separated word.
.TP 10
.BI ^D
Terminate the shell.
.TP 10
.BI ^V
Escape next character.
Editing characters, the user's erase or kill
characters may be entered
in a command line or in a search string if preceded by a
.BR ^V .
The
.B ^V
removes the next character's
editing features (if any).
.TP 10
.BI \e
Escape the next
.I erase
or
.I kill
character.
.P
.RE
.SS "\ \ \ \ \ Motion Edit Commands"
.RS
These commands will move the cursor.
.TP 10
[\f2count\fP]\f3l\fP
Cursor forward (right) one character.
.TP 10
[\f2count\fP]\f3w\fP
Cursor forward one alpha-numeric word.
.TP 10
[\f2count\fP]\f3W\fP
Cursor to the beginning of the next word that follows a blank.
.TP 10
[\f2count\fP]\f3e\fP
Cursor to end of word.
.TP 10
[\f2count\fP]\f3E\fP
Cursor to end of the current blank delimited word.
.TP 10
[\f2count\fP]\f3h\fP
Cursor backward (left) one character.
.TP 10
[\f2count\fP]\f3b\fP
Cursor backward one word.
.TP 10
[\f2count\fP]\f3B\fP
Cursor to preceding blank separated word.
.TP 10
[\f2count\fP]\f3f\fP\f2c\fP
Find the next character \fIc\fP in the current line.
.TP 10
[\f2count\fP]\f3F\fP\f2c\fP
Find the previous character \fIc\fP in the current line.
.TP 10
[\f2count\fP]\f3t\fP\f2c\fP
Equivalent to
.B f
followed by
.BR h .
.TP 10
[\f2count\fP]\f3T\fP\f2c\fP
Equivalent to
.B F
followed by
.BR l .
.TP 10
.B ;
Repeats the last single character find command,
.BR f ,
.BR F ,
.BR t ,
or
.BR T .
.TP 10
.B ,
Reverses the last single character find command.
.TP 10
.B 0
Cursor to start of line.
.TP 10
.B ^
Cursor to first non-blank character in line.
.TP 10
.B $
Cursor to end of line.
.RE
.SS "\ \ \ \ \ Search Edit Commands"
.RS
These commands access your command history.
.TP 10
[\f2count\fP]\f3k\fP
Fetch previous command.
Each time
.B k
is entered
the previous command back in time is accessed.
.TP 10
[\f2count\fP]\f3\-\fP
Equivalent to
.BR k .
.TP 10
[\f2count\fP]\f3j\fP
Fetch next command.
Each time
.B j
is entered
the next command forward in time is accessed.
.TP 10
[\f2count\fP]\f3+\fP
Equivalent to
.BR j .
.TP 10
[\f2count\fP]\f3G\fP
The command number
.I count
is fetched.
The default is the least recent history command.
.TP 10
.BI / string
Search backward through history for a previous command containing
.IR string .
.I String
is terminated by a "RETURN" or "NEW\ LINE".
If \fIstring\fP is null the previous string will be used.
.TP 10
.BI ? string
Same as
.B /
except that search will be in the forward direction.
.TP 10
.B n
Search for next match of the last pattern to
.B /
or
.B ?
commands.
.TP 10
.B N
Search for next match of the last pattern to
.B /
or
.BR ? ,
but in reverse direction.
Search history for the \fIstring\fP entered by the previous \fB/\fP command.
.RE
.SS "\ \ \ \ \ Text Modification Edit Commands"
.RS
These commands will modify the line.
.TP 10
.B a
Enter input mode and enter text after the current character.
.TP 10
.B A
Append text to the end of the line. Equivalent to
.BR $a .
.TP 10
[\f2count\fP]\f3c\fP\f2motion\fP
.TP 10
\f3c\fP[\f2count\fP]\f2motion\fP
Delete current character through the character
.I motion
moves the cursor to and enter input mode.
If \fImotion\fP is
.BR c ,
the entire line will be deleted and
input mode entered.
.TP 10
.B C
Delete the current character through the end of line and enter input mode.
Equivalent to
.BR c$ .
.TP 10
.B S
Equivalent to
.BR cc .
.TP 10
.B D
Delete the current character through the end of line.
.TP 10
[\f2count\fP]\f3d\fP\f2motion\fP
.TP 10
\f3d\fP[\f2count\fP]\f2motion\fP
Delete current character through the character
.I motion
moves the cursor to. Equivalent to
.BR d$ .
If \fImotion\fP is
.B d ,
the entire line will be deleted.
.TP 10
.B i
Enter input mode and insert text before the current character.
.TP 10
.B I
Insert text before the beginning of the line. Equivalent to
the two character sequence
.BR ^i .
.TP 10
[\f2count\fP]\f3P\fP
Place the previous text modification before the cursor.
.TP 10
[\f2count\fP]\f3p\fP
Place the previous text modification after the cursor.
.TP 10
.B R
Enter input mode and
replace characters on the screen with characters you type overlay fashion.
.TP 10
.BI r c
Replace the current character with
.IR c .
.TP 10
[\f2count\fP]\f3x\fP
Delete current character.
.TP 10
[\f2count\fP]\f3X\fP
Delete preceding character.
.TP 10
[\f2count\fP]\f3.\fP
Repeat the previous text modification command.
.TP 10
.B \(ap
Invert the case of the current character and advance the cursor.
.TP 10
[\f2count\fP]\f3_\fP
Causes the
.I count\^
word of the previous command to be appended and
input mode entered.
The last word is used
if
.I count\^
is omitted.
.TP 10
.B *
Causes an
.B *
to be appended to the current word and file name generation attempted.
If no match is found,
it rings the bell. Otherwise, the word is replaced
by the matching pattern and input mode is entered.
.RE
.SS "\ \ \ \ \ Other Edit Commands"
.RS
Miscellaneous commands.
.TP 10
.B u
Undo the last text modifying command.
.TP 10
.B U
Undo all the text modifying commands performed on the line.
.TP 10
[\f2count\fP]\f3v\fP
Returns the command
.BI "fc \-e ${\s-1VISUAL\s+1:\-${\s-1EDITOR\s+1:\-vi}}" " count"
in the input buffer.
If
.I count\^
is omitted, then the current line is used.
.TP 10
.BI ^L
Line feed and print current line.
Has effect only in control mode.
.TP 10
.BI ^J
(New\ line) Execute the current line, regardless of mode.
.TP 10
.BI ^M
(Return) Execute the current line, regardless of mode.
.TP 10
.B \#
Equivalent to
\f3I#\fP\f2<cr>\fP.
Useful for causing the current line to be
inserted in the history without being executed.
.RE
.PD
.SS Special Commands.
The following simple-commands are executed in the shell process.
Input/Output redirection is permitted.
File descriptor 1 is the default output location.
Parameter assignment lists preceding the command do not
remain in effect when the command completes unless noted.
.TP
\f3:\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
Parameter assignments remain in effect after the command completes.
The command only expands parameters.
A zero exit code is returned.
.br
.ne 2
.TP
\f3\|. \f2file\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
Parameter assignments remain in effect after the command completes.
Read and execute commands from
.I file\^
and return.
The commands are executed in the current Shell environment.
The search path
specified by
.B
.SM PATH
is used to find the directory containing
.IR file .
If any arguments
.I arg\^
are given,
they become the positional parameters.
Otherwise the positional parameters are unchanged.
.TP
\f3alias\fP \*(OK \f3\-tx\fP \*(CK \*(OK \f2name\fP\*(OK \f2=value\^\fP \*(CK .\|.\|. \*(CK
.I Alias\^
with no arguments prints the list of aliases
in the form
.I name=value\^
on standard output.
An
.I alias\^
is defined
for each name whose
.I value\^
is given.
A trailing space in
.I value\^
causes the next word to be checked for
alias substitution.
The
.B \-t
flag is used to set and list tracked aliases.
The value of a tracked alias is the full pathname
corresponding to the given
.IR name .
The value becomes undefined when the value of
.SM
.B PATH
is reset but the aliases remained tracked.
Without the
.B \-t
flag,
for each
.I name\^
in the argument list
for which no
.I value\^
is given, the name
and value of the alias is printed.
The
.B \-x
flag is used to set or print exported aliases.
An exported alias is defined across sub-shell environments.
Alias returns true unless a
.I name\^
is given for which no alias has been defined.
.TP
\f3bg\fP \*(OK \f3%\f2job\^\fP \*(CK
This command is only built-in on systems that support job control.
Puts the specified
.I job\^
into the background.
The current job is put in the background
if
.I job\^
is not specified.
.TP
\f3break\fP \*(OK \f2n\^\fP \*(CK
Exit from the enclosing
.BR for
.BR while
.BR until
or
.B select\^
loop, if any.
If
.I n\^
is specified then break
.I n\^
levels.
.TP
\f3continue\fP \*(OK \f2n\^\fP \*(CK
Resume the next iteration of the enclosing
.BR for
.BR while
.BR until
or
.B select\^
loop.
If
.I n\^
is specified then resume at the
.IR n -th
enclosing loop.
.TP
.PD 0
\f3cd\fP \*(OK \f2arg\^\fP \*(CK
.TP
\f3cd\fP \f2old\^\fP \f2new\^\fP
.PD
This command can be in either of two forms.
In the first form it
changes the current directory to
.IR arg .
If
.I arg\^
is
.B \-
the directory is changed to the previous
directory.
The shell
parameter
.B
.SM HOME
is the default
.IR arg .
The parameter
.SM
.B PWD
is set to the current directory.
The shell parameter
.B
.SM CDPATH
defines the search path for
the directory containing
.IR arg .
Alternative directory names are separated by
a colon
.RB ( : ).
The default path is
.B <null>
(specifying the current directory).
Note that the current directory is specified by a null path name,
which can appear immediately after the equal sign
or between the colon delimiters anywhere else in the path list.
If
.I arg
begins with a \f3/\fP then the search path
is not used.
Otherwise, each directory in the path is
searched for
.IR arg .
.P
The second form of
.B cd
substitutes the string
.I new
for the string
.I old
in the current directory name,
.SM
.B PWD
and tries to change to this new directory.
.P
The
.B cd\^
command may not be executed by
.I rsh\^.
.TP
\f3eval\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
The arguments are read as input
to the shell
and the resulting command(s) executed.
.TP
\f3exec\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
Parameter assignments remain in effect after the command completes.
If
.I arg\^
is given,
the command specified by
the arguments is executed in place of this shell
without creating a new process.
Input/output arguments may appear and
affect the current process.
If no
arguments are given
the effect of this command is to
modify file descriptors
as prescribed by the input/output redirection list.
In this case,
any file descriptor numbers greater than 2 that are
opened with this mechanism are closed when invoking
another program.
.TP
\f3exit\fP \*(OK \f2n\^\fP \*(CK
Causes the shell to exit
with the exit status specified by
.IR n .
If
.I n\^
is omitted then the exit status is that of the last command executed.
An end-of-file will also cause the shell to exit
except for a
shell which has the
.I ignoreeof
option (See
.B set
below) turned on.
.TP
\f3export\fP \*(OK \f2name\^\fP .\|.\|. \*(CK
The given
.IR name s
are marked for automatic
export to the
.I environment\^
of subsequently-executed commands.
.TP
.PD 0
\f3fc\fP \*(OK \f3\-e \f2ename\^\fP \ \*(CK \*(OK \f3\-\f3nlr\^\f1 \*(CK \*(OK \f2first\^\fP \*(CK \*(OK \f2last\^\fP \*(CK
.TP
\f3fc \-e \-\fP \*(OK \f2old\fP\f3\=\fP\f2new\^\fP \*(CK \*(OK \f2command\^\fP \*(CK
.PD
In the first form,
a range of commands from
.I first\^
to
.I last\^
is selected from the last
.SM
.B HISTSIZE
commands that were typed at the terminal.
The arguments
.I first\^
and
.I last\^
may be specified as a number or as a string.
A string is used to locate the most recent command starting with
the given string.
A negative number is used as an offset to the current command number.
If the flag
.BR \-l ,
is selected,
the commands are listed on standard output.
Otherwise, the editor program
.I ename\^
is invoked on a file containing these
keyboard commands.
If
.I ename\^
is not supplied, then the value of the parameter
.SM
.B FCEDIT
(default /bin/ed)
is used as the editor.
When editing is complete, the edited command(s)
is executed.
.I last\^
is not specified
then it will be set to
.IR first .
If
.I first\^
is not specified
the default is the previous command
for editing and \-16 for listing.
The flag
.B \-r
reverses the order of the commands and
the flag
.B \-n
suppresses command numbers when listing.
In the second form the
.I command\^
is re-executed after the substitution
\f2old\^\fP\f3=\fP\f2new\^\fP
is performed.
.TP
\f3fg\fP \*(OK \f3%\f2job\^\fP \*(CK
This command is only built-in on systems that support job control.
If
.I job\^
is specified it brings it to the foreground.
Otherwise, the current job is
brought into the foreground.
.TP
\f3jobs\fP \*(OK \f3\-l\^\fP \*(CK
Lists the active jobs; given the
.B \-l
options lists process id's in addition to the normal information.
.TP
\f3kill\fP \*(OK \f3\-\f2sig\^\fP \*(CK \f2process\^\fP .\|.\|.
Sends either the TERM (terminate) signal or the
specified signal to the specified jobs or processes.
Signals are either given by number or by names (as given in
.I /usr/include/signal.h,
stripped of the prefix ``SIG'').
The signal names are listed by
.BR "kill \-l'" .
There is no default, saying just `kill' does not
send a signal to the current job.
If the signal being sent is TERM (terminate) or HUP (hangup),
then the job or process will be sent a CONT (continue) signal
if it is stopped.
The argument
.I process\^
can be either a process id or a job.
.TP
\f3let\fP \f2arg\^\fP .\|.\|.
Each
.I arg
is an
.IR "arithmetic expression"
to be evaluated.
All calculations are done as long
integers and no check for overflow
is performed.
Expressions consist of constants,
named parameters, and operators.
The following set of operators,
listed in order of decreasing precedence,
have been implemented:
.RS
.PD 0
.TP
.B \-
unary minus
.TP
.B !
logical negation
.TP
.B "* / %"
.br
multiplication, division, remainder
.TP
.B "+ \-"
addition, subtraction
.TP
.B "<= >= < >"
.br
comparison
.TP
.B "== !="
.br
equality inequality
.TP
.B =
arithmetic replacement
.PD
.PP
Sub-expressions in parentheses
.B (\|)
are evaluated first and can be used
to override the above precedence rules.
The evaluation within a precedence group
is from right to left for the
.B =
operator
and from left to right for the others.
.PP
A parameter name must be a valid
.IR identifier .
When a parameter is encountered,
the value associated with the
parameter name is substituted and expression evaluation resumes.
Up to nine levels of recursion are
permitted.
.PP
The return code is
0 if the value of the last expression
is non-zero, and 1 otherwise.
.RE
.TP
\f3newgrp\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
Equivalent to
.BI "exec newgrp" " arg\^"
\&.\|.\|.\^.
.TP
\f3print\fP \*(OK \f3\-Rnprsu\^\fP\*(OK\f2n\fP \*(CK \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
The shell output mechanism.
With no flags or with flag
.BR \- ,
the arguments are printed
on standard output as described by
.IR echo (1).
In raw mode,
.B \-R
or
.BR \-r ,
the escape conventions of
.I echo
are ignored.
The
.B \-R
option will print all subsequent arguments and options
other than
.BR \-n .
The
.B \-p
option causes the
arguments to be written onto the pipe
of the process spawned with
.B \(bv&
instead of standard output.
The
.B \-s
option causes the
arguments to be written onto the history file
instead of standard output.
The
.B \-u
flag can be used to specify a one digit
file descriptor unit number
.B n\^
on which the
output will be placed.
The default is 1.
If the flag
.B \-n
is used, no
.B new-line\^
is added to the output.
.TP
\f3read\fP \*(OK \f3\-prsu\^\fP\*(OK \f2n\^\fP \*(CK \*(CK \*(OK \f2name\f3?\f2prompt\^\f1 \*(CK \*(OK \f2name\^\fP .\|.\|. \*(CK
The shell input mechanism.
One line is read and
is broken up into words using the characters in
.B
.SM IFS
as separators.
In raw mode,
.B \-r,
a
.B \e
at the end of a line does not signify
line continuation.
The first
word is assigned to the first
.IR name ,
the second word
to the second
.IR name ,
etc., with leftover words assigned to the last
.IR name .
The
.B \-p
option causes the input line
to be taken from the input pipe
of a process spawned by the shell
using
.BR \(bv& .
If the
.B \-s
fag is present,
the input will be saved as a command in the history file.
The flag
.B \-u
can be used to specify a one digit file
descriptor unit to read from.
The file descriptor can be opened with the
.B exec\^
special command.
The default value of
.I n\^
is 0.
If
.IR name
is omitted then
.SM
.B REPLY
is used as the default
.IR name.
The return code is 0 unless an end-of-file is encountered.
An end-of-file with the
.B \-p
option causes cleanup for this process
so that another can be spawned.
If the first argument contains a
.BR ? ,
the remainder of this word is used as a
.I prompt\^
when the shell is interactive.
If the given file descriptor is open for writing
and is a terminal device then the prompt is placed
on this unit.
Otherwise the prompt is issued on file descriptor 2.
The return code is 0 unless an end-of-file is encountered.
.TP
\f3readonly\fP \*(OK \f2name\fP .\|.\|. \*(CK
The given
.IR names
are marked
readonly and these
names cannot be changed
by subsequent assignment.
.TP
\f3return\fP \*(OK \f2n\^\fP \*(CK
Causes a shell
.I function
to return
to the invoking script
with the return status specified by
.IR n .
If
.I n\^
is omitted then the return status is that of the last command executed.
If
.B return
is invoked while not in a
.I function
then it is the same as an
.BR exit .
.TP
\f3set\fP \*(OK \f3\-aefhkmnostuvx\fP \*(CK \*(OK \f3\-o\fP \f2option\^\fP .\|.\|. \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
The flags for this command have meaning as follows:
.RS
.PD 0
.TP 8
.B \-a
All subsequent parameters that are defined are automatically exported.
.TP 8
.B \-e
If the shell is non-interactive and if a command fails,
execute the
.SM
.B ERR
trap, if set,
and exit immediately.
This mode is disabled while reading profiles.
.TP 8
.B \-f
Disables file name generation.
.TP 8
.B \-h
Each command whose name is an
.I identifier\^
becomes a tracked alias when first encountered.
.TP 8
.B \-k
All parameter assignment arguments are placed in the environment for a command,
not just those that precede the command name.
.TP 8
.B \-m
Background jobs will run in a separate process group
and a line will print upon completion.
The exit status of background jobs is reported in a completion message.
On systems with job control,
this flag is turned on automatically for
interactive shells.
.TP 8
.B \-n
Read commands but do not execute them.
.TP 8
.B \-o
The following argument can be one of the following option names:
.RS
.TP 8
.B allexport
Same as
.BR \-a .
.TP 8
.B errexit
Same as
.BR \-e .
.TP 8
.B emacs
Puts you in an
.I emacs
style in-line editor for command entry.
.TP 8
.B gmacs
Puts you in a
.I gmacs
style in-line editor for command entry.
.TP 8
.B ignoreeof
The shell will not exit on end-of-file.
The command
.B exit
must be used.
.TP 8
.B keyword
Same as
.BR \-k .
.TP 8
.B markdirs
All directory names resulting from file name generation have a trailing
.B /
appended.
.TP 8
.B monitor
Same as
.BR \-m .
.TP 8
.B noexec
Same as
.BR \-n .
.TP 8
.B noglob
Same as
.BR \-f .
.TP 8
.B nounset
Same as
.BR \-u .
.TP 8
.B verbose
Same as
.BR \-v .
.TP 8
.B trackall
Same as
.BR \-h .
.TP 8
.B vi
Puts you in insert mode of a
.I vi\^
style in-line editor
until you hit escape character
.BR 033 .
This puts you in move mode.
A return sends the line.
.TP 8
.B viraw
Each character is processed as it is typed
in
.I vi\^
mode.
.TP 8
.B xtrace
Same as
.BR \-x .
.TP 8
If no option name is supplied then the current option settings are printed.
.RE
.TP 8
.B \-s
Sort the positional parameters.
.TP 8
.B \-t
Exit after reading and executing one command.
.TP 8
.B \-u
Treat unset parameters as an error when substituting.
.TP 8
.B \-v
Print shell input lines as they are read.
.TP 8
.B \-x
Print commands and their arguments as they are executed.
.TP 8
.B \-
Turns off
.B \-x
and
.B \-v
flags and stops examining arguments for flags.
.TP 8
.B \-\-
Do not change any of the flags; useful in setting
.B $1
to a value beginning with
.BR \- .
If no arguments follow this flag then the positional parameters are unset.
.PD
.PP
Using
.B \+
rather than
.B \-
causes these flags to be turned off.
These flags can also be used upon invocation of the shell.
The current set of flags may be found in
.BR $\- .
The remaining arguments are positional
parameters and are assigned, in order,
.if t to\p
.if n to
.BR $1 ,
.BR $2 ,
\&.\|.\|.\^.
If no arguments are given then the values
of all names are printed on the standard output.
.RE
.TP
\f3shift\fP \*(OK \f2n\^\fP \*(CK
.br
The positional parameters from
\f3$\fP\f2n\fP\f3+1\fP
\&.\|.\|.
are renamed
.B $1
\&.\|.\|.\^
, default
.I n\^
is 1.
The parameter
.I n\^
can be any arithmetic expression that evaluates to a non-negative
number less than or equal to
.BR $# .
.TP
\f3test\fP \*(OK \f2expr\^\fP \*(CK
.br
Evaluate conditional expression
.IR expr .
See
.IR test (1)
for usage and description.
The arithmetic comparison operators
are not restricted to integers.
They allow any arithmetic expression.
Four additional primitive expressions are allowed:
.RS
.PD 0
.TP
\f3\-L\fP \f2file\^\fP
True if
.I file\^
is a symbolic link.
.TP
\f2file1\^\fP \f3\-nt\fP \f2file2\^\fP
True if
.I file1\^
is newer than
.IR file2 .
.TP
\f2file1\^\fP \f3\-ot\fP \f2file2\^\fP
True if
.I file1\^
is older than
.IR file2 .
.TP
\f2file1\^\fP \f3\-ef\fP \f2file2\^\fP
True if
.I file1\^
has the same device and i-node number as
.IR file2 .
.PD
.RE
.TP
\f3times\fP
.br
Print the accumulated user and system times for
the shell and for processes
run from the shell.
.TP
\f3trap\fP \*(OK \f2arg\^\fP \*(CK \*(OK \f2sig\^\fP \*(CK .\|.\|.
.I arg\^
is a command to be read and executed when the shell
receives signal(s)
.IR sig .
(Note that
.I arg\^
is scanned once when
the trap is set and once when the trap
is taken.)
Each
.I sig\^
can be given as a number or as the name of the signal.
Trap commands are executed in order of signal number.
Any attempt to set a trap on a signal that
was ignored on entry to the current shell
is ineffective.
An attempt to trap on signal 11 (memory fault) produces an error.
If
.I arg\^
is omitted or is
.BR \- ,
then all trap(s)
.I sig\^
are reset
to their original values.
If
.I arg\^
is the null
string then this signal is ignored by the shell and by the commands
it invokes.
If
.I sig\^
is
.SM
.B ERR
then
.I arg\^
will be executed whenever a command has a non-zero exit code.
This trap is not inherited by functions.
If
.I sig\^
is
.B 0
or
.SM
.B EXIT
and the
.B trap
statement is executed inside the body of a function,
then the command
.I arg\^
is executed
after the function completes.
If
.I sig\^
is
.B 0
or
.SM
.B EXIT
for a
.B trap
set outside any function
then the command
.I arg\^
is executed
on exit from the shell.
The
.B trap
command
with no arguments prints a list
of commands associated with each signal number.
.TP
\f3typeset\fP \*(OK \f3\-FLRZefilprtux\^\fP\*(OK\f2n\fP \*(CK \*(OK \f2name\fP\*(OK \f2=value\^\fP \*(CK \^ \*(CK .\|.\|. \*(CK
Parameter assignments remain in effect after the command completes.
When invoked inside a function,
a new instance of the parameter
.I name\^
is created.
The parameter value and type are restored
when the function completes.
The following list of attributes may be specified:
.RS
.PD 0
.TP
.B \-F
This flag provides UNIX to host-name file mapping on non-UNIX
machines.
.TP
.B \-L
Left justify and remove leading blanks from
.IR value .
If
.I n
is non-zero it defines the width
of the field,
otherwise it is determined by the width of the value of
first assignment.
When the parameter is assigned to, it is
filled on the right with blanks or truncated, if necessary, to
fit into the field.
Leading zeros are removed if the
.B \-Z
flag is also set.
The
.B \-R
flag is turned off.
.TP
.B \-R
Right justify and fill with leading blanks.
If
.I n
is non-zero it defines the width
of the field,
otherwise it is determined by the width of the value of
first assignment.
The field is left filled with blanks or
truncated from the end if the
parameter is reassigned.
The
.B L
flag is turned off.
.TP
.B \-Z
Right justify and fill with leading zeros if
the first non-blank character is a digit and the
.B \-L
flag has not been set.
If
.I n
is non-zero it defines the width
of the field,
otherwise it is determined by the width of the value of
first assignment.
.TP
.B \-e
Tag the parameter as having an error.
This tag is currently unused by the shell and can be
set or cleared by the user.
.TP
.B \-f
The names refer to function names rather than
parameter names.
No assignments can be made and the only other
valid flag is
.BR \-x .
.TP
.B \-i
Parameter is an integer.
This makes arithmetic faster.
If
.I n
is non-zero it defines the output arithmetic base,
otherwise the first assignment determines the output base.
.TP
.B \-l
All upper-case characters
converted to lower-case.
The upper-case flag,
.B \-u
is turned off.
.TP
.B \-p
The output of this command, if any, is written onto the two-way pipe
.TP
.B \-r
The given
.IR names
are marked
readonly and these
names cannot be changed
by subsequent assignment.
.TP
.B \-t
Tags the named parameters.
Tags are user definable and have no special
meaning to the shell.
.TP
.B \-u
All lower-case characters are converted
to upper-case characters.
The lower-case flag,
.B \-l
is turned off.
.TP
.B \-x
The given
.IR name s
are marked for automatic
export to the
.I environment\^
of subsequently-executed commands.
.PD
.PP
Using
.B \+
rather than
.B \-
causes these flags to be turned off.
If no
.I name\^
arguments are given but flags are specified,
a list of
.I names\^
(and optionally the
.I values\^
)
of the
.I parameters\^
which have these
flags set
is printed.
(Using
.B \+
rather than
.B \-
keeps the
values to be printed.)
If no
.IR name s
and flags
are given,
the
.I names\^
and
.I attributes\^
of all
.I parameters\^
are printed.
.RE
.TP
\f3ulimit\fP \*(OK \f3\-cdfmpt\fP \*(CK \*(OK \f2n\^\fP \*(CK
.RS
.PD 0
.TP
.B \-c
imposes a size limit of
.I n\^
blocks on the size of core dumps
(\s-1BSD\s+1 only).
.TP
.B \-d
imposes a size limit of
.I n\^
blocks on the size of the data area
(\s-1BSD\s+1 only).
.TP
.B \-f
imposes a size limit of
.I n\^
blocks on files written by child processes (files of any size may be read).
.TP
.B \-m
imposes a soft limit of
.I n\^
blocks on the size of physical memory
(\s-1BSD\s+1 only).
.TP
.B \-p
changes the pipe size to
.I n\^
(\s-1UNIX\s+1/\s-1RT\s+1 only).
.TP
.B \-t
imposes a time limit of
.I n\^
seconds to be used by each process
(\s-1BSD\s+1 only).
.PD
.PP
If no option is given,
.B \-f
is assumed.
If
.I n\^
is not given the current limit is printed.
.RE
.TP
\f3umask\fP \*(OK \f2nnn\^\fP \*(CK
The user file-creation mask is set to
.I nnn\^
(see
.IR umask (2)).
If
.I nnn\^
is omitted, the current value of the mask is printed.
.TP
\f3unalias\fP \f2name\^\fP .\|.\|.
The
.IR
parameters
given by the list of
.IR name s
are removed from the
.I alias\^
list.
.TP
\f3unset\fP \*(OK \f3\-f\fP \*(CK \f2name\^\fP .\|.\|.
The parameters given by the list of
.IR name s
are unassigned,
i. e.,
their values and attributes are erased.
Readonly variables cannot be unset.
If the flag,
.BR \-f ,
is set, then the names refer to
.I function\^
names.
.TP
\f3wait\fP \*(OK \f2n\^\fP \*(CK
Wait for the specified process and
report its termination status.
If
.I n\^
is not given then all currently active child processes are waited for.
The return code from this command is that of
the process waited for.
.TP
\f3whence\fP \*(OK \f3\-v\fP \*(CK \f2name\^\fP .\|.\|.
For each
.IR name ,
indicate how it
would be interpreted if used as a command name.
.P
The flag,
.BR \-v ,
produces a more verbose report.
.SS Invocation.
If the shell is invoked by
.IR exec (2),
and the first character of argument zero
.RB ( $0 )
is
.BR \- ,
then the shell is assumed to be a
.I login
shell and
commands are read from
.B /etc/profile
and then from either
.B .profile
in the current directory or
.BR \s-1$HOME\s+1/.profile ,
if either file exists.
Next, commands are read from
the file named by
performing parameter substitution on
the value of the environment parameter
.SM
.B ENV
if the file exists.
Commands are then read as described below;
the following flags are interpreted by the shell
when it is invoked:
.PP
.PD 0
.TP 10
.BI \-c "\| string\^"
If the
.B \-c
flag is present then
commands are read from
.IR string .
.TP
.B \-s
If the
.B \-s
flag is present or if no
arguments remain
then commands are read from the standard input.
Shell output,
except for the output of some of the
.I Special commands\^
listed above,
is written to
file descriptor 2.
.TP
.B \-i
If the
.B \-i
flag is present or
if the shell input and output are attached to a terminal (as told by
.IR gtty (2))
then this shell is
.IR interactive .
In this case \s-1TERMINATE\s+1 is ignored (so that \f3kill 0\fP
does not kill an interactive shell) and \s-1INTERRUPT\s+1 is caught and ignored
(so that
.B wait
is interruptible).
In all cases, \s-1QUIT\s+1 is ignored by the shell.
.TP
.B \-r
If the
.B \-r
flag is present the shell is a restricted shell.
.PD
.PP
The remaining flags and arguments are described under the
.B set
command above.
.SS Rsh Only.
.I Rsh
is used to set up login names and execution environments whose
capabilities are more controlled than those of the standard shell.
The actions of
.I rsh\^
are identical to those of
.IR sh ,
except that the following are disallowed:
.RS
.PD 0
.PP
changing directory (see
.IR cd (1)),
.br
setting the value of
.SM
.B SHELL
or
.SM
.BR PATH\*S,
.br
specifying path or
command names containing
.BR / ,
.br
redirecting output
.RB ( >
and
.BR >> ).
.PD
.RE
.PP
The restrictions above are enforced
after \f3.profile\fP and the
.SM
.B ENV
files are interpreted.
.PP
When a command to be executed is found to be a shell procedure,
.I rsh\^
invokes
.I sh\^
to execute it.
Thus, it is possible to provide to the end-user shell procedures
that have access to the full power of
the standard shell,
while imposing a limited menu of commands;
this scheme assumes that the end-user does not have write and
execute permissions in the same directory.
.PP
The net effect of these rules is that the writer of the
.B .profile
has complete control over user actions,
by performing guaranteed setup actions
and leaving the user in an appropriate directory
(probably
.I not\^
the login directory).
.PP
The system administrator often sets up a directory
of commands
(i.e.,
.BR /usr/rbin )
that can be safely invoked by
.IR rsh .
Some systems also provide a restricted editor
.IR red .
.SH EXIT STATUS
Errors detected by the shell, such as syntax errors,
cause the shell
to return a non-zero exit status.
If the shell is being used non-interactively
then execution of the shell file is abandoned.
Otherwise, the shell returns the exit status of
the last command executed (see also the
.B exit
command above).
.SH FILES
/etc/passwd
.br
/etc/profile
.br
\s-1$HOME\s+1/\f3.\fPprofile
.br
/tmp/sh\(**
.br
/dev/null
.SH SEE ALSO
cat(1),
cd(1),
echo(1),
emacs(1),
env(1),
gmacs(1),
newgrp(1),
test(1),
umask(1),
vi(1),
dup(2),
exec(2),
fork(2),
gtty(2),
pipe(2),
signal(2),
umask(2),
ulimit(2),
wait(2),
rand(3),
a.out(5),
profile(5),
environ(7).
.SH CAVEATS
.PP
If a command which is a
.I "tracked alias"
is executed, and then a command with the same name is
installed in a directory in the search path before the directory where the
original command was found, the shell will continue to
.I exec\^
the original command.
Use the
.B \-t
option of the
.B alias\^
command to correct this situation
.PP
If you move the current directory or one above it,
.B pwd\^
may not give the correct response.
Use the
.B cd\^
command with a full path name
to correct this situation.
.PP
Some very old shell scripts contain a
.B ^
as a synonym for the pipe character
.BR \(bv .
|