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
|
.TH "ZSHMODULES" "1" "March 7, 2006" "zsh 4\&.3\&.2-dev-1"
.SH "NAME"
zshmodules \- zsh loadable modules
.\" Yodl file: Zsh/modules.yo
.SH "DESCRIPTION"
Some optional parts of zsh are in modules, separate from the core
of the shell\&. Each of these modules may be linked in to the
shell at build time,
or can be dynamically linked while the shell is running
if the installation supports this feature\&. The modules that
are bundled with the zsh distribution are:
.PP
.\" Yodl file: Zsh/modlist.yo
.PD 0
.TP
.PD
\fBzsh/cap\fP
Builtins for manipulating POSIX\&.1e (POSIX\&.6) capability (privilege) sets\&.
.TP
\fBzsh/clone\fP
A builtin that can clone a running shell onto another terminal\&.
.TP
\fBzsh/compctl\fP
The \fBcompctl\fP builtin for controlling completion\&.
.TP
\fBzsh/complete\fP
The basic completion code\&.
.TP
\fBzsh/complist\fP
Completion listing extensions\&.
.TP
\fBzsh/computil\fP
A module with utility builtins needed for the shell function based
completion system\&.
.TP
\fBzsh/datetime\fP
Some date/time commands and parameters\&.
.TP
\fBzsh/deltochar\fP
A ZLE function duplicating EMACS\&' \fBzap\-to\-char\fP\&.
.TP
\fBzsh/example\fP
An example of how to write a module\&.
.TP
\fBzsh/files\fP
Some basic file manipulation commands as builtins\&.
.TP
\fBzsh/mapfile\fP
Access to external files via a special associative array\&.
.TP
\fBzsh/mathfunc\fP
Standard scientific functions for use in mathematical evaluations\&.
.TP
\fBzsh/newuser\fP
Arrange for files for new users to be installed\&.
.TP
\fBzsh/parameter\fP
Access to internal hash tables via special associative arrays\&.
.TP
\fBzsh/pcre\fP
Interface to the PCRE library\&.
.TP
\fBzsh/sched\fP
A builtin that provides a timed execution facility within the shell\&.
.TP
\fBzsh/net/socket\fP
Manipulation of Unix domain sockets
.TP
\fBzsh/stat\fP
A builtin command interface to the \fBstat\fP system call\&.
.TP
\fBzsh/system\fP
A builtin interface to various low\-level system features\&.
.TP
\fBzsh/net/tcp\fP
Manipulation of TCP sockets
.TP
\fBzsh/termcap\fP
Interface to the termcap database\&.
.TP
\fBzsh/terminfo\fP
Interface to the terminfo database\&.
.TP
\fBzsh/zftp\fP
A builtin FTP client\&.
.TP
\fBzsh/zle\fP
The Zsh Line Editor, including the \fBbindkey\fP and \fBvared\fP builtins\&.
.TP
\fBzsh/zleparameter\fP
Access to internals of the Zsh Line Editor via parameters\&.
.TP
\fBzsh/zprof\fP
A module allowing profiling for shell functions\&.
.TP
\fBzsh/zpty\fP
A builtin for starting a command in a pseudo\-terminal\&.
.TP
\fBzsh/zselect\fP
Block and return when file descriptors are ready\&.
.TP
\fBzsh/zutil\fP
Some utility builtins, e\&.g\&. the one for supporting configuration via
styles\&.
.\" Yodl file: Zsh/modmenu.yo
.SH "THE ZSH/CAP MODULE"
.\" Yodl file: Zsh/mod_cap.yo
The \fBzsh/cap\fP module is used for manipulating POSIX\&.1e (POSIX\&.6) capability
sets\&. If the operating system does not support this interface, the
builtins defined by this module will do nothing\&.
The builtins in this module are:
.PP
.PD 0
.TP
.PD
\fBcap\fP [ \fIcapabilities\fP ]
Change the shell\&'s process capability sets to the specified \fIcapabilities\fP,
otherwise display the shell\&'s current capabilities\&.
.TP
\fBgetcap\fP \fIfilename\fP \&.\&.\&.
This is a built\-in implementation of the POSIX standard utility\&. It displays
the capability sets on each specified \fIfilename\fP\&.
.TP
\fBsetcap\fP \fIcapabilities\fP \fIfilename\fP \&.\&.\&.
This is a built\-in implementation of the POSIX standard utility\&. It sets
the capability sets on each specified \fIfilename\fP to the specified
\fIcapabilities\fP\&.
.SH "THE ZSH/CLONE MODULE"
.\" Yodl file: Zsh/mod_clone.yo
The \fBzsh/clone\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD
\fBclone\fP \fItty\fP
Creates a forked instance of the current shell, attached to the specified
\fItty\fP\&. In the new shell, the \fBPID\fP, \fBPPID\fP and \fBTTY\fP special
parameters are changed appropriately\&. \fB$!\fP is set to zero in the new
shell, and to the new shell\&'s PID in the original shell\&.
.RS
.PP
The return status of the builtin is zero in both shells if successful,
and non\-zero on error\&.
.PP
The target of \fBclone\fP should be an unused terminal, such as an unused virtual
console or a virtual terminal created by
.PP
xterm \-e sh \-c \&'trap : INT QUIT TSTP; tty; while :; do sleep 100000000; done'
.PP
Some words of explanation are warranted about this long xterm command
line: when doing clone on a pseudo\-terminal, some other session
("session" meant as a unix session group, or SID) is already owning
the terminal\&. Hence the cloned zsh cannot acquire the pseudo\-terminal
as a controlling tty\&. That means two things:
.PP
the job control signals will go to the sh\-started\-by\-xterm process
group (that\&'s why we disable INT QUIT and TSTP with trap; otherwise
the while loop could get suspended or killed)
.PP
the cloned shell will have job control disabled, and the job
control keys (control\-C, control\-\e and control\-Z) will not work\&.
.PP
This does not apply when cloning to an \fBunused\fP vc\&.
.PP
Cloning to an used (and unprepared) terminal will result in two
processes reading simultaneously from the same terminal, with
input bytes going randomly to either process\&.
.PP
\fBclone\fP is mostly useful as a shell built\-in replacement for
openvt\&.
.RE
.RE
.SH "THE ZSH/COMPCTL MODULE"
.\" Yodl file: Zsh/mod_compctl.yo
The \fBzsh/compctl\fP module makes available two builtin commands\&. \fBcompctl\fP,
is the old, deprecated way to control completions for ZLE\&. See
\fIzshcompctl\fP(1)\&.
The other builtin command, \fBcompcall\fP can be used in user\-defined
completion widgets, see
\fIzshcompwid\fP(1)\&.
.SH "THE ZSH/COMPLETE MODULE"
.\" Yodl file: Zsh/mod_complete.yo
The \fBzsh/complete\fP module makes available several builtin commands which
can be used in user\-defined completion widgets, see
\fIzshcompwid\fP(1)\&.
.SH "THE ZSH/COMPLIST MODULE"
.\" Yodl file: Zsh/mod_complist.yo
The \fBzsh/complist\fP module offers three extensions to completion listings:
the ability to highlight matches in such a list, the ability to
scroll through long lists and a different style of menu completion\&.
.PP
.SS "Colored completion listings"
Whenever one of the parameters \fBZLS_COLORS\fP or \fBZLS_COLOURS\fP is set
and the \fBzsh/complist\fP module is loaded or linked into the shell,
completion lists will be colored\&. Note, however, that \fBcomplist\fP will
not automatically be loaded if it is not linked in: on systems with
dynamic loading, `\fBzmodload zsh/complist\fP\&' is required\&.
.PP
The parameters \fBZLS_COLORS\fP and \fBZLS_COLOURS\fP describe how matches
are highlighted\&. To turn on highlighting an empty value suffices, in
which case all the default values given below will be used\&. The format of
the value of these parameters is the same as used by the GNU version of the
\fBls\fP command: a colon\-separated list of specifications of the form
`\fIname\fP=\fIvalue\fP\&'\&. The \fIname\fP may be one of the following strings,
most of which specify file types for which the \fIvalue\fP will be used\&.
The strings and their default values are:
.PP
.PD 0
.TP
.PD
\fBno 0\fP
for normal text (i\&.e\&. when displaying something other than a matched file)
.TP
\fBfi 0\fP
for regular files
.TP
\fBdi 32\fP
for directories
.TP
\fBln 36\fP
for symbolic links
.TP
\fBpi 31\fP
for named pipes (FIFOs)
.TP
\fBso 33\fP
for sockets
.TP
\fBbd 44;37\fP
for block devices
.TP
\fBcd 44;37\fP
for character devices
.TP
\fBex 35\fP
for executable files
.TP
\fBmi\fP \fInone\fP
for a non\-existent file (default is the value defined for \fBfi\fP)
.TP
\fBlc \ee[\fP
for the left code (see below)
.TP
\fBrc m\fP
for the right code
.TP
\fBtc 0\fP
for the character indicating the file type printed after filenames if
the \fBLIST_TYPES\fP option is set
.TP
\fBsp 0\fP
for the spaces printed after matches to align the next column
.TP
\fBec\fP \fInone\fP
for the end code
.PP
Apart from these strings, the \fIname\fP may also be an asterisk
(`\fB*\fP\&') followed by any string\&. The \fIvalue\fP given for such a
string will be used for all files whose name ends with the string\&.
The \fIname\fP may also be an equals sign (`\fB=\fP\&') followed by a
pattern\&. The \fIvalue\fP given for this pattern will be used for all
matches (not just filenames) whose display string are matched by
the pattern\&. Definitions for both of these take precedence over the
values defined for file types and the form with the leading asterisk
takes precedence over the form with the leading equal sign\&.
.PP
The last form also allows different parts of the displayed
strings to be colored differently\&. For this, the pattern has to use the
`\fB(#b)\fP\&' globbing flag and pairs of parentheses surrounding the
parts of the strings that are to be colored differently\&. In this case
the \fIvalue\fP may consist of more than one color code separated by
equal signs\&. The first code will be used for all parts for which no
explicit code is specified and the following codes will be used for
the parts matched by the sub\-patterns in parentheses\&. For example,
the specification `\fB=(#b)(?)*(?)=0=3=7\fP\&' will be used for all
matches which are at least two characters long and will use
the code `\fB3\fP\&' for the first character, `\fB7\fP' for the last
character and `\fB0\fP\&' for the rest\&.
.PP
All three forms of \fIname\fP may be preceded by a pattern in
parentheses\&. If this is given, the \fIvalue\fP will be used
only for matches in groups whose names are matched by the pattern
given in the parentheses\&. For example, `\fB(g*)m*=43\fP\&' highlights all
matches beginning with `\fBm\fP\&' in groups whose names begin with
`\fBg\fP\&' using the color code `\fB43\fP'\&. In case of the `\fBlc\fP',
`\fBrc\fP\&', and `\fBec\fP' codes, the group pattern is ignored\&.
.PP
Note also that all patterns are tried in the order in which they
appear in the parameter value until the first one matches which is
then used\&.
.PP
When printing a match, the code prints the value of \fBlc\fP, the value
for the file\-type or the last matching specification with a `\fB*\fP\&',
the value of \fBrc\fP, the string to display for the match itself, and
then the value of \fBec\fP if that is defined or the values of \fBlc\fP,
\fBno\fP, and \fBrc\fP if \fBec\fP is not defined\&.
.PP
The default values are ISO 6429 (ANSI) compliant and can be used on
vt100 compatible terminals such as \fBxterm\fPs\&. On monochrome terminals
the default values will have no visible effect\&. The \fBcolors\fP
function from the contribution can be used to get associative arrays
containing the codes for ANSI terminals (see
the section `Other Functions\&' in \fIzshcontrib\fP(1))\&. For example, after loading \fBcolors\fP, one could use
`\fB$colors[red]\fP\&' to get the code for foreground color red and
`\fB$colors[bg\-green]\fP\&' for the code for background color green\&.
.PP
If the completion system invoked by compinit is used, these
parameters should not be set directly because the system controls them
itself\&. Instead, the \fBlist\-colors\fP style should be used (see
the section `Completion System Configuration\&' in \fIzshcompsys\fP(1))\&.
.PP
.SS "Scrolling in completion listings"
To enable scrolling through a completion list, the \fBLISTPROMPT\fP
parameter must be set\&. Its value will be used as the prompt; if it
is the empty string, a default prompt will be used\&. The value may
contain escapes of the form `\fB%x\fP\&'\&. It supports the escapes
`\fB%B\fP\&', `\fB%b\fP', `\fB%S\fP', `\fB%s\fP', `\fB%U\fP', `\fB%u\fP' and
`\fB%{\&.\&.\&.%}\fP\&' used also in shell prompts as well as three pairs of
additional sequences: a `\fB%l\fP\&' or `\fB%L\fP' is replaced by the number
of the last line shown and the total number of lines in the form
`\fInumber\fP\fB/\fP\fItotal\fP\&'; a `\fB%m\fP' or `\fB%M\fP' is replaced with
the number of the last match shown and the total number of matches; and
`\fB%p\fP\&' or `\fB%P\fP' is replaced with `\fBTop\fP', `\fBBottom\fP' or the
position of the first line shown in percent of the total number of
lines, respectively\&. In each of these cases the form with the uppercase
letter will be replaced with a string of fixed width, padded to the
right with spaces, while the lowercase form will not be padded\&.
.PP
If the parameter \fBLISTPROMPT\fP is set, the completion code will not ask if
the list should be shown\&. Instead it immediately starts displaying the
list, stopping after the first screenful, showing the prompt at the bottom,
waiting for a keypress after temporarily switching to the \fBlistscroll\fP
keymap\&. Some of the zle functions have a special meaning while scrolling
lists:
.PP
.PD 0
.TP
.PD
\fBsend\-break\fP
stops listing discarding the key pressed
.TP
.PD 0
\fBaccept\-line\fP, \fBdown\-history\fP, \fBdown\-line\-or\-history\fP
.TP
.PD
\fBdown\-line\-or\-search\fP, \fBvi\-down\-line\-or\-history\fP
scrolls forward one line
.TP
.PD 0
\fBcomplete\-word\fP, \fBmenu\-complete\fP, \fBexpand\-or\-complete\fP
.TP
.PD
\fBexpand\-or\-complete\-prefix\fP, \fBmenu\-complete\-or\-expand\fP
scrolls forward one screenful
.PP
Every other character stops listing and immediately processes the key
as usual\&. Any key that is not bound in the \fBlistscroll\fP keymap or
that is bound to \fBundefined\-key\fP is looked up in the keymap
currently selected\&.
.PP
As for the \fBZLS_COLORS\fP and \fBZLS_COLOURS\fP parameters,
\fBLISTPROMPT\fP should not be set directly when using the shell
function based completion system\&. Instead, the \fBlist\-prompt\fP style
should be used\&.
.PP
.SS "Menu selection"
The \fBzsh/complist\fP module also offers an alternative style of selecting
matches from a list, called menu selection, which can be used if the
shell is set up to return to the last prompt after showing a
completion list (see the \fBALWAYS_LAST_PROMPT\fP option in
\fIzshoptions\fP(1))\&. It can be invoked directly by
the widget \fBmenu\-select\fP defined by the module\&. Alternatively,
the parameter \fBMENUSELECT\fP can be set to an integer, which gives the
minimum number of matches that must be present before menu selection is
automatically turned on\&. This second method requires that menu completion
be started, either directly from a widget such as \fBmenu\-complete\fP, or due
to one of the options \fBMENU_COMPLETE\fP or \fBAUTO_MENU\fP being set\&. If
\fBMENUSELECT\fP is set, but is 0, 1 or empty, menu selection will always be
started during an ambiguous menu completion\&.
.PP
When using the completion system based on shell functions, the
\fBMENUSELECT\fP parameter should not be used (like the \fBZLS_COLORS\fP
and \fBZLS_COLOURS\fP parameters described above)\&. Instead, the \fBmenu\fP
style should be used with the \fBselect=\fP\fI\&.\&.\&.\fP keyword\&.
.PP
After menu selection is started, the matches will be listed\&. If there
are more matches than fit on the screen, only the first screenful is
shown\&. The
matches to insert into the command line can be selected from this
list\&. In the list one match is highlighted using the value for \fBma\fP
from the \fBZLS_COLORS\fP or \fBZLS_COLOURS\fP parameter\&. The default
value for this is `\fB7\fP\&' which forces the selected match to be
highlighted using standout mode on a vt100\-compatible terminal\&. If
neither \fBZLS_COLORS\fP nor \fBZLS_COLOURS\fP is set, the same terminal
control sequence as for the `\fB%S\fP\&' escape in prompts is used\&.
.PP
If there are more matches than fit on the screen and the parameter
\fBMENUPROMPT\fP is set, its value will be shown below the matches\&. It
supports the same escape sequences as \fBLISTPROMPT\fP, but the number
of the match or line shown will be that of the one where the mark is
placed\&. If its value is the empty string, a default prompt will be
used\&.
.PP
The \fBMENUSCROLL\fP parameter can be used to specify how the list is
scrolled\&. If the parameter is unset, this is done line by line, if it
is set to `\fB0\fP\&' (zero), the list will scroll half the number of
lines of the screen\&. If the value is positive, it gives the number of
lines to scroll and if it is negative, the list will be scrolled
the number of lines of the screen minus the (absolute) value\&.
.PP
As for the \fBZLS_COLORS\fP, \fBZLS_COLOURS\fP and \fBLISTPROMPT\fP
parameters, neither \fBMENUPROMPT\fP nor \fBMENUSCROLL\fP should be
set directly when using the shell function based completion
system\&. Instead, the \fBselect\-prompt\fP and \fBselect\-scroll\fP styles
should be used\&.
.PP
The completion code sometimes decides not to show all of the matches
in the list\&. These hidden matches are either matches for which the
completion function which added them explicitly requested that they
not appear in the list (using the \fB\-n\fP option of the \fBcompadd\fP
builtin command) or they are matches which duplicate a string already
in the list (because they differ only in things like prefixes or
suffixes that are not displayed)\&. In the list used for menu selection,
however, even these matches are shown so that it is possible to select
them\&. To highlight such matches the \fBhi\fP and \fBdu\fP capabilities in
the \fBZLS_COLORS\fP and \fBZLS_COLOURS\fP parameters are supported for
hidden matches of the first and second kind, respectively\&.
.PP
Selecting matches is done by moving the mark around using the zle movement
functions\&. When not all matches can be shown on the screen at the same
time, the list will scroll up and down when crossing the top or
bottom line\&. The following zle functions have special meaning during
menu selection:
.PP
.PD 0
.TP
.PD
\fBaccept\-line\fP
accepts the current match and leaves menu selection
.TP
\fBsend\-break\fP
leaves menu selection and restores the previous contents of the
command line
.TP
\fBredisplay\fP, \fBclear\-screen\fP
execute their normal function without leaving menu selection
.TP
\fBaccept\-and\-hold\fP, \fBaccept\-and\-menu\-complete\fP
accept the currently inserted match and continue selection allowing to
select the next match to insert into the line
.TP
\fBaccept\-and\-infer\-next\-history\fP
accepts the current match and then tries completion with
menu selection again; in the case of files this allows one to select
a directory and immediately attempt to complete files in it; if there
are no matches, a message is shown and one can use \fBundo\fP to go back
to completion on the previous level, every other key leaves menu
selection (including the other zle functions which are otherwise
special during menu selection)
.TP
\fBundo\fP
removes matches inserted during the menu selection by one of the three
functions before
.TP
.PD 0
\fBdown\-history\fP, \fBdown\-line\-or\-history\fP
.TP
.PD
\fBvi\-down\-line\-or\-history\fP, \fBdown\-line\-or\-search\fP
moves the mark one line down
.TP
.PD 0
\fBup\-history\fP, \fBup\-line\-or\-history\fP
.TP
.PD
\fBvi\-up\-line\-or\-history\fP, \fBup\-line\-or\-search\fP
moves the mark one line up
.TP
\fBforward\-char\fP, \fBvi\-forward\-char\fP
moves the mark one column right
.TP
\fBbackward\-char\fP, \fBvi\-backward\-char\fP
moves the mark one column left
.TP
.PD 0
\fBforward\-word\fP, \fBvi\-forward\-word\fP
.TP
.PD
\fBvi\-forward\-word\-end\fP, \fBemacs\-forward\-word\fP
moves the mark one screenful down
.TP
\fBbackward\-word\fP, \fBvi\-backward\-word\fP, \fBemacs\-backward\-word\fP
moves the mark one screenful up
.TP
\fBvi\-forward\-blank\-word\fP, \fBvi\-forward\-blank\-word\-end\fP
moves the mark to the first line of the next group of matches
.TP
\fBvi\-backward\-blank\-word\fP
moves the mark to the last line of the previous group of matches
.TP
\fBbeginning\-of\-history\fP
moves the mark to the first line
.TP
\fBend\-of\-history\fP
moves the mark to the last line
.TP
.PD 0
\fBbeginning\-of\-buffer\-or\-history\fP, \fBbeginning\-of\-line\fP
.TP
.PD
\fBbeginning\-of\-line\-hist\fP, \fBvi\-beginning\-of\-line\fP
moves the mark to the leftmost column
.TP
.PD 0
\fBend\-of\-buffer\-or\-history\fP, \fBend\-of\-line\fP
.TP
.PD
\fBend\-of\-line\-hist\fP, \fBvi\-end\-of\-line\fP
moves the mark to the rightmost column
.TP
.PD 0
\fBcomplete\-word\fP, \fBmenu\-complete\fP, \fBexpand\-or\-complete\fP
.TP
.PD
\fBexpand\-or\-complete\-prefix\fP, \fBmenu\-expand\-or\-complete\fP
moves the mark to the next match
.TP
\fBreverse\-menu\-complete\fP
moves the mark to the previous match
.TP
\fBvi\-insert\fP
this toggles between normal and interactive mode; in interactive mode
the keys bound to \fBself\-insert\fP and \fBself\-insert\-unmeta\fP insert
into the command line as in normal editing mode but without leaving
menu selection; after each character completion is tried again and the
list changes to contain only the new matches; the completion widgets
make the longest unambiguous string be inserted in the command line
and \fBundo\fP and \fBbackward\-delete\-char\fP go back to the previous set
of matches
.TP
\fBhistory\-incremental\-search\-forward\fP,
\fBhistory\-incremental\-search\-backward\fP
this starts incremental searches in the list of completions displayed;
in this mode, \fBaccept\-line\fP only leaves incremental search, going
back to the normal menu selection mode
.PP
All movement functions wrap around at the edges; any other zle function not
listed leaves menu selection and executes that function\&. It is possible to
make widgets in the above list do the same by using the form of the widget
with a `\fB\&.\fP\&' in front\&. For example, the widget `\fB\&.accept\-line\fP' has
the effect of leaving menu selection and accepting the entire command line\&.
.PP
During this selection the widget uses the keymap \fBmenuselect\fP\&. Any
key that is not defined in this keymap or that is bound to
\fBundefined\-key\fP is looked up in the keymap currently selected\&. This
is used to ensure that the most important keys used during selection
(namely the cursor keys, return, and TAB) have sensible defaults\&. However,
keys in the \fBmenuselect\fP keymap can be modified directly using the
\fBbindkey\fP builtin command (see
\fIzshmodules\fP(1))\&. For example, to make the return key leave menu selection without
accepting the match currently selected one could call
.PP
.RS
.nf
\fBbindkey \-M menuselect \&'^M' send\-break\fP
.fi
.RE
.PP
after loading the \fBzsh/complist\fP module\&.
.SH "THE ZSH/COMPUTIL MODULE"
.\" Yodl file: Zsh/mod_computil.yo
The \fBzsh/computil\fP module adds several builtin commands that are used by
some of the completion functions in the completion system based on shell
functions (see
\fIzshcompsys\fP(1)
)\&. Except for \fBcompquote\fP these builtin commands are very
specialised and thus not very interesting when writing your own
completion functions\&. In summary, these builtin commands are:
.PP
.PD 0
.TP
.PD
\fBcomparguments\fP
This is used by the \fB_arguments\fP function to do the argument and
command line parsing\&. Like \fBcompdescribe\fP it has an option \fB\-i\fP to
do the parsing and initialize some internal state and various options
to access the state information to decide what should be completed\&.
.TP
\fBcompdescribe\fP
This is used by the \fB_describe\fP function to build the displays for
the matches and to get the strings to add as matches with their
options\&. On the first call one of the options \fB\-i\fP or \fB\-I\fP should be
supplied as the first argument\&. In the first case, display strings without
the descriptions will be generated, in the second case, the string used to
separate the matches from their descriptions must be given as the
second argument and the descriptions (if any) will be shown\&. All other
arguments are like the definition arguments to \fB_describe\fP itself\&.
.RS
.PP
Once \fBcompdescribe\fP has been called with either the \fB\-i\fP or the
\fB\-I\fP option, it can be repeatedly called with the \fB\-g\fP option and
the names of five arrays as its arguments\&. This will step through the
different sets of matches and store the options in the first array,
the strings with descriptions in the second, the matches for these in
the third, the strings without descriptions in the fourth, and the
matches for them in the fifth array\&. These are then directly given to
\fBcompadd\fP to register the matches with the completion code\&.
.RE
.TP
\fBcompfiles\fP
Used by the \fB_path_files\fP function to optimize complex recursive
filename generation (globbing)\&. It does three things\&. With the
\fB\-p\fP and \fB\-P\fP options it builds the glob patterns to use,
including the paths already handled and trying to optimize the
patterns with respect to the prefix and suffix from the line and the
match specification currently used\&. The \fB\-i\fP option does the
directory tests for the \fBignore\-parents\fP style and the \fB\-r\fP option
tests if a component for some of the matches are equal to the string
on the line and removes all other matches if that is true\&.
.TP
\fBcompgroups\fP
Used by the \fB_tags\fP function to implement the internals of the
\fBgroup\-order\fP style\&. This only takes its arguments as names of
completion groups and creates the groups for it (all six types: sorted
and unsorted, both without removing duplicates, with removing all
duplicates and with removing consecutive duplicates)\&.
.TP
\fBcompquote\fP [ \fB\-p\fP ] \fInames\fP \&.\&.\&.
There may be reasons to write completion functions that have to add
the matches using the \fB\-Q\fP option to \fBcompadd\fP and perform quoting
themselves\&. Instead of interpreting the first character of the
\fBall_quotes\fP key of the \fBcompstate\fP special association and using
the \fBq\fP flag for parameter expansions, one can use this builtin
command\&. The arguments are the names of scalar or array parameters
and the values of these parameters are quoted as needed for the
innermost quoting level\&. If the \fB\-p\fP option is given, quoting is
done as if there is some prefix before the values of the parameters,
so that a leading equal sign will not be quoted\&.
.RS
.PP
The return status is non\-zero in case of an error and zero otherwise\&.
.RE
.TP
.PD 0
\fBcomptags\fP
.TP
.PD
\fBcomptry\fP
These implement the internals of the tags mechanism\&.
.TP
\fBcompvalues\fP
Like \fBcomparguments\fP, but for the \fB_values\fP function\&.
.SH "THE ZSH/DATETIME MODULE"
.\" Yodl file: Zsh/mod_datetime.yo
The \fBzsh/datetime\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD 0
\fBstrftime\fP [ \fB\-s\fP \fIscalar\fP ] \fIformat\fP \fIepochtime\fP
.TP
.PD
\fBstrftime\fP \fB\-r\fP [ \fB\-q\fP ] [ \fB\-s\fP \fIscalar\fP ] \fIformat\fP \fItimestring\fP
Output the date denoted by \fIepochtime\fP in the \fIformat\fP
specified\&.
.RS
.PP
With the option \fB\-r\fP (reverse), use the format \fIformat\fP to parse the
input string \fItimestring\fP and output the number of seconds since the
epoch at which the time occurred\&. If no timezone is parsed, the current
timezone is used; other parameters are set to zero if not present\&. If
\fItimestring\fP does not match \fIformat\fP the command returns status 1; it
will additionally print an error message unless the option \fB\-q\fP (quiet)
is given\&. If \fItimestring\fP matches \fIformat\fP but not all characters in
\fItimestring\fP were used, the conversion succeeds; however, a warning is
issued unless the option \fB\-q\fP is given\&. The matching is implemented by
the system function \fBstrptime\fP; see \fIstrptime\fP(3)\&. This means that
zsh format extensions are not available, however for reverse lookup they
are not required\&. If the function is not implemented, the command returns
status 2 and (unless \fB\-q\fP is given) prints a message\&.
.PP
If \fB\-s\fP \fIscalar\fP is given, assign the date string (or epoch time
in seconds if \fB\-r\fP is given) to \fIscalar\fP instead of printing it\&.
.RE
.RE
.PP
The \fBzsh/datetime\fP module makes available one parameter:
.PP
.PD 0
.TP
.PD
\fBEPOCHSECONDS\fP
An integer value representing the number of seconds since the
epoch\&.
.SH "THE ZSH/DELTOCHAR MODULE"
.\" Yodl file: Zsh/mod_deltochar.yo
The \fBzsh/deltochar\fP module makes available two ZLE functions:
.PP
.PD 0
.TP
.PD
\fBdelete\-to\-char\fP
Read a character from the keyboard, and
delete from the cursor position up to and including the next
(or, with repeat count \fIn\fP, the \fIn\fPth) instance of that character\&.
Negative repeat counts mean delete backwards\&.
.TP
\fBzap\-to\-char\fP
This behaves like \fBdelete\-to\-char\fP, except that the final occurrence of
the character itself is not deleted\&.
.SH "THE ZSH/EXAMPLE MODULE"
.\" Yodl file: Zsh/mod_example.yo
The \fBzsh/example\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD
\fBexample\fP [ \fB\-flags\fP ] [ \fIargs\fP \&.\&.\&. ]
Displays the flags and arguments it is invoked with\&.
.PP
The purpose of the module is to serve as an example of how to write a
module\&.
.SH "THE ZSH/FILES MODULE"
.\" Yodl file: Zsh/mod_files.yo
The \fBzsh/files\fP module makes some standard commands available as builtins:
.PP
.PD 0
.TP
.PD
\fBchgrp\fP [ \fB\-Rs\fP ] \fIgroup\fP \fIfilename\fP \&.\&.\&.
Changes group of files specified\&. This is equivalent to \fBchown\fP with
a \fIuser\-spec\fP argument of `\fB:\fP\fIgroup\fP\&'\&.
.TP
\fBchown\fP [ \fB\-Rs\fP ] \fIuser\-spec\fP \fIfilename\fP \&.\&.\&.
Changes ownership and group of files specified\&.
.RS
.PP
The \fIuser\-spec\fP can be in four forms:
.PP
.PD 0
.TP
\fIuser\fP
change owner to \fIuser\fP; do not change group
.TP
\fIuser\fP\fB::\fP
change owner to \fIuser\fP; do not change group
.TP
\fIuser\fP\fB:\fP
change owner to \fIuser\fP; change group to \fIuser\fP\&'s primary group
.TP
\fIuser\fP\fB:\fP\fIgroup\fP
change owner to \fIuser\fP; change group to \fIgroup\fP
.TP
\fB:\fP\fIgroup\fP
do not change owner; change group to \fIgroup\fP
.PD
.PP
In each case, the `\fB:\fP\&' may instead be a `\fB\&.\fP'\&. The rule is that
if there is a `\fB:\fP\&' then the separator is `\fB:\fP', otherwise
if there is a `\fB\&.\fP\&' then the separator is `\fB\&.\fP', otherwise
there is no separator\&.
.PP
Each of \fIuser\fP and \fIgroup\fP may be either a username (or group name, as
appropriate) or a decimal user ID (group ID)\&. Interpretation as a name
takes precedence, if there is an all\-numeric username (or group name)\&.
.PP
The \fB\-R\fP option causes \fBchown\fP to recursively descend into directories,
changing the ownership of all files in the directory after
changing the ownership of the directory itself\&.
.PP
The \fB\-s\fP option is a zsh extension to \fBchown\fP functionality\&. It enables
paranoid behaviour, intended to avoid security problems involving
a \fBchown\fP being tricked into affecting files other than the ones
intended\&. It will refuse to follow symbolic links, so that (for example)
``\fBchown luser /tmp/foo/passwd\fP\&'' can't accidentally chown \fB/etc/passwd\fP
if \fB/tmp/foo\fP happens to be a link to \fB/etc\fP\&. It will also check
where it is after leaving directories, so that a recursive chown of
a deep directory tree can\&'t end up recursively chowning \fB/usr\fP as
a result of directories being moved up the tree\&.
.RE
.TP
.PD 0
\fBln\fP [ \fB\-dfis\fP ] \fIfilename\fP \fIdest\fP
.TP
.PD
\fBln\fP [ \fB\-dfis\fP ] \fIfilename\fP \&.\&.\&. \fIdir\fP
Creates hard (or, with \fB\-s\fP, symbolic) links\&. In the first form, the
specified \fIdest\fPination is created, as a link to the specified
\fIfilename\fP\&. In the second form, each of the \fIfilename\fPs is
taken in turn, and linked to a pathname in the specified \fIdir\fPectory
that has the same last pathname component\&.
.RS
.PP
Normally, \fBln\fP will not attempt to create hard links to
directories\&. This check can be overridden using the \fB\-d\fP option\&.
Typically only the super\-user can actually succeed in creating
hard links to directories\&.
This does not apply to symbolic links in any case\&.
.PP
By default, existing files cannot be replaced by links\&.
The \fB\-i\fP option causes the user to be queried about replacing
existing files\&. The \fB\-f\fP option causes existing files to be
silently deleted, without querying\&. \fB\-f\fP takes precedence\&.
.RE
.TP
\fBmkdir\fP [ \fB\-p\fP ] [ \fB\-m\fP \fImode\fP ] \fIdir\fP \&.\&.\&.
Creates directories\&. With the \fB\-p\fP option, non\-existing parent
directories are first created if necessary, and there will be
no complaint if the directory already exists\&.
The \fB\-m\fP option can be used to specify (in octal) a set of file permissions
for the created directories, otherwise mode 777 modified by the current
\fBumask\fP (see \fIumask\fP(2)) is used\&.
.TP
.PD 0
\fBmv\fP [ \fB\-fi\fP ] \fIfilename\fP \fIdest\fP
.TP
.PD
\fBmv\fP [ \fB\-fi\fP ] \fIfilename\fP \&.\&.\&. \fIdir\fP
Moves files\&. In the first form, the specified \fIfilename\fP is moved
to the specified \fIdest\fPination\&. In the second form, each of the
\fIfilename\fPs is
taken in turn, and moved to a pathname in the specified \fIdir\fPectory
that has the same last pathname component\&.
.RS
.PP
By default, the user will be queried before replacing any file
that the user cannot write to, but writable files will be silently
removed\&.
The \fB\-i\fP option causes the user to be queried about replacing
any existing files\&. The \fB\-f\fP option causes any existing files to be
silently deleted, without querying\&. \fB\-f\fP takes precedence\&.
.PP
Note that this \fBmv\fP will not move files across devices\&.
Historical versions of \fBmv\fP, when actual renaming is impossible,
fall back on copying and removing files; if this behaviour is desired,
use \fBcp\fP and \fBrm\fP manually\&. This may change in a future version\&.
.RE
.TP
\fBrm\fP [ \fB\-dfirs\fP ] \fIfilename\fP \&.\&.\&.
Removes files and directories specified\&.
.RS
.PP
Normally, \fBrm\fP will not remove directories (except with the \fB\-r\fP
option)\&. The \fB\-d\fP option causes \fBrm\fP to try removing directories
with \fBunlink\fP (see \fIunlink\fP(2)), the same method used for files\&.
Typically only the super\-user can actually succeed in unlinking
directories in this way\&.
\fB\-d\fP takes precedence over \fB\-r\fP\&.
.PP
By default, the user will be queried before removing any file
that the user cannot write to, but writable files will be silently
removed\&.
The \fB\-i\fP option causes the user to be queried about removing
any files\&. The \fB\-f\fP option causes files to be
silently deleted, without querying, and suppresses all error indications\&.
\fB\-f\fP takes precedence\&.
.PP
The \fB\-r\fP option causes \fBrm\fP to recursively descend into directories,
deleting all files in the directory before removing the directory with
the \fBrmdir\fP system call (see \fIrmdir\fP(2))\&.
.PP
The \fB\-s\fP option is a zsh extension to \fBrm\fP functionality\&. It enables
paranoid behaviour, intended to avoid common security problems involving
a root\-run \fBrm\fP being tricked into removing files other than the ones
intended\&. It will refuse to follow symbolic links, so that (for example)
``\fBrm /tmp/foo/passwd\fP\&'' can't accidentally remove \fB/etc/passwd\fP
if \fB/tmp/foo\fP happens to be a link to \fB/etc\fP\&. It will also check
where it is after leaving directories, so that a recursive removal of
a deep directory tree can\&'t end up recursively removing \fB/usr\fP as
a result of directories being moved up the tree\&.
.RE
.TP
\fBrmdir\fP \fIdir\fP \&.\&.\&.
Removes empty directories specified\&.
.TP
\fBsync\fP
Calls the system call of the same name (see \fIsync\fP(2)), which
flushes dirty buffers to disk\&. It might return before the I/O has
actually been completed\&.
.SH "THE ZSH/MAPFILE MODULE"
.\" Yodl file: Zsh/mod_mapfile.yo
The \fBzsh/mapfile\fP module provides one special associative array parameter of
the same name\&.
.PP
.PD 0
.TP
.PD
\fBmapfile\fP
This associative array takes as keys the names of files; the resulting
value is the content of the file\&. The value is treated identically to any
other text coming from a parameter\&. The value may also be assigned to, in
which case the file in question is written (whether or not it originally
existed); or an element may be unset, which will delete the file in
question\&. For example, `\fBvared mapfile[myfile]\fP\&' works as expected,
editing the file `\fBmyfile\fP\&'\&.
.RS
.PP
When the array is accessed as a whole, the keys are the names of files in
the current directory, and the values are empty (to save a huge overhead in
memory)\&. Thus \fB${(k)mapfile}\fP has the same affect as the glob operator
\fB*(D)\fP, since files beginning with a dot are not special\&. Care must be
taken with expressions such as \fBrm ${(k)mapfile}\fP, which will delete
every file in the current directory without the usual `\fBrm *\fP\&' test\&.
.PP
The parameter \fBmapfile\fP may be made read\-only; in that case, files
referenced may not be written or deleted\&.
.RE
.RE
.PP
.SS "Limitations"
.PP
Although reading and writing of the file in question is efficiently
handled, zsh\&'s internal memory management may be arbitrarily baroque\&. Thus
it should not automatically be assumed that use of \fBmapfile\fP represents a
gain in efficiency over use of other mechanisms\&. Note in particular that
the whole contents of the file will always reside physically in memory when
accessed (possibly multiple times, due to standard parameter substitution
operations)\&. In particular, this means handling of sufficiently long files
(greater than the machine\&'s swap space, or than the range of the pointer
type) will be incorrect\&.
.PP
No errors are printed or flagged for non\-existent, unreadable, or
unwritable files, as the parameter mechanism is too low in the shell
execution hierarchy to make this convenient\&.
.PP
It is unfortunate that the mechanism for loading modules does not yet allow
the user to specify the name of the shell parameter to be given the special
behaviour\&.
.SH "THE ZSH/MATHFUNC MODULE"
.\" Yodl file: Zsh/mod_mathfunc.yo
The \fBzsh/mathfunc\fP module provides standard
mathematical functions for use when
evaluating mathematical formulae\&. The syntax agrees with normal C and
FORTRAN conventions, for example,
.PP
.RS
.nf
\fB(( f = sin(0\&.3) ))\fP
.fi
.RE
.PP
assigns the sine of 0\&.3 to the parameter f\&.
.PP
Most functions take floating point arguments and return a floating point
value\&. However, any necessary conversions from or to integer type will be
performed automatically by the shell\&. Apart from \fBatan\fP with a second
argument and the \fBabs\fP, \fBint\fP and \fBfloat\fP functions, all functions
behave as noted in the manual page for the corresponding C function,
except that any arguments out of range for the function in question will be
detected by the shell and an error reported\&.
.PP
The following functions take a single floating point argument: \fBacos\fP,
\fBacosh\fP, \fBasin\fP, \fBasinh\fP, \fBatan\fP, \fBatanh\fP, \fBcbrt\fP, \fBceil\fP,
\fBcos\fP, \fBcosh\fP, \fBerf\fP, \fBerfc\fP, \fBexp\fP, \fBexpm1\fP, \fBfabs\fP,
\fBfloor\fP, \fBgamma\fP, \fBj0\fP, \fBj1\fP, \fBlgamma\fP, \fBlog\fP, \fBlog10\fP,
\fBlog1p\fP, \fBlogb\fP, \fBsin\fP, \fBsinh\fP, \fBsqrt\fP, \fBtan\fP, \fBtanh\fP,
\fBy0\fP, \fBy1\fP\&. The \fBatan\fP function can optionally take a second
argument, in which case it behaves like the C function \fBatan2\fP\&.
The \fBilogb\fP function takes a single floating point argument, but
returns an integer\&.
.PP
The function \fBsigngam\fP takes no arguments, and returns an integer, which
is the C variable of the same name, as described in \fIgamma\fP(3)\&. Note
that it is therefore only useful immediately after a call to \fBgamma\fP or
\fBlgamma\fP\&. Note also that `\fBsigngam(RPAR\fP\&' and `\fBsigngam\fP' are
distinct expressions\&.
.PP
The following functions take two floating point arguments: \fBcopysign\fP,
\fBfmod\fP, \fBhypot\fP, \fBnextafter\fP\&.
.PP
The following take an integer first argument and a floating point second
argument: \fBjn\fP, \fByn\fP\&.
.PP
The following take a floating point first argument and an integer second
argument: \fBldexp\fP, \fBscalb\fP\&.
.PP
The function \fBabs\fP does not convert the type of its single argument; it
returns the absolute value of either a floating point number or an
integer\&. The functions \fBfloat\fP and \fBint\fP convert their arguments into
a floating point or integer value (by truncation) respectively\&.
.PP
Note that the C \fBpow\fP function is available in ordinary math evaluation
as the `\fB**\fP\&' operator and is not provided here\&.
.PP
The function \fBrand48\fP is available if your system\&'s mathematical library
has the function \fBerand48(3)\fP\&. It returns a pseudo\-random floating point
number between 0 and 1\&. It takes a single string optional argument\&.
.PP
If the argument is not present, the random number seed is initialised by
three calls to the \fBrand(3)\fP function \-\-\- this produces the
same random
numbers as the next three values of \fB$RANDOM\fP\&.
.PP
If the argument is present, it gives the name of a scalar parameter where
the current random number seed will be stored\&. On the first call, the
value must contain at least twelve hexadecimal digits (the remainder of the
string is ignored), or the seed will be initialised in the same manner as
for a call to \fBrand48\fP with no argument\&. Subsequent calls to
\fBrand48\fP(\fIparam\fP) will then maintain the seed in the
parameter \fIparam\fP as a string of twelve hexadecimal digits, with no base
signifier\&. The random number sequences for different parameters are
completely independent, and are also independent from that used by calls to
\fBrand48\fP with no argument\&.
.PP
For example, consider
.PP
.RS
.nf
\fBprint $(( rand48(seed) ))
print $(( rand48() ))
print $(( rand48(seed) ))\fP
.fi
.RE
.PP
Assuming \fB$seed\fP does not exist, it will be initialised by the first
call\&. In the second call, the default seed is initialised; note, however,
that because of the properties of \fBrand()\fP there is a
correlation between
the seeds used for the two initialisations, so for more secure uses, you
should generate your own 12\-byte seed\&. The third call returns to the same
sequence of random numbers used in the first call, unaffected by the
intervening \fBrand48()\fP\&.
.SH "THE ZSH/NEWUSER MODULE"
.\" Yodl file: Zsh/mod_newuser.yo
The \fBzsh/newuser\fP module is loaded at boot if it is
available, the \fBRCS\fP option is set, and the \fBPRIVILEGED\fP option is not
set (all three are true by default)\&. This takes
place immediately after commands in the global \fBzshenv\fP file (typically
\fB/etc/zshenv\fP), if any, have been executed\&. If the module is not
available it is silently ignored by the shell; the module may safely be
removed from \fB$MODULE_PATH\fP by the administrator if it is not required\&.
.PP
On loading, the module tests if any of the start\-up files \fB\&.zshenv\fP,
\fB\&.zprofile\fP, \fB\&.zshrc\fP or \fB\&.zlogin\fP exist in the directory given by
the environment variable \fBZDOTDIR\fP, or the user\&'s home directory if that
is not set\&. The test is not performed and the module halts processing if
the shell was in an emulation mode (i\&.e\&. had been invoked as some other
shell than zsh)\&.
.PP
If none of the start\-up files were found, the module then looks for the
file \fBnewuser\fP first in a sitewide directory, usually the parent
directory of the \fBsite\-functions\fP directory, and if that is not found the
module searches in a version\-specific directory, usually the parent of the
\fBfunctions\fP directory containing version\-specific functions\&. (These
directories can be configured when zsh is built using the
\fB\-\-enable\-site\-scriptdir=\fP\fIdir\fP and \fB\-\-enable\-scriptdir=\fP\fIdir\fP
flags to \fBconfigure\fP, respectively; the defaults are
\fIprefix\fP\fB/share/zsh\fP and \fIprefix\fP\fB/share/zsh/$ZSH_VERSION\fP where
the default \fIprefix\fP is \fB/usr/local\fP\&.)
.PP
If the file \fBnewuser\fP is found, it is then sourced in the same manner as
a start\-up file\&. The file is expected to contain code to install start\-up
files for the user, however any valid shell code will be executed\&.
.PP
The \fBzsh/newuser\fP module is then unconditionally unloaded\&.
.PP
Note that it is possible to achieve exactly the same effect as the
\fBzsh/newuser\fP module by adding code to \fB/etc/zshenv\fP\&. The module
exists simply to allow the shell to make arrangements for new users without
the need for invervention by package maintainers and system administrators\&.
.SH "THE ZSH/PARAMETER MODULE"
.\" Yodl file: Zsh/mod_parameter.yo
The \fBzsh/parameter\fP module gives access to some of the internal hash
tables used by the shell by defining some special parameters\&.
.PP
.PD 0
.TP
.PD
\fBoptions\fP
The keys for this associative array are the names of the options that
can be set and unset using the \fBsetopt\fP and \fBunsetopt\fP
builtins\&. The value of each key is either the string \fBon\fP if the
option is currently set, or the string \fBoff\fP if the option is unset\&.
Setting a key to one of these strings is like setting or unsetting
the option, respectively\&. Unsetting a key in this array is like
setting it to the value \fBoff\fP\&.
.TP
\fBcommands\fP
This array gives access to the command hash table\&. The keys are the
names of external commands, the values are the pathnames of the files
that would be executed when the command would be invoked\&. Setting a
key in this array defines a new entry in this table in the same way as
with the \fBhash\fP builtin\&. Unsetting a key as in `\fBunset
"commands[foo]"\fP\&' removes the entry for the given key from the command
hash table\&.
.TP
\fBfunctions\fP
This associative array maps names of enabled functions to their
definitions\&. Setting a key in it is like defining a function with the
name given by the key and the body given by the value\&. Unsetting a key
removes the definition for the function named by the key\&.
.TP
\fBdis_functions\fP
Like \fBfunctions\fP but for disabled functions\&.
.TP
\fBbuiltins\fP
This associative array gives information about the builtin commands
currently enabled\&. The keys are the names of the builtin commands and
the values are either `\fBundefined\fP\&' for builtin commands that will
automatically be loaded from a module if invoked or `\fBdefined\fP\&' for
builtin commands that are already loaded\&.
.TP
\fBdis_builtins\fP
Like \fBbuiltins\fP but for disabled builtin commands\&.
.TP
\fBreswords\fP
This array contains the enabled reserved words\&.
.TP
\fBdis_reswords\fP
Like \fBreswords\fP but for disabled reserved words\&.
.TP
\fBaliases\fP
This maps the names of the regular aliases currently enabled to their
expansions\&.
.TP
\fBdis_aliases\fP
Like \fBaliases\fP but for disabled regular aliases\&.
.TP
\fBgaliases\fP
Like \fBaliases\fP, but for global aliases\&.
.TP
\fBdis_galiases\fP
Like \fBgaliases\fP but for disabled global aliases\&.
.TP
\fBsaliases\fP
Like \fBraliases\fP, but for suffix aliases\&.
.TP
\fBdis_saliases\fP
Like \fBsaliases\fP but for disabled suffix aliases\&.
.TP
\fBparameters\fP
The keys in this associative array are the names of the parameters
currently defined\&. The values are strings describing the type of the
parameter, in the same format used by the \fBt\fP parameter flag, see
\fIzshexpn\fP(1)
\&.
Setting or unsetting keys in this array is not possible\&.
.TP
\fBmodules\fP
An associative array giving information about modules\&. The keys are the names
of the modules loaded, registered to be autoloaded, or aliased\&. The
value says which state the named module is in and is one of the
strings `\fBloaded\fP\&', `\fBautoloaded\fP', or `\fBalias:\fP\fIname\fP',
where \fIname\fP is the name the module is aliased to\&.
.RS
.PP
Setting or unsetting keys in this array is not possible\&.
.RE
.TP
\fBdirstack\fP
A normal array holding the elements of the directory stack\&. Note that
the output of the \fBdirs\fP builtin command includes one more
directory, the current working directory\&.
.TP
\fBhistory\fP
This associative array maps history event numbers to the full history lines\&.
.TP
\fBhistorywords\fP
A special array containing the words stored in the history\&.
.TP
\fBjobdirs\fP
This associative array maps job numbers to the directories from which the
job was started (which may not be the current directory of the job)\&.
.TP
\fBjobtexts\fP
This associative array maps job numbers to the texts of the command lines
that were used to start the jobs\&.
.TP
\fBjobstates\fP
This associative array gives information about the states of the jobs
currently known\&. The keys are the job numbers and the values are
strings of the form
`\fIjob\-state\fP:\fImark\fP:\fIpid\fP\fB=\fP\fIstate\fP\fB\&.\&.\&.\fP\&'\&. The
\fIjob\-state\fP gives the state the whole job is currently in, one of
`\fBrunning\fP\&', `\fBsuspended\fP', or `\fBdone\fP'\&. The \fImark\fP is
`\fB+\fP\&' for the current job, `\fB\-\fP' for the previous job and empty
otherwise\&. This is followed by one `\fIpid\fP\fB=\fP\fIstate\fP\&' for every
process in the job\&. The \fIpid\fPs are, of course, the process IDs and
the \fIstate\fP describes the state of that process\&.
.TP
\fBnameddirs\fP
This associative array maps the names of named directories to the pathnames
they stand for\&.
.TP
\fBuserdirs\fP
This associative array maps user names to the pathnames of their home
directories\&.
.TP
\fBfuncstack\fP
This array contains the names of the functions currently being
executed\&. The first element is the name of the function using the
parameter\&.
.TP
\fBfunctrace\fP
This array contains the names and line numbers of the callers
corresponding to the functions currently being executed\&.
The format of each element is name:lineno\&.
.SH "THE ZSH/PCRE MODULE"
.\" Yodl file: Zsh/mod_pcre.yo
The \fBzsh/pcre\fP module makes some commands available as builtins:
.PP
.PD 0
.TP
.PD
\fBpcre_compile\fP [ \fB\-aimx\fP ] \fIPCRE\fP
Compiles a perl\-compatible regular expression\&.
.RS
.PP
Option \fB\-a\fP will force the pattern to be anchored\&.
Option \fB\-i\fP will compile a case\-insensitive pattern\&.
Option \fB\-m\fP will compile a multi\-line pattern; that is,
\fB^\fP and \fB$\fP will match newlines within the pattern\&.
Option \fB\-x\fP will compile an extended pattern, wherein
whitespace and \fB#\fP comments are ignored\&.
.RE
.TP
\fBpcre_study\fP
Studies the previously\-compiled PCRE which may result in faster
matching\&.
.TP
\fBpcre_match\fP [ \fB\-a\fP \fIarr\fP ] \fIstring\fP
Returns successfully if \fBstring\fP matches the previously\-compiled
PCRE\&.
.RS
.PP
If the expression captures substrings within parentheses,
\fBpcre_match\fP will set the array \fI$match\fP to those
substrings, unless the \fB\-a\fP option is given, in which
case it will set the array \fIarr\fP\&.
.RE
.RE
.PP
The \fBzsh/pcre\fP module makes available the following test condition:
.PD 0
.TP
.PD
expr \fB\-pcre\-match\fP pcre
Matches a string against a perl\-compatible regular expression\&.
.RS
.PP
For example,
.PP
[[ "$text" \-pcre\-match ^d+$ ]] && print text variable contains only "d\&'s"\&.
.RE
.RE
.SH "THE ZSH/SCHED MODULE"
.\" Yodl file: Zsh/mod_sched.yo
The \fBzsh/sched\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD 0
\fBsched\fP [\fB\-o\fP] [\fB+\fP]\fIhh\fP\fB:\fP\fImm\fP[:\fIss\fP] \fIcommand\fP \&.\&.\&.
.TP
.PD 0
\fBsched\fP [\fB\-o\fP] [\fB+\fP]\fIseconds\fP \fIcommand\fP \&.\&.\&.
.TP
.PD
\fBsched\fP [ \fB\-\fP\fIitem\fP ]
Make an entry in the scheduled list of commands to execute\&.
The time may be specified in either absolute or relative time,
and either as hours, minutes and (optionally) seconds separated by a
colon, or seconds alone\&.
An absolute number of seconds indicates the time since the epoch
(1970/01/01 00:00); this is useful in combination with the features in
the \fBzsh/datetime\fP module, see
the zsh/datetime module entry in \fIzshmodules\fP(1)\&.
.RS
.PP
With no arguments, prints the list of scheduled commands\&. If the
scheduled command has the \fB\-o\fP flag set, this is shown at the
start of the command\&.
.PP
With the argument `\fB\-\fP\fIitem\fP\&', removes the given item
from the list\&. The numbering of the list is continuous and entries are
in time order, so the numbering can change when entries are added or
deleted\&.
.PP
Commands are executed either immediately before a prompt, or while
the shell\&'s line editor is waiting for input\&. In the latter case
it is useful to be able to produce output that does not interfere
with the line being edited\&. Providing the option \fB\-o\fP causes
the shell to clear the command line before the event and redraw it
afterwards\&. This should be used with any scheduled event that produces
visible output to the terminal; it is not needed, for example, with
output that updates a terminal emulator\&'s title bar\&.
.RE
.RE
.SH "THE ZSH/NET/SOCKET MODULE"
.\" Yodl file: Zsh/mod_socket.yo
The \fBzsh/net/socket\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD
\fBzsocket\fP [ \fB\-altv\fP ] [ \fB\-d\fP \fIfd\fP ] [ \fIargs\fP ]
\fBzsocket\fP is implemented as a builtin to allow full use of shell
command line editing, file I/O, and job control mechanisms\&.
.PP
.SS "Outbound Connections"
.PP
.PD 0
.TP
.PD
\fBzsocket\fP [ \fB\-v\fP ] [ \fB\-d\fP \fIfd\fP ] \fIfilename\fP
Open a new Unix domain connection to \fIfilename\fP\&.
The shell parameter \fBREPLY\fP will be set to the file descriptor
associated with that connection\&. Currently, only stream connections
are supported\&.
.RS
.PP
If \fB\-d\fP is specified, its argument
will be taken as the target file descriptor for the
connection\&.
.PP
In order to elicit more verbose output, use \fB\-v\fP\&.
.RE
.RE
.PP
.SS "Inbound Connections"
.PP
.PD 0
.TP
.PD
\fBzsocket\fP \fB\-l\fP [ \fB\-v\fP ] [ \fB\-d\fP \fIfd\fP ] \fIfilename\fP
\fBzsocket \-l\fP will open a socket listening on \fIfilename\fP\&.
The shell parameter \fBREPLY\fP will be set to the file descriptor
associated with that listener\&.
.RS
.PP
If \fB\-d\fP is specified, its argument
will be taken as the target file descriptor for
the connection\&.
.PP
In order to elicit more verbose output, use \fB\-v\fP\&.
.RE
.TP
\fBzsocket\fP \fB\-a\fP [ \fB\-tv\fP ] [ \fB\-d\fP \fItargetfd\fP ] \fIlistenfd\fP
\fBzsocket \-a\fP will accept an incoming connection
to the socket associated with \fIlistenfd\fP\&.
The shell parameter \fBREPLY\fP will
be set to the file descriptor associated with
the inbound connection\&.
.RS
.PP
If \fB\-d\fP is specified, its argument
will be taken as the target file descriptor for the
connection\&.
.PP
If \fB\-t\fP is specified, \fBzsocket\fP will return
if no incoming connection is pending\&. Otherwise
it will wait for one\&.
.PP
In order to elicit more verbose output, use \fB\-v\fP\&.
.RE
.RE
.SH "THE ZSH/STAT MODULE"
.\" Yodl file: Zsh/mod_stat.yo
The \fBzsh/stat\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD
\fBstat\fP [ \fB\-gnNolLtTrs\fP ] [ \fB\-f\fP \fIfd\fP ] [ \fB\-H\fP \fIhash\fP ] [ \fB\-A\fP \fIarray\fP ] [ \fB\-F\fP \fIfmt\fP ] [ \fB+\fP\fIelement\fP ] [ \fIfile\fP \&.\&.\&. ]
The command acts as a front end to the \fBstat\fP system call (see
\fIstat\fP(2))\&.
If the \fBstat\fP call fails, the appropriate system error message
printed and status 1 is returned\&.
The fields of \fBstruct stat\fP give information about
the files provided as arguments to the command\&. In addition to those
available from the \fBstat\fP call, an extra element `\fBlink\fP\&' is provided\&.
These elements are:
.RS
.PP
.PD 0
.TP
.PD
\fBdevice\fP
The number of the device on which the file resides\&.
.TP
\fBinode\fP
The unique number of the file on this device (`\fIinode\fP\&' number)\&.
.TP
\fBmode\fP
The mode of the file; that is, the file\&'s type and access permissions\&.
With the \fB\-s\fP option, this will
be returned as a string corresponding to the first column in the
display of the \fBls \-l\fP command\&.
.TP
\fBnlink\fP
The number of hard links to the file\&.
.TP
\fBuid\fP
The user ID of the owner of the file\&. With the \fB\-s\fP
option, this is displayed as a user name\&.
.TP
\fBgid\fP
The group ID of the file\&. With the \fB\-s\fP option, this
is displayed as a group name\&.
.TP
\fBrdev\fP
The raw device number\&. This is only useful for special devices\&.
.TP
\fBsize\fP
The size of the file in bytes\&.
.TP
.PD 0
\fBatime\fP
.TP
.PD 0
\fBmtime\fP
.TP
.PD
\fBctime\fP
The last access, modification and inode change times
of the file, respectively, as the number of seconds since
midnight GMT on 1st January, 1970\&. With the \fB\-s\fP option,
these are printed as strings for the local time zone; the format
can be altered with the \fB\-F\fP option, and with the \fB\-g\fP
option the times are in GMT\&.
.TP
\fBblksize\fP
The number of bytes in one allocation block on the
device on which the file resides\&.
.TP
\fBblock\fP
The number of disk blocks used by the file\&.
.TP
\fBlink\fP
If the file is a link and the \fB\-L\fP option is in
effect, this contains the name of the file linked to, otherwise
it is empty\&. Note that if this element is selected (``\fBstat +link\fP\&'')
then the \fB\-L\fP option is automatically used\&.
.PP
A particular element may be selected by including its name
preceded by a `\fB+\fP\&' in the option list; only one element is allowed\&.
The element may be shortened to any unique set of leading
characters\&. Otherwise, all elements will be shown for all files\&.
.PP
Options:
.PP
.PD 0
.TP
.PD
\fB\-A\fP \fIarray\fP
Instead of displaying the results on standard
output, assign them to an \fIarray\fP, one \fBstruct stat\fP element per array
element for each file in order\&. In this case neither the name
of the element nor the name of the files appears in \fIarray\fP unless the
\fB\-t\fP or \fB\-n\fP options were given, respectively\&. If \fB\-t\fP is given,
the element name appears as a prefix to the
appropriate array element; if \fB\-n\fP is given, the file name
appears as a separate array element preceding all the others\&.
Other formatting options are respected\&.
.TP
\fB\-H\fP \fIhash\fP
Similar to \fB\-A\fP, but instead assign the values to \fIhash\fP\&. The keys
are the elements listed above\&. If the \fB\-n\fP option is provided then the
name of the file is included in the hash with key \fBname\fP\&.
.TP
\fB\-f\fP \fIfd\fP
Use the file on file descriptor \fIfd\fP instead of
named files; no list of file names is allowed in this case\&.
.TP
\fB\-F\fP \fIfmt\fP
Supplies a \fBstrftime\fP (see \fIstrftime\fP(3)) string for the
formatting of the time elements\&. The \fB\-s\fP option is implied\&.
.TP
\fB\-g\fP
Show the time elements in the GMT time zone\&. The
\fB\-s\fP option is implied\&.
.TP
\fB\-l\fP
List the names of the type elements (to standard
output or an array as appropriate) and return immediately;
options other than \fB\-A\fP and arguments are ignored\&.
.TP
\fB\-L\fP
Perform an \fBlstat\fP (see \fIlstat\fP(2)) rather than a \fBstat\fP
system call\&. In this case, if the file is a link, information
about the link itself rather than the target file is returned\&.
This option is required to make the \fBlink\fP element useful\&.
.TP
\fB\-n\fP
Always show the names of files\&. Usually these are
only shown when output is to standard output and there is more
than one file in the list\&.
.TP
\fB\-N\fP
Never show the names of files\&.
.TP
\fB\-o\fP
If a raw file mode is printed, show it in octal, which is more useful for
human consumption than the default of decimal\&. A leading zero will be
printed in this case\&. Note that this does not affect whether a raw or
formatted file mode is shown, which is controlled by the \fB\-r\fP and \fB\-s\fP
options, nor whether a mode is shown at all\&.
.TP
\fB\-r\fP
Print raw data (the default format) alongside string
data (the \fB\-s\fP format); the string data appears in parentheses
after the raw data\&.
.TP
\fB\-s\fP
Print \fBmode\fP, \fBuid\fP, \fBgid\fP and the three time
elements as strings instead of numbers\&. In each case the format
is like that of \fBls \-l\fP\&.
.TP
\fB\-t\fP
Always show the type names for the elements of
\fBstruct stat\fP\&. Usually these are only shown when output is to
standard output and no individual element has been selected\&.
.TP
\fB\-T\fP
Never show the type names of the \fBstruct stat\fP elements\&.
.RE
.RE
.SH "THE ZSH/SYSTEM MODULE"
.\" Yodl file: Zsh/mod_system.yo
The \fBzsh/system\fP module makes available three builtin commands and
two parameters\&.
.PP
.SH "BUILTINS"
.PP
.PD 0
.TP
.PD
\fBsyserror\fP \fB[ \-e\fP \fIerrvar\fP \fB] [ \-p\fP \fIprefix\fP \fB] [\fP \fIerrno\fP \fB|\fP \fIerrname\fP \fB]\fP
This command prints out the error message associated with \fIerrno\fP, a
system error number, followed by a newline to standard error\&.
.RS
.PP
Instead of the error number, a name \fIerrname\fP, for example
\fBENOENT\fP, may be used\&. The set of names is the same as the contents
of the array \fBerrnos\fP, see below\&.
.PP
If the string \fIprefix\fP is given, it is printed in front of the error
message, with no intervening space\&.
.PP
If \fIerrvar\fP is supplied, the entire message, without a newline, is
assigned to the parameter names \fIerrvar\fP and nothing is output\&.
.PP
A return status of 0 indicates the message was successfully printed
(although it may not be useful if the error number was out of the
system\&'s range), a return status of 1 indicates an error in the
parameters, and a return status of 2 indicates the error name was
not recognised (no message is printed for this)\&.
.RE
.TP
.PD 0
\fBsysread [ \-c\fP \fIcountvar\fP \fB] [ \-i\fP \fIinfd\fP \fB] [ \-o\fP \fIoutfd\fP \fB]\fP
.TP
.PD
\fB[ \-s\fP \fIbufsize\fP \fB] [ \-t\fP \fItimeout\fP \fB] [\fP \fIparam\fP \fB]\fP
Perform a single system read from file descriptor \fIinfd\fP, or zero if
that is not given\&. The result of the read is stored in \fIparam\fP or
\fIREPLY\fP if that is not given\&. If \fIcountvar\fP is given, the number
of bytes read is assigned to the parameter named by \fIcountvar\fP\&.
.RS
.PP
The maximum number of bytes read is \fIbufsize\fP or 8192 if that is not
given, however the command returns as soon as any number of bytes was
successfully read\&.
.PP
If \fItimeout\fP is given, it specifies a timeout in seconds, which may
be zero to poll the file descriptor\&. This is handled by the \fBpoll\fP
system call if available, otherwise the \fBselect\fP system call if
available\&.
.PP
If \fIoutfd\fP is given, an attempt is made to write all the bytes just
read to the file descriptor \fIoutfd\fP\&. If this fails, because of a
system error other than \fBEINTR\fP or because of an internal zsh error
during an interrupt, the bytes read but not written are stored in the
parameter named by \fIparam\fP if supplied (no default is used in this
case), and the number of bytes read but not written is stored in the
parameter named by \fIcountvar\fP if that is supplied\&. If it was
successful, \fIcountvar\fP contains the full number of bytes transferred,
as usual, and \fIparam\fP is not set\&.
.PP
The error \fBEINTR\fP (interrupted system call) is handled internally so
that shell interrupts are transparent to the caller\&. Any other error
causes a return\&.
.PP
The possible return statuses are
.PD 0
.TP
.PD
0
At least one byte of data was successfully read and, if appropriate,
written\&.
.TP
1
There was an error in the parameters to the command\&. This is the only
error for which a message is printed to standard error\&.
.TP
2
There was an error on the read, or on polling the input file descriptor
for a timeout\&. The parameter \fBERRNO\fP gives the error\&.
.TP
3
Data were successfully read, but there was an error writing them
to \fIoutfd\fP\&. The parameter \fBERRNO\fP gives the error\&.
.TP
4
The attempt to read timed out\&. Note this does not set \fBERRNO\fP as this
is not a system error\&.
.TP
5
No system error occurred, but zero bytes were read\&. This usually
indicates end of file\&. The parameters are set according to the
usual rules; no write to \fIoutfd\fP is attempted\&.
.RE
.TP
\fBsyswrite [ \-c\fP \fIcountvar\fP \fB] [ \-o\fP \fIoutfd\fP \fB]\fP \fIdata\fP
The data (a single string of bytes) are written to the file descriptor
\fIoutfd\fP, or 1 if that is not given, using the \fBwrite\fP system call\&.
Multiple write operations may be used if the first does not write all
the data\&.
.RS
.PP
If \fIcountvar\fP is given, the number of byte written is stored in the
parameter named by \fIcountvar\fP; this may not be the full length of
\fIdata\fP if an error occurred\&.
.PP
The error \fBEINTR\fP (interrupted system call) is handled internally by
retrying; otherwise an error causes the command to return\&. For example,
if the file descriptor is set to non\-blocking output, an error
\fBEAGAIN\fP (on some systems, \fBEWOULDBLOCK\fP) may result in the command
returning early\&.
.PP
The return status may be 0 for success, 1 for an error in the parameters
to the command, or 2 for an error on the write; no error message is
printed in the last case, but the parameter \fBERRNO\fP will reflect
the error that occurred\&.
.RE
.RE
.PP
.SH "PARAMETERS"
.PP
.PD 0
.TP
.PD
\fBerrnos\fP
A readonly array of the names of errors defined on the system\&. These
are typically macros defined in C by including the system header file
\fBerrno\&.h\fP\&. The index of each name (assuming the option \fBKSH_ARRAYS\fP
is unset) corresponds to the error number\&. Error numbers \fInum\fP
before the last known error which have no name are given the name
\fBE\fP\fInum\fP in the array\&.
.RS
.PP
Note that aliases for errors are not handled; only the canonical name is
used\&.
.RE
.TP
\fBsysparams\fP
A readonly associative array\&. The keys are:
.PD 0
.TP
.PD
\fBpid\fP
Returns the process ID of the current process, even in subshells\&. Compare
\fB$$\fP, which returns the process ID of the main shell process\&.
.TP
\fBppid\fP
Returns the process ID of the parent of the current process, even in
subshells\&. Compare \fB$PPID\fP, which returns the process ID of the parent
of the main shell process\&.
.RE
.RE
.SH "THE ZSH/NET/TCP MODULE"
.\" Yodl file: Zsh/mod_tcp.yo
The \fBzsh/net/tcp\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD
\fBztcp\fP [ \fB\-acflLtv\fP ] [ \fB\-d\fP \fIfd\fP ] [ \fIargs\fP ]
\fBztcp\fP is implemented as a builtin to allow full use of shell
command line editing, file I/O, and job control mechanisms\&.
.RS
.PP
If \fBztcp\fP is run with no options, it will output
the contents of its session table\&.
.PP
If it is run with only the option \fB\-L\fP, it will output the contents of
the session table in a format suitable for automatic parsing\&. The option
is ignored if given with a command to open or close a session\&. The output
consists of a set of lines, one per session, each containing the following
elements separated by spaces:
.PP
.PD 0
.TP
.PD
File descriptor
The file descriptor in use for the connection\&. For normal inbound (\fBI\fP)
and outbound (\fBO\fP) connections this may be read and written by the usual
shell mechanisms\&. However, it should only be close with `\fBztcp \-c\fP\&'\&.
.TP
Connection type
A letter indicating how the session was created:
.RS
.PP
.PD 0
.TP
.PD
\fBZ\fP
A session created with the \fBzftp\fP command\&.
.TP
\fBL\fP
A connection opened for listening with `\fBztcp \-l\fP\&'\&.
.TP
\fBI\fP
An inbound connection accepted with `\fBztcp \-a\fP\&'\&.
.TP
\fBO\fP
An outbound connection created with `\fBztcp\fP \fIhost\fP \fI\&.\&.\&.\fP\&'\&.
.PP
.RE
.TP
The local host
This is usually set to an all\-zero IP address as the address of the
localhost is irrelevant\&.
.TP
The local port
This is likely to be zero unless the connection is for listening\&.
.TP
The remote host
This is the fully qualified domain name of the peer, if available, else an
IP address\&. It is an all\-zero IP address for a session opened for
listening\&.
.TP
The remote port
This is zero for a connection opened for listening\&.
.RE
.RE
.PP
.SS "Outbound Connections"
.PP
.PD 0
.TP
.PD
\fBztcp\fP [ \fB\-v\fP ] [ \fB\-d\fP \fIfd\fP ] \fIhost\fP [ \fIport\fP ]
Open a new TCP connection to \fIhost\fP\&. If the \fIport\fP is
omitted, it will default to port 23\&. The connection will
be added to the session table and the shell parameter
\fBREPLY\fP will be set to the file descriptor associated
with that connection\&.
.RS
.PP
If \fB\-d\fP is specified, its argument will be taken as the target file
descriptor for the connection\&.
.PP
In order to elicit more verbose output, use \fB\-v\fP\&.
.RE
.RE
.PP
.SS "Inbound Connections"
.PP
.PD 0
.TP
.PD
\fBztcp\fP \fB\-l\fP [ \fB\-v\fP ] [ \fB\-d\fP \fIfd\fP ] \fIport\fP
\fBztcp \-l\fP will open a socket listening on TCP
\fIport\fP\&. The socket will be added to the
session table and the shell parameter \fBREPLY\fP
will be set to the file descriptor associated
with that listener\&.
.RS
.PP
If \fB\-d\fP is specified, its argument will be taken as the target file
descriptor for the connection\&.
.PP
In order to elicit more verbose output, use \fB\-v\fP\&.
.RE
.TP
\fBztcp\fP \fB\-a\fP [ \fB\-tv\fP ] [ \fB\-d\fP \fItargetfd\fP ] \fIlistenfd\fP
\fBztcp \-a\fP will accept an incoming connection
to the port associated with \fIlistenfd\fP\&.
The connection will be added to the session
table and the shell parameter \fBREPLY\fP will
be set to the file descriptor associated with
the inbound connection\&.
.RS
.PP
If \fB\-d\fP is specified, its argument
will be taken as the target file descriptor for the
connection\&.
.PP
If \fB\-t\fP is specified, \fBztcp\fP will return
if no incoming connection is pending\&. Otherwise
it will wait for one\&.
.PP
In order to elicit more verbose output, use \fB\-v\fP\&.
.RE
.RE
.PP
.SS "Closing Connections"
.PP
.PD 0
.TP
.PD 0
\fBztcp\fP \fB\-cf\fP [ \fB\-v\fP ] [ \fIfd\fP ]
.TP
.PD
\fBztcp\fP \fB\-c\fP [ \fB\-v\fP ] [ \fIfd\fP ]
\fBztcp \-c\fP will close the socket associated
with \fIfd\fP\&. The socket will be removed from the
session table\&. If \fIfd\fP is not specified,
\fBztcp\fP will close everything in the session table\&.
.RS
.PP
Normally, sockets registered by zftp (see
\fIzshmodules\fP(1)
) cannot be closed this way\&. In order
to force such a socket closed, use \fB\-f\fP\&.
.PP
In order to elicit more verbose output, use \fB\-v\fP\&.
.RE
.RE
.PP
.SS "Example"
Here is how to create a TCP connection between two instances of zsh\&. We
need to pick an unassigned port; here we use the randomly chosen 5123\&.
.PP
On \fBhost1\fP,
.RS
.nf
\fBzmodload zsh/net/tcp
ztcp \-l 5123
listenfd=$REPLY
ztcp \-a $listenfd
fd=$REPLY\fP
.fi
.RE
The second from last command blocks until there is an incoming connection\&.
.PP
Now create a connection from \fBhost2\fP (which may, of course, be the same
machine):
.RS
.nf
\fBzmodload zsh/net/tcp
ztcp host1 5123
fd=$REPLY\fP
.fi
.RE
.PP
Now on each host, \fB$fd\fP contains a file descriptor for talking to the
other\&. For example, on \fBhost1\fP:
.RS
.nf
\fBprint This is a message >&$fd\fP
.fi
.RE
and on \fBhost2\fP:
.RS
.nf
\fBread \-r line <&$fd; print \-r \- $line\fP
.fi
.RE
prints `\fBThis is a message\fP\&'\&.
.PP
To tidy up, on \fBhost1\fP:
.RS
.nf
\fBztcp \-c $listenfd
ztcp \-c $fd\fP
.fi
.RE
and on \fBhost2\fP
.RS
.nf
\fBztcp \-c $fd\fP
.fi
.RE
.SH "THE ZSH/TERMCAP MODULE"
.\" Yodl file: Zsh/mod_termcap.yo
The \fBzsh/termcap\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD
\fBechotc\fP \fIcap\fP [ \fIarg\fP \&.\&.\&. ]
Output the termcap value corresponding to the capability
\fIcap\fP, with optional arguments\&.
.PP
The \fBzsh/termcap\fP module makes available one parameter:
.PP
.PD 0
.TP
.PD
\fBtermcap\fP
An associative array that maps termcap capability codes to
their values\&.
.SH "THE ZSH/TERMINFO MODULE"
.\" Yodl file: Zsh/mod_terminfo.yo
The \fBzsh/terminfo\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD
\fBechoti\fP \fIcap\fP [ \fIarg\fP ]
Output the terminfo value corresponding to the capability
\fIcap\fP, instantiated with \fIarg\fP if applicable\&.
.PP
The \fBzsh/terminfo\fP module makes available one parameter:
.PP
.PD 0
.TP
.PD
\fBterminfo\fP
An associative array that maps terminfo capability names to
their values\&.
.SH "THE ZSH/ZFTP MODULE"
.\" Yodl file: Zsh/mod_zftp.yo
The \fBzsh/zftp\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD
\fBzftp\fP \fIsubcommand\fP [ \fIargs\fP ]
The \fBzsh/zftp\fP module is a client for FTP (file transfer protocol)\&. It
is implemented as a builtin to allow full use of shell command line
editing, file I/O, and job control mechanisms\&. Often, users will
access it via shell functions providing a more powerful interface; a set is
provided with the \fBzsh\fP distribution and is described in
\fIzshzftpsys\fP(1)\&. However, the \fBzftp\fP command is entirely usable in its
own right\&.
.RS
.PP
All commands consist of the command name \fBzftp\fP followed by the name
of a subcommand\&. These are listed below\&. The return status of each
subcommand is supposed to reflect the success or failure of the remote
operation\&. See a description of the variable \fBZFTP_VERBOSE\fP for
more information on how responses from the server may be printed\&.
.RE
.RE
.PP
.SS "Subcommands"
.PP
.PD 0
.TP
.PD
\fBopen\fP \fIhost\fP[\fB:\fP\fIport\fP] [ \fIuser\fP [ \fIpassword\fP [ \fIaccount\fP ] ] ]
Open a new FTP session to \fIhost\fP, which may be the name of a TCP/IP
connected host or an IP number in the standard dot notation\&. If the
argument is in the form \fIhost\fP\fB:\fP\fIport\fP, open a connection to
TCP port \fIport\fP instead of the standard FTP port 21\&. This may be
the name of a TCP service or a number: see the description of
\fBZFTP_PORT\fP below for more information\&.
.RS
.PP
If IPv6 addresses in colon format are used, the \fIhost\fP should be
surrounded by quoted square brackets to distinguish it from the \fIport\fP,
for example \fB\&'[fe80::203:baff:fe02:8b56]'\fP\&. For consistency this is
allowed with all forms of \fIhost\fP\&.
.PP
Remaining arguments are passed to the \fBlogin\fP subcommand\&. Note that
if no arguments beyond \fIhost\fP are supplied, \fBopen\fP will \fInot\fP
automatically call \fBlogin\fP\&. If no arguments at all are supplied,
\fBopen\fP will use the parameters set by the \fBparams\fP subcommand\&.
.PP
After a successful open, the shell variables \fBZFTP_HOST\fP, \fBZFTP_PORT\fP,
\fBZFTP_IP\fP and \fBZFTP_SYSTEM\fP are available; see `Variables\&'
below\&.
.RE
.TP
.PD 0
\fBlogin\fP [ \fIname\fP [ \fIpassword\fP [ \fIaccount\fP ] ] ]
.TP
.PD
\fBuser\fP [ \fIname\fP [ \fIpassword\fP [ \fIaccount\fP ] ] ]
Login the user \fIname\fP with parameters \fIpassword\fP and \fIaccount\fP\&.
Any of the parameters can be omitted, and will be read from standard
input if needed (\fIname\fP is always needed)\&. If
standard input is a terminal, a prompt for each one will be printed on
standard error and \fIpassword\fP will not be echoed\&. If any of the
parameters are not used, a warning message is printed\&.
.RS
.PP
After a successful login, the shell variables \fBZFTP_USER\fP,
\fBZFTP_ACCOUNT\fP and \fBZFTP_PWD\fP are available; see `Variables\&'
below\&.
.PP
This command may be re\-issued when a user is already logged in, and
the server will first be reinitialized for a new user\&.
.RE
.TP
.PD 0
\fBparams\fP [ \fIhost\fP [ \fIuser\fP [ \fIpassword\fP [ \fIaccount\fP ] ] ] ]
.TP
.PD
\fBparams\fP \fB\-\fP
Store the given parameters for a later \fBopen\fP command with no
arguments\&. Only those given on the command line will be remembered\&.
If no arguments are given, the parameters currently set are printed,
although the password will appear as a line of stars; the return status is
one if no parameters were set, zero otherwise\&.
.RS
.PP
Any of the parameters may be specified as a `\fB?\fP\&', which
may need to be quoted to protect it from shell expansion\&. In this case,
the appropriate parameter will be read from stdin as with the
\fBlogin\fP subcommand, including special handling of \fIpassword\fP\&. If the
`\fB?\fP\&' is followed by a string, that is used as the prompt for reading the
parameter instead of the default message (any necessary punctuation and
whitespace should be included at the end of the prompt)\&. The first letter
of the parameter (only) may be quoted with a `\fB\e\fP\&'; hence an argument
\fB"\e\e$word"\fP guarantees that the string from the shell parameter \fB$word\fP
will be treated literally, whether or not it begins with a `\fB?\fP\&'\&.
.PP
If instead a single `\fB\-\fP\&' is given, the existing parameters, if any,
are deleted\&. In that case, calling \fBopen\fP with no arguments will
cause an error\&.
.PP
The list of parameters is not deleted after a \fBclose\fP, however it
will be deleted if the \fBzsh/zftp\fP module is unloaded\&.
.PP
For example,
.PP
.RS
.nf
\fBzftp params ftp\&.elsewhere\&.xx juser \&'?Password for juser: '\fP
.fi
.RE
.PP
will store the host \fBftp\&.elsewhere\&.xx\fP and the user \fBjuser\fP and
then prompt the user for the corresponding password with the given prompt\&.
.RE
.TP
\fBtest\fP
Test the connection; if the server has reported
that it has closed the connection (maybe due to a timeout), return
status 2; if no connection was open anyway, return status 1; else
return status 0\&. The \fBtest\fP subcommand is
silent, apart from messages printed by the \fB$ZFTP_VERBOSE\fP
mechanism, or error messages if the connection closes\&. There is no
network overhead for this test\&.
.RS
.PP
The test is only supported on systems with either the
\fBselect(2)\fP or
\fBpoll(2)\fP system calls; otherwise the message `\fBnot
supported on this system\fP\&' is printed instead\&.
.PP
The \fBtest\fP subcommand will automatically be called at the start of any
other subcommand for the current session when a connection is open\&.
.RE
.TP
\fBcd\fP \fIdirectory\fP
Change the remote directory to \fIdirectory\fP\&. Also alters the shell
variable \fBZFTP_PWD\fP\&.
.TP
\fBcdup\fP
Change the remote directory to the one higher in the directory tree\&.
Note that \fBcd \&.\&.\fP will also work correctly on non\-UNIX systems\&.
.TP
\fBdir\fP [ \fIargs\&.\&.\&.\fP ]
Give a (verbose) listing of the remote directory\&. The \fIargs\fP are
passed directly to the server\&. The command\&'s behaviour is implementation
dependent, but a UNIX server will typically interpret \fIargs\fP as
arguments to the \fBls\fP command and with no arguments return the
result of `\fBls \-l\fP\&'\&. The directory is listed to standard output\&.
.TP
\fBls\fP [ \fIargs\fP ]
Give a (short) listing of the remote directory\&. With no \fIargs\fP,
produces a raw list of the files in the directory, one per line\&.
Otherwise, up to vagaries of the server implementation, behaves
similar to \fBdir\fP\&.
.TP
\fBtype\fP [ \fItype\fP ]
Change the type for the transfer to \fItype\fP, or print the current type
if \fItype\fP is absent\&. The allowed values are `\fBA\fP\&' (ASCII),
`\fBI\fP\&' (Image, i\&.e\&. binary), or `\fBB\fP' (a synonym for `\fBI\fP')\&.
.RS
.PP
The FTP default for a transfer is ASCII\&. However, if \fBzftp\fP finds
that the remote host is a UNIX machine with 8\-bit byes, it will
automatically switch to using binary for file transfers upon
\fBopen\fP\&. This can subsequently be overridden\&.
.PP
The transfer type is only passed to the remote host when a data
connection is established; this command involves no network overhead\&.
.RE
.TP
\fBascii\fP
The same as \fBtype A\fP\&.
.TP
\fBbinary\fP
The same as \fBtype I\fP\&.
.TP
\fBmode\fP [ \fBS\fP | \fBB\fP ]
Set the mode type to stream (\fBS\fP) or block (\fBB\fP)\&. Stream mode is
the default; block mode is not widely supported\&.
.TP
.PD 0
\fBremote\fP \fIfiles\&.\&.\&.\fP
.TP
.PD
\fBlocal\fP [ \fIfiles\&.\&.\&.\fP ]
Print the size and last modification time of the remote or local
files\&. If there is more than one item on the list, the name of the
file is printed first\&. The first number is the file size, the second
is the last modification time of the file in the format
\fBCCYYMMDDhhmmSS\fP consisting of year, month, date, hour, minutes and
seconds in GMT\&. Note that this format, including the length, is
guaranteed, so that time strings can be directly compared via the
\fB[[\fP builtin\&'s \fB<\fP and \fB>\fP operators, even if they are too long
to be represented as integers\&.
.RS
.PP
Not all servers support the commands for retrieving this information\&.
In that case, the \fBremote\fP command will print nothing and return
status 2, compared with status 1 for a file not found\&.
.PP
The \fBlocal\fP command (but not \fBremote\fP) may be used with no
arguments, in which case the information comes from examining file
descriptor zero\&. This is the same file as seen by a \fBput\fP command
with no further redirection\&.
.RE
.TP
\fBget\fP \fIfile\fP [\&.\&.\&.]
Retrieve all \fIfile\fPs from the server, concatenating them
and sending them to standard output\&.
.TP
\fBput\fP \fIfile\fP [\&.\&.\&.]
For each \fIfile\fP, read a file from standard input and send that to
the remote host with the given name\&.
.TP
\fBappend\fP \fIfile\fP [\&.\&.\&.]
As \fBput\fP, but if the remote \fIfile\fP already exists, data is
appended to it instead of overwriting it\&.
.TP
.PD 0
\fBgetat\fP \fIfile\fP \fIpoint\fP
.TP
.PD 0
\fBputat\fP \fIfile\fP \fIpoint\fP
.TP
.PD
\fBappendat\fP \fIfile\fP \fIpoint\fP
Versions of \fBget\fP, \fBput\fP and \fBappend\fP which will start the
transfer at the given \fIpoint\fP in the remote \fIfile\fP\&. This is
useful for appending to an incomplete local file\&. However, note that
this ability is not universally supported by servers (and is not quite
the behaviour specified by the standard)\&.
.TP
\fBdelete\fP \fIfile\fP [\&.\&.\&.]
Delete the list of files on the server\&.
.TP
\fBmkdir\fP \fIdirectory\fP
Create a new directory \fIdirectory\fP on the server\&.
.TP
\fBrmdir\fP \fIdirectory\fP
Delete the directory \fIdirectory\fP on the server\&.
.TP
\fBrename\fP \fIold\-name\fP \fInew\-name\fP
Rename file \fIold\-name\fP to \fInew\-name\fP on the server\&.
.TP
\fBsite\fP \fIargs\&.\&.\&.\fP
Send a host\-specific command to the server\&. You will probably
only need this if instructed by the server to use it\&.
.TP
\fBquote\fP \fIargs\&.\&.\&.\fP
Send the raw FTP command sequence to the server\&. You should be
familiar with the FTP command set as defined in RFC959 before doing
this\&. Useful commands may include \fBSTAT\fP and \fBHELP\fP\&. Note also
the mechanism for returning messages as described for the variable
\fBZFTP_VERBOSE\fP below, in particular that all messages from the
control connection are sent to standard error\&.
.TP
.PD 0
\fBclose\fP
.TP
.PD
\fBquit\fP
Close the current data connection\&. This unsets the shell parameters
\fBZFTP_HOST\fP, \fBZFTP_PORT\fP, \fBZFTP_IP\fP, \fBZFTP_SYSTEM\fP, \fBZFTP_USER\fP,
\fBZFTP_ACCOUNT\fP, \fBZFTP_PWD\fP, \fBZFTP_TYPE\fP and \fBZFTP_MODE\fP\&.
.TP
\fBsession\fP [ \fIsessname\fP ]
Allows multiple FTP sessions to be used at once\&. The name of the session
is an arbitrary string of characters; the default session is called
`\fBdefault\fP\&'\&. If this command is called without an argument, it will list
all the current sessions; with an argument, it will either switch to the
existing session called \fIsessname\fP, or create a new session of that name\&.
.RS
.PP
Each session remembers the status of the connection, the set of
connection\-specific shell parameters (the same set as are unset when a
connection closes, as given in the description of \fBclose\fP), and any user
parameters specified with the \fBparams\fP subcommand\&. Changing to a
previous session restores those values; changing to a new session
initialises them in the same way as if \fBzftp\fP had just been loaded\&. The
name of the current session is given by the parameter \fBZFTP_SESSION\fP\&.
.RE
.TP
\fBrmsession\fP [ \fIsessname\fP ]
Delete a session; if a name is not given, the current session is deleted\&.
If the current session is deleted, the earliest existing session becomes
the new current session, otherwise the current session is not changed\&.
If the session being deleted is the only one, a new session called
`\fBdefault\fP\&' is created and becomes the current session; note that this is
a new session even if the session being deleted is also called
`\fBdefault\fP\&'\&. It is recommended that sessions not be deleted while
background commands which use \fBzftp\fP are still active\&.
.PP
.SS "Parameters"
The following shell parameters are used by \fBzftp\fP\&. Currently none
of them are special\&.
.PP
.PD 0
.TP
.PD
\fBZFTP_TMOUT\fP
Integer\&. The time in seconds to wait for a network operation to
complete before returning an error\&. If this is not set when the
module is loaded, it will be given the default value 60\&. A value of
zero turns off timeouts\&. If a timeout occurs on the control
connection it will be closed\&. Use a larger value if this occurs too
frequently\&.
.TP
\fBZFTP_IP\fP
Readonly\&. The IP address of the current connection in dot notation\&.
.TP
\fBZFTP_HOST\fP
Readonly\&. The hostname of the current remote server\&. If the host was
opened as an IP number, \fBZFTP_HOST\fP contains that instead; this
saves the overhead for a name lookup, as IP numbers are most commonly
used when a nameserver is unavailable\&.
.TP
\fBZFTP_PORT\fP
Readonly\&. The number of the remote TCP port to which the connection is
open (even if the port was originally specified as a named service)\&.
Usually this is the standard FTP port, 21\&.
.RS
.PP
In the unlikely event that your system does not have the appropriate
conversion functions, this appears in network byte order\&. If your
system is little\-endian, the port then consists of two swapped bytes and the
standard port will be reported as 5376\&. In that case, numeric ports passed
to \fBzftp open\fP will also need to be in this format\&.
.RE
.TP
\fBZFTP_SYSTEM\fP
Readonly\&. The system type string returned by the server in response
to an FTP \fBSYST\fP request\&. The most interesting case is a string
beginning \fB"UNIX Type: L8"\fP, which ensures maximum compatibility
with a local UNIX host\&.
.TP
\fBZFTP_TYPE\fP
Readonly\&. The type to be used for data transfers , either `\fBA\fP\&' or
`\fBI\fP\&'\&. Use the \fBtype\fP subcommand to change this\&.
.TP
\fBZFTP_USER\fP
Readonly\&. The username currently logged in, if any\&.
.TP
\fBZFTP_ACCOUNT\fP
Readonly\&. The account name of the current user, if any\&. Most servers
do not require an account name\&.
.TP
\fBZFTP_PWD\fP
Readonly\&. The current directory on the server\&.
.TP
\fBZFTP_CODE\fP
Readonly\&. The three digit code of the last FTP reply from the server
as a string\&. This can still be read after the connection is closed, and
is not changed when the current session changes\&.
.TP
\fBZFTP_REPLY\fP
Readonly\&. The last line of the last reply sent by the server\&. This
can still be read after the connection is closed, and is not changed when
the current session changes\&.
.TP
\fBZFTP_SESSION\fP
Readonly\&. The name of the current FTP session; see the description of the
\fBsession\fP subcommand\&.
.TP
\fBZFTP_PREFS\fP
A string of preferences for altering aspects of \fBzftp\fP\&'s behaviour\&.
Each preference is a single character\&. The following are defined:
.RS
.PP
.PD 0
.TP
.PD
\fBP\fP
Passive: attempt to make the remote server initiate data transfers\&.
This is slightly more efficient than sendport mode\&. If the letter
\fBS\fP occurs later in the string, \fBzftp\fP will use sendport mode if
passive mode is not available\&.
.TP
\fBS\fP
Sendport: initiate transfers by the FTP \fBPORT\fP command\&. If this
occurs before any \fBP\fP in the string, passive mode will never be
attempted\&.
.TP
\fBD\fP
Dumb: use only the bare minimum of FTP commands\&. This prevents
the variables \fBZFTP_SYSTEM\fP and \fBZFTP_PWD\fP from being set, and
will mean all connections default to ASCII type\&. It may prevent
\fBZFTP_SIZE\fP from being set during a transfer if the server
does not send it anyway (many servers do)\&.
.PP
If \fBZFTP_PREFS\fP is not set when \fBzftp\fP is loaded, it will be set to a
default of `\fBPS\fP\&', i\&.e\&. use passive mode if available, otherwise
fall back to sendport mode\&.
.RE
.TP
\fBZFTP_VERBOSE\fP
A string of digits between 0 and 5 inclusive, specifying which
responses from the server should be printed\&. All responses go to
standard error\&. If any of the numbers 1 to 5 appear in the string,
raw responses from the server with reply codes beginning with that
digit will be printed to standard error\&. The first digit of the three
digit reply code is defined by RFC959 to correspond to:
.RS
.PP
.PD 0
.TP
.PD
1\&.
A positive preliminary reply\&.
.TP
2\&.
A positive completion reply\&.
.TP
3\&.
A positive intermediate reply\&.
.TP
4\&.
A transient negative completion reply\&.
.TP
5\&.
A permanent negative completion reply\&.
.PP
It should be noted that, for unknown reasons, the reply `Service not
available\&', which forces termination of a connection, is classified as
421, i\&.e\&. `transient negative\&', an interesting interpretation of the word
`transient\&'\&.
.PP
The code 0 is special: it indicates that all but the last line of
multiline replies read from the server will be printed to standard
error in a processed format\&. By convention, servers use this
mechanism for sending information for the user to read\&. The
appropriate reply code, if it matches the same response, takes
priority\&.
.PP
If \fBZFTP_VERBOSE\fP is not set when \fBzftp\fP is loaded, it will be
set to the default value \fB450\fP, i\&.e\&., messages destined for the user
and all errors will be printed\&. A null string is valid and
specifies that no messages should be printed\&.
.RE
.RE
.PP
.SS "Functions"
.PP
.PD 0
.TP
.PD
\fBzftp_chpwd\fP
If this function is set by the user, it is called every time the
directory changes on the server, including when a user is logged
in, or when a connection is closed\&. In the last case, \fB$ZFTP_PWD\fP
will be unset; otherwise it will reflect the new directory\&.
.TP
\fBzftp_progress\fP
If this function is set by the user, it will be called during
a \fBget\fP, \fBput\fP or \fBappend\fP operation each time sufficient data
has been received from the host\&. During a \fBget\fP, the data is sent
to standard output, so it is vital that this function should write
to standard error or directly to the terminal, \fInot\fP to standard
output\&.
.RS
.PP
When it is called with a transfer in progress, the following
additional shell parameters are set:
.PP
.PD 0
.TP
.PD
\fBZFTP_FILE\fP
The name of the remote file being transferred from or to\&.
.TP
\fBZFTP_TRANSFER\fP
A \fBG\fP for a \fBget\fP operation and a \fBP\fP for a \fBput\fP operation\&.
.TP
\fBZFTP_SIZE\fP
The total size of the complete file being transferred:
the same as the first value provided by the
\fBremote\fP and \fBlocal\fP subcommands for a particular file\&.
If the server cannot supply this value for a remote file being
retrieved, it will not be set\&. If input is from a pipe the value may
be incorrect and correspond simply to a full pipe buffer\&.
.TP
\fBZFTP_COUNT\fP
The amount of data so far transferred; a number between zero and
\fB$ZFTP_SIZE\fP, if that is set\&. This number is always available\&.
.PP
The function is initially called with \fBZFTP_TRANSFER\fP set
appropriately and \fBZFTP_COUNT\fP set to zero\&. After the transfer is
finished, the function will be called one more time with
\fBZFTP_TRANSFER\fP set to \fBGF\fP or \fBPF\fP, in case it wishes to tidy
up\&. It is otherwise never called twice with the same value of
\fBZFTP_COUNT\fP\&.
.PP
Sometimes the progress meter may cause disruption\&. It is up to the
user to decide whether the function should be defined and to use
\fBunfunction\fP when necessary\&.
.RE
.RE
.PP
.SS "Problems"
.PP
A connection may not be opened in the left hand side of a pipe as this
occurs in a subshell and the file information is not updated in the main
shell\&. In the case of type or mode changes or closing the connection in a
subshell, the information is returned but variables are not updated until
the next call to \fBzftp\fP\&. Other status changes in subshells will not be
reflected by changes to the variables (but should be otherwise harmless)\&.
.PP
Deleting sessions while a \fBzftp\fP command is active in the background can
have unexpected effects, even if it does not use the session being deleted\&.
This is because all shell subprocesses share information on the state of
all connections, and deleting a session changes the ordering of that
information\&.
.PP
On some operating systems, the control connection is not valid after a
fork(), so that operations in subshells, on the left hand side
of a pipeline, or in the background are not possible, as they should be\&.
This is presumably a bug in the operating system\&.
.SH "THE ZSH/ZLE MODULE"
.\" Yodl file: Zsh/mod_zle.yo
The \fBzsh/zle\fP module contains the Zsh Line Editor\&. See
\fIzshzle\fP(1)\&.
.SH "THE ZSH/ZLEPARAMETER MODULE"
.\" Yodl file: Zsh/mod_zleparameter.yo
The \fBzsh/zleparameter\fP module defines two special parameters that can be
used to access internal information of the Zsh Line Editor (see
\fIzshzle\fP(1))\&.
.PP
.PD 0
.TP
.PD
\fBkeymaps\fP
This array contains the names of the keymaps currently defined\&.
.TP
\fBwidgets\fP
This associative array contains one entry per widget defined\&. The name
of the widget is the key and the value gives information about the
widget\&. It is either the string `\fBbuiltin\fP\&' for builtin widgets, a
string of the form `\fBuser:\fP\fIname\fP\&' for user\-defined widgets,
where \fIname\fP is the name of the shell function implementing the
widget, or it is a string of the form
`\fBcompletion:\fP\fItype\fP\fB:\fP\fIname\fP\&', for completion widgets\&. In
the last case \fItype\fP is the name of the builtin widgets the
completion widget imitates in its behavior and \fIname\fP is the name
of the shell function implementing the completion widget\&.
.SH "THE ZSH/ZPROF MODULE"
.\" Yodl file: Zsh/mod_zprof.yo
When loaded, the \fBzsh/zprof\fP causes shell functions to be profiled\&.
The profiling results can be obtained with the \fBzprof\fP
builtin command made available by this module\&. There is no way to turn
profiling off other than unloading the module\&.
.PP
.PD 0
.TP
.PD
\fBzprof\fP [ \fB\-c\fP ]
Without the \fB\-c\fP option, \fBzprof\fP lists profiling results to
standard output\&. The format is comparable to that of commands like
\fBgprof\fP\&.
.RS
.PP
At the top there is a summary listing all functions that were called
at least once\&. This summary is sorted in decreasing order of the
amount of time spent in each\&. The lines contain
the number of the function in order, which is used in
other parts of the list in suffixes of the form
`\fB[\fP\fInum\fP\fB]\fP\&'.RE, then the number of calls made to the function\&.
The next three columns list the time in
milliseconds spent in the function and its descendents, the average
time in milliseconds spent in the function and its descendents per
call and the percentage of time spent in all shell functions used in
this function and its descendents\&. The following three columns give
the same information, but counting only the time spent in the function
itself\&. The final column shows the name of the function\&.
.PP
After the summary, detailed information about every function that was
invoked is listed, sorted in decreasing order of the amount of time spent
in each function and its descendents\&. Each of these entries consists of
descriptions for the functions that called the function described, the
function itself, and the functions that were called from it\&. The
description for the function itself has the same format as in the summary
(and shows the same information)\&. The other lines don\&'t show the number of
the function at the beginning and have their function named indented to
make it easier to distinguish the line showing the function described in
the section from the surrounding lines\&.
.PP
The information shown in this case is almost the same as in the summary,
but only refers to the call hierarchy being displayed\&. For example, for a
calling function the column showing the total running time lists the time
spent in the described function and its descendents only for the times when
it was called from that particular calling function\&. Likewise, for a
called function, this columns lists the total time spent in the called
function and its descendents only for the times when it was called from the
function described\&.
.PP
Also in this case, the column showing the number of calls to a function
also shows a slash and then the total number of invocations made to the
called function\&.
.PP
As long as the \fBzsh/zprof\fP module is loaded, profiling will be done and
multiple invocations of the \fBzprof\fP builtin command will show the
times and numbers of calls since the module was loaded\&. With the
\fB\-c\fP option, the \fBzprof\fP builtin command will reset its internal
counters and will not show the listing\&.
)
.RE
.SH "THE ZSH/ZPTY MODULE"
.\" Yodl file: Zsh/mod_zpty.yo
The \fBzsh/zpty\fP module offers one builtin:
.PP
.PD 0
.TP
.PD
\fBzpty\fP [ \fB\-e\fP ] [ \fB\-b\fP ] \fIname\fP [ \fIarg \&.\&.\&.\fP ]
The arguments following \fIname\fP are concatenated with spaces between,
then executed as a command, as if passed to the \fBeval\fP builtin\&. The
command runs under a newly assigned pseudo\-terminal; this is useful for
running commands non\-interactively which expect an interactive
environment\&. The \fIname\fP is not part of the command, but is used to
refer to this command in later calls to \fBzpty\fP\&.
.RS
.PP
With the \fB\-e\fP option, the pseudo\-terminal is set up so that input
characters are echoed\&.
.PP
With the \fB\-b\fP option, input to and output from the pseudo\-terminal are
made non\-blocking\&.
.RE
.TP
\fBzpty\fP \fB\-d\fP [ \fInames\fP \&.\&.\&. ]
The second form, with the \fB\-d\fP option, is used to delete commands
previously started, by supplying a list of their \fIname\fPs\&. If no
\fInames\fP are given, all commands are deleted\&. Deleting a command causes
the HUP signal to be sent to the corresponding process\&.
.TP
\fBzpty\fP \fB\-w\fP [ \fB\-n\fP ] \fIname\fP [ \fIstrings \&.\&.\&.\fP ]
The \fB\-w\fP option can be used to send the to command \fIname\fP the given
\fIstrings\fP as input (separated by spaces)\&. If the \fB\-n\fP option is
\fInot\fP given, a newline is added at the end\&.
.RS
.PP
If no \fIstrings\fP are provided, the standard input is copied to the
pseudo\-terminal; this may stop before copying the full input if the
pseudo\-terminal is non\-blocking\&.
.PP
Note that the command under the pseudo\-terminal sees this input as if it
were typed, so beware when sending special tty driver characters such as
word\-erase, line\-kill, and end\-of\-file\&.
.RE
.TP
\fBzpty\fP \fB\-r\fP [ \fB\-t\fP ] \fIname\fP [ \fIparam\fP [ \fIpattern\fP ] ]
The \fB\-r\fP option can be used to read the output of the command \fIname\fP\&.
With only a \fIname\fP argument, the output read is copied to the standard
output\&. Unless the pseudo\-terminal is non\-blocking, copying continues
until the command under the pseudo\-terminal exits; when non\-blocking, only
as much output as is immediately available is copied\&. The return status is
zero if any output is copied\&.
.RS
.PP
When also given a \fIparam\fP argument, at most one line is read and stored
in the parameter named \fIparam\fP\&. Less than a full line may be read if
the pseudo\-terminal is non\-blocking\&. The return status is zero if at least
one character is stored in \fIparam\fP\&.
.PP
If a \fIpattern\fP is given as well, output is read until the whole string
read matches the \fIpattern\fP, even in the non\-blocking case\&. The return
status is zero if the string read matches the pattern, or if the command
has exited but at least one character could still be read\&. As of this
writing, a maximum of one megabyte of output can be consumed this way; if
a full megabyte is read without matching the pattern, the return status is
non\-zero\&.
.PP
In all cases, the return status is non\-zero if nothing could be read, and
is \fB2\fP if this is because the command has finished\&.
.PP
If the \fB\-r\fP option is combined with the \fB\-t\fP option, \fBzpty\fP tests
whether output is available before trying to read\&. If no output is
available, \fBzpty\fP immediately returns the status \fB1\fP\&.
.RE
.TP
\fBzpty\fP \fB\-t\fP \fIname\fP
The \fB\-t\fP option without the \fB\-r\fP option can be used to test
whether the command \fIname\fP is still running\&. It returns a zero
status if the command is running and a non\-zero value otherwise\&.
.TP
\fBzpty\fP [ \fB\-L\fP ]
The last form, without any arguments, is used to list the commands
currently defined\&. If the \fB\-L\fP option is given, this is done in the
form of calls to the \fBzpty\fP builtin\&.
.SH "THE ZSH/ZSELECT MODULE"
.\" Yodl file: Zsh/mod_zselect.yo
The \fBzsh/zselect\fP module makes available one builtin command:
.PP
.PD 0
.TP
.PD
\fBzselect\fP [ \fB\-rwe\fP \fB\-t\fP \fItimeout\fP \fB\-a\fP \fIarray\fP ] [ \fIfd\fP \&.\&.\&. ]
The \fBzselect\fP builtin is a front\-end to the `select\&' system call, which
blocks until a file descriptor is ready for reading or writing, or has an
error condition, with an optional timeout\&. If this is not available on
your system, the command prints an error message and returns status 2
(normal errors return status 1)\&. For more information, see your systems
documentation for \fIselect\fP(3)\&. Note there is no connection with the
shell builtin of the same name\&.
.RS
.PP
Arguments and options may be intermingled in any order\&. Non\-option
arguments are file descriptors, which must be decimal integers\&. By
default, file descriptors are to be tested for reading, i\&.e\&. \fBzselect\fP
will return when data is available to be read from the file descriptor, or
more precisely, when a read operation from the file descriptor will not
block\&. After a \fB\-r\fP, \fB\-w\fP and \fB\-e\fP, the given file descriptors are
to be tested for reading, writing, or error conditions\&. These options and
an arbitrary list of file descriptors may be given in any order\&.
.PP
(The presence of an `error condition\&' is not well defined in the
documentation for many implementations of the select system call\&.
According to recent versions of the POSIX specification, it is really an
\fIexception\fP condition, of which the only standard example is out\-of\-band
data received on a socket\&. So zsh users are unlikely to find the \fB\-e\fP
option useful\&.)
.PP
The option `\fB\-t\fP \fItimeout\fP\&' specifies a timeout in hundredths of a
second\&. This may be zero, in which case the file descriptors will simply
be polled and \fBzselect\fP will return immediately\&. It is possible to call
zselect with no file descriptors and a non\-zero timeout for use as a
finer\-grained replacement for `sleep\&'; not, however, the return status is
always 1 for a timeout\&.
.PP
The option `\fB\-a\fP \fIarray\fP\&' indicates that \fBarray\fP should be set to
indicate the file descriptor(s) which are ready\&. If the option
is not
given, the array \fBreply\fP will be used for this purpose\&. The array will
contain a string similar to the arguments for \fBzselect\fP\&. For example,
.PP
.RS
.nf
\fBzselect \-t 0 \-r 0 \-w 1\fP
.fi
.RE
.PP
might return immediately with status 0 and \fB$reply\fP containing `\fB\-r 0 \-w
1\fP\&' to show that both file descriptors are ready for the requested
operations\&.
.PP
The option `\fB\-A\fP \fIassoc\fP\&' indicates that the associative array
\fBassoc\fP should be set to indicate the file descriptor(s(
which are ready\&. This option overrides the option \fB\-a\fP, nor will
\fBreply\fP be modified\&. The keys of \fBassoc\fP are the file descriptors, and
the corresponding values are any of the characters `\fBrwe\fP\&' to indicate
the condition\&.
.PP
The command returns status 0 if some file descriptors are ready for
reading\&. If the operation timed out, or a timeout of 0 was given and no
file descriptors were ready, or there was an error, it returns status 1 and
the array will not be set (nor modified in any way)\&. If there was an error
in the select operation the appropriate error message is printed\&.
.RE
.RE
.SH "THE ZSH/ZUTIL MODULE"
.\" Yodl file: Zsh/mod_zutil.yo
The \fBzsh/zutil\fP module only adds some builtins:
.PP
.PD 0
.TP
.PD 0
\fBzstyle\fP [ \fB\-L\fP [ \fIpattern\fP [ \fIstyle\fP ] ] ]
.TP
.PD 0
\fBzstyle\fP [ \fB\-e\fP | \fB\-\fP | \fB\-\fP\fB\-\fP ] \fIpattern\fP \fIstyle\fP \fIstrings\fP \&.\&.\&.
.TP
.PD 0
\fBzstyle \-d\fP [ \fIpattern\fP [ \fIstyles\fP \&.\&.\&. ] ]
.TP
.PD 0
\fBzstyle \-g\fP \fIname\fP [ \fIpattern\fP [ \fIstyle\fP ] ]
.TP
.PD 0
\fBzstyle \-abs\fP \fIcontext\fP \fIstyle\fP \fIname\fP [ \fIsep\fP ]
.TP
.PD 0
\fBzstyle \-Tt\fP \fIcontext\fP \fIstyle\fP [ \fIstrings\fP \&.\&.\&.]
.TP
.PD
\fBzstyle \-m\fP \fIcontext\fP \fIstyle\fP \fIpattern\fP
This builtin command is used to define and lookup styles\&. Styles are
pairs of names and values, where the values consist of any number of
strings\&. They are stored together with patterns and lookup is done by
giving a string, called the `context\&', which is compared to the
patterns\&. The definition stored for the first matching pattern will be
returned\&.
.RS
.PP
For ordering of comparisons, patterns are searched from most specific to
least specific, and patterns that are equally specific keep the order in
which they were defined\&. A pattern is considered to be more specific
than another if it contains more components (substrings separated by
colons) or if the patterns for the components are more specific, where
simple strings are considered to be more specific than patterns and
complex patterns are considered to be more specific than the pattern
`\fB*\fP\&'\&.
.PP
The first form (without arguments) lists the definitions in the order
\fBzstyle\fP will test them\&.
.PP
If the \fB\-L\fP option is given, listing is done in the form of calls to
\fBzstyle\fP\&. The optional first argument is a pattern which will be matched
against the string supplied as the pattern for the context; note that
this means, for example, `\fBzstyle \-L ":completion:*"\fP\&' will
match any supplied pattern beginning `\fB:completion:\fP\&', not
just \fB":completion:*"\fP: use \fB":completion:\e*"\fP to match that\&.
The optional second argument limits the output to a specific style (not a
pattern)\&. \fB\-L\fP is not compatible with any other options\&.
.PP
The other forms are the following:
.PP
.PD 0
.TP
.PD
\fBzstyle\fP [ \fB\-\fP | \fB\-\fP\fB\-\fP | \fB\-e\fP ] \fIpattern\fP \fIstyle\fP \fIstrings\fP \&.\&.\&.
Defines the given \fIstyle\fP for the \fIpattern\fP with the \fIstrings\fP as
the value\&. If the \fB\-e\fP option is given, the \fIstrings\fP will be
concatenated (separated by spaces) and the resulting string will be
evaluated (in the same way as it is done by the \fBeval\fP builtin
command) when the style is looked up\&. In this case the parameter
`\fBreply\fP\&' must be assigned to set the strings returned after the
evaluation\&. Before evaluating the value, \fBreply\fP is unset, and
if it is still unset after the evaluation, the style is treated as if
it were not set\&.
.TP
\fBzstyle \-d\fP [ \fIpattern\fP [ \fIstyles\fP \&.\&.\&. ] ]
Delete style definitions\&. Without arguments all definitions are deleted,
with a \fIpattern\fP all definitions for that pattern are deleted and if
any \fIstyles\fP are given, then only those styles are deleted for the
\fIpattern\fP\&.
.TP
\fBzstyle \-g\fP \fIname\fP [ \fIpattern\fP [ \fIstyle\fP ] ]
Retrieve a style definition\&. The \fIname\fP is
used as the name of an array in which the results are stored\&. Without
any further arguments, all \fIpatterns\fP defined are returned\&. With a
\fIpattern\fP the styles defined for that pattern are returned and with
both a \fIpattern\fP and a \fIstyle\fP, the value strings of that
combination is returned\&.
.PP
The other forms can be used to look up or test patterns\&.
.PP
.PD 0
.TP
.PD
\fBzstyle \-s\fP \fIcontext\fP \fIstyle\fP \fIname\fP [ \fIsep\fP ]
The parameter \fIname\fP is set to the value of the style interpreted as a
string\&. If the value contains several strings they are concatenated with
spaces (or with the \fIsep\fP string if that is given) between them\&.
.TP
\fBzstyle \-b\fP \fIcontext\fP \fIstyle\fP \fIname\fP
The value is stored in \fIname\fP as a boolean, i\&.e\&. as the string
`\fByes\fP\&' if the value has only one string and that string is equal to one
of `\fByes\fP\&', `\fBtrue\fP', `\fBon\fP', or `\fB1\fP'\&. If the value is any other
string or has more than one string, the parameter is set to `\fBno\fP\&'\&.
.TP
\fBzstyle \-a\fP \fIcontext\fP \fIstyle\fP \fIname\fP
The value is stored in \fIname\fP as an array\&. If \fIname\fP is declared
as an associative array, the first, third, etc\&. strings are used as the
keys and the other strings are used as the values\&.
.TP
.PD 0
\fBzstyle \-t\fP \fIcontext\fP \fIstyle\fP [ \fIstrings\fP \&.\&.\&.]
.TP
.PD
\fBzstyle \-T\fP \fIcontext\fP \fIstyle\fP [ \fIstrings\fP \&.\&.\&.]
Test the value of a style, i\&.e\&. the \fB\-t\fP option only returns a status
(sets \fB$?\fP)\&. Without any \fIstrings\fP the return status is zero if the
style is defined for at least one matching pattern, has only one string in
its value, and that is equal to one of `\fBtrue\fP\&', `\fByes\fP', `\fBon\fP' or
`\fB1\fP\&'\&. If any \fIstrings\fP are given the status is zero if and only if
at least one of the \fIstrings\fP is equal to at least one of the strings
in the value\&. If the style is not defined, the status is \fB2\fP\&.
.RS
.PP
The \fB\-T\fP option tests the values of the style like \fB\-t\fP, but it
returns status zero (rather than \fB2\fP) if the style is not defined for any
matching pattern\&.
.RE
.TP
\fBzstyle \-m\fP \fIcontext\fP \fIstyle\fP \fIpattern\fP
Match a value\&. Returns status zero if the
\fIpattern\fP matches at least one of the strings in the value\&.
.RE
.TP
.PD 0
\fBzformat \-f\fP \fIparam\fP \fIformat\fP \fIspecs\fP \&.\&.\&.
.TP
.PD
\fBzformat \-a\fP \fIarray\fP \fIsep\fP \fIspecs\fP \&.\&.\&.
This builtin provides two different forms of formatting\&. The first form
is selected with the \fB\-f\fP option\&. In this case the \fIformat\fP
string will be modified by replacing sequences starting with a percent
sign in it with strings from the \fIspecs\fP\&. Each \fIspec\fP should be
of the form `\fIchar\fP\fB:\fP\fIstring\fP\&' which will cause every
appearance of the sequence `\fB%\fP\fIchar\fP\&' in \fIformat\fP to be replaced
by the \fIstring\fP\&. The `\fB%\fP\&' sequence may also contain optional
minimum and maximum field width specifications between the `\fB%\fP\&' and
the `\fIchar\fP\&' in the form `\fB%\fP\fImin\fP\fB\&.\fP\fImax\fP\fBc\fP',
i\&.e\&. the minimum field width is given first and if the maximum field
width is used, it has to be preceded by a dot\&. Specifying a minimum field
width makes the result be padded with spaces to the right if the
\fIstring\fP is shorter than the requested width\&. Padding to the left
can be achieved by giving a negative minimum field width\&. If a maximum
field width is specified, the \fIstring\fP will be truncated after that
many characters\&. After all `\fB%\fP\&' sequences for the given \fIspecs\fP
have been processed, the resulting string is stored in the parameter
\fIparam\fP\&.
.RS
.PP
The \fB%\fP\-escapes also understand ternary expressions in the form used by
prompts\&. The \fB%\fP is followed by a `\fB(\fP\&' and then an ordinary
format specifier character as described above\&. There may be a set of
digits either before or after the `\fB(\fP\&'; these specify a test
number, which defaults to zero\&. Negative numbers are also allowed\&. An
arbitrary delimiter character follows the format specifier, which is
followed by a piece of `true\&' text, the delimiter character again, a piece
of `false\&' text, and a closing parenthesis\&. The complete expression
(without the digits) thus looks like
`\fB%(\fP\fIX\fP\fB\&.\fP\fItext1\fP\fB\&.\fP\fItext2\fP\fB)\fP\&', except that
the `\fB\&.\fP\&' character is arbitrary\&. The value given for the format
specifier in the \fIchar\fP\fB:\fP\fIstring\fP expressions is evaluated as a
mathematical expression, and compared with the test number\&. If they are
the same, \fItext1\fP is output, else \fItext2\fP is output\&. A parenthesis
may be escaped in \fItext2\fP as \fB%)\fP\&. Either of \fItext1\fP or
\fItext2\fP may contain nested \fB%\fP\-escapes\&.
.PP
For example:
.PP
.RS
.nf
\fBzformat \-f REPLY "The answer is \&'%3(c\&.yes\&.no)'\&." c:3\fP
.fi
.RE
.PP
outputs "The answer is \&'yes'\&." to \fBREPLY\fP since the value for the format
specifier \fBc\fP is 3, agreeing with the digit argument to the ternary
expression\&.
.PP
The second form, using the \fB\-a\fP option, can be used for aligning
strings\&. Here, the \fIspecs\fP are of the form
`\fIleft\fP\fB:\fP\fIright\fP\&' where `\fIleft\fP' and `\fIright\fP' are
arbitrary strings\&. These strings are modified by replacing the colons
by the \fIsep\fP string and padding the \fIleft\fP strings with spaces
to the right so that the \fIsep\fP strings in the result (and hence the
\fIright\fP strings after them) are all aligned if the strings are
printed below each other\&. All strings without a colon are left
unchanged and all strings with an empty \fIright\fP string have the
trailing colon removed\&. In both cases the lengths of the strings
are not used to determine how the other strings are to be aligned\&.
The resulting strings are stored in the \fIarray\fP\&.
.RE
.TP
\fBzregexparse\fP
This implements some internals of the \fB_regex_arguments\fP function\&.
.TP
\fBzparseopts\fP [ \fB\-D\fP ] [ \fB\-K\fP ] [ \fB\-E\fP ] [ \fB\-a\fP \fIarray\fP ] [ \fB\-A\fP \fIassoc\fP ] \fIspecs\fP
This builtin simplifies the parsing of options in positional parameters,
i\&.e\&. the set of arguments given by \fB$*\fP\&. Each \fIspec\fP describes one
option and must be of the form `\fIopt\fP[\fB=\fP\fIarray\fP]\&'\&. If an option
described by \fIopt\fP is found in the positional parameters it is copied
into the \fIarray\fP specified with the \fB\-a\fP option; if the optional
`\fB=\fP\fIarray\fP\&' is given, it is instead copied into that array\&.
.RS
.PP
Note that it is an error to give any \fIspec\fP without an
`\fB=\fP\fIarray\fP\&' unless one of the \fB\-a\fP or \fB\-A\fP options is used\&.
.PP
Unless the \fB\-E\fP option is given, parsing stops at the first string
that isn\&'t described by one of the \fIspecs\fP\&. Even with \fB\-E\fP,
parsing always stops at a positional parameter equal to `\fB\-\fP\&' or
`\fB\-\fP\fB\-\fP\&'\&.
.PP
The \fIopt\fP description must be one of the following\&. Any of the special
characters can appear in the option name provided it is preceded by a
backslash\&.
.PP
.PD 0
.TP
.PD 0
\fIname\fP
.TP
.PD
\fIname\fP\fB+\fP
The \fIname\fP is the name of the option without the leading `\fB\-\fP\&'\&. To
specify a GNU\-style long option, one of the usual two leading `\fB\-\fP\&' must
be included in \fIname\fP; for example, a `\fB\-\fP\fB\-file\fP\&' option is
represented by a \fIname\fP of `\fB\-file\fP\&'\&.
.RS
.PP
If a `\fB+\fP\&' appears after \fIname\fP, the option is appended to \fIarray\fP
each time it is found in the positional parameters; without the `\fB+\fP\&'
only the \fIlast\fP occurrence of the option is preserved\&.
.PP
If one of these forms is used, the option takes no argument, so parsing
stops if the next positional parameter does not also begin with `\fB\-\fP\&'
(unless the \fB\-E\fP option is used)\&.
.RE
.TP
.PD 0
\fIname\fP\fB:\fP
.TP
.PD 0
\fIname\fP\fB:\-\fP
.TP
.PD
\fIname\fP\fB::\fP
If one or two colons are given, the option takes an argument; with one
colon, the argument is mandatory and with two colons it is optional\&. The
argument is appended to the \fIarray\fP after the option itself\&.
.RS
.PP
An optional argument is put into the same array element as the option name
(note that this makes empty strings as arguments indistinguishable)\&. A
mandatory argument is added as a separate element unless the `\fB:\-\fP\&' form
is used, in which case the argument is put into the same element\&.
.PP
A `\fB+\fP\&' as described above may appear between the \fIname\fP and the
first colon\&.
.RE
.RE
.PP
The options of \fBzparseopts\fP itself are:
.PP
.PD 0
.TP
.PD
\fB\-a\fP \fIarray\fP
As described above, this names the default array in which to store the
recognised options\&.
.TP
\fB\-A\fP \fIassoc\fP
If this is given, the options and their values are also put into an
associative array with the option names as keys and the arguments (if any)
as the values\&.
.TP
\fB\-D\fP
If this option is given, all options found are removed from the positional
parameters of the calling shell or shell function, up to but not including
any not described by the \fIspecs\fP\&. This is similar to using the \fBshift\fP
builtin\&.
.TP
\fB\-K\fP
With this option, the arrays specified with the \fB\-a\fP and \fB\-A\fP
options and with the `\fB=\fP\fIarray\fP\&' forms are kept unchanged when none
of the \fIspecs\fP for them is used\&. This allows assignment of default
values to them before calling \fBzparseopts\fP\&.
.TP
\fB\-E\fP
This changes the parsing rules to \fInot\fP stop at the first string
that isn\&'t described by one of the \fIspec\fPs\&. It can be used to test
for or (if used together with \fB\-D\fP) extract options and their
arguments, ignoring all other options and arguments that may be in the
positional parameters\&.
.PP
For example,
.PP
.RS
.nf
\fBset \-\- \-a \-bx \-c y \-cz baz \-cend
zparseopts a=foo b:=bar c+:=bar\fP
.fi
.RE
.PP
will have the effect of
.PP
.RS
.nf
\fBfoo=(\-a)
bar=(\-b x \-c y \-c z)\fP
.fi
.RE
.PP
The arguments from `\fBbaz\fP\&' on will not be used\&.
.PP
As an example for the \fB\-E\fP option, consider:
.PP
.RS
.nf
\fBset \-\- \-a x \-b y \-c z arg1 arg2
zparseopts \-E \-D b:=bar\fP
.fi
.RE
.PP
will have the effect of
.PP
.RS
.nf
\fBbar=(\-b y)
set \-\- \-a x \-c z arg1 arg2\fP
.fi
.RE
.PP
I\&.e\&., the option \fB\-b\fP and its arguments are taken from the
positional parameters and put into the array \fBbar\fP\&.
.RE
.RE
|