1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614
|
Please review changes against upstream code using SCM,
see the Vcs-* tags in debian/control for its location.
--- mksh-59c.orig/Build.sh
+++ mksh-59c/Build.sh
@@ -1,9 +1,9 @@
#!/bin/sh
-srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.763 2020/09/04 21:01:37 tg Exp $'
+srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.767 2021/01/27 16:45:26 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019,
-# 2020
+# 2020, 2021
# mirabilos <m@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
@@ -499,6 +499,13 @@ x)
exit 1
;;
esac
+srcdisp=`cd "$srcdir" && pwd` || srcdisp=
+test_n "$srcdisp" || srcdisp=$srcdir
+if test x"$srcdisp" = x"$curdir"; then
+ srcdisp=
+else
+ srcdisp=$srcdir/
+fi
dstversion=`sed -n '/define MKSH_VERSION/s/^.*"\([^"]*\)".*$/\1/p' "$srcdir/sh.h"`
add_cppflags -DMKSH_BUILDSH
@@ -1368,6 +1375,7 @@ esac
etd=" on $et"
case $et in
klibc)
+ add_cppflags -DMKSH_NO_SIGSETJMP -D_setjmp=setjmp -D_longjmp=longjmp
: "${MKSH_UNLIMITED=1}"
;;
unknown)
@@ -2303,16 +2311,30 @@ ac_test sys_siglist_decl sys_siglist 0 '
int main(void) { return (sys_siglist[0][0] + isatty(0)); }
EOF
-ac_test st_mtim '' 'for struct stat.st_mtim.tv_nsec' <<-'EOF'
+ac_testn st_mtimensec '' 'for struct stat.st_mtimensec' <<-'EOF'
#define MKSH_INCLUDES_ONLY
#include "sh.h"
- int main(void) { struct stat sb; return (sizeof(sb.st_mtim.tv_nsec)); }
+ int main(void) { struct stat sb; return (sizeof(sb.st_mtimensec)); }
EOF
-ac_test st_mtimensec '!' st_mtim 0 'for struct stat.st_mtimensec' <<-'EOF'
+ac_testn st_mtimespec '!' st_mtimensec 0 'for struct stat.st_mtimespec.tv_nsec' <<-'EOF'
#define MKSH_INCLUDES_ONLY
#include "sh.h"
- int main(void) { struct stat sb; return (sizeof(sb.st_mtimensec)); }
+ int main(void) { struct stat sb; return (sizeof(sb.st_mtimespec.tv_nsec)); }
EOF
+if test 1 = "$HAVE_ST_MTIMESPEC"; then
+ add_cppflags -Dst_mtimensec=st_mtimespec.tv_nsec
+ HAVE_ST_MTIMENSEC=1
+fi
+ac_testn st_mtim '!' st_mtimensec 0 'for struct stat.st_mtim.tv_nsec' <<-'EOF'
+ #define MKSH_INCLUDES_ONLY
+ #include "sh.h"
+ int main(void) { struct stat sb; return (sizeof(sb.st_mtim.tv_nsec)); }
+EOF
+if test 1 = "$HAVE_ST_MTIM"; then
+ add_cppflags -Dst_mtimensec=st_mtim.tv_nsec
+ HAVE_ST_MTIMENSEC=1
+fi
+ac_cppflags ST_MTIMENSEC
#
# other checks
@@ -2491,7 +2513,7 @@ addsrcs USE_PRINTF_BUILTIN printf.c
addsrcs '!' MKSH_UNLIMITED ulimit.c
test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
-add_cppflags -DMKSH_BUILD_R=593
+add_cppflags -DMKSH_BUILD_R=599
$e $bi$me: Finished configuration testing, now producing output.$ao
@@ -2760,7 +2782,7 @@ $e Installing the shell:
$e "# $i -c -s -o root -g bin -m 555 $tfn /bin/$tfn"
if test $legacy = 0; then
$e "# grep -x /bin/$tfn /etc/shells >/dev/null || echo /bin/$tfn >>/etc/shells"
- $e "# $i -c -o root -g bin -m 444 dot.mkshrc /usr/share/doc/mksh/examples/"
+ $e "# $i -c -o root -g bin -m 444 ${srcdisp}dot.mkshrc /usr/share/doc/mksh/examples/"
fi
$e
$e Installing the manual:
@@ -2777,12 +2799,12 @@ if test -f mksh.cat1; then
"/usr/share/man/cat1/mksh.0"
$e or
fi
-$e "# $i -c -o root -g bin -m 444 lksh.1 mksh.1 /usr/share/man/man1/"
+$e "# $i -c -o root -g bin -m 444 ${srcdisp}lksh.1 ${srcdisp}mksh.1 /usr/share/man/man1/"
$e
$e Run the regression test suite: ./test.sh
-$e Please also read the sample file dot.mkshrc and the fine manual.
+$e Please also read the sample file ${srcdisp}dot.mkshrc and the fine manual.
test -f FAQ.htm || \
- $e Run FAQ2HTML.sh and place FAQ.htm into a suitable location as well.
+ $e Run ${srcdisp}FAQ2HTML.sh and place FAQ.htm into a suitable location as well.
exit 0
: <<'EOD'
--- mksh-59c.orig/FAQ2HTML.sh
+++ mksh-59c/FAQ2HTML.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-rcsid='$MirOS: src/bin/mksh/FAQ2HTML.sh,v 1.2 2020/10/31 04:17:36 tg Exp $'
+rcsid='$MirOS: src/bin/mksh/FAQ2HTML.sh,v 1.3 2021/06/15 01:09:43 tg Exp $'
#-
# Copyright © 2020
# mirabilos <m@mirbsd.org>
@@ -109,7 +109,7 @@ cat <<EOF
}
/*]]>*/--></style>
</head><body>
-<p>Note: Links marked like <a href="irc://chat.freenode.net/!/bin/mksh">this
+<p>Note: Links marked like <a href="irc://irc.mirbsd.org/!/bin/mksh">this
one to the mksh IRC channel</a> connect to external resources.</p>
<p>⚠ <b>Notice:</b> the website will have <a
href="http://www.mirbsd.org/mksh-faq.htm">the latest version of the
--- mksh-59c.orig/check.t
+++ mksh-59c/check.t
@@ -1,9 +1,9 @@
-# $MirOS: src/bin/mksh/check.t,v 1.853 2020/10/31 03:53:03 tg Exp $
+# $MirOS: src/bin/mksh/check.t,v 1.859 2021/01/24 19:41:07 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
-# 2019, 2020
+# 2019, 2020, 2021
# mirabilos <m@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
@@ -31,7 +31,7 @@
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
- KSH R59 2020/10/31
+ KSH R59 2021/07/10
description:
Check base version of full shell
stdin:
@@ -150,9 +150,8 @@ name: selftest-direct-builtin-call
description:
Check that direct builtin calls work
stdin:
- ln -s "$__progname" cat || cp "$__progname" cat
ln -s "$__progname" echo || cp "$__progname" echo
- ./echo -c 'echo foo' | ./cat -u
+ ./echo -c 'echo foo'
expected-stdout:
-c echo foo
---
@@ -4786,7 +4785,7 @@ description:
'emulate sh' zsh has extra fields in
- a5ins (IFS_NWS unquoted $*)
- b5ins, matching mksh’s
- !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888
+ !!WARNING!! more to come: https://www.austingroupbugs.net/view.php?id=888
stdin:
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
@@ -4936,7 +4935,7 @@ expected-stdout:
---
name: IFS-subst-8
description:
- http://austingroupbugs.net/view.php?id=221
+ https://www.austingroupbugs.net/view.php?id=221
stdin:
n() { echo "$#"; }; n "${foo-$@}"
expected-stdout:
@@ -4996,7 +4995,7 @@ expected-stdout:
---
name: IFS-arith-1
description:
- http://austingroupbugs.net/view.php?id=832
+ https://www.austingroupbugs.net/view.php?id=832
stdin:
${ZSH_VERSION+false} || emulate sh
${BASH_VERSION+set -o posix}
@@ -6184,7 +6183,7 @@ expected-stdout:
---
name: regression-35
description:
- Temporay files used for here-docs in functions get trashed after
+ Temporary files used for heredocs in functions get trashed after
the function is parsed (before it is executed)
stdin:
f1() {
@@ -6228,8 +6227,8 @@ description:
Machines with broken times() (reported by <sjg@void.zen.oz.au>)
time does not report correct real time
stdin:
- time sleep 1
-expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
+ time -p sleep 1
+expected-stderr-pattern: /^real +(?![0.]*$)[0-9]+(?:\.[0-9]+)?$/m
---
name: regression-38
description:
@@ -6799,19 +6798,6 @@ stdin:
time
}
---
-name: regression-65
-description:
- check for a regression with sleep builtin and signal mask
-category: !nojsig
-time-limit: 5
-stdin:
- sleep 1
- echo blub |&
- while read -p line; do :; done
- echo ok
-expected-stdout:
- ok
----
name: regression-66
description:
Check that quoting is sane
@@ -6971,7 +6957,7 @@ expected-stderr-pattern:
---
name: readonly-1
description:
- http://austingroupbugs.net/view.php?id=367 for export
+ https://www.austingroupbugs.net/view.php?id=367 for export
stdin:
"$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
expected-stdout:
@@ -6990,7 +6976,7 @@ expected-stdout:
---
name: readonly-2b
description:
- http://austingroupbugs.net/view.php?id=367 for getopts
+ https://www.austingroupbugs.net/view.php?id=367 for getopts
stdin:
"$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
expected-stdout:
@@ -7000,7 +6986,7 @@ expected-stderr-pattern:
---
name: readonly-3
description:
- http://austingroupbugs.net/view.php?id=367 for read
+ https://www.austingroupbugs.net/view.php?id=367 for read
stdin:
echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
@@ -7130,7 +7116,7 @@ expected-stdout:
---
name: xxx-exec-environment-1
description:
- Check to see if exec sets it's environment correctly
+ Check to see if exec sets its environment correctly
stdin:
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
@@ -7162,47 +7148,73 @@ expected-stdout:
y1-
x-3- z-
---
-name: exec-modern-korn-shell
+name: exec-execs
+description:
+ Ensure that exec never returns
+need-ctty: yes
+env-setup: !ENV=./envf!
+file-setup: file 644 "envf"
+ PS1=X
+arguments: !-i!
+stdin:
+ oldPATH=$PATH
+ PATH=$PWD
+ exec bla
+ PATH=$oldPATH
+ echo fail
+expected-stderr-pattern:
+ /X+.*: bla: (?:inaccessible or )?not found\n/
+expected-exit: 127
+---
+name: exec-modern
description:
Check that exec can execute any command that makes it
through syntax and parser
stdin:
- print '#!'"$__progname"'\necho tf' >lq
- chmod +x lq
+ echo '#!'"$__progname" >f
+ echo 'echo >&3 FAIL' >>f
+ echo '#!'"$__progname" >lq
+ echo 'echo tf' >>lq
+ chmod +x lq f
PATH=$PWD
- exec 2>&1
- foo() { print two; }
- print =1
- (exec print one)
- print =2
- (exec foo)
- print =3
- (exec ls)
- print =4
- (exec lq)
+ exec 3>&2 2>&1
+ foo() { echo two; }
+ echo =1
+ (exec echo one; ./f)
+ echo =2
+ (exec foo; ./f)
+ echo =3
+ (exec ls; ./f)
+ echo =4
+ (exec lq; ./f)
expected-stdout-pattern:
- /=1\none\n=2\ntwo\n=3\n.*: ls: inaccessible or not found\n=4\ntf\n/
+ /=1\none\n=2\ntwo\n=3\n.*: ls: (?:inaccessible or )?not found\n=4\ntf\n/
---
name: exec-ksh88
description:
Check that exec only executes after a PATH search
+ (POSIX Issue 8 uses utility ipv command for the synopsis)
+ cf. https://www.austingroupbugs.net/view.php?id=1157
arguments: !-o!posix!
stdin:
- print '#!'"$__progname"'\necho tf' >lq
- chmod +x lq
+ echo '#!'"$__progname" >f
+ echo 'echo >&3 FAIL' >>f
+ echo '#!'"$__progname" >lq
+ echo 'echo tf' >>lq
+ chmod +x lq f
PATH=$PWD
- exec 2>&1
- foo() { print two; }
- print =1
- (exec print one)
- print =2
- (exec foo)
- print =3
- (exec ls)
- print =4
- (exec lq)
+ exec 3>&2 2>&1
+ foo() { echo two; }
+ echo =1
+ (exec echo one; ./f)
+ echo =2
+ (exec foo; ./f)
+ echo =3
+ (exec ls; ./f)
+ echo =4
+ (exec lq; ./f)
expected-stdout-pattern:
- /=1\n.*: print: inaccessible or not found\n=2\n.*: foo: inaccessible or not found\n=3\n.*: ls: inaccessible or not found\n=4\ntf\n/
+ /=1\n.*: echo: (?:inaccessible or )?not found\n=2\n.*: foo: (?:inaccessible or )?not found\n=3\n.*: ls: (?:inaccessible or )?not found\n=4\ntf\n/
---
name: xxx-what-do-you-call-this-1
stdin:
@@ -7339,7 +7351,7 @@ need-ctty: yes
arguments: !-i!
stdin:
exec echo hi
- echo still herre
+ echo still here
expected-stdout:
hi
expected-stderr-pattern: /.*/
@@ -7884,6 +7896,77 @@ expected-stdout:
G 12
H 0
---
+name: exit-stdout-1
+description:
+ cf. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990265, Austin ML
+stdin:
+ if test -c /dev/full && test -w /dev/full; then
+ if pwd >/dev/full 2>e; then
+ cat e
+ echo fail
+ else
+ echo pass
+ fi
+ else
+ echo skip
+ fi
+ case " $(echo $( (set -o posix) >/dev/null 2>&1 && set -o posix >/dev/null 2>&1; kill -l)) " in
+ (*' PIPE '*)
+ :>s
+ { trap '' PIPE; sleep 1; pwd 2>e; echo $? >s; } | :
+ case x$(cat s) in
+ (x)
+ cat e
+ echo fail else ;;
+ (x0)
+ cat e
+ echo fail 0 ;;
+ (*)
+ echo pass ;;
+ esac
+ ;;
+ (*)
+ echo skip ;;
+ esac
+expected-stdout-pattern:
+ /^(pass|skip)\n(pass|skip)\n$/
+---
+name: exit-stdout-2
+description:
+ same, except for external utility / direct builtin call
+stdin:
+ ln -s "$__progname" pwd || cp "$__progname" pwd
+ if test -c /dev/full && test -w /dev/full; then
+ if ./pwd >/dev/full 2>e; then
+ cat e
+ echo fail
+ else
+ echo pass
+ fi
+ else
+ echo skip
+ fi
+ case " $(echo $( (set -o posix) >/dev/null 2>&1 && set -o posix >/dev/null 2>&1; kill -l)) " in
+ (*' PIPE '*)
+ :>s
+ { trap '' PIPE; sleep 1; ./pwd 2>e; echo $? >s; } | :
+ case x$(cat s) in
+ (x)
+ cat e
+ echo fail else ;;
+ (x0)
+ cat e
+ echo fail 0 ;;
+ (*)
+ echo pass ;;
+ esac
+ ;;
+ (*)
+ echo skip ;;
+ esac
+expected-stdout-pattern:
+ /^(pass|skip)\n(pass|skip)\n$/
+---
name: exit-trap-1
description:
Check that "exit" with no arguments behaves SUSv4 conformant.
@@ -8878,7 +8961,7 @@ expected-stderr-pattern:
---
name: utf8opt-1
description:
- Check that the utf8-mode flag is not set at non-interactive startup
+ Check that the utf8-mode flag *is* set at non-interactive startup
env-setup: !PS1=!PS2=!LC_CTYPE=@utflocale@!
stdin:
if [[ $- = *U* ]]; then
@@ -8887,7 +8970,7 @@ stdin:
echo is not set
fi
expected-stdout:
- is not set
+ is set
---
name: utf8opt-2
description:
@@ -9921,13 +10004,19 @@ stdin:
print -r -- "s=\"$s\""
eval "$s"
typeset -p u v w
+ set -o asis
+ typeset -p w
+ set -U
+ typeset -p w
expected-stdout:
<i=x j=a b k=c
de€f>
- s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
+ s="u=x v='a b' w=$'c\nde\202f'"
typeset u=x
typeset v='a b'
- typeset w=$'c\nd\240e\u20ACf'
+ typeset w=$'c\nde\202f'
+ typeset w=$'c\nde€f'
+ typeset w=$'c\nd\240e€f'
---
name: varexpand-special-quote-faux-EBCDIC
description:
@@ -13218,6 +13307,41 @@ expected-stdout:
2=\x7Cfoo-e \x4B
3=\x7Cfoo-e \x4B
---
+name: env-intvars
+description:
+ Check that importing integers fails except for numbers
+stdin:
+ unset foo bar
+ print 1 $foo , $(typeset -p bar) .
+ print 2 $(foo=123 "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
+ $(env 'bar[123]=baz' "$__progname" -c 'typeset -p bar') .
+ print 3 $(foo='abc[$(echo >&2 fowled)0]' "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
+ $(env 'bar[$(echo >&2 fowled)0]=baz' "$__progname" -c 'typeset -p bar') .
+ print 4 $(foo=0123 "$__progname" +o posix -c 'integer foo; print -- $foo' 2>&1) , \
+ $(env 'bar[0123]=baz' "$__progname" +o posix -c 'typeset -p bar') .
+ # ksh93 does not do this:
+ print 5 $(foo=0123 "$__progname" -o posix -c 'integer foo; print -- $foo' 2>&1) .
+ # at import time FPOSIX is not yet set
+ print 6 $(foo=0x123 "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
+ $(env 'bar[0x123]=baz' "$__progname" -c 'typeset -p bar') .
+ print 7 $(foo=12#123 "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
+ $(env 'bar[12#123]=baz' "$__progname" -c 'typeset -p bar') .
+ print 8 $(foo=1+1 "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
+ $(env 'bar[1+1]=baz' "$__progname" -c 'typeset -p bar') .
+ print 9 $(a=1 b=2 c=a "$__progname" -c 'typeset -p c; c=b; typeset -p c; integer c; typeset -p c') .
+ print 0 $(a=1 b=2 c=a "$__progname" -c 'typeset -p c; typeset -p c; integer c; typeset -p c') .
+expected-stdout:
+ 1 , .
+ 2 123 , set -A bar typeset -x bar[123]=baz .
+ 3 0 , .
+ 4 123 , set -A bar typeset -x bar[123]=baz .
+ 5 8#123 .
+ 6 16#123 , .
+ 7 12#123 , .
+ 8 0 , .
+ 9 typeset -x c=a typeset -x c=b typeset -i -x c=2 .
+ 0 typeset -x c=a typeset -x c=a typeset -i -x c=0 .
+---
name: utilities-getopts-1
description:
getopts sets OPTIND correctly for unparsed option
@@ -13740,8 +13864,14 @@ stdin:
done
s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
typeset -p s
+ set -o asis
+ typeset -p s
+ set -U
+ typeset -p s
expected-stdout:
- typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\u00A0\u20AC\uFFFD\357\277\276\357\277\277\360\220\200\200.'
+ typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237 \202�\220\200\200.'
+ typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177 €�𐀀.'
+ typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377 €�\357\277\276\357\277\277\360\220\200\200.'
---
name: duffs-device-ebcdic
description:
--- mksh-59c.orig/dot.mkshrc
+++ mksh-59c/dot.mkshrc
@@ -1,9 +1,9 @@
# $Id$
-# $MirOS: src/bin/mksh/dot.mkshrc,v 1.128 2020/04/13 18:39:03 tg Exp $
+# $MirOS: src/bin/mksh/dot.mkshrc,v 1.136 2021/01/24 20:38:30 tg Exp $
#-
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019,
-# 2020
+# 2020, 2021
# mirabilos <m@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
@@ -38,24 +38,51 @@ function setenv {
fi
}
+# internal helper function to cat all arguments if necessary
+function _dot_mkshrc_wrapped_cat {
+ \\builtin typeset fn=$1
+ \\builtin shift
+
+ if [[ $# = 0 || $#,$1 = 1,- ]]; then
+ "$fn"
+ else
+ \cat "$@" | "$fn"
+ fi
+}
+function _dot_mkshrc_cat_for_readN {
+ \\builtin typeset fn=$1
+ \\builtin shift
+
+ if (( $# )); then
+ \\builtin print -nr -- "$*" | "$fn"
+ elif [[ -t 0 ]]; then
+ \cat | "$fn"
+ else
+ "$fn"
+ fi
+}
+
# pager (not control character safe)
-smores() (
- \\builtin set +m
- \\builtin cat "$@" |&
- \\builtin trap "rv=\$?; \\\\builtin kill $! >/dev/null 2>&1; \\\\builtin exit \$rv" EXIT
- while IFS= \\builtin read -pr line; do
+function smores {
+ \_dot_mkshrc_wrapped_cat _dot_mkshrc_smores "$@"
+}
+function _dot_mkshrc_smores {
+ \\builtin set +e
+ \\builtin typeset line llen curlin=0 x
+
+ while IFS= \\builtin read -r line; do
llen=${%line}
- (( llen == -1 )) && llen=${#line}
+ (( llen != -1 )) || llen=${#line}
(( llen = llen ? (llen + COLUMNS - 1) / COLUMNS : 1 ))
if (( (curlin += llen) >= LINES )); then
\\builtin print -nr -- $'\e[7m--more--\e[0m'
- \\builtin read -u1 || \\builtin exit $?
- [[ $REPLY = [Qq]* ]] && \\builtin exit 0
+ \\builtin read -u1 x || \\builtin return $?
+ [[ $x != [Qq]* ]] || \\builtin return 0
curlin=$llen
fi
\\builtin print -r -- "$line"
done
-)
+}
# customise your favourite editor here; the first one found is used
for EDITOR in "${EDITOR:-}" jupp jstar mcedit ed vi; do
@@ -82,10 +109,10 @@ fi
# prompts
PS4='[$EPOCHREALTIME] '; PS1='#'; (( USER_ID )) && PS1='$'; PS1=$'\001\r''${|
- \\builtin typeset e=$?
+ \\builtin typeset e=$? hn=${HOSTNAME:-nil}
- (( e )) && REPLY+="$e|"
- REPLY+=${USER}@${HOSTNAME%%.*}:
+ (( !!e )) || REPLY+="$e|"
+ REPLY+=${USER:-?}@${hn%%.*}:
\\builtin typeset d=${PWD:-?}/ p=~; [[ $p = ?(*/) ]] || d=${d/#$p\//\~/}
d=${d%/}; \\builtin typeset m=${%d} n p=...; (( m > 0 )) || m=${#d}
@@ -104,12 +131,13 @@ if \\builtin command -v hd >/dev/null; t
\:
elif \\builtin command -v hexdump >/dev/null; then
function hd {
- hexdump -e '"%08.8_ax " 8/1 "%02X " " - " 8/1 "%02X "' \
+ \hexdump -e '"%08.8_ax " 8/1 "%02X " " - " 8/1 "%02X "' \
-e '" |" "%_p"' -e '"|\n"' "$@"
}
else
function hd {
- \\builtin cat "$@" | hd_mksh
+ # cannot use _dot_mkshrc_wrapped_cat as hd_mksh sets stdin raw
+ \cat "$@" | \hd_mksh
}
fi
@@ -118,7 +146,7 @@ function hd_mksh {
\\builtin typeset -Uui16 -Z11 pos=0
\\builtin typeset -Uui16 -Z5 hv=2147483647
\\builtin typeset dasc dn line i
- \\builtin set +U
+ \\builtin set +Ue
while \\builtin read -arn 512 line; do
\\builtin typeset -i1 'line[*]'
@@ -219,6 +247,7 @@ function cd_csh {
\cd "$t"
}
function dirs {
+ \\builtin set +e
\\builtin typeset d dwidth
\\builtin typeset -i fl=0 fv=0 fn=0 cpos=0
@@ -343,9 +372,17 @@ function pushd {
# base64 encoder and decoder, RFC compliant, NUL safe, not EBCDIC safe
function Lb64decode {
- \\builtin set +U
- \\builtin typeset c s="$*" t
- [[ -n $s ]] || { s=$(\\builtin cat; \\builtin print x); s=${s%x}; }
+ \\builtin set +Ue
+ \\builtin typeset c s t
+ if (( $# )); then
+ s="$*"
+ elif [[ -t 0 ]]; then
+ s=$(\cat || \\builtin exit $?; \\builtin print x) || \
+ \\builtin return $?
+ s=${s%x}
+ else
+ \\builtin read -rN-1 s || \\builtin return $?
+ fi
\\builtin typeset -i i=0 j=0 n=${#s} p=0 v x
\\builtin typeset -i16 o
@@ -371,22 +408,20 @@ function Lb64decode {
}
t+=\\x${o#16#}
(( ++j & 4095 )) && \\builtin continue
- \\builtin print -n $t
+ \\builtin print -n -- "$t"
t=
done
- \\builtin print -n $t
+ \\builtin print -n -- "$t"
}
function Lb64encode {
- \\builtin set +U
+ \_dot_mkshrc_cat_for_readN _dot_mkshrc_b64encode "$@"
+}
+function _dot_mkshrc_b64encode {
+ \\builtin set +Ue
\\builtin typeset c s t table
\\builtin set -A table -- A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \
a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 + /
- if (( $# )); then
- \\builtin read -raN-1 s <<<"$*"
- \\builtin unset s[${#s[*]}-1]
- else
- \\builtin read -raN-1 s
- fi
+ \\builtin read -raN-1 s || \\builtin return $?
\\builtin typeset -i i=0 n=${#s[*]} v
while (( i < n )); do
@@ -403,10 +438,11 @@ function Lb64encode {
t+===
fi
if (( ${#t} == 76 || i >= n )); then
- \\builtin print -r $t
+ \\builtin print -r -- "$t"
t=
fi
done
+ \:
}
# Better Avalanche for the Jenkins Hash
@@ -415,22 +451,22 @@ function Lbafh_init {
Lbafh_v=0
}
function Lbafh_add {
- \\builtin set +U
+ \_dot_mkshrc_cat_for_readN _dot_mkshrc_bafh_add "$@"
+}
+function _dot_mkshrc_bafh_add {
+ \\builtin set +Ue
\\builtin typeset s
- if (( $# )); then
- \\builtin read -raN-1 s <<<"$*"
- \\builtin unset s[${#s[*]}-1]
- else
- \\builtin read -raN-1 s
- fi
+ \\builtin read -raN-1 s || \\builtin return $?
\\builtin typeset -i i=0 n=${#s[*]}
while (( i < n )); do
((# Lbafh_v = (Lbafh_v + s[i++] + 1) * 1025 ))
((# Lbafh_v ^= Lbafh_v >> 6 ))
done
+ \:
}
function Lbafh_finish {
+ \\builtin set +e
\\builtin typeset -Ui t
((# t = (((Lbafh_v >> 7) & 0x01010101) * 0x1B) ^ \
@@ -443,11 +479,20 @@ function Lbafh_finish {
# strip comments (and leading/trailing whitespace if IFS is set) from
# any file(s) given as argument, or stdin if none, and spew to stdout
function Lstripcom {
+ \_dot_mkshrc_wrapped_cat _dot_mkshrc_stripcom "$@"
+}
+function _dot_mkshrc_stripcom {
+ \\builtin typeset line x
\\builtin set -o noglob
- \\builtin cat "$@" | while \\builtin read _line; do
- _line=${_line%%#*}
- [[ -n $_line ]] && \\builtin print -r -- $_line
+ while \\builtin read -r line; do
+ while [[ $line = *\\ && $line != *'#'* ]] && \
+ \\builtin read -r x; do
+ line=${line%\\}$x
+ done
+ line=${line%%#*}
+ [[ -z $line ]] || \\builtin print -r -- $line
done
+ \:
}
# toggle built-in aliases and utilities, and aliases and functions from mkshrc
@@ -479,7 +524,6 @@ function enable {
i_func[nfunc++]=break
# \\builtin cannot, by design, be overridden
i_func[nfunc++]=builtin
- i_func[nfunc++]=cat
i_func[nfunc++]=cd
i_func[nfunc++]=chdir
i_func[nfunc++]=command
@@ -522,8 +566,6 @@ function enable {
i_func[nfunc++]=bind
i_func[nfunc++]=mknod
i_func[nfunc++]=printf
- i_func[nfunc++]=sleep
- i_func[nfunc++]=domainname
i_func[nfunc++]=extproc
# accumulate aliases from dot.mkshrc, in definition order
@@ -585,7 +627,7 @@ function enable {
(*)
\\builtin print -ru2 enable: usage: \
"enable [-adnps] [-f filename] [name ...]"
- return 2
+ \\builtin return 2
;;
}
done
--- mksh-59c.orig/edit.c
+++ mksh-59c/edit.c
@@ -6,7 +6,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
- * 2019, 2020
+ * 2019, 2020, 2021
* mirabilos <m@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@@ -29,7 +29,7 @@
#ifndef MKSH_NO_CMDLINE_EDITING
-__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.357 2020/10/31 05:02:17 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.362 2021/02/26 11:51:07 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@@ -74,6 +74,7 @@ static struct {
#define XCF_COMMAND_FILE (XCF_COMMAND | XCF_FILE)
#define XCF_IS_COMMAND BIT(3) /* return flag: is command */
#define XCF_IS_NOSPACE BIT(4) /* return flag: do not append a space */
+#define XCF_IS_HOMEDIR BIT(5) /* return flag: tilde needs slash */
static char editmode;
static int xx_cols; /* for Emacs mode */
@@ -92,7 +93,7 @@ static int x_do_comment(char *, ssize_t,
static void x_print_expansions(int, char * const *, bool);
static int x_cf_glob(int *, const char *, int, int, int *, int *, char ***);
static size_t x_longest_prefix(int, char * const *);
-static void x_glob_hlp_add_qchar(char *);
+static char *x_glob_hlp_add_qchar(char *);
static char *x_glob_hlp_tilde_and_rem_qchar(char *, bool);
static size_t x_basename(const char *, const char *);
static void x_free_words(int, char **);
@@ -103,6 +104,7 @@ static void x_init_prompt(bool);
static int x_vi(char *);
#endif
static void x_intr(int, int) MKSH_A_NORETURN;
+static void x_clrtoeol(int, bool);
#define x_flush() shf_flush(shl_out)
#if defined(MKSH_SMALL) && !defined(MKSH_SMALL_BUT_FAST)
@@ -296,21 +298,32 @@ x_print_expansions(int nwords, char * co
/*
* Convert backslash-escaped string to QCHAR-escaped
- * string useful for globbing; loses QCHAR unless it
- * can squeeze in, eg. by previous loss of backslash
+ * string useful for globbing
*/
-static void
+static char *
x_glob_hlp_add_qchar(char *cp)
{
- char ch, *dp = cp;
+ char ch, *dp;
bool escaping = false;
+ XString xs;
+ size_t n;
+
+ if (memchr(cp, QCHAR, (n = strlen(cp)))) {
+ Xinit(xs, dp, n, ATEMP);
+ } else {
+ xs.len = n + 1;
+ xs.areap = NULL; /* won’t be used */
+ xs.beg = dp = cp;
+ xs.end = xs.beg + xs.len;
+ }
while ((ch = *cp++)) {
if (ch == '\\' && !escaping) {
escaping = true;
continue;
}
- if (escaping || (ch == QCHAR && (cp - dp) > 1)) {
+ XcheckN(xs, dp, 2);
+ if (escaping || ch == QCHAR) {
/*
* empirically made list of chars to escape
* for globbing as well as QCHAR itself
@@ -323,6 +336,7 @@ x_glob_hlp_add_qchar(char *cp)
case ORD('['):
case ORD('\\'):
case ORD('`'):
+ case ORD('~'):
*dp++ = QCHAR;
break;
}
@@ -331,6 +345,7 @@ x_glob_hlp_add_qchar(char *cp)
*dp++ = ch;
}
*dp = '\0';
+ return (Xstring(xs, dp));
}
/*
@@ -366,8 +381,12 @@ x_glob_hlp_tilde_and_rem_qchar(char *s,
}
/* ... convert it from backslash-escaped via QCHAR-escaped... */
- if (magic_flag)
- x_glob_hlp_add_qchar(s);
+ if (magic_flag) {
+ cp = x_glob_hlp_add_qchar(s);
+ if (cp != s)
+ afree(s, ATEMP);
+ s = cp;
+ }
/* ... to unescaped, for comparison with the matches */
cp = dp = s;
@@ -390,25 +409,26 @@ x_glob_hlp_tilde_and_rem_qchar(char *s,
static int
x_file_glob(int *flagsp, char *toglob, char ***wordsp)
{
- char **words, *cp;
+ char **words, *cp, *qglob;
int nwords;
XPtrV w;
struct source *s, *sold;
/* remove all escaping backward slashes */
- x_glob_hlp_add_qchar(toglob);
+ qglob = x_glob_hlp_add_qchar(toglob);
/*
* Convert "foo*" (toglob) to an array of strings (words)
*/
sold = source;
s = pushs(SWSTR, ATEMP);
- s->start = s->str = toglob;
+ s->start = s->str = qglob;
source = s;
if (yylex(ONEWORD | LQCHAR) != LWORD) {
source = sold;
internal_warningf(Tfg_badsubst);
- return (0);
+ nwords = 0;
+ goto out;
}
source = sold;
afree(s, ATEMP);
@@ -433,7 +453,7 @@ x_file_glob(int *flagsp, char *toglob, c
struct stat statb;
/* Expand any tilde and drop all QCHAR for comparison */
- toglob = x_glob_hlp_tilde_and_rem_qchar(toglob, false);
+ qglob = x_glob_hlp_tilde_and_rem_qchar(qglob, false);
/*
* Check if globbing failed (returned glob pattern),
@@ -443,7 +463,7 @@ x_file_glob(int *flagsp, char *toglob, c
* to glob something which evaluated to an empty
* string (e.g., "$FOO" when there is no FOO, etc).
*/
- if ((strcmp(words[0], toglob) == 0 &&
+ if ((strcmp(words[0], qglob) == 0 &&
stat(words[0], &statb) < 0) ||
words[0][0] == '\0') {
x_free_words(nwords, words);
@@ -455,6 +475,9 @@ x_file_glob(int *flagsp, char *toglob, c
if ((*wordsp = nwords ? words : NULL) == NULL && words != NULL)
x_free_words(nwords, words);
+ out:
+ if (qglob != toglob)
+ afree(qglob, ATEMP);
return (nwords);
}
@@ -670,7 +693,7 @@ x_cf_glob(int *flagsp, const char *buf,
if (*toglob == '~' && /* not vdirsep */ !vstrchr(toglob, '/')) {
/* neither for '~foo' (but '~foo/bar') */
- *flagsp |= XCF_IS_NOSPACE;
+ *flagsp |= XCF_IS_HOMEDIR;
goto dont_add_glob;
}
@@ -982,8 +1005,8 @@ static int x_col; /* current column on
static int x_ins(const char *);
static void x_delete(size_t, bool);
-static size_t x_bword(void);
-static size_t x_fword(bool);
+static void x_bword(uint32_t, bool);
+static void x_fword(uint32_t, bool);
static void x_goto(char *);
static char *x_bs0(char *, char *) MKSH_A_PURE;
static void x_bs3(char **);
@@ -1006,7 +1029,7 @@ static void x_e_putc2(int);
static void x_e_putc3(const char **);
static void x_e_puts(const char *);
#ifndef MKSH_SMALL
-static int x_fold_case(int);
+static int x_fold_case(int, uint32_t);
#endif
static char *x_lastcp(void);
static void x_lastpos(void);
@@ -1042,6 +1065,12 @@ static struct x_defbindings const x_defb
{ XFUNC_mv_bword, 1, 'b' },
{ XFUNC_mv_fword, 1, 'f' },
{ XFUNC_del_fword, 1, 'd' },
+#ifndef MKSH_SMALL
+ { XFUNC_del_bbigword, 1, 'H' },
+ { XFUNC_mv_bbigword, 1, 'B' },
+ { XFUNC_mv_fbigword, 1, 'F' },
+ { XFUNC_del_fbigword, 1, 'D' },
+#endif
{ XFUNC_mv_back, 0, CTRL_B },
{ XFUNC_mv_forw, 0, CTRL_F },
{ XFUNC_search_char_forw, 0, CTRL_BC },
@@ -1096,11 +1125,11 @@ static struct x_defbindings const x_defb
{ XFUNC_set_arg, 1, '8' },
{ XFUNC_set_arg, 1, '9' },
#ifndef MKSH_SMALL
- { XFUNC_fold_upper, 1, 'U' },
+ { XFUNC_foldb_upper, 1, 'U' },
{ XFUNC_fold_upper, 1, 'u' },
- { XFUNC_fold_lower, 1, 'L' },
+ { XFUNC_foldb_lower, 1, 'L' },
{ XFUNC_fold_lower, 1, 'l' },
- { XFUNC_fold_capitalise, 1, 'C' },
+ { XFUNC_foldb_capitalise, 1, 'C' },
{ XFUNC_fold_capitalise, 1, 'c' },
#endif
/*
@@ -1524,75 +1553,105 @@ x_delete(size_t nc, bool push)
static int
x_del_bword(int c MKSH_A_UNUSED)
{
- x_delete(x_bword(), true);
+ x_bword(C_MFS, true);
return (KSTD);
}
static int
x_mv_bword(int c MKSH_A_UNUSED)
{
- x_bword();
+ x_bword(C_MFS, false);
return (KSTD);
}
static int
x_mv_fword(int c MKSH_A_UNUSED)
{
- x_fword(true);
+ x_fword(C_MFS, false);
return (KSTD);
}
static int
x_del_fword(int c MKSH_A_UNUSED)
{
- x_delete(x_fword(false), true);
+ x_fword(C_MFS, true);
return (KSTD);
}
-static size_t
-x_bword(void)
+#ifndef MKSH_SMALL
+static int
+x_del_bbigword(int c MKSH_A_UNUSED)
+{
+ x_bword(C_BLANK, true);
+ return (KSTD);
+}
+
+static int
+x_mv_bbigword(int c MKSH_A_UNUSED)
+{
+ x_bword(C_BLANK, false);
+ return (KSTD);
+}
+
+static int
+x_mv_fbigword(int c MKSH_A_UNUSED)
+{
+ x_fword(C_BLANK, false);
+ return (KSTD);
+}
+
+static int
+x_del_fbigword(int c MKSH_A_UNUSED)
+{
+ x_fword(C_BLANK, true);
+ return (KSTD);
+}
+#endif
+
+static void
+x_bword(uint32_t separator, bool erase)
{
size_t nb = 0;
char *cp = xcp;
if (cp == xbuf) {
x_e_putc2(KSH_BEL);
- return (0);
+ return;
}
while (x_arg--) {
- while (cp != xbuf && ctype(cp[-1], C_MFS)) {
+ while (cp != xbuf && ctype(cp[-1], separator)) {
cp--;
nb++;
}
- while (cp != xbuf && !ctype(cp[-1], C_MFS)) {
+ while (cp != xbuf && !ctype(cp[-1], separator)) {
cp--;
nb++;
}
}
x_goto(cp);
- return (x_nb2nc(nb));
+ if (erase)
+ x_delete(x_nb2nc(nb), true);
}
-static size_t
-x_fword(bool move)
+static void
+x_fword(uint32_t separator, bool erase)
{
- size_t nc;
char *cp = xcp;
if (cp == xep) {
x_e_putc2(KSH_BEL);
- return (0);
+ return;
}
while (x_arg--) {
- while (cp != xep && ctype(*cp, C_MFS))
+ while (cp != xep && ctype(*cp, separator))
cp++;
- while (cp != xep && !ctype(*cp, C_MFS))
+ while (cp != xep && !ctype(*cp, separator))
cp++;
}
- nc = x_nb2nc(cp - xcp);
- if (move)
+ if (erase)
+ x_delete(x_nb2nc(cp - xcp), true);
+ else
x_goto(cp);
- return (nc);
}
static void
@@ -1618,7 +1677,7 @@ static char *
x_bs0(char *cp, char *lower_bound)
{
if (UTFMODE)
- while ((!lower_bound || (cp > lower_bound)) &&
+ while ((cp > lower_bound) &&
((rtt2asc(*cp) & 0xC0) == 0x80))
--cp;
return (cp);
@@ -1629,7 +1688,7 @@ x_bs3(char **p)
{
int i;
- *p = x_bs0((*p) - 1, NULL);
+ *p = x_bs0((*p) - 1, xbuf);
i = x_size2(*p, NULL);
while (i--)
x_e_putc2('\b');
@@ -1784,10 +1843,11 @@ x_newline(int c MKSH_A_UNUSED)
static int
x_end_of_text(int c MKSH_A_UNUSED)
{
- unsigned char tmp[1], *cp = tmp;
+ unsigned char tmp[2], *cp = tmp;
*tmp = isedchar(edchars.eof) ? (unsigned char)edchars.eof :
(unsigned char)CTRL_D;
+ tmp[1] = '\0';
x_zotc3((char **)&cp);
x_putc('\r');
x_putc('\n');
@@ -2035,7 +2095,7 @@ x_match(const char *str, const char *pat
if (*pat == '^') {
return ((strncmp(str, pat + 1, strlen(pat + 1)) == 0) ? 0 : -1);
} else {
- char *q = strstr(str, pat);
+ const char *q = cstrstr(str, pat);
return ((q == NULL) ? -1 : q - str);
}
}
@@ -2079,6 +2139,11 @@ static int
x_cls(int c MKSH_A_UNUSED)
{
shf_puts(MKSH_CLS_STRING, shl_out);
+ if (prompt_trunc) {
+ /* multi-line prompt */
+ pprompt(prompt, 0);
+ /* x_redraw takes care of the last line */
+ }
x_redraw(0);
return (KSTD);
}
@@ -2094,12 +2159,14 @@ x_clrtoeol(int lastch, bool line_was_cle
{
int col;
- if (lastch == ' ' && !line_was_cleared && x_term_mode == 1) {
- shf_puts(KSH_ESC_STRING "[K", shl_out);
- line_was_cleared = true;
+ if (lastch == ' ') {
+ if (line_was_cleared)
+ return;
+ if (x_term_mode == 1) {
+ shf_puts(KSH_ESC_STRING "[K", shl_out);
+ return;
+ }
}
- if (lastch == ' ' && line_was_cleared)
- return;
col = x_col;
while (col < (xx_cols - 2)) {
@@ -2840,11 +2907,13 @@ do_complete(
x_adjust();
/*
* append a space if this is a single non-directory match
- * and not a parameter or homedir substitution
+ * and not a parameter substitution, slash for homedir
*/
- if (nwords == 1 && !mksh_cdirsep(words[0][nlen - 1]) &&
- !(flags & XCF_IS_NOSPACE)) {
- x_ins(T1space);
+ if (nwords == 1 && !mksh_cdirsep(words[0][nlen - 1])) {
+ if (flags & XCF_IS_HOMEDIR)
+ x_ins("/");
+ else if (!(flags & XCF_IS_NOSPACE))
+ x_ins(T1space);
}
x_free_words(nwords, words);
@@ -3149,12 +3218,12 @@ x_edit_line(int c MKSH_A_UNUSED)
/*-
* NAME:
- * x_prev_histword - recover word from prev command
+ * x_prev_histword - recover bigword from prev command
*
* DESCRIPTION:
- * This function recovers the last word from the previous
+ * This function recovers the last bigword from the previous
* command and inserts it into the current edit line. If a
- * numeric arg is supplied then the n'th word from the
+ * numeric arg is supplied then the n'th bigword from the
* start of the previous command is used.
* As a side effect, trashes the mark in order to achieve
* being called in a repeatable fashion.
@@ -3192,13 +3261,13 @@ x_prev_histword(int c MKSH_A_UNUSED)
rcp = &cp[strlen(cp) - 1];
/*
- * ignore white-space after the last word
+ * ignore whitespace after the last bigword
*/
- while (rcp > cp && ctype(*rcp, C_CFS))
+ while (rcp > cp && ctype(*rcp, C_BLANK))
rcp--;
- while (rcp > cp && !ctype(*rcp, C_CFS))
+ while (rcp > cp && !ctype(*rcp, C_BLANK))
rcp--;
- if (ctype(*rcp, C_CFS))
+ if (ctype(*rcp, C_BLANK))
rcp++;
x_ins(rcp);
} else {
@@ -3207,18 +3276,18 @@ x_prev_histword(int c MKSH_A_UNUSED)
rcp = cp;
/*
- * ignore white-space at start of line
+ * ignore whitespace at start of line
*/
- while (*rcp && ctype(*rcp, C_CFS))
+ while (*rcp && ctype(*rcp, C_BLANK))
rcp++;
while (x_arg-- > 0) {
- while (*rcp && !ctype(*rcp, C_CFS))
+ while (*rcp && !ctype(*rcp, C_BLANK))
rcp++;
- while (*rcp && ctype(*rcp, C_CFS))
+ while (*rcp && ctype(*rcp, C_BLANK))
rcp++;
}
cp = rcp;
- while (*rcp && !ctype(*rcp, C_CFS))
+ while (*rcp && !ctype(*rcp, C_BLANK))
rcp++;
ch = *rcp;
*rcp = '\0';
@@ -3236,21 +3305,42 @@ x_prev_histword(int c MKSH_A_UNUSED)
static int
x_fold_upper(int c MKSH_A_UNUSED)
{
- return (x_fold_case('U'));
+ return (x_fold_case('U', C_MFS));
}
/* Lowercase N(1) words */
static int
x_fold_lower(int c MKSH_A_UNUSED)
{
- return (x_fold_case('L'));
+ return (x_fold_case('L', C_MFS));
}
/* Titlecase N(1) words */
static int
x_fold_capitalise(int c MKSH_A_UNUSED)
{
- return (x_fold_case('C'));
+ return (x_fold_case('C', C_MFS));
+}
+
+/* Uppercase N(1) bigwords */
+static int
+x_foldb_upper(int c MKSH_A_UNUSED)
+{
+ return (x_fold_case('U', C_BLANK));
+}
+
+/* Lowercase N(1) bigwords */
+static int
+x_foldb_lower(int c MKSH_A_UNUSED)
+{
+ return (x_fold_case('L', C_BLANK));
+}
+
+/* Titlecase N(1) bigwords */
+static int
+x_foldb_capitalise(int c MKSH_A_UNUSED)
+{
+ return (x_fold_case('C', C_BLANK));
}
/*-
@@ -3259,13 +3349,13 @@ x_fold_capitalise(int c MKSH_A_UNUSED)
*
* DESCRIPTION:
* This function is used to implement M-U/M-u, M-L/M-l, M-C/M-c
- * to UPPER CASE, lower case or Capitalise Words.
+ * to UPPER CASE, lower case or Capitalise words and bigwords.
*
* RETURN VALUE:
* None
*/
static int
-x_fold_case(int c)
+x_fold_case(int c, uint32_t separator)
{
char *cp = xcp;
@@ -3277,7 +3367,7 @@ x_fold_case(int c)
/*
* first skip over any white-space
*/
- while (cp != xep && ctype(*cp, C_MFS))
+ while (cp != xep && ctype(*cp, separator))
cp++;
/*
* do the first char on its own since it may be
@@ -3295,7 +3385,7 @@ x_fold_case(int c)
/*
* now for the rest of the word
*/
- while (cp != xep && !ctype(*cp, C_MFS)) {
+ while (cp != xep && !ctype(*cp, separator)) {
if (c == 'U')
/* uppercase */
*cp = ksh_toupper(*cp);
@@ -5471,11 +5561,14 @@ complete_word(int cmd, int count)
/*
* append a space if this is a non-directory match
- * and not a parameter or homedir substitution
+ * and not a parameter substitution, slash for homedir
*/
- if (match_len > 0 && !mksh_cdirsep(match[match_len - 1]) &&
- !(flags & XCF_IS_NOSPACE))
- rval = putbuf(T1space, 1, false);
+ if (match_len > 0 && !mksh_cdirsep(match[match_len - 1])) {
+ if (flags & XCF_IS_HOMEDIR)
+ rval = putbuf("/", 1, false);
+ else if (!(flags & XCF_IS_NOSPACE))
+ rval = putbuf(T1space, 1, false);
+ }
}
x_free_words(nwords, words);
--- mksh-59c.orig/emacsfn.h
+++ mksh-59c/emacsfn.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2009, 2010, 2015, 2016, 2020
+ * Copyright (c) 2009, 2010, 2015, 2016, 2020, 2021
* mirabilos <m@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@@ -19,7 +19,7 @@
*/
#if defined(EMACSFN_DEFNS)
-__RCSID("$MirOS: src/bin/mksh/emacsfn.h,v 1.11 2020/04/13 20:46:39 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/emacsfn.h,v 1.15 2021/02/26 11:51:08 tg Exp $");
#define FN(cname,sname,flags) static int x_##cname(int);
#elif defined(EMACSFN_ENUMS)
#define FN(cname,sname,flags) XFUNC_##cname,
@@ -42,8 +42,14 @@ FN(comp_list, "complete-list", 0)
FN(complete, "complete", 0)
FN(del_back, "delete-char-backward", XF_ARG)
FN(del_bword, "delete-word-backward", XF_ARG)
+#ifndef MKSH_SMALL
+FN(del_bbigword, "delete-bigword-backward", XF_ARG)
+#endif
FN(del_char, "delete-char-forward", XF_ARG)
FN(del_fword, "delete-word-forward", XF_ARG)
+#ifndef MKSH_SMALL
+FN(del_fbigword, "delete-bigword-forward", XF_ARG)
+#endif
FN(del_line, "kill-line", 0)
FN(draw_line, "redraw", 0)
#ifndef MKSH_SMALL
@@ -59,8 +65,11 @@ FN(eval_region, "evaluate-region", 0)
#endif
FN(expand, "expand-file", 0)
#ifndef MKSH_SMALL
-FN(fold_capitalise, "capitalize-word", XF_ARG)
+FN(foldb_capitalise, "capitalise-bigword", XF_ARG)
+FN(fold_capitalise, "capitalise-word", XF_ARG)
+FN(foldb_lower, "downcase-bigword", XF_ARG)
FN(fold_lower, "downcase-word", XF_ARG)
+FN(foldb_upper, "upcase-bigword", XF_ARG)
FN(fold_upper, "upcase-word", XF_ARG)
#endif
FN(goto_hist, "goto-history", XF_ARG)
@@ -80,15 +89,21 @@ FN(meta_yank, "yank-pop", 0)
FN(mv_back, "backward-char", XF_ARG)
FN(mv_beg, "beginning-of-line", 0)
FN(mv_bword, "backward-word", XF_ARG)
+#ifndef MKSH_SMALL
+FN(mv_bbigword, "backward-bigword", XF_ARG)
+#endif
FN(mv_end, "end-of-line", 0)
FN(mv_forw, "forward-char", XF_ARG)
FN(mv_fword, "forward-word", XF_ARG)
+#ifndef MKSH_SMALL
+FN(mv_fbigword, "forward-bigword", XF_ARG)
+#endif
FN(newline, "newline", 0)
FN(next_com, "down-history", XF_ARG)
FN(nl_next_com, "newline-and-next", 0)
FN(noop, "no-op", 0)
FN(prev_com, "up-history", XF_ARG)
-FN(prev_histword, "prev-hist-word", XF_ARG)
+FN(prev_histword, "prev-hist-bigword", XF_ARG)
#ifndef MKSH_SMALL
FN(quote_region, "quote-region", 0)
#endif
--- mksh-59c.orig/eval.c
+++ mksh-59c/eval.c
@@ -1300,7 +1300,7 @@ varsub(Expand *xp, const char *sp, const
if (sc & 2) {
stype = 0;
XPinit(wv, 32);
- vp = global(arrayname(sp));
+ vp = arraybase(sp);
do {
if (vp->flag & ISSET)
XPput(wv, shf_smprintf(Tf_lu,
@@ -1347,7 +1347,7 @@ varsub(Expand *xp, const char *sp, const
case ORD('#'):
switch (sc & 3) {
case 3:
- vp = global(arrayname(sp));
+ vp = arraybase(sp);
if (vp->flag & (ISSET|ARRAY))
zero_ok = true;
sc = 0;
@@ -1458,7 +1458,7 @@ varsub(Expand *xp, const char *sp, const
/* do what we can */
if (sc & 2) {
XPinit(wv, 32);
- vp = global(arrayname(sp));
+ vp = arraybase(sp);
do {
if (vp->flag & ISSET)
XPput(wv, str_val(vp));
--- mksh-59c.orig/exec.c
+++ mksh-59c/exec.c
@@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
- * 2019, 2020
+ * 2019, 2020, 2021
* mirabilos <m@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@@ -24,7 +24,7 @@
#include "sh.h"
-__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.224 2020/08/27 19:52:43 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.226 2021/01/27 15:49:12 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
@@ -773,8 +773,17 @@ comexec(struct op *t, struct tbl * volat
if (tp->flag & FKSH) {
/* Korn style functions restore Flags on return */
old_flags[(int)FXTRACE] = Flag(FXTRACE);
+ /* some must not be restored / need special handling */
for (type_flags = 0; type_flags < FNFLAGS; ++type_flags)
- shell_flags[type_flags] = old_flags[type_flags];
+#ifndef MKSH_UNEMPLOYED
+ if (type_flags == FMONITOR)
+ change_flag(type_flags, OF_INTERNAL,
+ old_flags[type_flags]);
+ else
+#endif
+ if (type_flags != FPRIVILEGED)
+ shell_flags[type_flags] =
+ old_flags[type_flags];
}
#endif
tp->flag = (tp->flag & ~FINUSE) | old_inuse;
@@ -1388,7 +1397,11 @@ call_builtin(struct tbl *tp, const char
shl_stdout_ok = true;
ksh_getopt_reset(&builtin_opt, GF_ERROR);
rv = (*tp->val.f)(wp);
- shf_flush(shl_stdout);
+ if (shf_flush(shl_stdout) < 0) {
+ bi_errorf(Tf_sD_s, Twrite, cstrerror(errno));
+ if (rv == 0)
+ rv = 1;
+ }
shl_stdout_ok = false;
builtin_argv0 = NULL;
builtin_spec = false;
--- mksh-59c.orig/funcs.c
+++ mksh-59c/funcs.c
@@ -38,7 +38,7 @@
#endif
#endif
-__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.379 2020/08/27 19:52:44 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.383 2021/01/27 15:59:33 tg Exp $");
#if HAVE_KILLPG
/*
@@ -98,7 +98,6 @@ const struct builtin mkshbuiltins[] = {
{Tsgbreak, c_brkcont},
{T__builtin, c_builtin},
{Tbuiltin, c_builtin},
- {Tbcat, c_cat},
{Tcd, c_cd},
/* dash compatibility hack */
{"chdir", c_cd},
@@ -152,13 +151,6 @@ const struct builtin mkshbuiltins[] = {
#ifdef MKSH_PRINTF_BUILTIN
{"~printf", c_printf},
#endif
-#if HAVE_SELECT
- {"sleep", c_sleep},
-#endif
-#ifdef __MirBSD__
- /* alias to "true" for historical reasons */
- {"domainname", c_true},
-#endif
#ifdef __OS2__
{Textproc, c_true},
#endif
@@ -562,6 +554,7 @@ c_print(const char **wp)
po.copipe = block_pipe();
continue;
}
+ bi_errorf(Tf_sD_s, Twrite, cstrerror(errno));
c = 1;
break;
}
@@ -1142,7 +1135,8 @@ c_kill(const char **wp)
n = 1;
while (n < ksh_NSIG) {
shf_puts(sigtraps[n].name, shl_stdout);
- shf_putc(++n == ksh_NSIG ? '\n' : ' ',
+ ++n;
+ shf_putc(n == ksh_NSIG ? '\n' : ' ',
shl_stdout);
}
} else {
@@ -2757,11 +2751,6 @@ test_isop(Test_meta meta, const char *s)
#define test_lstat(name,buffer) lstat((name), (buffer))
#endif
-#if HAVE_ST_MTIM
-#undef st_mtimensec
-#define st_mtimensec st_mtim.tv_nsec
-#endif
-
static int
mtimecmp(const struct stat *sb1, const struct stat *sb2)
{
@@ -2769,7 +2758,7 @@ mtimecmp(const struct stat *sb1, const s
return (-1);
if (sb1->st_mtime > sb2->st_mtime)
return (1);
-#if (HAVE_ST_MTIMENSEC || HAVE_ST_MTIM)
+#if HAVE_ST_MTIMENSEC
if (sb1->st_mtimensec < sb2->st_mtimensec)
return (-1);
if (sb1->st_mtimensec > sb2->st_mtimensec)
@@ -3276,167 +3265,6 @@ c_realpath(const char **wp)
return (rv);
}
-int
-c_cat(const char **wp)
-{
- int fd = 0, rv;
- ssize_t n, w;
- const char *fn = "<stdin>";
- char *buf, *cp;
- bool opipe;
-#define MKSH_CAT_BUFSIZ 4096
-
- /* parse options: POSIX demands we support "-u" as no-op */
- while ((rv = ksh_getopt(wp, &builtin_opt, Tu)) != -1) {
- switch (rv) {
- case 'u':
- /* we already operate unbuffered */
- break;
- default:
- bi_errorf(Tsynerr);
- return (1);
- }
- }
- wp += builtin_opt.optind;
- rv = 0;
-
- if ((buf = malloc_osfunc(MKSH_CAT_BUFSIZ)) == NULL) {
- bi_errorf(Toomem, (size_t)MKSH_CAT_BUFSIZ);
- return (1);
- }
-
- /* catch SIGPIPE */
- opipe = block_pipe();
-
- do {
- if (*wp) {
- fn = *wp++;
- if (ksh_isdash(fn))
- fd = 0;
- else if ((fd = binopen2(fn, O_RDONLY)) < 0) {
- bi_errorf(Tf_sD_s, fn, cstrerror(errno));
- rv = 1;
- continue;
- }
- }
- while (/* CONSTCOND */ 1) {
- if ((n = blocking_read(fd, (cp = buf),
- MKSH_CAT_BUFSIZ)) == -1) {
- if (errno == EINTR) {
- if (opipe)
- restore_pipe();
- /* give the user a chance to ^C out */
- intrcheck();
- /* interrupted, try again */
- opipe = block_pipe();
- continue;
- }
- /* an error occurred during reading */
- bi_errorf(Tf_sD_s, fn, cstrerror(errno));
- rv = 1;
- break;
- } else if (n == 0)
- /* end of file reached */
- break;
- while (n) {
- if (intrsig)
- goto has_intrsig;
- if ((w = write(1, cp, n)) != -1) {
- n -= w;
- cp += w;
- continue;
- }
- if (errno == EINTR) {
- has_intrsig:
- if (opipe)
- restore_pipe();
- /* give the user a chance to ^C out */
- intrcheck();
- /* interrupted, try again */
- opipe = block_pipe();
- continue;
- }
- if (errno == EPIPE) {
- /* fake receiving signal */
- rv = ksh_sigmask(SIGPIPE);
- } else {
- /* an error occurred during writing */
- bi_errorf(Tf_sD_s, "<stdout>",
- cstrerror(errno));
- rv = 1;
- }
- if (fd != 0)
- close(fd);
- goto out;
- }
- }
- if (fd != 0)
- close(fd);
- } while (*wp);
-
- out:
- if (opipe)
- restore_pipe();
- free_osfunc(buf);
- return (rv);
-}
-
-#if HAVE_SELECT
-int
-c_sleep(const char **wp)
-{
- struct timeval tv;
- int rv = 1;
-
- /* skip argv[0] */
- ++wp;
- if (wp[0] && !strcmp(wp[0], "--"))
- /* skip "--" (options separator) */
- ++wp;
-
- if (!wp[0] || wp[1])
- bi_errorf(Tsynerr);
- else if (parse_usec(wp[0], &tv))
- bi_errorf(Tf_sD_s_qs, Tsynerr, cstrerror(errno), wp[0]);
- else {
-#ifndef MKSH_NOPROSPECTOFWORK
- sigset_t omask, bmask;
-
- /* block a number of signals from interrupting us, though */
- (void)sigemptyset(&bmask);
- (void)sigaddset(&bmask, SIGPIPE);
- (void)sigaddset(&bmask, SIGCHLD);
-#ifdef SIGWINCH
- (void)sigaddset(&bmask, SIGWINCH);
-#endif
-#ifdef SIGINFO
- (void)sigaddset(&bmask, SIGINFO);
-#endif
-#ifdef SIGUSR1
- (void)sigaddset(&bmask, SIGUSR1);
-#endif
-#ifdef SIGUSR2
- (void)sigaddset(&bmask, SIGUSR2);
-#endif
- sigprocmask(SIG_BLOCK, &bmask, &omask);
-#endif
- if (select(1, NULL, NULL, NULL, &tv) == 0 || errno == EINTR)
- /*
- * strictly speaking only for SIGALRM, but the
- * execution may be interrupted by other signals
- */
- rv = 0;
- else
- bi_errorf(Tf_sD_s, Tselect, cstrerror(errno));
-#ifndef MKSH_NOPROSPECTOFWORK
- /* this will re-schedule signal delivery */
- sigprocmask(SIG_SETMASK, &omask, NULL);
-#endif
- }
- return (rv);
-}
-#endif
-
#if !defined(MKSH_UNEMPLOYED) && HAVE_GETSID
static int
c_suspend(const char **wp)
--- mksh-59c.orig/lex.c
+++ mksh-59c/lex.c
@@ -23,7 +23,7 @@
#include "sh.h"
-__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.251 2020/03/10 23:48:40 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.252 2020/12/14 00:21:09 tg Exp $");
/*
* states while lexing word
@@ -552,7 +552,7 @@ yylex(int cf)
* "…`…\"…`…" because, unlike for COMSUBs, the
* outer double quoteing changes the backslash
* meaning for the inside. For more details:
- * http://austingroupbugs.net/view.php?id=1015
+ * https://www.austingroupbugs.net/view.php?id=1015
*/
statep->ls_bool = false;
s2 = statep;
@@ -1487,6 +1487,8 @@ set_prompt(int to, Source *s)
Area *saved_atemp;
int saved_lineno;
+ saved_atemp = ATEMP;
+ newenv(E_ERRH);
ps1 = str_val(global("PS1"));
shf = shf_sopen(NULL, strlen(ps1) * 2,
SHF_WR | SHF_DYNAMIC, NULL);
@@ -1500,8 +1502,6 @@ set_prompt(int to, Source *s)
saved_lineno = current_lineno;
if (s)
current_lineno = s->line + 1;
- saved_atemp = ATEMP;
- newenv(E_ERRH);
if (kshsetjmp(e->jbuf)) {
prompt = safe_prompt;
/*
@@ -1516,6 +1516,7 @@ set_prompt(int to, Source *s)
strdupx(prompt, cp, saved_atemp);
}
current_lineno = saved_lineno;
+ /* frees everything in post-newenv ATEMP */
quitenv(NULL);
}
break;
@@ -1792,7 +1793,6 @@ yyskiputf8bom(void)
ungetsc_i(asc2rtt(0xEF));
return;
}
- UTFMODE |= 8;
}
static Lex_state *
--- mksh-59c.orig/lksh.1
+++ mksh-59c/lksh.1
@@ -1,4 +1,4 @@
-.\" $MirOS: src/bin/mksh/lksh.1,v 1.26 2020/09/04 22:37:01 tg Exp $
+.\" $MirOS: src/bin/mksh/lksh.1,v 1.28 2021/06/15 13:20:05 tg Exp $
.\"-
.\" Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015, 2016, 2017, 2018
.\" mirabilos <m@mirbsd.org>
@@ -81,7 +81,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
-.Dd $Mdocdate: September 4 2020 $
+.Dd $Mdocdate: June 15 2021 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"
@@ -346,16 +346,12 @@ Talk to the
.Mx
development team and users using the mailing list at
.Aq Mt miros\-mksh@mirbsd.org
-(please note the EU-DSGVO/GDPR notice on
-.Pa http://www.mirbsd.org/rss.htm#lists
-and in the SMTP banner!) or the
+or in the
.Li \&#\&!/bin/mksh
-.Pq or Li \&#ksh
-IRC channel at
-.Pa irc.freenode.net
-.Pq Port 6697 SSL, 6667 unencrypted
-if you need any further quirks or assistance,
-and consider migrating your legacy scripts to work with
+IRC channel; mind the infos from
+.Pa http://www.mirbsd.org/mksh\-faq.htm#contact
+for either.
+Consider migrating your legacy scripts to work with
.Nm mksh
instead of requiring
.Nm .
--- mksh-59c.orig/main.c
+++ mksh-59c/main.c
@@ -6,7 +6,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
- * 2019, 2020
+ * 2019, 2020, 2021
* mirabilos <m@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@@ -35,7 +35,7 @@
#include <locale.h>
#endif
-__RCSID("$MirOS: src/bin/mksh/main.c,v 1.374 2020/10/01 20:28:54 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/main.c,v 1.377 2021/02/07 02:02:26 tg Exp $");
#ifndef MKSHRC_PATH
#define MKSHRC_PATH "~/.mkshrc"
@@ -84,13 +84,13 @@ static const char *initcoms[] = {
NULL,
/* this is what AT&T ksh seems to track, with the addition of emacs */
Talias, "-tU",
- Tcat, "cc", "chmod", "cp", "date", "ed", "emacs", "grep", "ls",
+ "cat", "cc", "chmod", "cp", "date", "ed", "emacs", "grep", "ls",
"make", "mv", "pr", "rm", "sed", Tsh, "vi", "who", NULL,
NULL
};
static const char *restr_com[] = {
- Ttypeset, Tdr, TPATH, TENV, TSHELL, NULL
+ Ttypeset, Tdr, TENV, "HISTFILE", TPATH, TSHELL, NULL
};
static bool initio_done;
@@ -306,7 +306,7 @@ main_init(int argc, const char *argv[],
/* define built-in commands and see if we were called as one */
ktinit(APERM, &builtins,
- /* currently up to 52 builtins: 75% of 128 = 2^7 */
+ /* currently up to 50 builtins: 75% of 128 = 2^7 */
7);
for (i = 0; mkshbuiltins[i].name != NULL; ++i) {
const char *builtin_name;
@@ -611,6 +611,8 @@ main_init(int argc, const char *argv[],
ccp = null;
switch (utf_flag) {
+ /* not set on command line, not FTALKING */
+ case 2:
/* auto-detect from locale or environment */
case 4:
#if HAVE_SETLOCALE_CTYPE
@@ -636,8 +638,6 @@ main_init(int argc, const char *argv[],
UTFMODE = isuc(ccp);
break;
- /* not set on command line, not FTALKING */
- case 2:
/* unknown values */
default:
utf_flag = 0;
@@ -738,6 +738,9 @@ main(int argc, const char *argv[])
if ((rv = main_init(argc, argv, &s, &l)) == 0) {
if (as_builtin) {
rv = c_builtin(l->argv);
+ exstat = rv & 0xFF;
+ unwind(LEXIT);
+ /* NOTREACHED */
} else {
shell(s, 0);
/* NOTREACHED */
@@ -2127,16 +2130,16 @@ void
recheck_ctype(void)
{
const char *ccp;
- uint8_t old_utfmode = UTFMODE;
ccp = str_val(global("LC_ALL"));
if (ccp == null)
ccp = str_val(global("LC_CTYPE"));
if (ccp == null)
ccp = str_val(global("LANG"));
+ /*XXX POSIXly, only the locale must determine the outcome */
UTFMODE = isuc(ccp);
#if HAVE_SETLOCALE_CTYPE
- ccp = setlocale(LC_CTYPE, ccp);
+ ccp = setlocale(LC_CTYPE, *ccp ? ccp : "C");
#if HAVE_LANGINFO_CODESET
if (!isuc(ccp))
ccp = nl_langinfo(CODESET);
@@ -2144,8 +2147,5 @@ recheck_ctype(void)
if (isuc(ccp))
UTFMODE = 1;
#endif
-
- if (Flag(FPOSIX) && UTFMODE && !old_utfmode)
- warningf(true, "early locale tracking enabled UTF-8 mode while in POSIX mode, you are now noncompliant");
}
#endif
--- mksh-59c.orig/misc.c
+++ mksh-59c/misc.c
@@ -4,7 +4,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019,
- * 2020
+ * 2020, 2021
* mirabilos <m@mirbsd.org>
* Copyright (c) 2015
* Daniel Richard G. <skunk@iSKUNK.ORG>
@@ -33,7 +33,7 @@
#include <grp.h>
#endif
-__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.302 2020/08/27 19:52:45 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.306 2021/01/26 23:49:49 tg Exp $");
#define KSH_CHVT_FLAG
#ifdef MKSH_SMALL
@@ -57,6 +57,8 @@ static const unsigned char *gmatch_cclas
#ifdef KSH_CHVT_CODE
static void chvt(const Getopt *);
#endif
+static unsigned int dollarqU(struct shf *, const unsigned char *);
+#define dollarq8 dollarqU
/*XXX this should go away */
static int make_path(const char *, const char *, char **, XString *, int *);
@@ -292,10 +294,6 @@ change_flag(enum sh_flag f, int what, bo
/* +++ privs changed +++ */
} else if ((f == FPOSIX || f == FSH) && newval) {
- /* Turning on -o posix? */
- if (f == FPOSIX)
- /* C locale required for compliance */
- UTFMODE = 0;
/* Turning on -o posix or -o sh? */
Flag(FBRACEEXPAND) = 0;
#ifndef MKSH_NO_CMDLINE_EDITING
@@ -1406,116 +1404,180 @@ print_value_quoted(struct shf *shf, cons
}
/* non-empty; check whether any quotes are needed */
- while (rtt2asc(c = *p++) >= 32)
- if (ctype(c, C_QUOTE | C_SPC))
- inquote = false;
+ if (UTFMODE) {
+ /* C1 always escaped; multibyte makes this tricky */
+ while ((c = *p++) != 0) {
+ if (ctype(c, C_CNTRL)) {
+ dollarqU(shf, (const unsigned char *)s);
+ return;
+ }
+ /* anything out of ASCII present? */
+ if (rtt2asc(c) > 0x7EU) {
+ /* dollar-quote, but be prepared to redo */
+ char *guess;
+ struct shf to;
+
+ shf_sopen(NULL, 0, SHF_WR | SHF_DYNAMIC, &to);
+ c = dollarqU(&to, (const unsigned char *)s);
+ guess = shf_sclose(&to);
+ /* output guess if it was right */
+ if (c > 1)
+ shf_puts(guess, shf);
+ afree(guess, ATEMP);
+ if (c == 1)
+ goto always_single;
+ if (c == 0)
+ noquoteneeded:
+ shf_puts(s, shf);
+ return;
+ }
+ if (ctype(c, C_QUOTE | C_SPC))
+ inquote = false;
+ }
+ /* assert: c == 0; all chars in [20;7E] ASCII */
+#ifndef MKSH_EBCDIC
+ } else if (Flag(FASIS)) {
+ while ((c = *p++), !ksh_asisctrl(c))
+ if (ctype(c, C_QUOTE | C_SPC))
+ inquote = false;
+#endif
+ } else {
+ while ((c = *p++), !ksh_isctrl(c))
+ if (ctype(c, C_QUOTE | C_SPC))
+ inquote = false;
+ }
+ /* state: if c == 0, all chars printable, inquote shortcuts */
+
+ if (c) {
+ /* otherwise, escape control chars */
+ dollarq8(shf, (const unsigned char *)s);
+ return;
+ }
+ /* can we shortcut? */
+ if (inquote)
+ goto noquoteneeded;
+ /* no */
+ always_single:
+ /* all chars printable, no control chars, quote nicely */
+ inquote = false;
p = (const unsigned char *)s;
- if (c == 0) {
- if (inquote) {
- /* nope, use the shortcut */
- shf_puts(s, shf);
- return;
- }
- /* otherwise, quote nicely via state machine */
- while ((c = *p++) != 0) {
- if (c == '\'') {
- /*
- * multiple single quotes or any of them
- * at the beginning of a string look nicer
- * this way than when simply substituting
- */
- if (inquote) {
- shf_putc('\'', shf);
- inquote = false;
- }
- shf_putc('\\', shf);
- } else if (!inquote) {
+ while ((c = *p++) != 0) {
+ if (c == '\'') {
+ if (inquote) {
shf_putc('\'', shf);
- inquote = true;
+ inquote = false;
}
- shf_putc(c, shf);
+ shf_putc('\\', shf);
+ } else if (!inquote) {
+ shf_putc('\'', shf);
+ inquote = true;
}
- } else {
- unsigned int wc;
- size_t n;
-
- /* use $'...' quote format */
- shf_putc('$', shf);
+ shf_putc(c, shf);
+ }
+ if (inquote)
shf_putc('\'', shf);
- while ((c = *p) != 0) {
-#ifndef MKSH_EBCDIC
- if (c >= 0xC2) {
- n = utf_mbtowc(&wc, (const char *)p);
- if (n != (size_t)-1) {
- p += n;
- shf_fprintf(shf, "\\u%04X", wc);
- continue;
- }
- }
-#endif
- ++p;
- switch (c) {
- /* see unbksl() in this file for comments */
- case KSH_BEL:
- c = 'a';
- if (0)
- /* FALLTHROUGH */
- case '\b':
- c = 'b';
- if (0)
- /* FALLTHROUGH */
- case '\f':
- c = 'f';
- if (0)
- /* FALLTHROUGH */
- case '\n':
- c = 'n';
- if (0)
- /* FALLTHROUGH */
- case '\r':
- c = 'r';
- if (0)
- /* FALLTHROUGH */
- case '\t':
- c = 't';
- if (0)
- /* FALLTHROUGH */
- case KSH_VTAB:
- c = 'v';
- if (0)
- /* FALLTHROUGH */
- case KSH_ESC:
- /* take E not e because \e is \ in *roff */
- c = 'E';
- /* FALLTHROUGH */
- case '\\':
- shf_putc('\\', shf);
+}
- if (0)
- /* FALLTHROUGH */
- default:
-#if defined(MKSH_EBCDIC) || defined(MKSH_FAUX_EBCDIC)
- if (ksh_isctrl(c))
+#ifdef MKSH_EBCDIC
+#define dollarq_isctrl8(c) ksh_isctrl(c)
#else
- if (!ctype(c, C_PRINT))
+#define dollarq_isctrl8(c) Flag(FASIS) ? ksh_asisctrl(c) : ksh_isctrl(c)
#endif
- {
- /* FALLTHROUGH */
- case '\'':
- shf_fprintf(shf, "\\%03o", c);
- break;
- }
- shf_putc(c, shf);
+#define dollarq_Uctrl(c) !ctype(c, C_PRINT)
+#define dollarq_isctrlU(c) UTFMODE ? dollarq_Uctrl(c) : dollarq_isctrl8(c)
+
+/* escape with $'...' (!MKSH_SMALL: in UTFMODE) */
+static unsigned int
+dollarqU(struct shf *shf, const unsigned char *s)
+{
+ unsigned char c;
+ unsigned int wc;
+ size_t n;
+ unsigned int rv = 0;
+
+ shf_putc('$', shf);
+ shf_putc('\'', shf);
+ while ((c = *s) != 0) {
+ if (UTFMODE &&
+ rtt2asc(c) >= 0xC2U && (n = utf_mbtowc(&wc,
+ (const char *)s)) != (size_t)-1) {
+ /* valid UTF-8 multibyte character > 0x7F */
+ if ((wc ^ 0x80U) < 0x20U) {
+ /* C1 control character */
+ shf_fprintf(shf, "\\u%04X", wc);
+ rv = 2;
+ } else {
+ /*
+ * print as-is; we assume the tty DTRT for
+ * interlinear annotations, LTR/RTL mark,
+ * U+2028, U+2029, U+2066..U+206F, etc.
+ */
+ shf_write((const char *)s, n, shf);
+ }
+ s += n;
+ continue;
+ }
+ ++s;
+ /* single octet */
+ rv |= ctype(c, C_QUOTE | C_SPC);
+ switch (c) {
+ /* see unbksl() in this file for comments */
+ case KSH_BEL:
+ c = 'a';
+ if (0)
+ /* FALLTHROUGH */
+ case '\b':
+ c = 'b';
+ if (0)
+ /* FALLTHROUGH */
+ case '\f':
+ c = 'f';
+ if (0)
+ /* FALLTHROUGH */
+ case '\n':
+ c = 'n';
+ if (0)
+ /* FALLTHROUGH */
+ case '\r':
+ c = 'r';
+ if (0)
+ /* FALLTHROUGH */
+ case '\t':
+ c = 't';
+ if (0)
+ /* FALLTHROUGH */
+ case KSH_VTAB:
+ c = 'v';
+ if (0)
+ /* FALLTHROUGH */
+ case KSH_ESC:
+ /* take E not e because \e is \ in *roff */
+ c = 'E';
+ rv = 2;
+ /* FALLTHROUGH */
+ case '\\':
+ shf_putc('\\', shf);
+
+ if (0)
+ /* FALLTHROUGH */
+ default:
+ if (dollarq_isctrlU(c)) {
+ rv = 2;
+ /* FALLTHROUGH */
+ case '\'':
+ shf_fprintf(shf, "\\%03o", c);
break;
}
+
+ shf_putc(c, shf);
+ break;
}
- inquote = true;
}
- if (inquote)
- shf_putc('\'', shf);
+ shf_putc('\'', shf);
+ return (rv);
}
/*
@@ -1678,14 +1740,18 @@ ksh_get_wd(void)
char *rv, *cp;
if ((cp = get_current_dir_name())) {
- strdupx(rv, cp, ATEMP);
+ if (mksh_abspath(cp))
+ strdupx(rv, cp, ATEMP);
+ else
+ rv = NULL;
free_gnu_gcdn(cp);
} else
rv = NULL;
#else
char *rv;
- if (!getcwd((rv = alloc(PATH_MAX + 1, ATEMP)), PATH_MAX)) {
+ if (!getcwd((rv = alloc(PATH_MAX + 1, ATEMP)), PATH_MAX) ||
+ !mksh_abspath(rv)) {
afree(rv, ATEMP);
rv = NULL;
}
@@ -1704,15 +1770,17 @@ do_realpath(const char *upath)
char *xp, *ip, *tp, *ipath, *ldest = NULL;
XString xs;
size_t pos, len;
- int llen;
+ ssize_t llen;
struct stat sb;
#ifdef MKSH__NO_PATH_MAX
- size_t ldestlen = 0;
-#define pathlen sb.st_size
-#define pathcnd (ldestlen < (pathlen + 1))
+ off_t ldestlen = 0;
+#define pathlen ((size_t)sb.st_size)
+#define pathcnd ((ldestlen < 1) || ((ldestlen - 1) < sb.st_size))
+#define ldestsz ((size_t)ldestlen)
#else
-#define pathlen PATH_MAX
+#define pathlen ((size_t)PATH_MAX)
#define pathcnd (!ldest)
+#define ldestsz (pathlen + 1U)
#endif
/* max. recursion depth */
int symlinks = 32;
@@ -1730,7 +1798,7 @@ do_realpath(const char *upath)
#endif
} else {
/* upath is a relative pathname, prepend cwd */
- if ((tp = ksh_get_wd()) == NULL || !mksh_abspath(tp))
+ if ((tp = ksh_get_wd()) == NULL)
return (NULL);
strpathx(ipath, tp, upath, 1);
afree(tp, ATEMP);
@@ -1813,15 +1881,19 @@ do_realpath(const char *upath)
/* get symlink(7) target */
if (pathcnd) {
#ifdef MKSH__NO_PATH_MAX
- if (notoktoadd(pathlen, 1)) {
+ /* same as notoktoadd(pathlen, 1) but adapted */
+ if ((uintmax_t)sb.st_size >= (uintmax_t)SIZE_MAX) {
errno = ENAMETOOLONG;
goto notfound;
}
+ ldestlen = sb.st_size + 1; /* <= SIZE_MAX */
#endif
- ldest = aresize(ldest, pathlen + 1, ATEMP);
+ /* ldestsz == pathlen + 1 */
+ ldest = aresize(ldest, ldestsz, ATEMP);
}
- llen = readlink(Xstring(xs, xp), ldest, pathlen);
- if (llen < 0)
+ errno = ENAMETOOLONG; /* for > pathlen case */
+ llen = readlink(Xstring(xs, xp), ldest, ldestsz);
+ if (llen < 0 || (size_t)llen > pathlen)
/* oops... */
goto notfound;
ldest[llen] = '\0';
@@ -1910,11 +1982,11 @@ do_realpath(const char *upath)
notfound:
/* save; freeing memory might trash it */
- llen = errno;
+ symlinks = errno;
afree(ldest, ATEMP);
afree(ipath, ATEMP);
Xfree(xs, xp);
- errno = llen;
+ errno = symlinks;
return (NULL);
#undef pathlen
@@ -2392,6 +2464,7 @@ chvt(const Getopt *go)
errorf(Tf_sD_s_s, "chvt", Tcant_open, dv);
}
}
+ afree(cp, ATEMP);
if (go->optarg[0] != '!') {
switch (fork()) {
case -1:
--- mksh-59c.orig/mksh.1
+++ mksh-59c/mksh.1
@@ -1,9 +1,9 @@
-.\" $MirOS: src/bin/mksh/mksh.1,v 1.494 2020/10/01 22:39:57 tg Exp $
+.\" $MirOS: src/bin/mksh/mksh.1,v 1.507+1.512+locale-tracking 2021/05/02 16:57:53 tg Exp $
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
.\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
.\" 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
-.\" 2018, 2019, 2020
+.\" 2018, 2019, 2020, 2021
.\" mirabilos <m@mirbsd.org>
.\"
.\" Provided that these terms and disclaimer and all copyright notices
@@ -84,7 +84,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
-.Dd $Mdocdate: October 1 2020 $
+.Dd $Mdocdate: July 10 2021 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"
@@ -309,31 +309,32 @@ files:
.Pp
.Bl -bullet -compact
.It
-The
-.Ic cd
-.Po and Ic chdir Pc
-command is disabled.
-.It
-The
-.Ev SHELL ,
-.Ev ENV
-and
+Command names cannot be specified with pathnames, absolute or relative,
+nor using the
+.Fl p
+option of the
+.Ic command
+built-in utility; the
+.Ev ENV ,
.Ev PATH
+and
+.Ev SHELL
parameters cannot be changed.
.It
-Command names can't be specified with absolute or relative paths.
-.It
-The
-.Fl p
-option of the built-in command
-.Ic command
-can't be used.
+The current location is fixed: the
+.Ic cd
+command and its alias
+.Ic chdir
+is disabled.
.It
Redirections that create files can't be used (i.e.\&
.Dq Li \*(Gt ,
.Dq Li \*(Gt\*(Ba ,
.Dq Li \*(Gt\*(Gt ,
-.Dq Li \*(Lt\*(Gt ) .
+.Dq Li \*(Lt\*(Gt ) ,
+and the
+.Ev HISTFILE
+parameter cannot be changed.
.El
.It Fl s
The shell reads commands from standard input; all non-option arguments
@@ -1316,7 +1317,7 @@ not
.Dq Li D
and
.Dq Li E .
-This behavior is POSIX compliant, but incompatible with some other shell
+This behaviour is POSIX compliant but incompatible with some other shell
implementations which do field splitting on the word which contained the
substitution or use
.Dv IFS
@@ -1356,7 +1357,8 @@ is interpreted to mean substitute the co
Note that
.Ic $(\*(Ltfoo)
has the same effect as
-.Ic $(cat foo) .
+.Ic $(cat foo)
+but is much more performant.
.Pp
Note that some shells do not use a recursive parser for command substitutions,
leading to failure for certain constructs; to be portable, use as workaround
@@ -2999,6 +3001,8 @@ outside the function).
.It
Shell options
.Pq Ic set Fl o
+except
+.Fl p Pq Fl o Ic privileged
have local scope, i.e. changes inside a function are reset upon its exit.
.El
.Pp
@@ -3046,13 +3050,12 @@ commands keeping assignments:
All other builtins are not special; these are at least:
.Pp
.Ic [\& , alias , bg , bind ,
-.Ic builtin , cat , cd , command ,
-.Ic echo , false , fc , fg ,
-.Ic getopts , jobs , kill , let ,
-.Ic print , pwd , read , realpath ,
-.Ic rename , sleep , suspend , test ,
-.Ic true , ulimit , umask , unalias ,
-.Ic wait , whence
+.Ic builtin , cd , command , echo ,
+.Ic false , fc , fg , getopts ,
+.Ic jobs , kill , let , print ,
+.Ic pwd , read , realpath , rename ,
+.Ic suspend , test , true , ulimit ,
+.Ic umask , unalias , wait , whence
.Pp
Once the type of command has been determined, any command-line parameter
assignments are performed and exported for the duration of the command.
@@ -3114,7 +3117,7 @@ variable for your consumption.
.It Ic Lstripcom Op Ar
.Pq Li dot.mkshrc No function
Same as
-.Ic cat
+.Xr cat 1
but strips any empty lines and comments (from any
.Sq #
character onwards, no escapes)
@@ -3297,26 +3300,6 @@ declaration utility (see
is a declaration utility.
.Pp
.It Xo
-.Ic cat
-.Op Fl u
-.Op Ar
-.Xc
-.Pq defer with flags
-Copy files in command line order to standard output.
-If a
-.Ar file
-is a single dash
-.Pq Dq Li \-
-or absent, read from standard input.
-For direct builtin calls, the
-.Tn POSIX
-.Fl u
-option is supported as a no-op.
-For calls from shell, if any options are given, an external
-.Xr cat 1
-utility is preferred over the builtin.
-.Pp
-.It Xo
.Ic cd
.Op Fl L
.Op Ar dir
@@ -4460,10 +4443,9 @@ and at least one of these returns someth
or
.Dq utf8
case-insensitively; for direct builtin calls depending on the
-aforementioned environment variables; or for stdin or scripts,
-if the input begins with a UTF-8 Byte Order Mark.
+aforementioned environment variables.
.Pp
-In near future, locale tracking will be implemented, which means that
+This build of the shell implements semi-early locale tracking, that is,
.Ic set Fl +U
is changed whenever one of the
.Tn POSIX
@@ -4488,6 +4470,15 @@ during globbing.
.It Fl x \*(Ba Fl o Ic xtrace
Print commands when they are executed, preceded by
.Ev PS4 .
+.It Fl o Ic asis
+When quoting output, if not in EBCDIC mode and
+.Ic utf8\-mode
+is disabled, show C1 control characters
+.Dq as is ,
+that is, do not escape them.
+Use with codepages where the range 0x80..0x9F contains printable
+characters (such as 437, 850, 1252, etc. but not the ISO\ 8859
+series, for example).
.It Fl o Ic bgnice
Background jobs are run with lower priority.
.It Fl o Ic braceexpand
@@ -4574,9 +4565,7 @@ and
this autodetection feature is compiled in.
As a side effect, setting this flag turns off the
.Ic braceexpand
-and
-.Ic utf8\-mode
-flags, which can be turned back on manually, and
+flag, which can be turned back on manually, and
.Pq unless both are set in the same command
.Ic sh
mode.
@@ -4672,13 +4661,6 @@ etc.
.Pq Ar number No defaults to 1
are renamed to 1, 2, etc.
.Pp
-.It Ic sleep Ar seconds
-.Pq regular , needs Xr select 2
-Suspends execution for a minimum of the
-.Ar seconds
-(specified as positive decimal value with an optional fractional part).
-Signal delivery may continue execution earlier.
-.Pp
.It Ic smores Op Ar
.Pq Li dot.mkshrc No function
Simple pager:
@@ -5405,6 +5387,12 @@ Limit the size of
message queues to
.Ar n
bytes.
+.It Fl R Ar n
+.Pq Cm Linux
+Limit the CPU time slice a real-time process can use before
+performing a blocking syscall to
+.Ar n
+milliseconds.
.It Fl r Ar n
.Pq Cm AIX
Limit the number of threads per process to
@@ -5907,21 +5895,28 @@ command.
.Pp
The following is a list of available editing commands.
Each description starts with the name of the command,
-suffixed with a colon;
-an
+suffixed with a colon; a
.Op Ar n
(if the command can be prefixed with a count); and any keys the command is
bound to by default, written using caret notation
-e.g. the ASCII Esc character is written as \*(ha[.
-These control sequences are not case sensitive.
+(e.g. the ASCII Esc character is written as
+.Li \*(ha[ )
+or terminal-specific indications.
A count prefix for a command is entered using the sequence
.Pf \*(ha[ Ns Ar n ,
where
.Ar n
-is a sequence of 1 or more digits.
+is one or more digits.
Unless otherwise specified, if a count is
omitted, it defaults to 1.
.Pp
+Bigwords, as used below, are separated by spaces or tabs;
+words consist of alphanumerics, underscore
+.Pq Ql _
+or dollar sign
+.Pq Ql $
+characters.
+.Pp
Note that editing command names are used only with the
.Ic bind
command.
@@ -5944,8 +5939,13 @@ Emacs key bindings:
Abort the current command, save it to the history, empty the line buffer and
set the exit state to interrupted.
.It auto\-insert: Op Ar n
+.Pq Most ordinary characters are bound to this command.
Simply causes the character to appear as literal input.
-Most ordinary characters are bound to this.
+.It Xo backward\-bigword:
+.Op Ar n
+.No \*(ha[B
+.Xc
+Moves the cursor backward to the beginning of the bigword.
.It Xo backward\-char:
.Op Ar n
.No \*(haB , \*(haXD , ANSI-CurLeft , PC-CurLeft
@@ -5957,19 +5957,21 @@ characters.
.Op Ar n
.No \*(ha[b , ANSI-Ctrl-CurLeft , ANSI-Alt-CurLeft
.Xc
-Moves the cursor backward to the beginning of the word; words consist of
-alphanumerics, underscore
-.Pq Ql _
-and dollar sign
-.Pq Ql $
-characters.
+Moves the cursor backward to the beginning of the word.
.It beginning\-of\-history: \*(ha[\*(Lt
Moves to the beginning of the history.
.It beginning\-of\-line: \*(haA, ANSI-Home, PC-Home
Moves the cursor to the beginning of the edited input line.
+.It Xo capitalise\-bigword:
+.Op Ar n
+.No \*(ha[C
+.Xc
+Uppercase the first character in the next
+.Ar n
+bigwords as below.
.It Xo capitalise\-word:
.Op Ar n
-.No \*(ha[C , \*(ha[c
+.No \*(ha[c
.Xc
Uppercase the first ASCII character in the next
.Ar n
@@ -6013,6 +6015,20 @@ match as in the
.Ic complete
command above.
Note that \*(haI is usually generated by the Tab (tabulator) key.
+.It Xo delete\-bigword\-backward:
+.Op Ar n
+.No \*(ha[H
+.Xc
+Deletes
+.Ar n
+bigwords before the cursor.
+.It Xo delete\-bigword\-forward:
+.Op Ar n
+.No \*(ha[D
+.Xc
+Deletes characters after the cursor up to the end of
+.Ar n
+bigwords.
.It Xo delete\-char\-backward:
.Op Ar n
.No ERASE Pq \*(haH ,
@@ -6060,9 +6076,16 @@ is not useful until either
or
.Ic up\-history
has been performed.
+.It Xo downcase\-bigword:
+.Op Ar n
+.No \*(ha[L
+.Xc
+Lowercases the next
+.Ar n
+bigwords.
.It Xo downcase\-word:
.Op Ar n
-.No \*(ha[L , \*(ha[l
+.No \*(ha[l
.Xc
Lowercases the next
.Ar n
@@ -6113,6 +6136,13 @@ Appends a
to the current word and replaces the word with the result of performing file
globbing on the word.
If no files match the pattern, the bell is rung.
+.It Xo forward\-bigword:
+.Op Ar n
+.No \*(ha[F
+.Xc
+Moves the cursor forward to the end of the
+.Ar n Ns th
+bigword.
.It Xo forward\-char:
.Op Ar n
.No \*(haF , \*(haXC , ANSI-CurRight , PC-CurRight
@@ -6181,15 +6211,18 @@ This does nothing.
Introduces a 2-character command sequence.
.It prefix\-2: \*(haX , \*(ha[[ , \*(ha[O
Introduces a multi-character command sequence.
-.It Xo prev\-hist\-word:
+.It prefix\-3: \*(ha@
+Introduces a PC keyboard scancode.
+.It Xo prev\-hist\-bigword:
.Op Ar n
.No \*(ha[. , \*(ha[_
.Xc
-The last word or, if given, the
-.Ar n Ns th
-word (zero-based) of the previous (on repeated execution, second-last,
-third-last, etc.) command is inserted at the cursor.
-Use of this editing command trashes the mark.
+If no count is given, the last bigword, otherwise the
+.No ( Ar n Ns +1)th
+bigword of the previous line is inserted at the cursor,
+and the mark is set to the beginning of the inserted word.
+When invoked repeatedly, the inserted text is replaced by the corresponding
+bigword from the second-last, third-last, etc. line.
.It quote: \*(ha\*(ha , \*(haV
The following character is taken literally rather than as an editing command.
.It quote\-region: \*(ha[Q
@@ -6219,7 +6252,7 @@ The internal history list is searched
backwards for commands matching the input.
An initial
.Ql \*(ha
-in the search string anchors the search.
+in the search string anchors the search at the beginning of the line.
The escape key will leave search mode.
Other commands, including sequences of escape as
.Ic prefix\-1
@@ -6227,31 +6260,33 @@ followed by a
.Ic prefix\-1
or
.Ic prefix\-2
-key will be executed after leaving search mode.
+key, will be executed after leaving search mode.
The
.Ic abort Pq \*(haG
-command will restore the input line before search started.
+command will restore the input line from before search started.
Successive
.Ic search\-history
-commands continue searching backward to the next previous occurrence of the
-pattern.
+commands continue searching backward to the following previous occurrence
+of the pattern.
The history buffer retains only a finite number of lines; the oldest
are discarded as necessary.
-.It search\-history\-up: ANSI-PgUp, PC-PgUp
-Search backwards through the history buffer for commands whose beginning match
-the portion of the input line before the cursor.
-When used on an empty line, this has the same effect as
-.Ic up\-history .
.It search\-history\-down: ANSI-PgDn, PC-PgDn
-Search forwards through the history buffer for commands whose beginning match
+Search forwards (this command is only useful after an
+.Ic up\-history ,
+.Ic search\-history\-up
+or
+.Ic search\-history )
+through the history buffer for commands whose beginning matches
the portion of the input line before the cursor.
When used on an empty line, this has the same effect as
.Ic down\-history .
-This is only useful after an
-.Ic up\-history ,
-.Ic search\-history
-or
-.Ic search\-history\-up .
+.It search\-history\-up: ANSI-PgUp, PC-PgUp
+Search backwards through the history buffer for commands whose beginning
+matches the portion of the input line before the cursor.
+When used on an empty line, this has the same effect as
+.Ic up\-history .
+.It set\-arg: \*(ha[0 .. \*(ha[9
+Mapped to begin prefixing a count to a command.
.It set\-mark\-command: \*(ha[ Ns Aq space
Set the mark at the cursor position.
.It transpose\-chars: \*(haT
@@ -6267,9 +6302,16 @@ character to the right.
Scrolls the history buffer backward
.Ar n
lines (earlier).
+.It Xo upcase\-bigword:
+.Op Ar n
+.No \*(ha[U
+.Xc
+Uppercase the next
+.Ar n
+bigwords.
.It Xo upcase\-word:
.Op Ar n
-.No \*(ha[U , \*(ha[u
+.No \*(ha[u
.Xc
Uppercase the next
.Ar n
@@ -6279,6 +6321,8 @@ Display the version of
.Nm mksh .
The current edit buffer is restored as soon as a key is pressed.
The restoring keypress is processed, unless it is a space.
+.It vt100\-hack: \*(ha[[1
+Mapped to internally represent some longer key sequences.
.It yank: \*(haY
Inserts the most recently killed text string at the current cursor position.
.It yank\-pop: \*(ha[y
@@ -6289,7 +6333,7 @@ replaces the inserted text string with t
.Pp
The tab completion escapes characters the same way as the following code:
.Bd -literal
-print \-nr \-\- "${x@/[\e"\-\e$\e&\-*:\-?[\e\e\e`\e{\-\e}${IFS\-$\*(aq \et\en\*(aq}]/\e\e$KSH_MATCH}"
+print \-nr \-\- "${x@/[\e"\-\e$\e&\-*:\-?[\e\e\e\`\e{\-\e\*(TI${IFS\-$\*(aq \et\en\*(aq}]/\e\e$KSH_MATCH}"
.Ed
.Ss Vi editing mode
.Em Note:
@@ -7066,6 +7110,12 @@ and wraparound defined, even (defying PO
currently uses OPTU-16 internally, which is the same as UTF-8 and CESU-8
with 0000..FFFD being valid codepoints; raw octets are mapped into the
PUA range EF80..EFFF, which is assigned by CSUR for this purpose.
+.Em Future compatibility note :
+there's work underway to use full 21-bit UTF-8 in mksh R60 or so.
+Raw octet mapping will almost certainly be moved out of the PUA and into
+some range outside of UCS, such as 0x00400000 with the lower bits
+corresponding to the octet; high-bit7 octets only to keep ASCII unambiguous
+(EBCDIC will have to see, perhaps using the extant ASCII mapping).
.Sh BUGS
Suspending (using \*(haZ) pipelines like the one below will only suspend
the currently running part of the pipeline; in this example,
@@ -7089,9 +7139,9 @@ for the in-memory portion of the history
.Xr memmove 3 .
.Pp
This document attempts to describe
-.Nm mksh\ R59c
+.Nm mksh\ R59-CURRENT
and up,
-.\" with vendor patches from insert-your-name-here,
+with vendor patches from Debian,
compiled without any options impacting functionality, such as
.Dv MKSH_SMALL ,
when not called as
@@ -7107,13 +7157,7 @@ Please report bugs in
.Nm
to the public development mailing list at
.Aq Mt miros\-mksh@mirbsd.org
-(please note the EU-DSGVO/GDPR notice on
-.Pa http://www.mirbsd.org/rss.htm#lists
-and in the SMTP banner!) or in the
+or, in the
.Li \&#\&!/bin/mksh
-.Pq or Li \&#ksh
-IRC channel at
-.Pa irc.freenode.net
-.Pq Port 6697 SSL, 6667 unencrypted ,
-or at:
-.Pa https://launchpad.net/mksh
+channel, on IRC; for both, note the information at:
+.Pa http://www.mirbsd.org/mksh\-faq.htm#contact
--- mksh-59c.orig/mksh.faq
+++ mksh-59c/mksh.faq
@@ -1,4 +1,4 @@
-RCSID: $MirOS: src/bin/mksh/mksh.faq,v 1.10 2020/10/01 22:59:12 tg Exp $
+RCSID: $MirOS: src/bin/mksh/mksh.faq,v 1.23+locale-tracking 2021/07/10 17:39:27 tg Exp $
ToC: spelling
Title: How do you spell <tt>mksh</tt>? How do you pronounce it?
@@ -8,12 +8,15 @@ Title: How do you spell <tt>mksh</tt>? H
initial lowercase letter</a>; this is important) or “MirBSD Korn Shell”,
possibly with “the”.</p>
<p>I usually pronounce it as “<span xml:lang="de-DE-1901">em-ka-es-ha</span>”,
- that is, the letters individually in my native German, or say “MirBSD Korn
- Shell”, although it is manageable, mostly for Slavic speakers, to actually
- say “mksh” as if it were a word ☺</p>
+ that is, the letters individually in my native German, emphasis on the
+ first syllable, or say “MirBSD Korn Shell”, although it is manageable,
+ mostly for Slavic speakers, to actually say “mksh” as if it were a word ☺</p>
<p>Oh… I’ve run into this one, didn’t I? “MirBSD” is pronounced “<span
xml:lang="de-DE-1901">Mir-Be-Es-De</span>” germanically, for anglophones
“Mir-beas’tie” is fine.</p>
+<p>This translates well into other languages, such as <span
+ xml:lang="es">eme-ka-ese-ache</span> in Spanish, although English
+ speakers may still find “Mir-beastie korn shell” more palatable.</p>
----
ToC: sowhatismksh
Title: I’m a $OS (<i>Android, OS/2, …</i>) user, so what’s mksh?
@@ -98,8 +101,8 @@ Title: How does this relate to ksh or th
getting close to, ksh88 compatibility.</p>
<p>SKsh is an AmigaOS-specific Korn Shell-lookalike by Steve Koren.</p>
<p>The <a href="@@RELPATH@@ksh-chan.htm">Homepage of the <tt>#ksh</tt>
- channel on Freenode IRC</a> contains more information about the Korn
- Shell in general and its flavours.</p>
+ channel on IRC</a> contains more information about the Korn Shell in
+ general and its flavours.</p>
----
ToC: packaging
Title: How should I package mksh? (common cases)
@@ -260,7 +263,7 @@ Title: My prompt is weird!
(This was agreed upon as suggestion in a discussion between bash, zsh and
Korn shell developers.) The feature set of different shells vastly differs
and each shell should use its default PS1 or from its startup files.</li>
-<li><tt>$ENV</tt> <a href="#env">is set and/or <tt>export</tt>ed</a>.</li>
+<li><tt>$ENV</tt> <a href="#env">is set and probably <tt>export</tt>ed</a>.</li>
<li>Your prompt is just “<tt># </tt>”: you’re entering a root shell, and
<tt>$PS1</tt> does not contain the ‘#’ character, in which case the shell
forces this prompt, making extra privileges obvious.</li>
@@ -284,7 +287,7 @@ Title: My prompt is weird!
ToC: env
Title: On startup files and <tt>$ENV</tt> across and detecting various shells
-Interactive shells look at <tt>~/.mkshrc</tt> (or <tt>/system/etc/mkshrc</tt>
+<p>Interactive shells look at <tt>~/.mkshrc</tt> (or <tt>/system/etc/mkshrc</tt>
on Android and <tt>/etc/mkshrc</tt> on FreeWRT and OpenWrt) by default. This
location can, however, be overridden by setting the <tt>ENV</tt> environment
variable. (FreeBSD is rumoured to set it in their system profile.) It’s better
@@ -295,7 +298,30 @@ or “MIRBSD KSH” for mksh, “PD KSH
for ksh93); <tt>$NETBSD_SHELL</tt> (NetBSD ash); <tt>POSH_VERSION</tt> (posh, a
pdksh derivative); <tt>$SH_VERSION</tt> (“PD KSH” as sh), <tt>$YASH_VERSION</tt>
(yash), <tt>$ZSH_VERSION</tt> (or if <tt>$VERSION</tt> begins with “zsh”); a <a
-href="@@RELPATH@@ksh-chan.htm#which-shell">list of more approaches</a> exists.
+href="@@RELPATH@@ksh-chan.htm#which-shell">list of more approaches</a> exists.</p>
+
+<p>Note that, in some scenarios, it might be very useful to actually set
+ <tt>$ENV</tt>: the regular interactive shell startup file lies in the
+ user’s home directory, relying on being copied from <tt>/etc/skel/</tt>
+ which normally is only done at user creation time. If mksh was installed
+ later, the user often won’t get it at all, and delivering updates is
+ challenging. One way of partially working around this is to ship an
+ <tt>/etc/skel/.mkshrc</tt> that reads <tt>/etc/mkshrc</tt> by default
+ (but the user can change it of course) and ship the <tt>dot.mkshrc</tt>
+ file as <tt>/etc/mkshrc</tt>, but that won’t fully help. This is where
+ <tt>$ENV</tt> comes into play:</p><ul>
+ <li>In <tt>/etc/profile</tt>, set <tt>ENV</tt> to a, say, <tt>shrc</tt>
+ file shipped in <tt>/etc/</tt> and export it.</li>
+ <li>In that new file, which must use only constructs compatible with
+ all shells, usually a subset of POSIX, read the various rc files
+ (<tt>.mkshrc</tt> for mksh, <tt>.kshrc</tt> for AT&T ksh93, etc.)
+ from the user’s home if they exist, from <tt>/etc/skel/</tt> otherwise.</li>
+</ul><p>This may very well be <em>required</em> if the alternative would
+ be <a href="#ps1weird">to <del><tt>export PS1</tt></del>[sic!]</a>. <a
+ href="https://gitlab.alpinelinux.org/alpine/aports/-/issues/12398#note_146574"
+ >alpine Linux</a> encountered this very problem, and the linked post is
+ a (draft) solution using the <tt>$ENV</tt> method and looks at various
+ other shells’ startup file situation as well.</p>
----
ToC: ctrl-x-e
Title: Multiline command editing
@@ -320,6 +346,27 @@ Title: Multiline command editing
nōn-zero (e.g. using jupp’s “abendjoe” command) to prevent execution.
This is <em>really</em> useful to write ad-hōc scripts as well.</p>
----
+ToC: escaping
+Title: Some characters don’t display right
+
+<p>First, make sure that either you’re using a UTF-8 terminal and system
+ and the shell’s UTF-8 mode is on (<tt>set -U</tt>) or that you’re using
+ an 8-bit codepage/CCSID and the UTF-8 mode is off (<tt>set +U</tt>). If
+ you’re on an EBCDIC system ensure to pick a codepage that has a bijective
+ mapping to (Extended) ASCII and in which all necessary characters are
+ present, for example 1047. Furthermore ensure the compile-time and runtime
+ codepages match. (Other encoding schemes, e.g. DBCS or ISO-2022-JP, are
+ not supported.) This should already fix most relevant issues.</p>
+<p>If using an 8-bit coding system that (unlike e.g. ISO 8859 or EBCDIC)
+ does not assign control characters to “Extended ASCII” codepoints 0x80‥0x9F,
+ such as codepages 437, 850, 1252, … (usually on OS/2 or DOS-based systems),
+ enable the option <tt>set -o asis</tt> (new in R60); otherwise, they will
+ be escaped to avoid accidentally setting off terminal control sequences.</p>
+<p>Note that escaping of characters is, at runtime, dependent on whether the
+ shell was compiled for EBCDIC and/or <tt>utf8-mode</tt> and/or <tt>asis</tt>
+ are enabled, the latter being ignored if either of the former two are true
+ (in UTF-8 mode, UCS C1 codepoints are always escaped).</p>
+----
ToC: ctrl-l-cls
Title: ^L (Ctrl-L) does not clear the screen
@@ -329,9 +376,15 @@ Use ^[^L (Escape+Ctrl-L) or rebind it:<b
ToC: ctrl-u-pico
Title: ^U (Ctrl-U) clears the entire line
-If it should only delete the line up to the cursor, use:<br />
+If you want it to only delete the line up to the cursor, use:<br />
<tt>bind -m ^U='^[0^K'</tt>
----
+ToC: ctrl-w-bash
+Title: ^W (Ctrl-W) deletes a word, not a bigword
+
+If you want it to delete more, with R60 you can use:<br />
+<tt>bind '^W=delete-bigword-backward'</tt>
+----
ToC: cur-up-zsh
Title: Cursor Up behaves differently from zsh
@@ -380,7 +433,7 @@ Title: What about programmable tab compl
The shell itself provides static deterministic tab completion.
However, you can use hooks like reprogramming the Tab key to a
command line editor macro, and using the <tt>evaluate-region</tt>
-editor command (modulo a bugfix) together with <tt>quote-region</tt> and shell functions to
+editor command together with <tt>quote-region</tt> and shell functions to
implement a programmable completion engine. Multiple people have
been considering doing so in our IRC channel; we’ll hyperlink to
these engines when they are available.
@@ -398,7 +451,12 @@ Title: How POSIX compliant is mksh? Also
<tt>utf8-mode</tt> (which only supports the BMP (Basic Multilingual Plane) of
UCS and maps raw octets into the U+EF80‥U+EFFF wide character range; see
<tt>Arithmetic expressions</tt> in mksh(1) for details) <em>must</em> stay
- disabled in POSIX mode (it is disabled upon enabling POSIX mode in R56+).</p>
+ disabled in POSIX mode (it is disabled upon enabling POSIX mode in R56+ but
+ don’t depend on this to stay once locale tracking will be implemented; the
+ disabling code is not present in this build).</p>
+<p><strong>Future compatibility note:</strong> there’s work underway to use
+ full 21-bit UTF-8 in mksh R60 or so. Raw octet mapping will almost certainly
+ be moved out of the PUA and to some range outside of UCS.</p>
<p class="boxhead">The following POSIX sh-compatible code toggles the
<tt>utf8-mode</tt> option dependent on the current POSIX locale, for mksh
to allow using the UTF-8 mode, within the constraints outlined above, in
@@ -414,7 +472,7 @@ Title: How POSIX compliant is mksh? Also
esac
</pre>
</div><p class="boxfoot">In near future, (UTF-8) locale tracking will
- be implemented, though.</p>
+ be implemented, though. This build of mksh already enables it.</p>
<p>The shell is pretty close to POSIX, when run as <tt>lksh -o posix</tt>
under the "C" locale it is intended to match. It does not do everything
like other POSIX-compatible or ‑compliant shells, though.</p>
@@ -532,6 +590,15 @@ This is because AT&T ksh93 ships a p
put this into your <tt>~/.mkshrc</tt>
(note the space before the closing single quote)
----
+ToC: builtin-cat
+Title: Didn’t there used to be a cat(1) builtin?
+
+<p>Up to and including mksh R59c, we indeed shipped a built-in cat(1)
+ inside mksh; this was added originally because Android did not have
+ one <em>at all</em> (but they have since imported a BSD cat). While
+ it could speed up some sh scripts correct signal handling is hard to
+ get right, so (with regret) it was removed in 2021. 🙀</p>
+----
ToC: builtin-rename
Title: “rename” doesn’t work as expected!
@@ -546,23 +613,39 @@ Title: “rename” doesn’t work as ex
<pre>alias rename="$(whence -p rename)"</pre>
----
ToC: builtin-sleep
-Title: “sleep” does not accept ‘m’ for minutes!
+Title: Didn’t there used to be a sleep(1) builtin?
-<p>mksh contains a <tt>sleep</tt> built-in utility, in order to be
- able to offer sub-second sleep to shell scripts for most platforms.
- (It does not exist if the platform lacks select(2) — which should
- be rare.)</p>
-<p>GNU coreutils contains a sleep implementation accepting suffixed
- numbers. If you wish to invoke an external utility (in favour over a
- builtin), you can use <tt>dot.mkshrc</tt>’s function <tt>enable</tt>
- or put something along the following lines into <tt>~/.mkshrc</tt>:</p>
-<pre>alias sleep="$(whence -p sleep)"</pre>
-<pre>timer() { sleep $(($1*60${2:++$2})); } # timer mins [secs]</pre>
-<pre>timer() {
- local arg=${1/m/'*60+'}
- [[ $arg = *+ ]] && arg+=0
- sleep $(($arg)
-}</pre>
+<p>Up to and including mksh R59c, we indeed shipped a subsecond-capable
+ select(2)-based built-in sleep(1). This got originally added because
+ too many platforms do not support sub-second sleep, which nowadays is
+ of less concern. It also led to users complaining about lack for system
+ *ahem* GNU extensions, but the cause of its demise is that getting signal
+ handling right, in a portable way and without too many syscalls (there’s
+ a threshold over which fork+exec is cheaper!), isn’t feasible if even at
+ all possible.</p>
+<p>The MirOS Project now ships <a href="@@RELPATH@@subprj.htm#sleep">a
+ portable sleep</a> which similarily is select(2)-based and capable of
+ subsecond sleep but in addition supports all GNU extensions related to
+ specifying the amount of time to sleep. It will work on <em>at least</em>
+ all platforms on which mksh had a builtin before. Please install this
+ if your operating system lacks a good enough sleep(1) utility.</p>
+<p>Note that, if your OS lacks select(2), you’ll lose out either way.
+ In that case, GNU coreutils’ sleep, which is built on older syscalls,
+ may work if the copyleft licence isn’t a showstopper for you.</p>
+----
+ToC: arith-import
+Title: Some integer variables are 0?
+
+<p class="boxhead">To mitigate potential exploits, variables imported
+ from the environment are not trusted in arithmetic context; that is…</p>
+<div class="boxtext">
+ <pre>
+ foo=1+1 mksh -c 'integer foo; print $foo'
+ foo=1+1 mksh -c 'integer foo=$foo; print $foo'
+ </pre>
+</div><p class="boxfoot">… will lose the value in the first line,
+ while the second line explicitly “untaints”, to use a Perl term,
+ the content. Purely numeric values will pass, though.</p>
----
ToC: string-concat
Title: “+=” behaves differently from other shells
@@ -635,18 +718,22 @@ Title: I use “set -eo pipefail” and
ToC: faq
Title: My question is not answered here!
-Do read the mksh(1) manual page. You might also wish to read the <a
- href="@@RELPATH@@ksh-chan.htm">homepage of the <tt>#ksh</tt> IRC channel
-on Freenode</a> which lists several resources for Korn or POSIX-compatible
-shells in general. Or, <a href="#contact">contact</a> us (developer and
-users), for example via IRC.
+Do read the mksh(1) and lksh(1) manual page. You might also wish to read the <a
+ href="@@RELPATH@@ksh-chan.htm">homepage of the <tt>#ksh</tt> IRC channel</a>
+which lists several resources for Korn or POSIX-compatible shells in general.
+Or, <a href="#contact">contact</a> us (developer and users).
----
ToC: contact
-Title: How do I contact you (to say thanks)?
+Title: How do I contact you (to say thanks, for bugreports and questions)?
-You can say hi in the <tt>#!/bin/mksh</tt> channel on Freenode <a
- href="@@RELPATH@@irc.htm">IRC</a>, although a <a
- href="@@RELPATH@@danke.htm">donation</a> wouldn’t be amiss ☺ The <a
- href="http://www.mail-archive.com/miros-mksh@mirbsd.org/">mailing
-list</a> can also be used.
+<p>You can say hi in the <tt>#!/bin/mksh</tt> channel on <a
+ href="@@RELPATH@@irc.htm">IRC</a> (OFTC, for now), although… a
+ <a href="@@RELPATH@@danke.htm">donation</a> wouldn’t be amiss ☻
+<br />The <a href="@@RELPATH@@rss.htm#lists">mailing list</a> can also
+ be used for this. The <a href="#faq">extra resources</a> from the FAQ
+ entry just one above should also be considered ;-)</p>
+<p>If you insist on sending a bugreport, IRC and the mailing list are
+ great places for that; <a href="https://launchpad.net/mksh">Launchpad</a>,
+ an external gratis service provided by a company, can also be used if you
+ like web-based issue trackers better.</p>
----
--- mksh-59c.orig/rlimits.opt
+++ mksh-59c/rlimits.opt
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2013, 2015, 2019
+ * Copyright (c) 2013, 2015, 2019, 2021
* mirabilos <m@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@@ -21,7 +21,7 @@
*/
@RLIMITS_DEFNS
-__RCSID("$MirOS: src/bin/mksh/rlimits.opt,v 1.5 2020/07/24 20:11:18 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/rlimits.opt,v 1.6 2021/01/10 18:44:06 tg Exp $");
@RLIMITS_ITEMS
#define FN(lname,lid,lfac,lopt) (const struct limits *)(&rlimits_ ## lid),
@@
@@ -94,6 +94,9 @@ FN("threadsperprocess", RLIMIT_THREADS,
>e|RLIMIT_NICE
FN("maxnice", RLIMIT_NICE, 1
+>R|RLIMIT_RTTIME
+FN("rttime(ms)", RLIMIT_RTTIME, 1
+
>r|RLIMIT_RTPRIO
FN("maxrtprio", RLIMIT_RTPRIO, 1
--- mksh-59c.orig/sh.h
+++ mksh-59c/sh.h
@@ -193,9 +193,9 @@
#endif
#ifdef EXTERN
-__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.904 2020/10/31 03:53:06 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.906 2021/01/24 19:37:31 tg Exp $");
#endif
-#define MKSH_VERSION "R59 2020/10/31"
+#define MKSH_VERSION "R59 2021/07/10"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES
@@ -666,7 +666,7 @@ char *ucstrstr(char *, const char *);
#endif
#endif
-#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 593)
+#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 599)
#error Must run Build.sh to compile this.
extern void thiswillneverbedefinedIhope(void);
int
@@ -999,8 +999,6 @@ EXTERN const char Tcant_cd[] E_INIT("res
EXTERN const char Tcant_find[] E_INIT("can't find");
EXTERN const char Tcant_open[] E_INIT("can't open");
#define Tbytes (Toomem + 24)
-EXTERN const char Tbcat[] E_INIT("!cat");
-#define Tcat (Tbcat + 1)
#define Tcd (Tcant_cd + 25)
#define T_command (T_funny_command + 9)
#define Tcommand (T_funny_command + 10)
@@ -1165,8 +1163,6 @@ EXTERN const char T_devtty[] E_INIT("/de
#define Tcant_find "can't find"
#define Tcant_open "can't open"
#define Tbytes "bytes"
-#define Tbcat "!cat"
-#define Tcat "cat"
#define Tcd "cd"
#define T_command "-command"
#define Tcommand "command"
@@ -1415,9 +1411,9 @@ EXTERN bool really_exit;
#define CiOCTAL BIT(5) /* 0‥7 */
#define CiQCL BIT(6) /* &();| */
#define CiALIAS BIT(7) /* !,.@ */
-#define CiQCX BIT(8) /* *[\\ */
+#define CiQCX BIT(8) /* *[\\~ */
#define CiVAR1 BIT(9) /* !*@ */
-#define CiQCM BIT(10) /* /^~ */
+#define CiQCM BIT(10) /* /^ */
#define CiDIGIT BIT(11) /* 89 */
#define CiQC BIT(12) /* "' */
#define CiSPX BIT(13) /* \x0B\x0C */
@@ -1474,7 +1470,7 @@ EXTERN char ifs0;
#define C_EDCMD (CiGRAVE | CiQCL)
/* \x09\x0A\x20"&'():;<=>`| editor non-word characters */
#define C_EDNWC (CiANGLE | CiCOLON | CiEQUAL | CiGRAVE | CiNL | CiQC | CiQCL | CiSP | CiTAB)
-/* "#$&'()*:;<=>?[\\`{|} editor quotes for tab completion */
+/* "#$&'()*:;<=>?[\\`{|}~ editor quotes for tab completion */
#define C_EDQ (CiANGLE | CiCOLON | CiCURLY | CiEQUAL | CiGRAVE | CiHASH | CiQC | CiQCL | CiQCX | CiQUEST | CiSS)
/* !‥~ POSIX graphical (alphanumerical plus punctuation) */
#define C_GRAPH (C_PUNCT | CiDIGIT | CiLOWER | CiOCTAL | CiUPPER)
@@ -1498,8 +1494,8 @@ EXTERN char ifs0;
#define C_PRINT (C_GRAPH | CiSP)
/* !"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ POSIX punctuation */
#define C_PUNCT (CiALIAS | CiANGLE | CiBRACK | CiCOLON | CiCURLY | CiEQUAL | CiGRAVE | CiHASH | CiMINUS | CiPERCT | CiPLUS | CiQC | CiQCL | CiQCM | CiQCX | CiQUEST | CiSS | CiUNDER)
-/* \x09\x0A"#$&'()*;<=>?[\\]`| characters requiring quoting, minus space */
-#define C_QUOTE (CiANGLE | CiBRACK | CiEQUAL | CiGRAVE | CiHASH | CiNL | CiQC | CiQCL | CiQCX | CiQUEST | CiSS | CiTAB)
+/* \x09\x0A"#$&'()*;<=>?[\\]`{|}~ characters requiring quoting, minus space */
+#define C_QUOTE (CiANGLE | CiBRACK | CiCURLY | CiEQUAL | CiGRAVE | CiHASH | CiNL | CiQC | CiQCL | CiQCX | CiQUEST | CiSS | CiTAB)
/* 0‥9A‥Fa‥f hexadecimal digit */
#define C_SEDEC (CiDIGIT | CiHEXLT | CiOCTAL)
/* \x09‥\x0D\x20 POSIX space class */
@@ -1580,6 +1576,7 @@ extern void ebcdic_init(void);
#define ksh_isctrl(c) (ord(c) < 0x40 || ord(c) == 0xFF)
#else
#define ksh_isctrl(c) ((ord(c) & 0x7F) < 0x20 || ord(c) == 0x7F)
+#define ksh_asisctrl(c) (ord(c) < 0x20U || ord(c) == 0x7FU)
#endif
/* new fast character classes */
#define ctype(c,t) tobool(ksh_ctypes[ord(c)] & (t))
@@ -2499,8 +2496,6 @@ int c_mknod(const char **);
#endif
int c_realpath(const char **);
int c_rename(const char **);
-int c_cat(const char **);
-int c_sleep(const char **);
/* histrap.c */
void init_histvec(void);
void hist_init(Source *);
@@ -2755,7 +2750,7 @@ struct tbl *arraysearch(struct tbl *, ui
char **makenv(void);
void change_winsz(void);
size_t array_ref_len(const char *) MKSH_A_PURE;
-char *arrayname(const char *);
+struct tbl *arraybase(const char *);
mksh_uari_t set_array(const char *, bool, const char **);
uint32_t hash(const void *) MKSH_A_PURE;
uint32_t chvt_rndsetup(const void *, size_t) MKSH_A_PURE;
--- mksh-59c.orig/sh_flags.opt
+++ mksh-59c/sh_flags.opt
@@ -43,6 +43,10 @@ __RCSID("$MirOS: src/bin/mksh/sh_flags.o
>a|
F0("allexport", FEXPORT, OF_ANY
+/* ./. when quoting, show C1 control characters as-is; +U only */
+>|
+FN("asis", FASIS, OF_ANY
+
/* ./. bgnice */
>| HAVE_NICE
FN("bgnice", FBGNICE, OF_ANY
--- mksh-59c.orig/shf.c
+++ mksh-59c/shf.c
@@ -383,6 +383,8 @@ shf_emptybuf(struct shf *shf, int flags)
memmove(shf->buf, buf,
ntowrite);
shf->wp = shf->buf + ntowrite;
+ /* restore errno for caller */
+ errno = shf->errnosv;
}
return (-1);
}
@@ -681,8 +683,13 @@ shf_write(const char *buf, ssize_t nbyte
if (shf->flags & SHF_STRING) {
/* resize buffer until there's enough space left */
while (nbytes > shf->wnleft)
- if (shf_emptybuf(shf, EB_GROW) == -1)
- return (-1);
+ if (shf_emptybuf(shf, EB_GROW) == -1) {
+ /* truncate if possible */
+ if (shf->wnleft == 0)
+ return (-1);
+ nbytes = shf->wnleft;
+ break;
+ }
/* then write everything into the buffer */
} else {
/* flush deals with sticky errors */
@@ -1063,8 +1070,7 @@ shf_vfprintf(struct shf *shf, const char
nwritten += precision;
precision = utf_skipcols(s, precision, &tmp) - s;
- while (precision--)
- shf_putc(*s++, shf);
+ shf_write(s, precision, shf);
nwritten += field;
while (field--)
@@ -1206,7 +1212,7 @@ const uint32_t tpl_ctypes[128] = {
CiLOWER, CiLOWER, CiLOWER, CiLOWER,
CiLOWER, CiLOWER, CiLOWER, CiLOWER,
CiLOWER, CiLOWER, CiLOWER, CiCURLY,
- CiQCL, CiCURLY, CiQCM, CiCNTRL
+ CiQCL, CiCURLY, CiQCX, CiCNTRL
};
void
--- mksh-59c.orig/syn.c
+++ mksh-59c/syn.c
@@ -74,8 +74,8 @@ static int symbol; /* yylex value */
#define REJECT (reject = true)
#define ACCEPT (reject = false)
-#define token(cf) ((reject) ? (ACCEPT, symbol) : (symbol = yylex(cf)))
-#define tpeek(cf) ((reject) ? (symbol) : (REJECT, symbol = yylex(cf)))
+#define token(cf) ((reject ? 0 : (symbol = yylex(cf))), ACCEPT, symbol)
+#define tpeek(cf) ((reject ? 0 : (symbol = yylex(cf))), REJECT, symbol)
#define musthave(c,cf) do { \
if ((unsigned int)token(cf) != (unsigned int)(c)) \
syntaxerr(NULL); \
--- mksh-59c.orig/tree.c
+++ mksh-59c/tree.c
@@ -43,8 +43,12 @@ static bool ptree_hashere;
static struct shf ptree_heredoc;
#define ptree_outhere(shf) do { \
if (ptree_hashere) { \
- shf_puts(shf_sclose(&ptree_heredoc), (shf)); \
+ char *ptree_thehere; \
+ \
+ ptree_thehere = shf_sclose(&ptree_heredoc); \
+ shf_puts(ptree_thehere, (shf)); \
shf_putc('\n', (shf)); \
+ afree(ptree_thehere, ATEMP); \
ptree_hashere = false; \
/*prevent_semicolon = true;*/ \
} \
--- mksh-59c.orig/var.c
+++ mksh-59c/var.c
@@ -3,7 +3,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
- * 2019
+ * 2019, 2021
* mirabilos <m@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@@ -29,7 +29,7 @@
#include <sys/sysctl.h>
#endif
-__RCSID("$MirOS: src/bin/mksh/var.c,v 1.237 2020/06/22 17:11:03 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/var.c,v 1.237+deb 2020/06/22 17:11:03 tg Exp $");
/*-
* Variables
@@ -57,6 +57,7 @@ static void getspec(struct tbl *);
static void setspec(struct tbl *);
static void unsetspec(struct tbl *, bool);
static int getint(struct tbl *, mksh_ari_u *, bool);
+static int getnum(const char *, mksh_ari_u *, bool, bool);
static const char *array_index_calc(const char *, bool *, uint32_t *);
static struct tbl *vtypeset(int *, const char *, uint32_t, uint32_t, int, int);
@@ -494,6 +495,7 @@ setstr(struct tbl *vq, const char *s, in
vq->flag |= ALLOC;
vq->type = 0;
}
+ vq->flag &= ~IMPORT;
afree(salloc, ATEMP);
} else {
/* integer dest */
@@ -527,10 +529,6 @@ setint(struct tbl *vq, mksh_ari_t n)
static int
getint(struct tbl *vp, mksh_ari_u *nump, bool arith)
{
- mksh_uari_t c, num = 0, base = 10;
- const char *s;
- bool have_base = false, neg = false;
-
if (vp->flag & SPECIAL)
getspec(vp);
/* XXX is it possible for ISSET to be set and val.s to be NULL? */
@@ -540,7 +538,15 @@ getint(struct tbl *vp, mksh_ari_u *nump,
nump->i = vp->val.i;
return (vp->type);
}
- s = vp->val.s + vp->type;
+ return (getnum(vp->val.s + vp->type, nump, arith,
+ Flag(FPOSIX) && !(vp->flag & ZEROFIL)));
+}
+
+static int
+getnum(const char *s, mksh_ari_u *nump, bool arith, bool psxoctal)
+{
+ mksh_uari_t c, num = 0, base = 10;
+ bool have_base = false, neg = false;
do {
c = (unsigned char)*s++;
@@ -561,8 +567,7 @@ getint(struct tbl *vp, mksh_ari_u *nump,
base = 16;
++s;
goto getint_c_style_base;
- } else if (Flag(FPOSIX) && ctype(s[0], C_DIGIT) &&
- !(vp->flag & ZEROFIL)) {
+ } else if (psxoctal && ctype(s[0], C_DIGIT)) {
/* interpret as octal (deprecated) */
base = 8;
getint_c_style_base:
@@ -641,10 +646,11 @@ setint_v(struct tbl *vq, struct tbl *vp,
void
setint_n(struct tbl *vq, mksh_ari_t num, int newbase)
{
- if (!(vq->flag & INTEGER) && (vq->flag & ALLOC)) {
- vq->flag &= ~ALLOC;
+ if (!(vq->flag & INTEGER)) {
+ if (vq->flag & ALLOC)
+ afree(vq->val.s, vq->areap);
+ vq->flag &= ~(ALLOC | IMPORT);
vq->type = 0;
- afree(vq->val.s, vq->areap);
}
vq->val.i = num;
if (newbase != 0)
@@ -938,7 +944,7 @@ vtypeset(int *ep, const char *var, uint3
set &= ~(LOCAL|LOCAL_COPY);
- vpbase = (vp->flag & ARRAY) ? global(arrayname(tvar)) : vp;
+ vpbase = (vp->flag & ARRAY) ? arraybase(tvar) : vp;
/*
* only allow export and readonly flag to be set; AT&T ksh
@@ -961,7 +967,7 @@ vtypeset(int *ep, const char *var, uint3
*/
for (t = vpbase; t; t = t->u.array) {
bool fake_assign;
- char *s = NULL;
+ const char *s = NULL;
char *free_me = NULL;
fake_assign = (t->flag & ISSET) && (!val || t != vp) &&
@@ -983,13 +989,27 @@ vtypeset(int *ep, const char *var, uint3
t->type = 0;
t->flag &= ~ALLOC;
}
- t->flag = (t->flag | set) & ~clr;
/*
* Don't change base if assignment is to be
* done, in case assignment fails.
*/
- if ((set & INTEGER) && base > 0 && (!val || t != vp))
- t->type = base;
+ if (set & INTEGER) {
+ if (base > 0 && (!val || t != vp))
+ t->type = base;
+ /*
+ * Do not permit content from the
+ * environment to e.g. execute commands.
+ */
+ if ((t->flag & IMPORT) && fake_assign) {
+ mksh_ari_u num;
+
+ if (getnum(s, &num, true,
+ tobool(Flag(FPOSIX))) == -1)
+ s = "0";
+ clr |= IMPORT;
+ }
+ }
+ t->flag = (t->flag | set) & ~clr;
if (set & (LJUST|RJUST|ZEROFIL))
t->u2.field = field;
if (fake_assign) {
@@ -1019,7 +1039,7 @@ vtypeset(int *ep, const char *var, uint3
if (vappend) {
size_t tlen;
- if ((vp->flag & (ISSET|ALLOC|SPECIAL|INTEGER|UCASEV_AL|LCASEV|LJUST|RJUST)) != (ISSET|ALLOC)) {
+ if ((vp->flag & (ISSET|ALLOC|SPECIAL|INTEGER|UCASEV_AL|LCASEV|LJUST|RJUST|IMPORT)) != (ISSET|ALLOC)) {
/* cannot special-case this */
strdup2x(tvar, str_val(vp), val);
val = tvar;
@@ -1038,9 +1058,11 @@ vtypeset(int *ep, const char *var, uint3
/* done after assignment to override default */
if (base > 0)
vp->type = base;
- } else
+ } else {
/* setstr can't fail (readonly check already done) */
setstr(vp, val, KSH_RETURN_ERROR | 0x4);
+ vp->flag |= (set & IMPORT);
+ }
/* came here from vappend? need to free temp val */
if (vappend)
@@ -1610,19 +1632,25 @@ array_ref_len(const char *cp)
}
/*
- * Make a copy of the base of an array name
+ * same effect as global(copy of the base of an array name)
*/
-char *
-arrayname(const char *str)
+struct tbl *
+arraybase(const char *str)
{
const char *p;
- char *rv;
-
- if (!(p = cstrchr(str, '[')))
- /* Shouldn't happen, but why worry? */
- strdupx(rv, str, ATEMP);
- else
- strndupx(rv, str, p - str, ATEMP);
+ char *s, sbuf[32];
+ size_t n;
+ struct tbl *rv;
+
+ n = strlen(str);
+ if ((p = memchr(str, '[', n)))
+ n = p - str;
+ s = n < sizeof(sbuf) ? sbuf : alloc(n + 1, ATEMP);
+ memcpy(s, str, n);
+ s[n] = '\0';
+ rv = global(s);
+ if (s != sbuf)
+ afree(s, ATEMP);
return (rv);
}
|