1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478
|
# $MirOS: src/bin/mksh/check.t,v 1.396 2010/11/01 17:29:00 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# Thorsten Glaser <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
# is granted to deal in this work without restriction, including un‐
# limited rights to use, publicly perform, distribute, sell, modify,
# merge, give away, or sublicence.
#
# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
# the utmost extent permitted by applicable law, neither express nor
# implied; without malicious intent or gross negligence. In no event
# may a licensor, author or contributor be held liable for indirect,
# direct, other damage, loss, or other issues arising in any way out
# of dealing in the work, even if advised of the possibility of such
# damage or existence of a defect, except proven that it results out
# of said person’s immediate fault when using the work as intended.
#-
# You may also want to test IFS with the script at
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R39 2010/11/01
category: mksh
description:
Check version of shell.
stdin:
echo $KSH_VERSION
name: KSH_VERSION
---
name: selftest-1
description:
Regression test self-testing
stdin:
echo ${foo:-baz}
expected-stdout:
baz
---
name: selftest-2
description:
Regression test self-testing
env-setup: !foo=bar!
stdin:
echo ${foo:-baz}
expected-stdout:
bar
---
name: selftest-3
description:
Regression test self-testing
env-setup: !ENV=fnord!
stdin:
echo "<$ENV>"
expected-stdout:
<fnord>
---
name: selftest-env
description:
Just output the environment variables set (always fails)
category: disabled
stdin:
set
---
name: alias-1
description:
Check that recursion is detected/avoided in aliases.
stdin:
alias fooBar=fooBar
fooBar
exit 0
expected-stderr-pattern:
/fooBar.*not found.*/
---
name: alias-2
description:
Check that recursion is detected/avoided in aliases.
stdin:
alias fooBar=barFoo
alias barFoo=fooBar
fooBar
barFoo
exit 0
expected-stderr-pattern:
/fooBar.*not found.*\n.*barFoo.*not found/
---
name: alias-3
description:
Check that recursion is detected/avoided in aliases.
category: mksh
stdin:
alias Echo='echo '
alias fooBar=barFoo
alias barFoo=fooBar
Echo fooBar
unalias barFoo
Echo fooBar
expected-stdout:
fooBar
barFoo
---
name: alias-4
description:
Check that alias expansion isn't done on keywords (in keyword
postitions).
category: mksh
stdin:
alias Echo='echo '
alias while=While
while false; do echo hi ; done
Echo while
expected-stdout:
While
---
name: alias-5
description:
Check that alias expansion done after alias with trailing space.
category: mksh
stdin:
alias Echo='echo '
alias foo='bar stuff '
alias bar='Bar1 Bar2 '
alias stuff='Stuff'
alias blah='Blah'
Echo foo blah
expected-stdout:
Bar1 Bar2 Stuff Blah
---
name: alias-6
description:
Check that alias expansion done after alias with trailing space.
category: mksh
stdin:
alias Echo='echo '
alias foo='bar bar'
alias bar='Bar '
alias blah=Blah
Echo foo blah
expected-stdout:
Bar Bar Blah
---
name: alias-7
description:
Check that alias expansion done after alias with trailing space
after a keyword.
category: mksh
stdin:
alias X='case '
alias Y=Z
X Y in 'Y') echo is y ;; Z) echo is z ; esac
expected-stdout:
is z
---
name: alias-8
description:
Check that newlines in an alias don't cause the command to be lost.
category: mksh
stdin:
alias foo='
echo hi
echo there
'
foo
expected-stdout:
hi
there
---
name: alias-9
description:
Check that recursion is detected/avoided in aliases.
This check fails for slow machines or Cygwin, raise
the time-limit clause (e.g. to 7) if this occurs.
category: mksh
time-limit: 3
stdin:
echo -n >tf
alias ls=ls
ls
echo $(ls)
exit 0
expected-stdout:
tf
tf
---
name: alias-10
description:
Check that recursion is detected/avoided in aliases.
Regression, introduced during an old bugfix.
category: mksh
stdin:
alias foo='print hello '
alias bar='foo world'
echo $(bar)
expected-stdout:
hello world
---
name: arith-lazy-1
description:
Check that only one side of ternary operator is evaluated
stdin:
x=i+=2
y=j+=2
i=1
j=1
echo $((1 ? 20 : (x+=2)))
echo $i,$x
echo $((0 ? (y+=2) : 30))
echo $j,$y
expected-stdout:
20
1,i+=2
30
1,j+=2
---
name: arith-lazy-2
description:
Check that assignments not done on non-evaluated side of ternary
operator
stdin:
x=i+=2
y=j+=2
i=1
j=1
echo $((1 ? 20 : (x+=2)))
echo $i,$x
echo $((0 ? (y+=2) : 30))
echo $i,$y
expected-stdout:
20
1,i+=2
30
1,j+=2
---
name: arith-lazy-3
description:
Check that assignments not done on non-evaluated side of ternary
operator and this construct is parsed correctly (Debian #445651)
stdin:
x=4
y=$((0 ? x=1 : 2))
echo = $x $y =
expected-stdout:
= 4 2 =
---
name: arith-ternary-prec-1
description:
Check precedence of ternary operator vs assignment
stdin:
x=2
y=$((1 ? 20 : x+=2))
expected-exit: e != 0
expected-stderr-pattern:
/.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
---
name: arith-ternary-prec-2
description:
Check precedence of ternary operator vs assignment
stdin:
x=2
echo $((0 ? x+=2 : 20))
expected-stdout:
20
---
name: arith-div-assoc-1
description:
Check associativity of division operator
stdin:
echo $((20 / 2 / 2))
expected-stdout:
5
---
name: arith-assop-assoc-1
description:
Check associativity of assignment-operator operator
stdin:
i=1
j=2
k=3
echo $((i += j += k))
echo $i,$j,$k
expected-stdout:
6
6,5,3
---
name: arith-unsigned-1
description:
Check if unsigned arithmetics work
category: mksh
stdin:
# signed vs unsigned
echo x1 $((-1)) $((#-1))
# calculating
typeset -i vs
typeset -Ui vu
vs=4123456789; vu=4123456789
echo x2 $vs $vu
(( vs %= 2147483647 ))
(( vu %= 2147483647 ))
echo x3 $vs $vu
vs=4123456789; vu=4123456789
(( # vs %= 2147483647 ))
(( # vu %= 2147483647 ))
echo x4 $vs $vu
# make sure the calculation does not change unsigned flag
vs=4123456789; vu=4123456789
echo x5 $vs $vu
# short form
echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
# array refs
set -A va
va[1975973142]=right
va[4123456789]=wrong
echo x7 ${va[#4123456789%2147483647]}
expected-stdout:
x1 -1 4294967295
x2 -171510507 4123456789
x3 -171510507 4123456789
x4 1975973142 1975973142
x5 -171510507 4123456789
x6 1975973142 1975973142
x7 right
---
name: arith-limit32-1
description:
Check if arithmetics are 32 bit
category: mksh
stdin:
# signed vs unsigned
echo x1 $((-1)) $((#-1))
# calculating
typeset -i vs
typeset -Ui vu
vs=2147483647; vu=2147483647
echo x2 $vs $vu
let vs++ vu++
echo x3 $vs $vu
vs=4294967295; vu=4294967295
echo x4 $vs $vu
let vs++ vu++
echo x5 $vs $vu
let vs++ vu++
echo x6 $vs $vu
expected-stdout:
x1 -1 4294967295
x2 2147483647 2147483647
x3 -2147483648 2147483648
x4 -1 4294967295
x5 0 0
x6 1 1
---
name: bksl-nl-ign-1
description:
Check that \newline is not collasped after #
stdin:
echo hi #there \
echo folks
expected-stdout:
hi
folks
---
name: bksl-nl-ign-2
description:
Check that \newline is not collasped inside single quotes
stdin:
echo 'hi \
there'
echo folks
expected-stdout:
hi \
there
folks
---
name: bksl-nl-ign-3
description:
Check that \newline is not collasped inside single quotes
stdin:
cat << \EOF
hi \
there
EOF
expected-stdout:
hi \
there
---
name: bksl-nl-ign-4
description:
Check interaction of aliases, single quotes and here-documents
with backslash-newline
(don't know what POSIX has to say about this)
category: mksh
stdin:
a=2
alias x='echo hi
cat << "EOF"
foo\
bar
some'
x
more\
stuff$a
EOF
expected-stdout:
hi
foo\
bar
some
more\
stuff$a
---
name: bksl-nl-ign-5
description:
Check what happens with backslash at end of input
(the old Bourne shell trashes them; so do we)
stdin: !
echo `echo foo\\`bar
echo hi\
expected-stdout:
foobar
hi
---
#
# Places \newline should be collapsed
#
name: bksl-nl-1
description:
Check that \newline is collasped before, in the middle of, and
after words
stdin:
\
echo hi\
There, \
folks
expected-stdout:
hiThere, folks
---
name: bksl-nl-2
description:
Check that \newline is collasped in $ sequences
(ksh93 fails this)
stdin:
a=12
ab=19
echo $\
a
echo $a\
b
echo $\
{a}
echo ${a\
b}
echo ${ab\
}
expected-stdout:
12
19
12
19
19
---
name: bksl-nl-3
description:
Check that \newline is collasped in $(..) and `...` sequences
(ksh93 fails this)
stdin:
echo $\
(echo foobar1)
echo $(\
echo foobar2)
echo $(echo foo\
bar3)
echo $(echo foobar4\
)
echo `
echo stuff1`
echo `echo st\
uff2`
expected-stdout:
foobar1
foobar2
foobar3
foobar4
stuff1
stuff2
---
name: bksl-nl-4
description:
Check that \newline is collasped in $((..)) sequences
(ksh93 fails this)
stdin:
echo $\
((1+2))
echo $(\
(1+2+3))
echo $((\
1+2+3+4))
echo $((1+\
2+3+4+5))
echo $((1+2+3+4+5+6)\
)
expected-stdout:
3
6
10
15
21
---
name: bksl-nl-5
description:
Check that \newline is collasped in double quoted strings
stdin:
echo "\
hi"
echo "foo\
bar"
echo "folks\
"
expected-stdout:
hi
foobar
folks
---
name: bksl-nl-6
description:
Check that \newline is collasped in here document delimiters
(ksh93 fails second part of this)
stdin:
a=12
cat << EO\
F
a=$a
foo\
bar
EOF
cat << E_O_F
foo
E_O_\
F
echo done
expected-stdout:
a=12
foobar
foo
done
---
name: bksl-nl-7
description:
Check that \newline is collasped in double-quoted here-document
delimiter.
stdin:
a=12
cat << "EO\
F"
a=$a
foo\
bar
EOF
echo done
expected-stdout:
a=$a
foo\
bar
done
---
name: bksl-nl-8
description:
Check that \newline is collasped in various 2+ character tokens
delimiter.
(ksh93 fails this)
stdin:
echo hi &\
& echo there
echo foo |\
| echo bar
cat <\
< EOF
stuff
EOF
cat <\
<\
- EOF
more stuff
EOF
cat <<\
EOF
abcdef
EOF
echo hi >\
> /dev/null
echo $?
i=1
case $i in
(\
x|\
1\
) echo hi;\
;
(*) echo oops
esac
expected-stdout:
hi
there
foo
stuff
more stuff
abcdef
0
hi
---
name: bksl-nl-9
description:
Check that \ at the end of an alias is collapsed when followed
by a newline
(don't know what POSIX has to say about this)
category: mksh
stdin:
alias x='echo hi\'
x
echo there
expected-stdout:
hiecho there
---
name: bksl-nl-10
description:
Check that \newline in a keyword is collapsed
stdin:
i\
f true; then\
echo pass; el\
se echo fail; fi
expected-stdout:
pass
---
#
# Places \newline should be collapsed (ksh extensions)
#
name: bksl-nl-ksh-1
description:
Check that \newline is collapsed in extended globbing
(ksh93 fails this)
category: mksh
stdin:
xxx=foo
case $xxx in
(f*\
(\
o\
)\
) echo ok ;;
*) echo bad
esac
expected-stdout:
ok
---
name: bksl-nl-ksh-2
description:
Check that \newline is collapsed in ((...)) expressions
(ksh93 fails this)
category: mksh
stdin:
i=1
(\
(\
i=i+2\
)\
)
echo $i
expected-stdout:
3
---
name: break-1
description:
See if break breaks out of loops
stdin:
for i in a b c; do echo $i; break; echo bad-$i; done
echo end-1
for i in a b c; do echo $i; break 1; echo bad-$i; done
echo end-2
for i in a b c; do
for j in x y z; do
echo $i:$j
break
echo bad-$i
done
echo end-$i
done
echo end-3
expected-stdout:
a
end-1
a
end-2
a:x
end-a
b:x
end-b
c:x
end-c
end-3
---
name: break-2
description:
See if break breaks out of nested loops
stdin:
for i in a b c; do
for j in x y z; do
echo $i:$j
break 2
echo bad-$i
done
echo end-$i
done
echo end
expected-stdout:
a:x
end
---
name: break-3
description:
What if break used outside of any loops
(ksh88,ksh93 don't print error messages here)
stdin:
break
expected-stderr-pattern:
/.*break.*/
---
name: break-4
description:
What if break N used when only N-1 loops
(ksh88,ksh93 don't print error messages here)
stdin:
for i in a b c; do echo $i; break 2; echo bad-$i; done
echo end
expected-stdout:
a
end
expected-stderr-pattern:
/.*break.*/
---
name: break-5
description:
Error if break argument isn't a number
stdin:
for i in a b c; do echo $i; break abc; echo more-$i; done
echo end
expected-stdout:
a
expected-exit: e != 0
expected-stderr-pattern:
/.*break.*/
---
name: continue-1
description:
See if continue continues loops
stdin:
for i in a b c; do echo $i; continue; echo bad-$i ; done
echo end-1
for i in a b c; do echo $i; continue 1; echo bad-$i; done
echo end-2
for i in a b c; do
for j in x y z; do
echo $i:$j
continue
echo bad-$i-$j
done
echo end-$i
done
echo end-3
expected-stdout:
a
b
c
end-1
a
b
c
end-2
a:x
a:y
a:z
end-a
b:x
b:y
b:z
end-b
c:x
c:y
c:z
end-c
end-3
---
name: continue-2
description:
See if continue breaks out of nested loops
stdin:
for i in a b c; do
for j in x y z; do
echo $i:$j
continue 2
echo bad-$i-$j
done
echo end-$i
done
echo end
expected-stdout:
a:x
b:x
c:x
end
---
name: continue-3
description:
What if continue used outside of any loops
(ksh88,ksh93 don't print error messages here)
stdin:
continue
expected-stderr-pattern:
/.*continue.*/
---
name: continue-4
description:
What if continue N used when only N-1 loops
(ksh88,ksh93 don't print error messages here)
stdin:
for i in a b c; do echo $i; continue 2; echo bad-$i; done
echo end
expected-stdout:
a
b
c
end
expected-stderr-pattern:
/.*continue.*/
---
name: continue-5
description:
Error if continue argument isn't a number
stdin:
for i in a b c; do echo $i; continue abc; echo more-$i; done
echo end
expected-stdout:
a
expected-exit: e != 0
expected-stderr-pattern:
/.*continue.*/
---
name: cd-history
description:
Test someone's CD history package (uses arrays)
category: mksh
stdin:
# go to known place before doing anything
cd /
alias cd=_cd
function _cd
{
typeset -i cdlen i
typeset t
if [ $# -eq 0 ]
then
set -- $HOME
fi
if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
then
typeset CDHIST
i=-1
while read -r t # read directory history file
do
CDHIST[i=i+1]=$t
done <$CDHISTFILE
fi
if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
then
_cdins # insert $PWD into cd history
fi
cdlen=${#CDHIST[*]} # number of elements in history
case "$@" in
-) # cd to new dir
if [ "$OLDPWD" = "" ] && ((cdlen>1))
then
'print' ${CDHIST[1]}
'cd' ${CDHIST[1]}
_pwd
else
'cd' $@
_pwd
fi
;;
-l) # print directory list
typeset -R3 num
((i=cdlen))
while (((i=i-1)>=0))
do
num=$i
'print' "$num ${CDHIST[i]}"
done
return
;;
-[0-9]|-[0-9][0-9]) # cd to dir in list
if (((i=${1#-})<cdlen))
then
'print' ${CDHIST[i]}
'cd' ${CDHIST[i]}
_pwd
else
'cd' $@
_pwd
fi
;;
-*) # cd to matched dir in list
t=${1#-}
i=1
while ((i<cdlen))
do
case ${CDHIST[i]} in
*$t*)
'print' ${CDHIST[i]}
'cd' ${CDHIST[i]}
_pwd
break
;;
esac
((i=i+1))
done
if ((i>=cdlen))
then
'cd' $@
_pwd
fi
;;
*) # cd to new dir
'cd' $@
_pwd
;;
esac
_cdins # insert $PWD into cd history
if [ "$CDHISTFILE" ]
then
cdlen=${#CDHIST[*]} # number of elements in history
i=0
while ((i<cdlen))
do
'print' -r ${CDHIST[i]} # update directory history
((i=i+1))
done >$CDHISTFILE
fi
}
function _cdins # insert $PWD into cd history
{ # meant to be called only by _cd
typeset -i i
((i=0))
while ((i<${#CDHIST[*]})) # see if dir is already in list
do
if [ "${CDHIST[$i]}" = "$PWD" ]
then
break
fi
((i=i+1))
done
if ((i>22)) # limit max size of list
then
i=22
fi
while (((i=i-1)>=0)) # bump old dirs in list
do
CDHIST[i+1]=${CDHIST[i]}
done
CDHIST[0]=$PWD # insert new directory in list
}
function _pwd
{
if [ -n "$ECD" ]
then
pwd 1>&6
fi
}
# Start of test
cd /tmp
cd /bin
cd /etc
cd -
cd -2
cd -l
expected-stdout:
/bin
/tmp
3 /
2 /etc
1 /bin
0 /tmp
---
name: env-prompt
description:
Check that prompt not printed when processing ENV
expected-fail: yes
env-setup: !ENV=./foo!
file-setup: file 644 "foo"
XXX=_
PS1=X
false && echo hmmm
arguments: !-i!
stdin:
echo hi${XXX}there
expected-stdout:
hi_there
expected-stderr: !
XX
---
name: expand-ugly
description:
Check that weird ${foo+bar} constructs are parsed correctly
expected-fail: yes
stdin:
IFS='
'
(echo 1 ${IFS+'}'z}) 2>&- || echo failed in 1
(echo 2 "${IFS+'}'z}") 2>&- || echo failed in 2
(echo 3 "foo ${IFS+'bar} baz") 2>&- || echo failed in 3
(echo -n '4 '; printf '%s\n' "foo ${IFS+"b c"} baz") 2>&- || echo failed in 4
(echo -n '5 '; printf '%s\n' "foo ${IFS+b c} baz") 2>&- || echo failed in 5
(echo 6 ${IFS+"}"z}) 2>&- || echo failed in 6
(echo 7 "${IFS+"}"z}") 2>&- || echo failed in 7
(echo 8 "${IFS+\"}\"z}") 2>&- || echo failed in 8
(echo 9 "${IFS+\"\}\"z}") 2>&- || echo failed in 9
(echo 10 foo ${IFS+'bar} baz'}) 2>&- || echo failed in 10
(echo 11 "$(echo "${IFS+'}'z}")") 2>&- || echo failed in 11
(echo 12 "$(echo ${IFS+'}'z})") 2>&- || echo failed in 12
(echo 13 ${IFS+\}z}) 2>&- || echo failed in 13
(echo 14 "${IFS+\}z}") 2>&- || echo failed in 14
u=x; (echo -n '15 '; printf '<%s> ' "foo ${IFS+a"b$u{ {"{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz; echo .) 2>&- || echo failed in 15
l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>&- || echo failed in 16
l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>&- || echo failed in 17
l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>&- || echo failed in 18
l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>&- || echo failed in 19
l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>&- || echo failed in 20
l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>&- || echo failed in 21
l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>&- || echo failed in 22
l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>&- || echo failed in 23
key=value; (echo -n '24 '; printf '%s\n' "${IFS+'$key'}") 2>&- || echo failed in 24
key=value; (echo -n '25 '; printf '%s\n' "${IFS+"'$key'"}") 2>&- || echo failed in 25 # ksh93: “'$key'”
key=value; (echo -n '26 '; printf '%s\n' ${IFS+'$key'}) 2>&- || echo failed in 26
key=value; (echo -n '27 '; printf '%s\n' ${IFS+"'$key'"}) 2>&- || echo failed in 27
(echo -n '28 '; printf '%s\n' "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>&- || echo failed in 28
u=x; (echo -n '29 '; printf '<%s> ' foo ${IFS+a"b$u{ {"{ {\}b} c ${IFS+d{}} bar ${IFS-e{}} baz; echo .) 2>&- || echo failed in 29
(echo -n '30 '; printf '<%s> ' ${IFS+foo 'b\
ar' baz}; echo .) 2>&- || (echo failed in 30; echo failed in 31)
(echo -n '32 '; printf '<%s> ' ${IFS+foo "b\
ar" baz}; echo .) 2>&- || echo failed in 32
(echo -n '33 '; printf '<%s> ' "${IFS+foo 'b\
ar' baz}"; echo .) 2>&- || echo failed in 33
(echo -n '34 '; printf '<%s> ' "${IFS+foo "b\
ar" baz}"; echo .) 2>&- || echo failed in 34
(echo -n '35 '; printf '<%s> ' ${v=a\ b} x ${v=c\ d}; echo .) 2>&- || echo failed in 35
(echo -n '36 '; printf '<%s> ' "${v=a\ b}" x "${v=c\ d}"; echo .) 2>&- || echo failed in 36
(echo -n '37 '; printf '<%s> ' ${v-a\ b} x ${v-c\ d}; echo .) 2>&- || echo failed in 37
(echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>&- || echo failed in 38
foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>&- || echo failed in 39
foo="a b c"; (echo -n '40 '; printf '<%s> ' "${foo#a}"; echo .) 2>&- || echo failed in 40
expected-stdout:
1 }z
2 ''z}
3 foo 'bar baz
4 foo b c baz
5 foo b c baz
6 }z
7 }z
8 ""z}
9 "}"z
10 foo bar} baz
11 ''z}
12 }z
13 }z
14 }z
15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
16 hi there
17 hi there
18 hi there
19 hi there
20 hi there
21 hi there
22 hi there
23 hi there
24 'value'
25 'value'
26 $key
27 'value'
28 'x ~ x''x}"x}" #
29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
30 <foo> <b\
ar> <baz> .
32 <foo> <bar> <baz> .
33 <foo 'bar' baz> .
34 <foo bar baz> .
35 <a> <b> <x> <a> <b> .
36 <a\ b> <x> <a\ b> .
37 <a b> <x> <c d> .
38 xay / x'a'y .
39 x' / x' .
40 < b c> .
---
name: expand-unglob-dblq
description:
Check that regular "${foo+bar}" constructs are parsed correctly
stdin:
u=x
tl_norm() {
v=$2
test x"$v" = x"-" && unset v
(echo "$1 plus norm foo ${v+'bar'} baz")
(echo "$1 dash norm foo ${v-'bar'} baz")
(echo "$1 eqal norm foo ${v='bar'} baz")
(echo "$1 qstn norm foo ${v?'bar'} baz") 2>&- || \
echo "$1 qstn norm -> error"
(echo "$1 PLUS norm foo ${v:+'bar'} baz")
(echo "$1 DASH norm foo ${v:-'bar'} baz")
(echo "$1 EQAL norm foo ${v:='bar'} baz")
(echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>&- || \
echo "$1 QSTN norm -> error"
}
tl_paren() {
v=$2
test x"$v" = x"-" && unset v
(echo "$1 plus parn foo ${v+(bar)} baz")
(echo "$1 dash parn foo ${v-(bar)} baz")
(echo "$1 eqal parn foo ${v=(bar)} baz")
(echo "$1 qstn parn foo ${v?(bar)} baz") 2>&- || \
echo "$1 qstn parn -> error"
(echo "$1 PLUS parn foo ${v:+(bar)} baz")
(echo "$1 DASH parn foo ${v:-(bar)} baz")
(echo "$1 EQAL parn foo ${v:=(bar)} baz")
(echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>&- || \
echo "$1 QSTN parn -> error"
}
tl_brace() {
v=$2
test x"$v" = x"-" && unset v
(echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
(echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
(echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
(echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>&- || \
echo "$1 qstn brac -> error"
(echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
(echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
(echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
(echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>&- || \
echo "$1 QSTN brac -> error"
}
tl_norm 1 -
tl_norm 2 ''
tl_norm 3 x
tl_paren 4 -
tl_paren 5 ''
tl_paren 6 x
tl_brace 7 -
tl_brace 8 ''
tl_brace 9 x
expected-stdout:
1 plus norm foo baz
1 dash norm foo 'bar' baz
1 eqal norm foo 'bar' baz
1 qstn norm -> error
1 PLUS norm foo baz
1 DASH norm foo 'bar' baz
1 EQAL norm foo 'bar' baz
1 QSTN norm -> error
2 plus norm foo 'bar' baz
2 dash norm foo baz
2 eqal norm foo baz
2 qstn norm foo baz
2 PLUS norm foo baz
2 DASH norm foo 'bar' baz
2 EQAL norm foo 'bar' baz
2 QSTN norm -> error
3 plus norm foo 'bar' baz
3 dash norm foo x baz
3 eqal norm foo x baz
3 qstn norm foo x baz
3 PLUS norm foo 'bar' baz
3 DASH norm foo x baz
3 EQAL norm foo x baz
3 QSTN norm foo x baz
4 plus parn foo baz
4 dash parn foo (bar) baz
4 eqal parn foo (bar) baz
4 qstn parn -> error
4 PLUS parn foo baz
4 DASH parn foo (bar) baz
4 EQAL parn foo (bar) baz
4 QSTN parn -> error
5 plus parn foo (bar) baz
5 dash parn foo baz
5 eqal parn foo baz
5 qstn parn foo baz
5 PLUS parn foo baz
5 DASH parn foo (bar) baz
5 EQAL parn foo (bar) baz
5 QSTN parn -> error
6 plus parn foo (bar) baz
6 dash parn foo x baz
6 eqal parn foo x baz
6 qstn parn foo x baz
6 PLUS parn foo (bar) baz
6 DASH parn foo x baz
6 EQAL parn foo x baz
6 QSTN parn foo x baz
7 plus brac foo c } baz
7 dash brac foo ax{{{}b c d{} baz
7 eqal brac foo ax{{{}b c ax{{{}b} baz
7 qstn brac -> error
7 PLUS brac foo c } baz
7 DASH brac foo ax{{{}b c d{} baz
7 EQAL brac foo ax{{{}b c ax{{{}b} baz
7 QSTN brac -> error
8 plus brac foo ax{{{}b c d{} baz
8 dash brac foo c } baz
8 eqal brac foo c } baz
8 qstn brac foo c } baz
8 PLUS brac foo c } baz
8 DASH brac foo ax{{{}b c d{} baz
8 EQAL brac foo ax{{{}b c ax{{{}b} baz
8 QSTN brac -> error
9 plus brac foo ax{{{}b c d{} baz
9 dash brac foo x c x} baz
9 eqal brac foo x c x} baz
9 qstn brac foo x c x} baz
9 PLUS brac foo ax{{{}b c d{} baz
9 DASH brac foo x c x} baz
9 EQAL brac foo x c x} baz
9 QSTN brac foo x c x} baz
---
name: expand-unglob-unq
description:
Check that regular ${foo+bar} constructs are parsed correctly
stdin:
u=x
tl_norm() {
v=$2
test x"$v" = x"-" && unset v
(echo $1 plus norm foo ${v+'bar'} baz)
(echo $1 dash norm foo ${v-'bar'} baz)
(echo $1 eqal norm foo ${v='bar'} baz)
(echo $1 qstn norm foo ${v?'bar'} baz) 2>&- || \
echo "$1 qstn norm -> error"
(echo $1 PLUS norm foo ${v:+'bar'} baz)
(echo $1 DASH norm foo ${v:-'bar'} baz)
(echo $1 EQAL norm foo ${v:='bar'} baz)
(echo $1 QSTN norm foo ${v:?'bar'} baz) 2>&- || \
echo "$1 QSTN norm -> error"
}
tl_paren() {
v=$2
test x"$v" = x"-" && unset v
(echo $1 plus parn foo ${v+\(bar')'} baz)
(echo $1 dash parn foo ${v-\(bar')'} baz)
(echo $1 eqal parn foo ${v=\(bar')'} baz)
(echo $1 qstn parn foo ${v?\(bar')'} baz) 2>&- || \
echo "$1 qstn parn -> error"
(echo $1 PLUS parn foo ${v:+\(bar')'} baz)
(echo $1 DASH parn foo ${v:-\(bar')'} baz)
(echo $1 EQAL parn foo ${v:=\(bar')'} baz)
(echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>&- || \
echo "$1 QSTN parn -> error"
}
tl_brace() {
v=$2
test x"$v" = x"-" && unset v
(echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
(echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
(echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
(echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>&- || \
echo "$1 qstn brac -> error"
(echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
(echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
(echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
(echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>&- || \
echo "$1 QSTN brac -> error"
}
tl_norm 1 -
tl_norm 2 ''
tl_norm 3 x
tl_paren 4 -
tl_paren 5 ''
tl_paren 6 x
tl_brace 7 -
tl_brace 8 ''
tl_brace 9 x
expected-stdout:
1 plus norm foo baz
1 dash norm foo bar baz
1 eqal norm foo bar baz
1 qstn norm -> error
1 PLUS norm foo baz
1 DASH norm foo bar baz
1 EQAL norm foo bar baz
1 QSTN norm -> error
2 plus norm foo bar baz
2 dash norm foo baz
2 eqal norm foo baz
2 qstn norm foo baz
2 PLUS norm foo baz
2 DASH norm foo bar baz
2 EQAL norm foo bar baz
2 QSTN norm -> error
3 plus norm foo bar baz
3 dash norm foo x baz
3 eqal norm foo x baz
3 qstn norm foo x baz
3 PLUS norm foo bar baz
3 DASH norm foo x baz
3 EQAL norm foo x baz
3 QSTN norm foo x baz
4 plus parn foo baz
4 dash parn foo (bar) baz
4 eqal parn foo (bar) baz
4 qstn parn -> error
4 PLUS parn foo baz
4 DASH parn foo (bar) baz
4 EQAL parn foo (bar) baz
4 QSTN parn -> error
5 plus parn foo (bar) baz
5 dash parn foo baz
5 eqal parn foo baz
5 qstn parn foo baz
5 PLUS parn foo baz
5 DASH parn foo (bar) baz
5 EQAL parn foo (bar) baz
5 QSTN parn -> error
6 plus parn foo (bar) baz
6 dash parn foo x baz
6 eqal parn foo x baz
6 qstn parn foo x baz
6 PLUS parn foo (bar) baz
6 DASH parn foo x baz
6 EQAL parn foo x baz
6 QSTN parn foo x baz
7 plus brac foo c } baz
7 dash brac foo ax{{{}b c d{} baz
7 eqal brac foo ax{{{}b c ax{{{}b} baz
7 qstn brac -> error
7 PLUS brac foo c } baz
7 DASH brac foo ax{{{}b c d{} baz
7 EQAL brac foo ax{{{}b c ax{{{}b} baz
7 QSTN brac -> error
8 plus brac foo ax{{{}b c d{} baz
8 dash brac foo c } baz
8 eqal brac foo c } baz
8 qstn brac foo c } baz
8 PLUS brac foo c } baz
8 DASH brac foo ax{{{}b c d{} baz
8 EQAL brac foo ax{{{}b c ax{{{}b} baz
8 QSTN brac -> error
9 plus brac foo ax{{{}b c d{} baz
9 dash brac foo x c x} baz
9 eqal brac foo x c x} baz
9 qstn brac foo x c x} baz
9 PLUS brac foo ax{{{}b c d{} baz
9 DASH brac foo x c x} baz
9 EQAL brac foo x c x} baz
9 QSTN brac foo x c x} baz
---
name: eglob-bad-1
description:
Check that globbing isn't done when glob has syntax error
category: ksh
file-setup: file 644 "abcx"
file-setup: file 644 "abcz"
file-setup: file 644 "bbc"
stdin:
echo !([*)*
echo +(a|b[)*
expected-stdout:
!([*)*
+(a|b[)*
---
name: eglob-bad-2
description:
Check that globbing isn't done when glob has syntax error
(AT&T ksh fails this test)
category: mksh
file-setup: file 644 "abcx"
file-setup: file 644 "abcz"
file-setup: file 644 "bbc"
stdin:
echo [a*(]*)z
expected-stdout:
[a*(]*)z
---
name: eglob-infinite-plus
description:
Check that shell doesn't go into infinite loop expanding +(...)
expressions.
category: ksh
file-setup: file 644 "abc"
time-limit: 3
stdin:
echo +()c
echo +()x
echo +(*)c
echo +(*)x
expected-stdout:
+()c
+()x
+(*)c
+(*)x
---
name: eglob-subst-1
description:
Check that eglobbing isn't done on substitution results
category: ksh
file-setup: file 644 "abc"
stdin:
x='@(*)'
echo $x
expected-stdout:
@(*)
---
name: eglob-nomatch-1
description:
Check that the pattern doesn't match
category: ksh
stdin:
echo 1: no-file+(a|b)stuff
echo 2: no-file+(a*(c)|b)stuff
echo 3: no-file+((((c)))|b)stuff
expected-stdout:
1: no-file+(a|b)stuff
2: no-file+(a*(c)|b)stuff
3: no-file+((((c)))|b)stuff
---
name: eglob-match-1
description:
Check that the pattern matches correctly
category: ksh
file-setup: file 644 "abd"
file-setup: file 644 "acd"
file-setup: file 644 "abac"
stdin:
echo 1: a+(b|c)d
echo 2: a!(@(b|B))d
echo 3: *(a(b|c)) # (...|...) can be used within X(..)
echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
expected-stdout:
1: abd acd
2: acd
3: abac
4: abd
---
name: eglob-case-1
description:
Simple negation tests
category: ksh
stdin:
case foo in !(foo|bar)) echo yes;; *) echo no;; esac
case bar in !(foo|bar)) echo yes;; *) echo no;; esac
expected-stdout:
no
no
---
name: eglob-case-2
description:
Simple kleene tests
category: ksh
stdin:
case foo in *(a|b[)) echo yes;; *) echo no;; esac
case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
expected-stdout:
no
yes
yes
---
name: eglob-trim-1
description:
Eglobbing in trim expressions...
(AT&T ksh fails this - docs say # matches shortest string, ## matches
longest...)
category: mksh
stdin:
x=abcdef
echo 1: ${x#a|abc}
echo 2: ${x##a|abc}
echo 3: ${x%def|f}
echo 4: ${x%%f|def}
expected-stdout:
1: bcdef
2: def
3: abcde
4: abc
---
name: eglob-trim-2
description:
Check eglobbing works in trims...
category: mksh
stdin:
x=abcdef
echo 1: ${x#*(a|b)cd}
echo 2: "${x#*(a|b)cd}"
echo 3: ${x#"*(a|b)cd"}
echo 4: ${x#a(b|c)}
expected-stdout:
1: ef
2: ef
3: abcdef
4: cdef
---
name: eglob-substrpl-1
description:
Check eglobbing works in substs... and they work at all
category: mksh
stdin:
[[ -n $BASH_VERSION ]] && shopt -s extglob
x=1222321_ab/cde_b/c_1221
y=xyz
echo 1: ${x/2}
echo 2: ${x//2}
echo 3: ${x/+(2)}
echo 4: ${x//+(2)}
echo 5: ${x/2/4}
echo 6: ${x//2/4}
echo 7: ${x/+(2)/4}
echo 8: ${x//+(2)/4}
echo 9: ${x/b/c/e/f}
echo 10: ${x/b\/c/e/f}
echo 11: ${x/b\/c/e\/f}
echo 12: ${x/b\/c/e\\/f}
echo 13: ${x/b\\/c/e\\/f}
echo 14: ${x//b/c/e/f}
echo 15: ${x//b\/c/e/f}
echo 16: ${x//b\/c/e\/f}
echo 17: ${x//b\/c/e\\/f}
echo 18: ${x//b\\/c/e\\/f}
echo 19: ${x/b\/*\/c/x}
echo 20: ${x/\//.}
echo 21: ${x//\//.}
echo 22: ${x///.}
echo 23: ${x//#1/9}
echo 24: ${x//%1/9}
echo 25: ${x//\%1/9}
echo 26: ${x//\\%1/9}
echo 27: ${x//\a/9}
echo 28: ${x//\\a/9}
echo 29: ${x/2/$y}
expected-stdout:
1: 122321_ab/cde_b/c_1221
2: 131_ab/cde_b/c_11
3: 1321_ab/cde_b/c_1221
4: 131_ab/cde_b/c_11
5: 1422321_ab/cde_b/c_1221
6: 1444341_ab/cde_b/c_1441
7: 14321_ab/cde_b/c_1221
8: 14341_ab/cde_b/c_141
9: 1222321_ac/e/f/cde_b/c_1221
10: 1222321_ae/fde_b/c_1221
11: 1222321_ae/fde_b/c_1221
12: 1222321_ae\/fde_b/c_1221
13: 1222321_ab/cde_b/c_1221
14: 1222321_ac/e/f/cde_c/e/f/c_1221
15: 1222321_ae/fde_e/f_1221
16: 1222321_ae/fde_e/f_1221
17: 1222321_ae\/fde_e\/f_1221
18: 1222321_ab/cde_b/c_1221
19: 1222321_ax_1221
20: 1222321_ab.cde_b/c_1221
21: 1222321_ab.cde_b.c_1221
22: 1222321_ab/cde_b/c_1221
23: 9222321_ab/cde_b/c_1221
24: 1222321_ab/cde_b/c_1229
25: 1222321_ab/cde_b/c_1229
26: 1222321_ab/cde_b/c_1221
27: 1222321_9b/cde_b/c_1221
28: 1222321_9b/cde_b/c_1221
29: 1xyz22321_ab/cde_b/c_1221
---
name: eglob-substrpl-2
description:
Check anchored substring replacement works, corner cases
category: mksh
stdin:
foo=123
echo 1: ${foo/#/x}
echo 2: ${foo/%/x}
echo 3: ${foo/#/}
echo 4: ${foo/#}
echo 5: ${foo/%/}
echo 6: ${foo/%}
expected-stdout:
1: x123
2: 123x
3: 123
4: 123
5: 123
6: 123
---
name: eglob-substrpl-3a
description:
Check substring replacement works with variables and slashes, too
category: mksh
stdin:
pfx=/home/user
wd=/home/user/tmp
echo "${wd/#$pfx/~}"
echo "${wd/#\$pfx/~}"
echo "${wd/#"$pfx"/~}"
echo "${wd/#'$pfx'/~}"
echo "${wd/#"\$pfx"/~}"
echo "${wd/#'\$pfx'/~}"
expected-stdout:
~/tmp
/home/user/tmp
~/tmp
/home/user/tmp
/home/user/tmp
/home/user/tmp
---
name: eglob-substrpl-3b
description:
More of this, bash fails it (bash4 passes)
category: mksh
stdin:
pfx=/home/user
wd=/home/user/tmp
echo "${wd/#$(echo /home/user)/~}"
echo "${wd/#"$(echo /home/user)"/~}"
echo "${wd/#'$(echo /home/user)'/~}"
expected-stdout:
~/tmp
~/tmp
/home/user/tmp
---
name: eglob-substrpl-3c
description:
Even more weird cases
category: mksh
stdin:
pfx=/home/user
wd='$pfx/tmp'
echo 1: ${wd/#$pfx/~}
echo 2: ${wd/#\$pfx/~}
echo 3: ${wd/#"$pfx"/~}
echo 4: ${wd/#'$pfx'/~}
echo 5: ${wd/#"\$pfx"/~}
echo 6: ${wd/#'\$pfx'/~}
ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
tp=a/b
tr=c/d
[[ -n $BASH_VERSION ]] && shopt -s extglob
echo 7: ${ts/a\/b/$tr}
echo 8: ${ts/a\/b/\$tr}
echo 9: ${ts/$tp/$tr}
echo 10: ${ts/\$tp/$tr}
echo 11: ${ts/\\$tp/$tr}
echo 12: ${ts/$tp/c/d}
echo 13: ${ts/$tp/c\/d}
echo 14: ${ts/$tp/c\\/d}
echo 15: ${ts/+(a\/b)/$tr}
echo 16: ${ts/+(a\/b)/\$tr}
echo 17: ${ts/+($tp)/$tr}
echo 18: ${ts/+($tp)/c/d}
echo 19: ${ts/+($tp)/c\/d}
echo 25: ${ts//a\/b/$tr}
echo 26: ${ts//a\/b/\$tr}
echo 27: ${ts//$tp/$tr}
echo 28: ${ts//$tp/c/d}
echo 29: ${ts//$tp/c\/d}
echo 30: ${ts//+(a\/b)/$tr}
echo 31: ${ts//+(a\/b)/\$tr}
echo 32: ${ts//+($tp)/$tr}
echo 33: ${ts//+($tp)/c/d}
echo 34: ${ts//+($tp)/c\/d}
tp="+($tp)"
echo 40: ${ts/$tp/$tr}
echo 41: ${ts//$tp/$tr}
expected-stdout:
1: $pfx/tmp
2: ~/tmp
3: $pfx/tmp
4: ~/tmp
5: ~/tmp
6: ~/tmp
7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
11: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
25: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
26: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
27: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
28: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
29: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
30: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
31: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
32: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
33: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
34: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
40: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
41: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
# This is what GNU bash does:
# 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
# 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
---
name: eglob-utf8-1
description:
UTF-8 mode differences for eglobbing
category: mksh
stdin:
s=blöd
set +U
print 1: ${s%???} .
print 2: ${s/b???d/x} .
set -U
print 3: ${s%???} .
print 4: ${s/b??d/x} .
x=nö
print 5: ${x%?} ${x%%?} .
x=äh
print 6: ${x#?} ${x##?} .
x=
print 7: ${x%?} ${x%%?} .
x=mä
print 8: ${x%?} ${x%%?} .
x=何
print 9: ${x%?} ${x%%?} .
expected-stdout:
1: bl .
2: x .
3: b .
4: x .
5: n n .
6: h h .
7: .
8: mä mä .
9: .
---
name: glob-bad-1
description:
Check that globbing isn't done when glob has syntax error
file-setup: dir 755 "[x"
file-setup: file 644 "[x/foo"
stdin:
echo [*
echo *[x
echo [x/*
expected-stdout:
[*
*[x
[x/foo
---
name: glob-bad-2
description:
Check that symbolic links aren't stat()'d
file-setup: dir 755 "dir"
file-setup: symlink 644 "dir/abc"
non-existent-file
stdin:
echo d*/*
echo d*/abc
expected-stdout:
dir/abc
dir/abc
---
name: glob-range-1
description:
Test range matching
file-setup: file 644 ".bc"
file-setup: file 644 "abc"
file-setup: file 644 "bbc"
file-setup: file 644 "cbc"
file-setup: file 644 "-bc"
stdin:
echo [ab-]*
echo [-ab]*
echo [!-ab]*
echo [!ab]*
echo []ab]*
expected-stdout:
-bc abc bbc
-bc abc bbc
cbc
-bc cbc
abc bbc
---
name: glob-range-2
description:
Test range matching
(AT&T ksh fails this; POSIX says invalid)
file-setup: file 644 "abc"
stdin:
echo [a--]*
expected-stdout:
[a--]*
---
name: glob-range-3
description:
Check that globbing matches the right things...
# breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
category: !os:darwin
file-setup: file 644 "ac"
stdin:
echo a[-]*
expected-stdout:
ac
---
name: glob-range-4
description:
Results unspecified according to POSIX
file-setup: file 644 ".bc"
stdin:
echo [a.]*
expected-stdout:
[a.]*
---
name: glob-range-5
description:
Results unspecified according to POSIX
(AT&T ksh treats this like [a-cc-e]*)
file-setup: file 644 "abc"
file-setup: file 644 "bbc"
file-setup: file 644 "cbc"
file-setup: file 644 "dbc"
file-setup: file 644 "ebc"
file-setup: file 644 "-bc"
stdin:
echo [a-c-e]*
expected-stdout:
-bc abc bbc cbc ebc
---
name: heredoc-1
description:
Check ordering/content of redundent here documents.
stdin:
cat << EOF1 << EOF2
hi
EOF1
there
EOF2
expected-stdout:
there
---
name: heredoc-2
description:
Check quoted here-doc is protected.
stdin:
a=foo
cat << 'EOF'
hi\
there$a
stuff
EO\
F
EOF
expected-stdout:
hi\
there$a
stuff
EO\
F
---
name: heredoc-3
description:
Check that newline isn't needed after heredoc-delimiter marker.
stdin: !
cat << EOF
hi
there
EOF
expected-stdout:
hi
there
---
name: heredoc-4
description:
Check that an error occurs if the heredoc-delimiter is missing.
stdin: !
cat << EOF
hi
there
expected-exit: e > 0
expected-stderr-pattern: /.*/
---
name: heredoc-5
description:
Check that backslash quotes a $, ` and \ and kills a \newline
stdin:
a=BAD
b=ok
cat << EOF
h\${a}i
h\\${b}i
th\`echo not-run\`ere
th\\`echo is-run`ere
fol\\ks
more\\
last \
line
EOF
expected-stdout:
h${a}i
h\oki
th`echo not-run`ere
th\is-runere
fol\ks
more\
last line
---
name: heredoc-6
description:
Check that \newline in initial here-delim word doesn't imply
a quoted here-doc.
stdin:
a=i
cat << EO\
F
h$a
there
EOF
expected-stdout:
hi
there
---
name: heredoc-7
description:
Check that double quoted $ expressions in here delimiters are
not expanded and match the delimiter.
POSIX says only quote removal is applied to the delimiter.
stdin:
a=b
cat << "E$a"
hi
h$a
hb
E$a
echo done
expected-stdout:
hi
h$a
hb
done
---
name: heredoc-8
description:
Check that double quoted escaped $ expressions in here
delimiters are not expanded and match the delimiter.
POSIX says only quote removal is applied to the delimiter
(\ counts as a quote).
stdin:
a=b
cat << "E\$a"
hi
h$a
h\$a
hb
h\b
E$a
echo done
expected-stdout:
hi
h$a
h\$a
hb
h\b
done
---
name: heredoc-9a
description:
Check that here strings work.
category: !no-herestrings
stdin:
bar="bar
baz"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
"$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
expected-stdout:
sbb
sbb
one
onm
$one
$one
-sbb
---
name: heredoc-9b
description:
Check that a corner case of here strings works like bash
category: !no-herestrings
stdin:
fnord=42
bar="bar
\$fnord baz"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
expected-stdout:
one $sabeq onm
---
name: heredoc-9c
description:
Check that a corner case of here strings works like ksh93, zsh
category: !no-herestrings
stdin:
fnord=42
bar="bar
\$fnord baz"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
expected-stdout:
one
$sabeq onm
---
name: heredoc-9d
description:
Check another corner case of here strings
category: !no-herestrings
stdin:
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
expected-stdout:
one
---
name: heredoc-quoting-unsubst
description:
Check for correct handling of quoted characters in
here documents without substitution (marker is quoted).
stdin:
foo=bar
cat <<-'EOF'
x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
EOF
expected-stdout:
x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
---
name: heredoc-quoting-subst
description:
Check for correct handling of quoted characters in
here documents with substitution (marker is not quoted).
stdin:
foo=bar
cat <<-EOF
x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
EOF
expected-stdout:
x " \" \ \ $ $ baz `echo baz` bar $foo x
---
name: heredoc-tmpfile-1
description:
Check that heredoc temp files aren't removed too soon or too late.
Heredoc in simple command.
stdin:
TMPDIR=$PWD
eval '
cat <<- EOF
hi
EOF
for i in a b ; do
cat <<- EOF
more
EOF
done
' &
sleep 1
echo Left overs: *
expected-stdout:
hi
more
more
Left overs: *
---
name: heredoc-tmpfile-2
description:
Check that heredoc temp files aren't removed too soon or too late.
Heredoc in function, multiple calls to function.
stdin:
TMPDIR=$PWD
eval '
foo() {
cat <<- EOF
hi
EOF
}
foo
foo
' &
sleep 1
echo Left overs: *
expected-stdout:
hi
hi
Left overs: *
---
name: heredoc-tmpfile-3
description:
Check that heredoc temp files aren't removed too soon or too late.
Heredoc in function in loop, multiple calls to function.
stdin:
TMPDIR=$PWD
eval '
foo() {
cat <<- EOF
hi
EOF
}
for i in a b; do
foo
foo() {
cat <<- EOF
folks $i
EOF
}
done
foo
' &
sleep 1
echo Left overs: *
expected-stdout:
hi
folks b
folks b
Left overs: *
---
name: heredoc-tmpfile-4
description:
Check that heredoc temp files aren't removed too soon or too late.
Backgrounded simple command with here doc
stdin:
TMPDIR=$PWD
eval '
cat <<- EOF &
hi
EOF
' &
sleep 1
echo Left overs: *
expected-stdout:
hi
Left overs: *
---
name: heredoc-tmpfile-5
description:
Check that heredoc temp files aren't removed too soon or too late.
Backgrounded subshell command with here doc
stdin:
TMPDIR=$PWD
eval '
(
sleep 1 # so parent exits
echo A
cat <<- EOF
hi
EOF
echo B
) &
' &
sleep 2
echo Left overs: *
expected-stdout:
A
hi
B
Left overs: *
---
name: heredoc-tmpfile-6
description:
Check that heredoc temp files aren't removed too soon or too late.
Heredoc in pipeline.
stdin:
TMPDIR=$PWD
eval '
cat <<- EOF | sed "s/hi/HI/"
hi
EOF
' &
sleep 1
echo Left overs: *
expected-stdout:
HI
Left overs: *
---
name: heredoc-tmpfile-7
description:
Check that heredoc temp files aren't removed too soon or too late.
Heredoc in backgrounded pipeline.
stdin:
TMPDIR=$PWD
eval '
cat <<- EOF | sed 's/hi/HI/' &
hi
EOF
' &
sleep 1
echo Left overs: *
expected-stdout:
HI
Left overs: *
---
name: heredoc-tmpfile-8
description:
Check that heredoc temp files aren't removed too soon or too
late. Heredoc in function, backgrounded call to function.
This check can fail on slow machines (<100 MHz), or Cygwin,
that's normal.
stdin:
TMPDIR=$PWD
# Background eval so main shell doesn't do parsing
eval '
foo() {
cat <<- EOF
hi
EOF
}
foo
# sleep so eval can die
(sleep 1; foo) &
(sleep 1; foo) &
foo
' &
sleep 2
echo Left overs: *
expected-stdout:
hi
hi
hi
hi
Left overs: *
---
name: history-basic
description:
See if we can test history at all
category: mksh
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo hi
fc -l
expected-stdout:
hi
1 echo hi
expected-stderr-pattern:
/^X*$/
---
name: history-dups
description:
Verify duplicates and spaces are not entered
category: mksh
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo hi
echo yo
echo hi
fc -l
expected-stdout:
hi
yo
hi
1 echo hi
expected-stderr-pattern:
/^X*$/
---
name: history-unlink
description:
Check if broken HISTFILEs do not cause trouble
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
file-setup: file 644 "Env"
PS1=X
file-setup: dir 755 "foo"
file-setup: file 644 "foo/hist.file"
sometext
time-limit: 5
perl-setup: chmod(0555, "foo");
stdin:
echo hi
fc -l
chmod 0755 foo
expected-stdout:
hi
1 echo hi
expected-stderr-pattern:
/(.*can't unlink HISTFILE.*\n)?X*$/
---
name: history-e-minus-1
description:
Check if more recent command is executed
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo hi
echo there
fc -e -
expected-stdout:
hi
there
there
expected-stderr-pattern:
/^X*echo there\nX*$/
---
name: history-e-minus-2
description:
Check that repeated command is printed before command
is re-executed.
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
exec 2>&1
echo hi
echo there
fc -e -
expected-stdout-pattern:
/X*hi\nX*there\nX*echo there\nthere\nX*/
expected-stderr-pattern:
/^X*$/
---
name: history-e-minus-3
description:
fc -e - fails when there is no history
(ksh93 has a bug that causes this to fail)
(ksh88 loops on this)
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
fc -e -
echo ok
expected-stdout:
ok
expected-stderr-pattern:
/^X*.*:.*history.*\nX*$/
---
name: history-e-minus-4
description:
Check if "fc -e -" command output goes to stdout.
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc
fc -e - | (read x; echo "A $x")
echo ok
expected-stdout:
abc
A abc
ok
expected-stderr-pattern:
/^X*echo abc\nX*/
---
name: history-e-minus-5
description:
fc is replaced in history by new command.
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def
echo ghi jkl
:
fc -e - echo
fc -l 2 5
expected-stdout:
abc def
ghi jkl
ghi jkl
2 echo ghi jkl
3 :
4 echo ghi jkl
5 fc -l 2 5
expected-stderr-pattern:
/^X*echo ghi jkl\nX*$/
---
name: history-list-1
description:
List lists correct range
(ksh88 fails 'cause it lists the fc command)
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
fc -l -- -2
expected-stdout:
line 1
line 2
line 3
2 echo line 2
3 echo line 3
expected-stderr-pattern:
/^X*$/
---
name: history-list-2
description:
Lists oldest history if given pre-historic number
(ksh93 has a bug that causes this to fail)
(ksh88 fails 'cause it lists the fc command)
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
fc -l -- -40
expected-stdout:
line 1
line 2
line 3
1 echo line 1
2 echo line 2
3 echo line 3
expected-stderr-pattern:
/^X*$/
---
name: history-list-3
description:
Can give number 'options' to fc
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
fc -l -3 -2
expected-stdout:
line 1
line 2
line 3
line 4
2 echo line 2
3 echo line 3
expected-stderr-pattern:
/^X*$/
---
name: history-list-4
description:
-1 refers to previous command
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
fc -l -1 -1
expected-stdout:
line 1
line 2
line 3
line 4
4 echo line 4
expected-stderr-pattern:
/^X*$/
---
name: history-list-5
description:
List command stays in history
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
fc -l -1 -1
fc -l -2 -1
expected-stdout:
line 1
line 2
line 3
line 4
4 echo line 4
4 echo line 4
5 fc -l -1 -1
expected-stderr-pattern:
/^X*$/
---
name: history-list-6
description:
HISTSIZE limits about of history kept.
(ksh88 fails 'cause it lists the fc command)
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc -l
expected-stdout:
line 1
line 2
line 3
line 4
line 5
4 echo line 4
5 echo line 5
expected-stderr-pattern:
/^X*$/
---
name: history-list-7
description:
fc allows too old/new errors in range specification
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc -l 1 30
expected-stdout:
line 1
line 2
line 3
line 4
line 5
4 echo line 4
5 echo line 5
6 fc -l 1 30
expected-stderr-pattern:
/^X*$/
---
name: history-list-r-1
description:
test -r flag in history
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc -l -r 2 4
expected-stdout:
line 1
line 2
line 3
line 4
line 5
4 echo line 4
3 echo line 3
2 echo line 2
expected-stderr-pattern:
/^X*$/
---
name: history-list-r-2
description:
If first is newer than last, -r is implied.
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc -l 4 2
expected-stdout:
line 1
line 2
line 3
line 4
line 5
4 echo line 4
3 echo line 3
2 echo line 2
expected-stderr-pattern:
/^X*$/
---
name: history-list-r-3
description:
If first is newer than last, -r is cancelled.
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc -l -r 4 2
expected-stdout:
line 1
line 2
line 3
line 4
line 5
2 echo line 2
3 echo line 3
4 echo line 4
expected-stderr-pattern:
/^X*$/
---
name: history-subst-1
description:
Basic substitution
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def
echo ghi jkl
fc -e - abc=AB 'echo a'
expected-stdout:
abc def
ghi jkl
AB def
expected-stderr-pattern:
/^X*echo AB def\nX*$/
---
name: history-subst-2
description:
Does subst find previous command?
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def
echo ghi jkl
fc -e - jkl=XYZQRT 'echo g'
expected-stdout:
abc def
ghi jkl
ghi XYZQRT
expected-stderr-pattern:
/^X*echo ghi XYZQRT\nX*$/
---
name: history-subst-3
description:
Does subst find previous command when no arguments given
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def
echo ghi jkl
fc -e - jkl=XYZQRT
expected-stdout:
abc def
ghi jkl
ghi XYZQRT
expected-stderr-pattern:
/^X*echo ghi XYZQRT\nX*$/
---
name: history-subst-4
description:
Global substitutions work
(ksh88 and ksh93 do not have -g option)
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def asjj sadjhasdjh asdjhasd
fc -e - -g a=FooBAR
expected-stdout:
abc def asjj sadjhasdjh asdjhasd
FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
expected-stderr-pattern:
/^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
---
name: history-subst-5
description:
Make sure searches don't find current (fc) command
(ksh88/ksh93 don't have the ? prefix thing so they fail this test)
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def
echo ghi jkl
fc -e - abc=AB \?abc
expected-stdout:
abc def
ghi jkl
AB def
expected-stderr-pattern:
/^X*echo AB def\nX*$/
---
name: history-ed-1-old
description:
Basic (ed) editing works (assumes you have generic ed editor
that prints no prompts). This is for oldish ed(1) which write
the character count to stdout.
category: stdout-ed
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def
fc echo
s/abc/FOOBAR/
w
q
expected-stdout:
abc def
13
16
FOOBAR def
expected-stderr-pattern:
/^X*echo FOOBAR def\nX*$/
---
name: history-ed-2-old
description:
Correct command is edited when number given
category: stdout-ed
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2 is here
echo line 3
echo line 4
fc 2
s/is here/is changed/
w
q
expected-stdout:
line 1
line 2 is here
line 3
line 4
20
23
line 2 is changed
expected-stderr-pattern:
/^X*echo line 2 is changed\nX*$/
---
name: history-ed-3-old
description:
Newly created multi line commands show up as single command
in history.
(NOTE: adjusted for COMPLEX HISTORY compile time option)
(ksh88 fails 'cause it lists the fc command)
category: stdout-ed
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def
fc echo
s/abc/FOOBAR/
$a
echo a new line
.
w
q
fc -l
expected-stdout:
abc def
13
32
FOOBAR def
a new line
1 echo abc def
2 echo FOOBAR def
3 echo a new line
expected-stderr-pattern:
/^X*echo FOOBAR def\necho a new line\nX*$/
---
name: history-ed-1
description:
Basic (ed) editing works (assumes you have generic ed editor
that prints no prompts). This is for newish ed(1) and stderr.
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def
fc echo
s/abc/FOOBAR/
w
q
expected-stdout:
abc def
FOOBAR def
expected-stderr-pattern:
/^X*13\n16\necho FOOBAR def\nX*$/
---
name: history-ed-2
description:
Correct command is edited when number given
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo line 1
echo line 2 is here
echo line 3
echo line 4
fc 2
s/is here/is changed/
w
q
expected-stdout:
line 1
line 2 is here
line 3
line 4
line 2 is changed
expected-stderr-pattern:
/^X*20\n23\necho line 2 is changed\nX*$/
---
name: history-ed-3
description:
Newly created multi line commands show up as single command
in history.
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
echo abc def
fc echo
s/abc/FOOBAR/
$a
echo a new line
.
w
q
fc -l
expected-stdout:
abc def
FOOBAR def
a new line
1 echo abc def
2 echo FOOBAR def
3 echo a new line
expected-stderr-pattern:
/^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
---
name: IFS-space-1
description:
Simple test, default IFS
stdin:
unset IFS
showargs() { for i; do echo -n " <$i>"; done; echo; }
set -- A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected-stdout:
<1> <A> <B> <C>
<2> <A B C>
<3> <A> <B> <C>
<4> <A> <B> <C>
---
name: IFS-colon-1
description:
Simple test, IFS=:
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS=:
set -- A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected-stdout:
<1> <A> <B> <C>
<2> <A:B:C>
<3> <A> <B> <C>
<4> <A> <B> <C>
---
name: IFS-null-1
description:
Simple test, IFS=""
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS=""
set -- A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected-stdout:
<1> <A B C>
<2> <ABC>
<3> <A B C>
<4> <A B C>
---
name: IFS-space-colon-1
description:
Simple test, IFS=<white-space>:
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS='
:'
set --
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
showargs 5 : "$@"
expected-stdout:
<1>
<2> <>
<3>
<4>
<5> <:>
---
name: IFS-space-colon-2
description:
Simple test, IFS=<white-space>:
AT&T ksh fails this, POSIX says the test is correct.
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS='
:'
set --
showargs :"$@"
expected-stdout:
<:>
---
name: IFS-space-colon-3
description:
Simple test, IFS=<white-space>:
pdksh fails both of these tests
not sure whether #2 is correct
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="
:"
x=
set --
showargs "$x$@" 1
showargs "$@$x" 2
expected-fail: yes
expected-stdout:
<> <1>
<> <2>
---
name: IFS-space-colon-4
description:
Simple test, IFS=<white-space>:
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="
:"
set --
showargs "$@$@"
expected-stdout:
---
name: IFS-space-colon-5
description:
Simple test, IFS=<white-space>:
Don't know what POSIX thinks of this. AT&T ksh does not do this.
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="
:"
set --
showargs "${@:-}"
expected-stdout:
<>
---
name: IFS-subst-1
description:
Simple test, IFS=<white-space>:
stdin:
showargs() { for i; do echo -n " <$i>"; done; echo; }
IFS="
:"
x=":b: :"
echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
showargs 3 $x
showargs 4 :b::
x="a:b:"
echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
showargs 6 $x
x="a::c"
echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
showargs 8 $x
echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
showargs 10 ${FOO-`echo -n h:i`th:ere}
showargs 11 "${FOO-`echo -n h:i`th:ere}"
x=" A : B::D"
echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
showargs 13 $x
expected-stdout:
1: [] [b] []
2: [:b::]
<3> <> <b> <>
<4> <:b::>
5: [a] [b]
<6> <a> <b>
7: [a] [] [c]
<8> <a> <> <c>
9: [h] [ith] [ere]
<10> <h> <ith> <ere>
<11> <h:ith:ere>
12: [A] [B] [] [D]
<13> <A> <B> <> <D>
---
name: integer-base-err-1
description:
Can't have 0 base (causes shell to exit)
category: mksh
expected-exit: e != 0
stdin:
typeset -i i
i=3
i=0#4
echo $i
expected-stderr-pattern:
/^.*:.*0#4.*\n$/
---
name: integer-base-err-2
description:
Can't have multiple bases in a 'constant' (causes shell to exit)
(ksh88 fails this test)
category: mksh
expected-exit: e != 0
stdin:
typeset -i i
i=3
i=2#110#11
echo $i
expected-stderr-pattern:
/^.*:.*2#110#11.*\n$/
---
name: integer-base-err-3
description:
Syntax errors in expressions and effects on bases
(interactive so errors don't cause exits)
(ksh88 fails this test - shell exits, even with -i)
category: mksh
arguments: !-i!
stdin:
PS1= # minimise prompt hassles
typeset -i4 a=10
typeset -i a=2+
echo $a
typeset -i4 a=10
typeset -i2 a=2+
echo $a
expected-stderr-pattern:
/^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
expected-stdout:
4#22
4#22
---
name: integer-base-err-4
description:
Are invalid digits (according to base) errors?
(ksh93 fails this test)
category: mksh
expected-exit: e != 0
stdin:
typeset -i i;
i=3#4
expected-stderr-pattern:
/^([#\$] )?.*:.*3#4.*\n$/
---
name: integer-base-1
description:
Missing number after base is treated as 0.
category: mksh
stdin:
typeset -i i
i=3
i=2#
echo $i
expected-stdout:
0
---
name: integer-base-2
description:
Check 'stickyness' of base in various situations
category: mksh
stdin:
typeset -i i=8
echo $i
echo ---------- A
typeset -i4 j=8
echo $j
echo ---------- B
typeset -i k=8
typeset -i4 k=8
echo $k
echo ---------- C
typeset -i4 l
l=3#10
echo $l
echo ---------- D
typeset -i m
m=3#10
echo $m
echo ---------- E
n=2#11
typeset -i n
echo $n
n=10
echo $n
echo ---------- F
typeset -i8 o=12
typeset -i4 o
echo $o
echo ---------- G
typeset -i p
let p=8#12
echo $p
expected-stdout:
8
---------- A
4#20
---------- B
4#20
---------- C
4#3
---------- D
3#10
---------- E
2#11
2#1010
---------- F
4#30
---------- G
8#12
---
name: integer-base-3
description:
More base parsing (hmm doesn't test much..)
category: mksh
stdin:
typeset -i aa
aa=1+12#10+2
echo $aa
typeset -i bb
bb=1+$aa
echo $bb
typeset -i bb
bb=$aa
echo $bb
typeset -i cc
cc=$aa
echo $cc
expected-stdout:
15
16
15
15
---
name: integer-base-4
description:
Check that things not declared as integers are not made integers,
also, check if base is not reset by -i with no arguments.
(ksh93 fails - prints 10#20 - go figure)
category: mksh
stdin:
xx=20
let xx=10
typeset -i | grep '^xx='
typeset -i4 a=10
typeset -i a=20
echo $a
expected-stdout:
4#110
---
name: integer-base-5
description:
More base stuff
category: mksh
stdin:
typeset -i4 a=3#10
echo $a
echo --
typeset -i j=3
j='~3'
echo $j
echo --
typeset -i k=1
x[k=k+1]=3
echo $k
echo --
typeset -i l
for l in 1 2+3 4; do echo $l; done
expected-stdout:
4#3
--
-4
--
2
--
1
5
4
---
name: integer-base-6
description:
Even more base stuff
(ksh93 fails this test - prints 0)
category: mksh
stdin:
typeset -i7 i
i=
echo $i
expected-stdout:
7#0
---
name: integer-base-7
description:
Check that non-integer parameters don't get bases assigned
category: mksh
stdin:
echo $(( zz = 8#100 ))
echo $zz
expected-stdout:
64
64
---
name: lineno-stdin
description:
See if $LINENO is updated and can be modified.
stdin:
echo A $LINENO
echo B $LINENO
LINENO=20
echo C $LINENO
expected-stdout:
A 1
B 2
C 20
---
name: lineno-inc
description:
See if $LINENO is set for .'d files.
file-setup: file 644 "dotfile"
echo dot A $LINENO
echo dot B $LINENO
LINENO=20
echo dot C $LINENO
stdin:
echo A $LINENO
echo B $LINENO
. ./dotfile
expected-stdout:
A 1
B 2
dot A 1
dot B 2
dot C 20
---
name: lineno-func
description:
See if $LINENO is set for commands in a function.
stdin:
echo A $LINENO
echo B $LINENO
bar() {
echo func A $LINENO
echo func B $LINENO
}
bar
echo C $LINENO
expected-stdout:
A 1
B 2
func A 4
func B 5
C 8
---
name: lineno-unset
description:
See if unsetting LINENO makes it non-magic.
file-setup: file 644 "dotfile"
echo dot A $LINENO
echo dot B $LINENO
stdin:
unset LINENO
echo A $LINENO
echo B $LINENO
bar() {
echo func A $LINENO
echo func B $LINENO
}
bar
. ./dotfile
echo C $LINENO
expected-stdout:
A
B
func A
func B
dot A
dot B
C
---
name: lineno-unset-use
description:
See if unsetting LINENO makes it non-magic even
when it is re-used.
file-setup: file 644 "dotfile"
echo dot A $LINENO
echo dot B $LINENO
stdin:
unset LINENO
LINENO=3
echo A $LINENO
echo B $LINENO
bar() {
echo func A $LINENO
echo func B $LINENO
}
bar
. ./dotfile
echo C $LINENO
expected-stdout:
A 3
B 3
func A 3
func B 3
dot A 3
dot B 3
C 3
---
name: lineno-trap
description:
Check if LINENO is tracked in traps
category: posix
expected-fail: yes
stdin:
fail() {
echo "line <$1>"
exit 1
}
trap 'fail $LINENO' INT ERR
false
expected-stdout:
line <6>
expected-exit: 1
---
name: read-IFS-1
description:
Simple test, default IFS
stdin:
unset IFS
echo "A B " > IN
unset x y z
read x y z < IN
echo 1: "x[$x] y[$y] z[$z]"
echo 1a: ${z-z not set}
read x < IN
echo 2: "x[$x]"
expected-stdout:
1: x[A] y[B] z[]
1a:
2: x[A B]
---
name: read-ksh-1
description:
If no var specified, REPLY is used
category: mksh
stdin:
echo "abc" > IN
read < IN
echo "[$REPLY]";
expected-stdout:
[abc]
---
name: regression-1
description:
Lex array code had problems with this.
stdin:
echo foo[
n=bar
echo "hi[ $n ]=1"
expected-stdout:
foo[
hi[ bar ]=1
---
name: regression-2
description:
When PATH is set before running a command, the new path is
not used in doing the path search
$ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
$ PATH=/tmp q
q: not found
$
in comexec() the two lines
while (*vp != NULL)
(void) typeset(*vp++, xxx, 0);
need to be moved out of the switch to before findcom() is
called - I don't know what this will break.
stdin:
: ${PWD:-`pwd 2> /dev/null`}
: ${PWD:?"PWD not set - can't do test"}
mkdir Y
cat > Y/xxxscript << EOF
#!/bin/sh
# Need to restore path so echo can be found (some shells don't have
# it as a built-in)
PATH=\$OLDPATH
echo hi
exit 0
EOF
chmod a+rx Y/xxxscript
export OLDPATH="$PATH"
PATH=$PWD/Y xxxscript
exit $?
expected-stdout:
hi
---
name: regression-6
description:
Parsing of $(..) expressions is non-optimal. It is
impossible to have any parentheses inside the expression.
I.e.,
$ ksh -c 'echo $(echo \( )'
no closing quote
$ ksh -c 'echo $(echo "(" )'
no closing quote
$
The solution is to hack the parsing clode in lex.c, the
question is how to hack it: should any parentheses be
escaped by a backslash, or should recursive parsing be done
(so quotes could also be used to hide hem). The former is
easier, the later better...
stdin:
echo $(echo \()
expected-stdout:
(
---
name: regression-9
description:
Continue in a for loop does not work right:
for i in a b c ; do
if [ $i = b ] ; then
continue
fi
echo $i
done
Prints a forever...
stdin:
first=yes
for i in a b c ; do
if [ $i = b ] ; then
if [ $first = no ] ; then
echo 'continue in for loop broken'
break # hope break isn't broken too :-)
fi
first=no
continue
fi
done
echo bye
expected-stdout:
bye
---
name: regression-10bis
description:
The following:
set -- `false`
echo $?
should print 0 according to POSIX (dash, bash, ksh93, posh).
category: posix
stdin:
set -- `false`
echo $?
expected-stdout:
0
---
name: regression-11
description:
The following:
x=/foo/bar/blah
echo ${x##*/}
should echo blah but on some machines echos /foo/bar/blah.
stdin:
x=/foo/bar/blah
echo ${x##*/}
expected-stdout:
blah
---
name: regression-12
description:
Both of the following echos produce the same output under sh/ksh.att:
#!/bin/sh
x="foo bar"
echo "`echo \"$x\"`"
echo "`echo "$x"`"
pdksh produces different output for the former (foo instead of foo\tbar)
stdin:
x="foo bar"
echo "`echo \"$x\"`"
echo "`echo "$x"`"
expected-stdout:
foo bar
foo bar
---
name: regression-13
description:
The following command hangs forever:
$ (: ; cat /etc/termcap) | sleep 2
This is because the shell forks a shell to run the (..) command
and this shell has the pipe open. When the sleep dies, the cat
doesn't get a SIGPIPE 'cause a process (ie, the second shell)
still has the pipe open.
NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
commands from /etc/termcap..)
time-limit: 10
stdin:
echo A line of text that will be duplicated quite a number of times.> t1
cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
cat t1 t1 t1 t1 > t2
(: ; cat t2 2>&-) | sleep 1
---
name: regression-14
description:
The command
$ (foobar) 2> /dev/null
generates no output under /bin/sh, but pdksh produces the error
foobar: not found
Also, the command
$ foobar 2> /dev/null
generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
no error (redirected to /dev/null).
stdin:
(you/should/not/see/this/error/1) 2> /dev/null
you/should/not/see/this/error/2 2> /dev/null
true
---
name: regression-15
description:
The command
$ whence foobar
generates a blank line under pdksh and sets the exit status to 0.
AT&T ksh88 generates no output and sets the exit status to 1. Also,
the command
$ whence foobar cat
generates no output under AT&T ksh88 (pdksh generates a blank line
and /bin/cat).
category: mksh
stdin:
whence does/not/exist > /dev/null
echo 1: $?
echo 2: $(whence does/not/exist | wc -l)
echo 3: $(whence does/not/exist cat | wc -l)
expected-stdout:
1: 1
2: 0
3: 0
---
name: regression-16
description:
${var%%expr} seems to be broken in many places. On the mips
the commands
$ read line < /etc/passwd
$ echo $line
root:0:1:...
$ echo ${line%%:*}
root
$ echo $line
root
$
change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
work. Haven't checked elsewhere...
script:
read x
y=$x
echo ${x%%:*}
echo $x
stdin:
root:asdjhasdasjhs:0:1:Root:/:/bin/sh
expected-stdout:
root
root:asdjhasdasjhs:0:1:Root:/:/bin/sh
---
name: regression-17
description:
The command
. /foo/bar
should set the exit status to non-zero (sh and AT&T ksh88 do).
XXX doting a non existent file is a fatal error for a script
stdin:
. does/not/exist
expected-exit: e != 0
expected-stderr-pattern: /.?/
---
name: regression-19
description:
Both of the following echos should produce the same thing, but don't:
$ x=foo/bar
$ echo ${x%/*}
foo
$ echo "${x%/*}"
foo/bar
stdin:
x=foo/bar
echo "${x%/*}"
expected-stdout:
foo
---
name: regression-21
description:
backslash does not work as expected in case labels:
$ x='-x'
$ case $x in
-\?) echo hi
esac
hi
$ x='-?'
$ case $x in
-\\?) echo hi
esac
hi
$
stdin:
case -x in
-\?) echo fail
esac
---
name: regression-22
description:
Quoting backquotes inside backquotes doesn't work:
$ echo `echo hi \`echo there\` folks`
asks for more info. sh and AT&T ksh88 both echo
hi there folks
stdin:
echo `echo hi \`echo there\` folks`
expected-stdout:
hi there folks
---
name: regression-23
description:
)) is not treated `correctly':
$ (echo hi ; (echo there ; echo folks))
missing ((
$
instead of (as sh and ksh.att)
$ (echo hi ; (echo there ; echo folks))
hi
there
folks
$
stdin:
( : ; ( : ; echo hi))
expected-stdout:
hi
---
name: regression-25
description:
Check reading stdin in a while loop. The read should only read
a single line, not a whole stdio buffer; the cat should get
the rest.
stdin:
(echo a; echo b) | while read x ; do
echo $x
cat > /dev/null
done
expected-stdout:
a
---
name: regression-26
description:
Check reading stdin in a while loop. The read should read both
lines, not just the first.
script:
a=
while [ "$a" != xxx ] ; do
last=$x
read x
cat /dev/null | sed 's/x/y/'
a=x$a
done
echo $last
stdin:
a
b
expected-stdout:
b
---
name: regression-27
description:
The command
. /does/not/exist
should cause a script to exit.
stdin:
. does/not/exist
echo hi
expected-exit: e != 0
expected-stderr-pattern: /does\/not\/exist/
---
name: regression-28
description:
variable assignements not detected well
stdin:
a.x=1 echo hi
expected-exit: e != 0
expected-stderr-pattern: /a\.x=1/
---
name: regression-29
description:
alias expansion different from AT&T ksh88
category: !no-aliases
stdin:
alias a='for ' b='i in'
a b hi ; do echo $i ; done
expected-stdout:
hi
---
name: regression-30
description:
strange characters allowed inside ${...}
stdin:
echo ${a{b}}
expected-exit: e != 0
expected-stderr-pattern: /.?/
---
name: regression-31
description:
Does read handle partial lines correctly
script:
a= ret=
while [ "$a" != xxx ] ; do
read x y z
ret=$?
a=x$a
done
echo "[$x]"
echo $ret
stdin: !
a A aA
b B Bb
c
expected-stdout:
[c]
1
---
name: regression-32
description:
Does read set variables to null at eof?
script:
a=
while [ "$a" != xxx ] ; do
read x y z
a=x$a
done
echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
stdin:
a A Aa
b B Bb
expected-stdout:
1:
2:
---
name: regression-33
description:
Does umask print a leading 0 when umask is 3 digits?
stdin:
umask 222
umask
expected-stdout:
0222
---
name: regression-35
description:
Tempory files used for here-docs in functions get trashed after
the function is parsed (before it is executed)
stdin:
f1() {
cat <<- EOF
F1
EOF
f2() {
cat <<- EOF
F2
EOF
}
}
f1
f2
unset -f f1
f2
expected-stdout:
F1
F2
F2
---
name: regression-36
description:
Command substitution breaks reading in while loop
(test from <sjg@void.zen.oz.au>)
stdin:
(echo abcdef; echo; echo 123) |
while read line
do
# the following line breaks it
c=`echo $line | wc -c`
echo $c
done
expected-stdout:
7
1
4
---
name: regression-37
description:
Machines with broken times() (reported by <sjg@void.zen.oz.au>)
time does not report correct real time
category: mksh
stdin:
time sleep 1
expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
---
name: regression-38
description:
set -e doesn't ignore exit codes for if/while/until/&&/||/!.
arguments: !-e!
stdin:
if false; then echo hi ; fi
false || true
false && true
while false; do echo hi; done
echo ok
expected-stdout:
ok
---
name: regression-39
description:
set -e: errors in command substitutions aren't ignored
Not clear if they should be or not... bash passes here
this may actually be required for make, so changed the
test to make this an mksh feature, not a bug
arguments: !-e!
stdin:
echo `false; echo hi`
#expected-fail: yes
#expected-stdout:
# hi
expected-stdout:
---
name: regression-40
description:
This used to cause a core dump
env-setup: !RANDOM=12!
stdin:
echo hi
expected-stdout:
hi
---
name: regression-41
description:
foo should be set to bar (should not be empty)
stdin:
foo=`
echo bar`
echo "($foo)"
expected-stdout:
(bar)
---
name: regression-42
description:
Can't use command line assignments to assign readonly parameters.
stdin:
foo=bar
readonly foo
foo=stuff env | grep '^foo'
expected-exit: e != 0
expected-stderr-pattern:
/.*read *only.*/
---
name: regression-43
description:
Can subshells be prefixed by redirections (historical shells allow
this)
stdin:
< /dev/null (sed 's/^/X/')
---
name: regression-44
description:
getopts sets OPTIND correctly for unparsed option
category: posh
stdin:
set -- -a -a -x
while getopts :a optc; do
echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
done
echo done
expected-stdout:
OPTARG=, OPTIND=2, optc=a.
OPTARG=, OPTIND=3, optc=a.
OPTARG=x, OPTIND=4, optc=?.
done
---
name: regression-45
description:
Parameter assignments with [] recognised correctly
stdin:
FOO=*[12]
BAR=abc[
MORE=[abc]
JUNK=a[bc
echo "<$FOO>"
echo "<$BAR>"
echo "<$MORE>"
echo "<$JUNK>"
expected-stdout:
<*[12]>
<abc[>
<[abc]>
<a[bc>
---
name: regression-46
description:
Check that alias expansion works in command substitutions and
at the end of file.
category: !no-aliases
stdin:
alias x='echo hi'
FOO="`x` "
echo "[$FOO]"
x
expected-stdout:
[hi ]
hi
---
name: regression-47
description:
Check that aliases are fully read.
category: !no-aliases
stdin:
alias x='echo hi;
echo there'
x
echo done
expected-stdout:
hi
there
done
---
name: regression-48
description:
Check that (here doc) temp files are not left behind after an exec.
stdin:
mkdir foo || exit 1
TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
x() {
sed 's/^/X /' << E_O_F
hi
there
folks
E_O_F
echo "done ($?)"
}
echo=echo; [ -x /bin/echo ] && echo=/bin/echo
exec $echo subtest-1 hi
EOF
echo subtest-1 foo/*
TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
echo=echo; [ -x /bin/echo ] && echo=/bin/echo
sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
a
few
lines
E_O_F
EOF
echo subtest-2 foo/*
expected-stdout:
subtest-1 hi
subtest-1 foo/*
X a
X few
X lines
subtest-2 hi
subtest-2 foo/*
---
name: regression-49
description:
Check that unset params with attributes are reported by set, those
sans attributes are not.
stdin:
unset FOO BAR
echo X$FOO
export BAR
set | grep FOO
set | grep BAR
expected-stdout:
X
BAR
---
name: regression-50
description:
Check that aliases do not use continuation prompt after trailing
semi-colon.
category: !no-aliases
file-setup: file 644 "env"
PS1=Y
PS2=X
env-setup: !ENV=./env!
arguments: !-i!
stdin:
alias foo='echo hi ; '
foo
foo echo there
expected-stdout:
hi
hi
there
expected-stderr: !
YYYY
---
name: regression-51
description:
Check that set allows both +o and -o options on same command line.
stdin:
set a b c
set -o noglob +o allexport
echo A: $*, *
expected-stdout:
A: a b c, *
---
name: regression-52
description:
Check that globbing works in pipelined commands
category: ksh
file-setup: file 644 "env"
PS1=P
file-setup: file 644 "abc"
stuff
env-setup: !ENV=./env!
arguments: !-i!
stdin:
sed 's/^/X /' < ab*
echo mark 1
sed 's/^/X /' < ab* | sed 's/^/Y /'
echo mark 2
expected-stdout:
X stuff
mark 1
Y X stuff
mark 2
expected-stderr: !
PPPPP
---
name: regression-53
description:
Check that getopts works in functions
category: ksh
stdin:
bfunc() {
echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
while getopts B oc; do
case $oc in
(B)
echo bfunc: B option
;;
(*)
echo bfunc: odd option "($oc)"
;;
esac
done
echo bfunc: leave
}
set -- -f -b -k -l
echo "line 1: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
bfunc -BBB blah
echo "line 3: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
echo
OPTIND=1
set -- -fbkl
echo "line 10: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
bfunc -BBB blah
echo "line 30: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
expected-stdout:
line 1: OPTIND=1
line 2: ret=0, optc=f, OPTIND=2
bfunc: enter (args: -BBB blah; OPTIND=2)
bfunc: B option
bfunc: B option
bfunc: leave
line 3: OPTIND=2
line 4: ret=0, optc=b, OPTIND=3
line 10: OPTIND=1
line 20: ret=0, optc=f, OPTIND=2
bfunc: enter (args: -BBB blah; OPTIND=2)
bfunc: B option
bfunc: B option
bfunc: leave
line 30: OPTIND=2
line 40: ret=1, optc=?, OPTIND=2
---
name: regression-54
description:
Check that ; is not required before the then in if (( ... )) then ...
category: mksh
stdin:
if (( 1 )) then
echo ok dparen
fi
if [[ -n 1 ]] then
echo ok dbrackets
fi
expected-stdout:
ok dparen
ok dbrackets
---
name: regression-55
description:
Check ${foo:%bar} is allowed (ksh88 allows it...)
category: mksh
stdin:
x=fooXbarXblah
echo 1 ${x%X*}
echo 2 ${x:%X*}
echo 3 ${x%%X*}
echo 4 ${x:%%X*}
echo 5 ${x#*X}
echo 6 ${x:#*X}
echo 7 ${x##*X}
echo 8 ${x:##*X}
expected-stdout:
1 fooXbar
2 fooXbar
3 foo
4 foo
5 barXblah
6 barXblah
7 blah
8 blah
---
name: regression-57
description:
Check if typeset output is correct for
uninitialised array elements.
category: mksh
stdin:
typeset -i xxx[4]
echo A
typeset -i | grep xxx | sed 's/^/ /'
echo B
typeset | grep xxx | sed 's/^/ /'
xxx[1]=2+5
echo M
typeset -i | grep xxx | sed 's/^/ /'
echo N
typeset | grep xxx | sed 's/^/ /'
expected-stdout:
A
xxx
B
typeset -i xxx
M
xxx[1]=7
N
typeset -i xxx
---
name: regression-58
description:
Check if trap exit is ok (exit not mistaken for signal name)
category: idontunderstand
stdin:
trap 'echo hi' exit
trap exit 1
expected-stdout:
hi
---
name: regression-59
description:
Check if ${#array[*]} is calculated correctly.
stdin:
a[12]=hi
a[8]=there
echo ${#a[*]}
expected-stdout:
2
---
name: regression-60
description:
Check if default exit status is previous command
stdin:
(true; exit)
echo A $?
(false; exit)
echo B $?
( (exit 103) ; exit)
echo C $?
expected-stdout:
A 0
B 1
C 103
---
name: regression-61
description:
Check if EXIT trap is executed for sub shells.
stdin:
trap 'echo parent exit' EXIT
echo start
(echo A; echo A last)
echo B
(echo C; trap 'echo sub exit' EXIT; echo C last)
echo parent last
expected-stdout:
start
A
A last
B
C
C last
sub exit
parent last
parent exit
---
name: regression-62
description:
Check if test -nt/-ot succeeds if second(first) file is missing.
category: mksh
stdin:
touch a
test a -nt b && echo nt OK || echo nt BAD
test b -ot a && echo ot OK || echo ot BAD
expected-stdout:
nt OK
ot OK
---
name: regression-64
description:
Check that we can redefine functions calling time builtin
stdin:
t() {
time >/dev/null
}
t 2>/dev/null
t() {
time
}
---
name: syntax-1
description:
Check that lone ampersand is a syntax error
stdin:
&
expected-exit: e != 0
expected-stderr-pattern:
/syntax error/
---
name: xxx-quoted-newline-1
description:
Check that \<newline> works inside of ${}
stdin:
abc=2
echo ${ab\
c}
expected-stdout:
2
---
name: xxx-quoted-newline-2
description:
Check that \<newline> works at the start of a here document
stdin:
cat << EO\
F
hi
EOF
expected-stdout:
hi
---
name: xxx-quoted-newline-3
description:
Check that \<newline> works at the end of a here document
stdin:
cat << EOF
hi
EO\
F
expected-stdout:
hi
---
name: xxx-multi-assignment-cmd
description:
Check that assignments in a command affect subsequent assignments
in the same command
stdin:
FOO=abc
FOO=123 BAR=$FOO
echo $BAR
expected-stdout:
123
---
name: xxx-multi-assignment-posix-cmd
description:
Check that the behaviour for multiple assignments with a
command name matches POSIX. See:
http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
category: posixisunclearaboutthis
stdin:
X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
unset X Y Z
X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
unset X Y Z
X=a Y=${X=b} Z=$X; echo 4 $Z .
expected-stdout:
1 b a .
2 a b .
3 b .
4 a .
---
name: xxx-multi-assignment-posix-nocmd
description:
Check that the behaviour for multiple assignments with no
command name matches POSIX (Debian #334182). See:
http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
stdin:
X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
expected-stdout:
1 b b .
---
name: xxx-multi-assignment-posix-subassign
description:
Check that the behaviour for multiple assignments matches POSIX:
- The assignment words shall be expanded in the current execution
environment.
- The assignments happen in the temporary execution environment.
category: ksh
stdin:
unset X Y Z
Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
echo /$X/
# Now for the special case:
unset X Y Z
X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
echo /$X/
expected-stdout:
++ +b+ +a+
/b/
++ +b+
/b/
---
name: xxx-exec-environment-1
description:
Check to see if exec sets it's environment correctly
stdin:
FOO=bar exec env
expected-stdout-pattern:
/(^|.*\n)FOO=bar\n/
---
name: xxx-exec-environment-2
description:
Check to make sure exec doesn't change environment if a program
isn't exec-ed
stdin:
sortprog=$(which sort) || sortprog=cat
env | $sortprog | grep -v '^RANDOM=' >bar1
FOO=bar exec; env | $sortprog | grep -v '^RANDOM=' >bar2
cmp -s bar1 bar2
---
name: exec-function-environment-1
description:
Check assignments in function calls and whether they affect
the current execution environment (ksh93, SUSv4)
category: posix
expected-fail: yes
stdin:
f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
echo x$a-$b- z$c-
expected-stdout:
y1-
x2-3- z1-
---
name: xxx-what-do-you-call-this-1
stdin:
echo "${foo:-"a"}*"
expected-stdout:
a*
---
name: xxx-prefix-strip-1
stdin:
foo='a cdef'
echo ${foo#a c}
expected-stdout:
def
---
name: xxx-prefix-strip-2
stdin:
set a c
x='a cdef'
echo ${x#$*}
expected-stdout:
def
---
name: xxx-variable-syntax-1
stdin:
echo ${:}
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: xxx-variable-syntax-2
stdin:
set 0
echo ${*:0}
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: xxx-variable-syntax-3
stdin:
set -A foo 0
echo ${foo[*]:0}
category: ksh
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: xxx-substitution-eval-order
description:
Check order of evaluation of expressions
category: mksh
stdin:
i=1 x= y=
set -A A abc def GHI j G k
echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
echo $x $y
expected-stdout:
HI
2 4
---
name: xxx-set-option-1
description:
Check option parsing in set
stdin:
set -v -- A 1 3 2
echo ${*}
expected-stderr:
echo ${*}
expected-stdout:
A 1 3 2
---
name: xxx-exec-1
description:
Check that exec exits for built-ins
arguments: !-i!
stdin:
exec echo hi
echo still herre
expected-stdout:
hi
expected-stderr-pattern: /.*/
---
name: xxx-while-1
description:
Check the return value of while loops
XXX need to do same for for/select/until loops
stdin:
i=x
while [ $i != xxx ] ; do
i=x$i
if [ $i = xxx ] ; then
false
continue
fi
done
echo loop1=$?
i=x
while [ $i != xxx ] ; do
i=x$i
if [ $i = xxx ] ; then
false
break
fi
done
echo loop2=$?
i=x
while [ $i != xxx ] ; do
i=x$i
false
done
echo loop3=$?
expected-stdout:
loop1=0
loop2=0
loop3=1
---
name: xxx-status-1
description:
Check that blank lines don't clear $?
arguments: !-i!
stdin:
(exit 1)
echo $?
(exit 1)
echo $?
true
expected-stdout:
1
1
expected-stderr-pattern: /.*/
---
name: xxx-status-2
description:
Check that $? is preserved in subshells, includes, traps.
stdin:
(exit 1)
echo blank: $?
(exit 2)
(echo subshell: $?)
echo 'echo include: $?' > foo
(exit 3)
. ./foo
(exit 4)
echo exit: $?
expected-stdout:
blank: 1
subshell: 2
include: 3
exit: 4
---
name: xxx-clean-chars-1
description:
Check MAGIC character is stuffed correctly
stdin:
echo `echo [`
expected-stdout:
[
---
name: xxx-param-subst-qmark-1
description:
Check suppresion of error message with null string. According to
POSIX, it shouldn't print the error as 'word' isn't ommitted.
ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error,
that's why the condition is reversed.
stdin:
unset foo
x=
echo x${foo?$x}
expected-exit: 1
# POSIX
#expected-fail: yes
#expected-stderr-pattern: !/not set/
# common use
expected-stderr-pattern: /parameter null or not set/
---
name: xxx-param-_-1
# fails due to weirdness of execv stuff
category: !os:uwin-nt
description:
Check c flag is set.
arguments: !-c!echo "[$-]"!
expected-stdout-pattern: /^\[.*c.*\]$/
---
name: tilde-expand-1
description:
Check tilde expansion after equal signs
env-setup: !HOME=/sweet!
stdin:
echo ${A=a=}~ b=~ c=d~ ~
expected-stdout:
a=~ b=~ c=d~ /sweet
---
name: exit-err-1
description:
Check some "exit on error" conditions
stdin:
set -ex
/usr/bin/env false && echo something
echo END
expected-stdout:
END
expected-stderr:
+ /usr/bin/env false
+ echo END
---
name: exit-err-2
description:
Check some "exit on error" edge conditions (POSIXly)
stdin:
set -ex
if /usr/bin/env true; then
/usr/bin/env false && echo something
fi
echo END
expected-stdout:
END
expected-stderr:
+ /usr/bin/env true
+ /usr/bin/env false
+ echo END
---
name: exit-err-3
description:
pdksh regression which AT&T ksh does right
TFM says: [set] -e | errexit
Exit (after executing the ERR trap) ...
stdin:
trap 'echo EXIT' EXIT
set -e
cd /XXXXX 2>/dev/null
echo DONE
exit 0
expected-stdout:
EXIT
expected-exit: e != 0
---
name: exit-err-4
description:
"set -e" test suite (POSIX)
stdin:
set -e
echo pre
if true ; then
false && echo foo
fi
echo bar
expected-stdout:
pre
bar
---
name: exit-err-5
description:
"set -e" test suite (POSIX)
stdin:
set -e
foo() {
while [ "$1" ]; do
for E in $x; do
[ "$1" = "$E" ] && { shift ; continue 2 ; }
done
x="$x $1"
shift
done
echo $x
}
echo pre
foo a b b c
echo post
expected-stdout:
pre
a b c
post
---
name: exit-err-6
description:
"set -e" test suite (BSD make)
category: os:mirbsd
stdin:
mkdir zd zd/a zd/b
print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
print 'all:\n\t@echo zwei\n' >zd/b/Makefile
wd=$(pwd)
set -e
for entry in a b; do ( set -e; if [[ -d $wd/zd/$entry.i386 ]]; then _newdir_="$entry.i386"; else _newdir_="$entry"; fi; if [[ -z $_THISDIR_ ]]; then _nextdir_="$_newdir_"; else _nextdir_="$_THISDIR_/$_newdir_"; fi; _makefile_spec_=; [[ ! -f $wd/zd/$_newdir_/Makefile.bsd-wrapper ]] || _makefile_spec_="-f Makefile.bsd-wrapper"; subskipdir=; for skipdir in ; do subentry=${skipdir#$entry}; if [[ $subentry != $skipdir ]]; then if [[ -z $subentry ]]; then echo "($_nextdir_ skipped)"; break; fi; subskipdir="$subskipdir ${subentry#/}"; fi; done; if [[ -z $skipdir || -n $subentry ]]; then echo "===> $_nextdir_"; cd $wd/zd/$_newdir_; make SKIPDIR="$subskipdir" $_makefile_spec_ _THISDIR_="$_nextdir_" all; fi; ) done 2>&1 | sed "s!$wd!WD!g"
expected-stdout:
===> a
eins
*** Error code 42
Stop in WD/zd/a (line 2 of Makefile).
---
name: exit-enoent-1
description:
SUSv4 says that the shell should exit with 126/127 in some situations
stdin:
i=0
(echo; echo :) >x
"$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
"$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
echo exit 42 >x
"$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
"$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
rm -f x
"$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
"$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
expected-stdout:
0 0 .
1 126 .
2 42 .
3 126 .
4 127 .
5 127 .
---
name: exit-eval-1
description:
Check eval vs substitution exit codes (ksh93 alike)
stdin:
eval $(false)
echo A $?
eval ' $(false)'
echo B $?
eval " $(false)"
echo C $?
eval "eval $(false)"
echo D $?
eval 'eval '"$(false)"
echo E $?
IFS="$IFS:"
eval $(echo :; false)
echo F $?
expected-stdout:
A 0
B 1
C 0
D 0
E 0
F 0
---
name: exit-trap-1
description:
Check that "exit" with no arguments behaves SUSv4 conformant.
category: posix
expected-fail: yes
stdin:
trap 'echo hi; exit' EXIT
exit 9
expected-stdout:
hi
expected-exit: 9
---
name: test-stlt-1
description:
Check that test also can handle string1 < string2 etc.
category: mksh
stdin:
test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
expected-stdout:
nein
ja
ja
nein
expected-stderr-pattern: !/unexpected op/
---
name: test-precedence-1
description:
Check a precedence case (and POSIX echo)
stdin:
test -f = -f
rv=$?
test -n "$POSH_VERSION" || set -o sh
echo -e $rv
expected-stdout:
-e 0
---
name: test-option-1
description:
Test the test -o operator
category: mksh
stdin:
runtest() {
test -o $1; echo $?
[ -o $1 ]; echo $?
[[ -o $1 ]]; echo $?
}
if_test() {
test -o $1 -o -o !$1; echo $?
[ -o $1 -o -o !$1 ]; echo $?
[[ -o $1 || -o !$1 ]]; echo $?
test -o ?$1; echo $?
}
echo 0y $(if_test utf8-mode) =
echo 0n $(if_test utf8-hack) =
echo 1= $(runtest utf8-hack) =
echo 2= $(runtest !utf8-hack) =
echo 3= $(runtest ?utf8-hack) =
set +U
echo 1+ $(runtest utf8-mode) =
echo 2+ $(runtest !utf8-mode) =
echo 3+ $(runtest ?utf8-mode) =
set -U
echo 1- $(runtest utf8-mode) =
echo 2- $(runtest !utf8-mode) =
echo 3- $(runtest ?utf8-mode) =
echo = short flags =
echo 0y $(if_test -U) =
echo 0y $(if_test +U) =
echo 0n $(if_test -_) =
echo 0n $(if_test -U-) =
echo 1= $(runtest -_) =
echo 2= $(runtest !-_) =
echo 3= $(runtest ?-_) =
set +U
echo 1+ $(runtest -U) =
echo 2+ $(runtest !-U) =
echo 3+ $(runtest ?-U) =
echo 1+ $(runtest +U) =
echo 2+ $(runtest !+U) =
echo 3+ $(runtest ?+U) =
set -U
echo 1- $(runtest -U) =
echo 2- $(runtest !-U) =
echo 3- $(runtest ?-U) =
echo 1- $(runtest +U) =
echo 2- $(runtest !+U) =
echo 3- $(runtest ?+U) =
expected-stdout:
0y 0 0 0 0 =
0n 1 1 1 1 =
1= 1 1 1 =
2= 1 1 1 =
3= 1 1 1 =
1+ 1 1 1 =
2+ 0 0 0 =
3+ 0 0 0 =
1- 0 0 0 =
2- 1 1 1 =
3- 0 0 0 =
= short flags =
0y 0 0 0 0 =
0y 0 0 0 0 =
0n 1 1 1 1 =
0n 1 1 1 1 =
1= 1 1 1 =
2= 1 1 1 =
3= 1 1 1 =
1+ 1 1 1 =
2+ 0 0 0 =
3+ 0 0 0 =
1+ 1 1 1 =
2+ 0 0 0 =
3+ 0 0 0 =
1- 0 0 0 =
2- 1 1 1 =
3- 0 0 0 =
1- 0 0 0 =
2- 1 1 1 =
3- 0 0 0 =
---
name: mkshrc-1
description:
Check that ~/.mkshrc works correctly.
Part 1: verify user environment is not read (internal)
category: mksh
stdin:
echo x $FNORD
expected-stdout:
x
---
name: mkshrc-2a
description:
Check that ~/.mkshrc works correctly.
Part 2: verify mkshrc is not read (non-interactive shells)
category: mksh
file-setup: file 644 ".mkshrc"
FNORD=42
env-setup: !HOME=.!ENV=!
stdin:
echo x $FNORD
expected-stdout:
x
---
name: mkshrc-2b
description:
Check that ~/.mkshrc works correctly.
Part 2: verify mkshrc can be read (interactive shells)
category: mksh
file-setup: file 644 ".mkshrc"
FNORD=42
arguments: !-i!
env-setup: !HOME=.!ENV=!PS1=!
stdin:
echo x $FNORD
expected-stdout:
x 42
expected-stderr-pattern:
/(# )*/
---
name: mkshrc-3
description:
Check that ~/.mkshrc works correctly.
Part 3: verify mkshrc can be turned off
category: mksh
file-setup: file 644 ".mkshrc"
FNORD=42
env-setup: !HOME=.!ENV=nonexistant!
stdin:
echo x $FNORD
expected-stdout:
x
---
name: sh-mode-1
description:
Braces are not a special character (only a reserved word)
in POSIX.
category: posix
stdin:
echo {a,b,c}
expected-stdout:
{a,b,c}
---
name: sh-mode-2a
description:
Check that sh mode is *not* automatically turned on
category: ksh-no-binsh
stdin:
ln -s "$__progname" ksh
ln -s "$__progname" sh
ln -s "$__progname" ./-ksh
ln -s "$__progname" ./-sh
for shell in {,-}{,k}sh; do
print -- $shell $(./$shell +l -c \
'[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh')
done
expected-stdout:
sh nosh
ksh nosh
-sh nosh
-ksh nosh
---
name: sh-mode-2b
description:
Check that sh mode *is* automatically turned on
category: ksh-binsh
stdin:
ln -s "$__progname" ksh
ln -s "$__progname" sh
ln -s "$__progname" ./-ksh
ln -s "$__progname" ./-sh
for shell in {,-}{,k}sh; do
print -- $shell $(./$shell +l -c \
'[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh')
done
expected-stdout:
sh sh
ksh nosh
-sh sh
-ksh nosh
---
name: pipeline-1
description:
pdksh bug: last command of a pipeline is executed in a
subshell - make sure it still is, scripts depend on it
file-setup: file 644 "abcx"
file-setup: file 644 "abcy"
stdin:
echo *
echo a | while read d; do
echo $d
echo $d*
echo *
set -o noglob
echo $d*
echo *
done
echo *
expected-stdout:
abcx abcy
a
abcx abcy
abcx abcy
a*
*
abcx abcy
---
name: pipeline-2
description:
check that co-processes work with TCOMs, TPIPEs and TPARENs
category: !no-coprocs
stdin:
"$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
"$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
"$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
expected-stdout:
100 hi
200 hi
300 hi
---
name: persist-history-1
description:
Check if persistent history saving works
category: !no-history
arguments: !-i!
env-setup: !ENV=./Env!HISTFILE=hist.file!
file-setup: file 644 "Env"
PS1=X
stdin:
cat hist.file
expected-stdout-pattern:
/cat hist.file/
expected-stderr-pattern:
/^X*$/
---
name: typeset-padding-1
description:
Check if left/right justification works as per TFM
category: !no-typeset
stdin:
typeset -L10 ln=0hall0
typeset -R10 rn=0hall0
typeset -ZL10 lz=0hall0
typeset -ZR10 rz=0hall0
typeset -Z10 rx=" hallo "
echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
expected-stdout:
<0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
---
name: typeset-padding-2
description:
Check if base-!10 integers are padded right
category: !no-typeset
stdin:
typeset -Uui16 -L9 ln=16#1
typeset -Uui16 -R9 rn=16#1
typeset -Uui16 -Z9 zn=16#1
typeset -L9 ls=16#1
typeset -R9 rs=16#1
typeset -Z9 zs=16#1
echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
expected-stdout:
<16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
---
name: utf8bom-1
description:
Check that the UTF-8 Byte Order Mark is ignored as the first
multibyte character of the shell input (with -c, from standard
input, as file, or as eval argument), but nowhere else
# breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
category: !os:darwin
stdin:
mkdir foo
echo '#!/bin/sh\necho ohne' >foo/fnord
echo '#!/bin/sh\necho mit' >foo/fnord
echo 'fnord\nfnord\nfnord\nfnord' >foo/bar
echo eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
chmod +x foo/*
export PATH=$(pwd)/foo:$PATH
"$__progname" -c 'fnord'
echo =
"$__progname" -c 'fnord; fnord; fnord; fnord'
echo =
"$__progname" foo/bar
echo =
"$__progname" <foo/bar
echo =
"$__progname" foo/zoo
echo =
"$__progname" -c 'echo : $(fnord)'
rm -rf foo
expected-stdout:
ohne
=
ohne
ohne
mit
ohne
=
ohne
ohne
mit
ohne
=
ohne
ohne
mit
ohne
=
ohne
ohne
mit
ohne
=
: mit
---
name: utf8bom-2
description:
Check that we can execute BOM-shebangs (failures not fatal)
XXX if the OS can already execute them, we lose
note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
category: !os:cygwin,!os:uwin-nt,!os:ultrix,!smksh
expected-fail: yes
env-setup: !FOO=BAR!
stdin:
echo '#!'"$__progname"'\necho "1 a=$ENV{FOO}";' >t1
echo '#!'"$__progname"'\necho "2 a=$ENV{FOO}";' >t2
echo '#!'"$__perlname"'\necho "3 a=$ENV{FOO}\n";' >t3
echo '#!'"$__perlname"'\necho "4 a=$ENV{FOO}\n";' >t4
chmod +x t?
./t1
./t2
./t3
./t4
expected-stdout:
1 a=/nonexistant{FOO}
2 a=/nonexistant{FOO}
3 a=BAR
4 a=BAR
expected-stderr-pattern:
/(Unrecognized character .... ignored at \..t4 line 1)*/
---
name: utf8bom-3
description:
Reading the UTF-8 BOM should enable the utf8-mode flag
category: mksh
stdin:
"$__progname" -c ':; if [[ $- = *U* ]]; then echo 1 on; else echo 1 off; fi'
"$__progname" -c ':; if [[ $- = *U* ]]; then echo 2 on; else echo 2 off; fi'
expected-stdout:
1 off
2 on
---
name: utf8opt-1a
description:
Check that the utf8-mode flag is not set at non-interactive startup
category: mksh
env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
stdin:
if [[ $- = *U* ]]; then
echo is set
else
echo is not set
fi
expected-stdout:
is not set
---
name: utf8opt-1b
description:
Check that the utf8-mode flag is not set at non-interactive startup
category: os:hpux
env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
stdin:
if [[ $- = *U* ]]; then
echo is set
else
echo is not set
fi
expected-stdout:
is not set
---
name: utf8opt-2a
description:
Check that the utf8-mode flag is set at interactive startup.
-DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
-DMKSH_ASSUME_UTF8=1 => not expected, please investigate
-UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
category: mksh
arguments: !-i!
env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
stdin:
if [[ $- = *U* ]]; then
echo is set
else
echo is not set
fi
expected-stdout:
is set
expected-stderr-pattern:
/(# )*/
---
name: utf8opt-2b
description:
Check that the utf8-mode flag is set at interactive startup
Expected failure if -DMKSH_ASSUME_UTF8=0
category: os:hpux
arguments: !-i!
env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
stdin:
if [[ $- = *U* ]]; then
echo is set
else
echo is not set
fi
expected-stdout:
is set
expected-stderr-pattern:
/(# )*/
---
name: utf8opt-3
description:
Ensure ±U on the command line is honoured
(this test may pass falsely depending on CPPFLAGS)
category: mksh
stdin:
export i=0
code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
let i++; "$__progname" -U -c "$code"
let i++; "$__progname" +U -c "$code"
let i++; "$__progname" -U -ic "$code"
let i++; "$__progname" +U -ic "$code"
echo $((++i)) done
expected-stdout:
1 on
2 off
3 on
4 off
5 done
---
name: aliases-1
description:
Check if built-in shell aliases are okay
category: !no-aliases
stdin:
alias
typeset -f
expected-stdout:
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nameref='typeset -n'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
stop='kill -STOP'
suspend='kill -STOP $$'
type='whence -v'
---
name: aliases-1-hartz4
description:
Check if built-in shell aliases are okay
category: !no-aliases
stdin:
alias
typeset -f
expected-stdout:
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nameref='typeset -n'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
type='whence -v'
---
name: aliases-2a
description:
Check if “set -o sh” disables built-in aliases (except a few)
category: disabled
arguments: !-o!sh!
stdin:
alias
typeset -f
expected-stdout:
integer='typeset -i'
local=typeset
---
name: aliases-3a
description:
Check if running as sh disables built-in aliases (except a few)
category: disabled
arguments: !-o!sh!
stdin:
cp "$__progname" sh
./sh -c 'alias; typeset -f'
rm -f sh
expected-stdout:
integer='typeset -i'
local=typeset
---
name: aliases-2b
description:
Check if “set -o sh” does not influence built-in aliases
category: mksh-no-arge
arguments: !-o!sh!
stdin:
alias
typeset -f
expected-stdout:
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nameref='typeset -n'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
stop='kill -STOP'
suspend='kill -STOP $$'
type='whence -v'
---
name: aliases-3b
description:
Check if running as sh does not influence built-in aliases
category: !no-aliases
arguments: !-o!sh!
stdin:
cp "$__progname" sh
./sh -c 'alias; typeset -f'
rm -f sh
expected-stdout:
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nameref='typeset -n'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
stop='kill -STOP'
suspend='kill -STOP $$'
type='whence -v'
---
name: aliases-2b-hartz4
description:
Check if “set -o sh” does not influence built-in aliases
category: !no-aliases
arguments: !-o!sh!
stdin:
alias
typeset -f
expected-stdout:
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nameref='typeset -n'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
type='whence -v'
---
name: aliases-3b-hartz4
description:
Check if running as sh does not influence built-in aliases
category: !no-aliases
arguments: !-o!sh!
stdin:
cp "$__progname" sh
./sh -c 'alias; typeset -f'
rm -f sh
expected-stdout:
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nameref='typeset -n'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
type='whence -v'
---
name: aliases-funcdef-1
description:
Check if POSIX functions take precedences over aliases
category: !no-aliases
stdin:
alias foo='echo makro'
foo() {
echo funktion
}
foo
expected-stdout:
funktion
---
name: aliases-funcdef-2
description:
Check if POSIX functions take precedences over aliases
category: !no-aliases
stdin:
alias foo='echo makro'
foo () {
echo funktion
}
foo
expected-stdout:
funktion
---
name: aliases-funcdef-3
description:
Check if aliases take precedences over Korn functions
category: !no-aliases
stdin:
alias foo='echo makro'
function foo {
echo funktion
}
foo
expected-stdout:
makro
---
name: arrays-1
description:
Check if Korn Shell arrays work as expected
category: !no-arrays
stdin:
v="c d"
set -A foo -- a \$v "$v" '$v' b
echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
expected-stdout:
5|a|$v|c d|$v|b|
---
name: arrays-2
description:
Check if bash-style arrays work as expected
category: !no-arrays
stdin:
v="c d"
foo=(a \$v "$v" '$v' b)
echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
expected-stdout:
5|a|$v|c d|$v|b|
---
name: arrays-3
description:
Check if array bounds are uint32_t
category: !no-arrays
stdin:
set -A foo a b c
foo[4097]=d
foo[2147483637]=e
echo ${foo[*]}
foo[-1]=f
echo ${foo[4294967295]} g ${foo[*]}
expected-stdout:
a b c d e
f g a b c d e f
---
name: arrays-4
description:
Check if Korn Shell arrays with specified indices work as expected
category: !no-arrays
stdin:
v="c d"
set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
expected-stdout:
5|a|$v|c d||$v|b|
---
name: arrays-5
description:
Check if bash-style arrays with specified indices work as expected
category: !no-arrays
stdin:
v="c d"
foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
x=([128]=foo bar baz)
echo k= ${!x[*]} .
echo v= ${x[*]} .
expected-stdout:
5|a|$v|c d||$v|b|
k= 128 129 130 .
v= foo bar baz .
---
name: arrays-6
description:
Check if we can get the array keys (indices) for indexed arrays,
Korn shell style
category: !no-arrays
stdin:
of() {
i=0
for x in "$@"; do
echo -n "$((i++))<$x>"
done
echo
}
foo[1]=eins
set | grep '^foo'
echo =
foo[0]=zwei
foo[4]=drei
set | grep '^foo'
echo =
echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
expected-stdout:
foo[1]=eins
=
foo[0]=zwei
foo[1]=eins
foo[4]=drei
=
a 0<zwei>1<eins>2<drei> = a
b 0<zwei eins drei> = 0<> b
c 0<zwei>1<eins>2<drei> = c
d 0<zwei>1<eins>2<drei> = d
e 0<0>1<1>2<4> = e
f 0<0 1 4> = 0<> f
g 0<0>1<1>2<4> = g
h 0<0>1<1>2<4> = h
---
name: arrays-7
description:
Check if we can get the array keys (indices) for indexed arrays,
Korn shell style, in some corner cases
category: !no-arrays
stdin:
echo !arz: ${!arz}
echo !arz[0]: ${!arz[0]}
echo !arz[1]: ${!arz[1]}
arz=foo
echo !arz: ${!arz}
echo !arz[0]: ${!arz[0]}
echo !arz[1]: ${!arz[1]}
unset arz
echo !arz: ${!arz}
echo !arz[0]: ${!arz[0]}
echo !arz[1]: ${!arz[1]}
expected-stdout:
!arz: 0
!arz[0]:
!arz[1]:
!arz: arz
!arz[0]: 0
!arz[1]:
!arz: 0
!arz[0]:
!arz[1]:
---
name: arrays-8
description:
Check some behavioural rules for arrays.
category: !no-arrays
stdin:
fna() {
set -A aa 9
}
fnb() {
typeset ab
set -A ab 9
}
fnc() {
typeset ac
set -A ac 91
unset ac
set -A ac 92
}
fnd() {
set +A ad 9
}
fne() {
unset ae
set +A ae 9
}
fnf() {
unset af[0]
set +A af 9
}
fng() {
unset ag[*]
set +A ag 9
}
set -A aa 1 2
set -A ab 1 2
set -A ac 1 2
set -A ad 1 2
set -A ae 1 2
set -A af 1 2
set -A ag 1 2
set -A ah 1 2
typeset -Z3 aa ab ac ad ae af ag
print 1a ${aa[*]} .
print 1b ${ab[*]} .
print 1c ${ac[*]} .
print 1d ${ad[*]} .
print 1e ${ae[*]} .
print 1f ${af[*]} .
print 1g ${ag[*]} .
print 1h ${ah[*]} .
fna
fnb
fnc
fnd
fne
fnf
fng
typeset -Z5 ah[*]
print 2a ${aa[*]} .
print 2b ${ab[*]} .
print 2c ${ac[*]} .
print 2d ${ad[*]} .
print 2e ${ae[*]} .
print 2f ${af[*]} .
print 2g ${ag[*]} .
print 2h ${ah[*]} .
expected-stdout:
1a 001 002 .
1b 001 002 .
1c 001 002 .
1d 001 002 .
1e 001 002 .
1f 001 002 .
1g 001 002 .
1h 1 2 .
2a 9 .
2b 001 002 .
2c 92 .
2d 009 002 .
2e 9 .
2f 9 002 .
2g 009 .
2h 00001 00002 .
---
name: varexpand-substr-1
description:
Check if bash-style substring expansion works
when using positive numerics
category: mksh
stdin:
x=abcdefghi
typeset -i y=123456789
typeset -i 16 z=123456789 # 16#75bcd15
echo a t${x:2:2} ${y:2:3} ${z:2:3} a
echo b ${x::3} ${y::3} ${z::3} b
echo c ${x:2:} ${y:2:} ${z:2:} c
echo d ${x:2} ${y:2} ${z:2} d
echo e ${x:2:6} ${y:2:6} ${z:2:7} e
echo f ${x:2:7} ${y:2:7} ${z:2:8} f
echo g ${x:2:8} ${y:2:8} ${z:2:9} g
expected-stdout:
a tcd 345 #75 a
b abc 123 16# b
c c
d cdefghi 3456789 #75bcd15 d
e cdefgh 345678 #75bcd1 e
f cdefghi 3456789 #75bcd15 f
g cdefghi 3456789 #75bcd15 g
---
name: varexpand-substr-2
description:
Check if bash-style substring expansion works
when using negative numerics or expressions
category: mksh
stdin:
x=abcdefghi
typeset -i y=123456789
typeset -i 16 z=123456789 # 16#75bcd15
n=2
echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
echo d t${x: n:2} ${y: n:3} ${z: n:3} d
expected-stdout:
a cde 345 #75 a
b cde 345 #75 b
c h 8 1 c
d tcd 345 #75 d
---
name: varexpand-substr-3
description:
Check that some things that work in bash fail.
This is by design. And that some things fail in both.
category: mksh
stdin:
export x=abcdefghi n=2
"$__progname" -c 'echo v${x:(n)}x'
"$__progname" -c 'echo w${x: n}x'
"$__progname" -c 'echo x${x:n}x'
"$__progname" -c 'echo y${x:}x'
"$__progname" -c 'echo z${x}x'
"$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
expected-stdout:
vcdefghix
wcdefghix
zabcdefghix
1
expected-stderr-pattern:
/x:n.*bad substitution.*\n.*bad substitution/
---
name: varexpand-substr-4
description:
Check corner cases for substring expansion
category: mksh
stdin:
x=abcdefghi
integer y=2
echo a ${x:(y == 1 ? 2 : 3):4} a
expected-stdout:
a defg a
---
name: varexpand-substr-5A
description:
Check that substring expansions work on characters
category: mksh
stdin:
set +U
x=mäh
echo a ${x::1} ${x: -1} a
echo b ${x::3} ${x: -3} b
echo c ${x:1:2} ${x: -3:2} c
echo d ${#x} d
expected-stdout:
a m h a
b mä äh b
c ä ä c
d 4 d
---
name: varexpand-substr-5W
description:
Check that substring expansions work on characters
category: mksh
stdin:
set -U
x=mäh
echo a ${x::1} ${x: -1} a
echo b ${x::2} ${x: -2} b
echo c ${x:1:1} ${x: -2:1} c
echo d ${#x} d
expected-stdout:
a m h a
b mä äh b
c ä ä c
d 3 d
---
name: varexpand-substr-6
description:
Check that string substitution works correctly
category: mksh
stdin:
foo=1
bar=2
baz=qwertyuiop
echo a ${baz: foo: bar}
echo b ${baz: foo: $bar}
echo c ${baz: $foo: bar}
echo d ${baz: $foo: $bar}
expected-stdout:
a we
b we
c we
d we
---
name: varexpand-null-1
description:
Ensure empty strings expand emptily
category: mksh
stdin:
print x ${a} ${b} y
print z ${a#?} ${b%?} w
print v ${a=} ${b/c/d} u
expected-stdout:
x y
z w
v u
---
name: varexpand-null-2
description:
Ensure empty strings, when quoted, are expanded as empty strings
category: mksh
stdin:
printf '<%s> ' 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
echo .
expected-stdout:
<1> <> <2> <> <+> <> <3> <> <+> <> .
---
name: print-funny-chars
description:
Check print builtin's capability to output designated characters
category: mksh
stdin:
print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
expected-stdout:
<dÛ€Û@>
---
name: print-bksl-c
description:
Check print builtin's \c escape
category: mksh
stdin:
print '\ca'; print b
expected-stdout:
ab
---
name: print-nul-chars
description:
Check handling of NUL characters for print and read
note: second line should output “4 3” but we cannot
handle NUL characters in strings yet
stdin:
echo $(($(echo '<\0>' | wc -c)))
x=$(echo '<\0>')
echo $(($(echo "$x" | wc -c))) ${#x}
expected-stdout:
4
3 2
---
name: print-escapes
description:
Check backslash expansion by the print builtin
category: mksh
stdin:
print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
'\9\:\;\<\=\>\?\@\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 \d\e\f\g\h\i\j\k\l\m\n\o\p' \
'\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
'\0x' '\0123' '\01234' | {
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z5 hv
typeset -i1 wc=0x0A
dasc=
nl=${wc#1#}
while IFS= read -r line; do
line=$line$nl
while [[ -n $line ]]; do
hv=1#${line::1}
if (( (pos & 15) == 0 )); then
(( pos )) && print "$dasc|"
print -n "${pos#16#} "
dasc=' |'
fi
print -n "${hv#16#} "
if (( (hv < 32) || (hv > 126) )); then
dasc=$dasc.
else
dasc=$dasc${line::1}
fi
(( (pos++ & 15) == 7 )) && print -n -- '- '
line=${line:1}
done
done
if (( (pos & 15) != 1 )); then
while (( pos & 15 )); do
print -n ' '
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
print "$dasc|"
fi
}
expected-stdout:
00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
00000020 5C 31 5C 32 5C 33 5C 34 - 5C 35 5C 36 5C 37 5C 38 |\1\2\3\4\5\6\7\8|
00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
00000050 5C 49 5C 4A 5C 4B 5C 4C - 5C 4D 5C 4E 5C 4F 5C 50 |\I\J\K\L\M\N\O\P|
00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
000000C0 53 34 0A - |S4.|
---
name: dollar-quoted-strings
description:
Check backslash expansion by $'…' strings
category: no-ksh-no-dollar
stdin:
printf '%s\n' $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
$'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
$'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
$'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
$'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
$'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
b' | {
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z5 hv
typeset -i1 wc=0x0A
dasc=
nl=${wc#1#}
while IFS= read -r line; do
line=$line$nl
while [[ -n $line ]]; do
hv=1#${line::1}
if (( (pos & 15) == 0 )); then
(( pos )) && print "$dasc|"
print -n "${pos#16#} "
dasc=' |'
fi
print -n "${hv#16#} "
if (( (hv < 32) || (hv > 126) )); then
dasc=$dasc.
else
dasc=$dasc${line::1}
fi
(( (pos++ & 15) == 7 )) && print -n -- '- '
line=${line:1}
done
done
if (( (pos & 15) != 1 )); then
while (( pos & 15 )); do
print -n ' '
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
print "$dasc|"
fi
}
expected-stdout:
00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
---
name: dollar-quotes-in-heredocs
description:
They are, however, not parsed in here documents
category: ksh
stdin:
cat <<EOF
dollar = strchr(s, '$'); /* ' */
EOF
cat <<$'a\tb'
a\tb
a b
expected-stdout:
dollar = strchr(s, '$'); /* ' */
a\tb
---
name: dollar-quotes-in-herestrings
description:
They are, not parsed in here strings either
category: ksh
stdin:
cat <<<"dollar = strchr(s, '$'); /* ' */"
cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
x="dollar = strchr(s, '$'); /* ' */"
cat <<<"$x"
cat <<<$'a\E[0m\tb'
expected-stdout:
dollar = strchr(s, '$'); /* ' */
dollar = strchr(s, '$'); /* ' */
dollar = strchr(s, '$'); /* ' */
a[0m b
---
name: dot-needs-argument
description:
check Debian #415167 solution: '.' without arguments should fail
stdin:
"$__progname" -c .
"$__progname" -c source
expected-exit: e != 0
expected-stderr-pattern:
/.*\.: no file specified for sourcing\n.*source: not found/
---
name: alias-function-no-conflict
description:
make aliases not conflict with functions
note: for ksh-like functions, the order of preference is
different; bash outputs baz instead of bar in line 2 below
category: !no-aliases
stdin:
alias foo='echo bar'
foo() {
echo baz
}
alias korn='echo bar'
function korn {
echo baz
}
foo
korn
unset -f foo
foo 2>&- || echo rab
expected-stdout:
baz
bar
rab
---
name: bash-function-parens
description:
ensure the keyword function is ignored when preceding
POSIX style function declarations (bashism)
category: mksh
stdin:
mk() {
echo '#!'"$__progname"
echo "$1 {"
echo ' echo "bar='\''$0'\'\"
echo '}'
echo ${2:-foo}
}
mk 'function foo' >f-korn
mk 'foo ()' >f-dash
mk 'function foo ()' >f-bash
mk 'function stop ()' stop >f-stop
chmod +x f-*
echo "korn: $(./f-korn)"
echo "dash: $(./f-dash)"
echo "bash: $(./f-bash)"
echo "stop: $(./f-stop)"
expected-stdout:
korn: bar='foo'
dash: bar='./f-dash'
bash: bar='./f-bash'
stop: bar='./f-stop'
---
name: integer-base-one-1
description:
check if the use of fake integer base 1 works
category: mksh
stdin:
set -U
typeset -Uui16 i0=1# i1=1#€
typeset -i1 o0a=64
typeset -i1 o1a=0x263A
typeset -Uui1 o0b=0x7E
typeset -Uui1 o1b=0xFDD0
integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
echo "in <$i0> <$i1>"
echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
typeset -Uui1 i0 i1
echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
typeset -Uui16 tv1=1#~ tv2=1# tv3=1# tv4=1# tv5=1# tv6=1# tv7=1# tv8=1#
echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
expected-stdout:
in <16#EFEF> <16#20AC>
out <@|~> <☺|>
pass <16#cafe> <1# > <1#…> <1#f> <|€>
specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
specW <~> <> <> <> <> <> < > <>
specU <> <> <>
---
name: integer-base-one-2a
description:
check if the use of fake integer base 1 stops at correct characters
category: mksh
stdin:
set -U
integer x=1#foo
echo /$x/
expected-stderr-pattern:
/1#foo: unexpected 'oo'/
expected-exit: e != 0
---
name: integer-base-one-2b
description:
check if the use of fake integer base 1 stops at correct characters
category: mksh
stdin:
set -U
integer x=1#
echo /$x/
expected-stderr-pattern:
/1#: unexpected ''/
expected-exit: e != 0
---
name: integer-base-one-2c1
description:
check if the use of fake integer base 1 stops at correct characters
category: mksh
stdin:
set -U
integer x=1#…
echo /$x/
expected-stdout:
/1#…/
---
name: integer-base-one-2c2
description:
check if the use of fake integer base 1 stops at correct characters
category: mksh
stdin:
set +U
integer x=1#…
echo /$x/
expected-stderr-pattern:
/1#…: unexpected ''/
expected-exit: e != 0
---
name: integer-base-one-2d1
description:
check if the use of fake integer base 1 handles octets okay
category: mksh
stdin:
set -U
typeset -i16 x=1#
echo /$x/ # invalid utf-8
expected-stdout:
/16#efff/
---
name: integer-base-one-2d2
description:
check if the use of fake integer base 1 handles octets
category: mksh
stdin:
set -U
typeset -i16 x=1#
echo /$x/ # invalid 2-byte
expected-stdout:
/16#efc2/
---
name: integer-base-one-2d3
description:
check if the use of fake integer base 1 handles octets
category: mksh
stdin:
set -U
typeset -i16 x=1#
echo /$x/ # invalid 2-byte
expected-stdout:
/16#efef/
---
name: integer-base-one-2d4
description:
check if the use of fake integer base 1 stops at invalid input
category: mksh
stdin:
set -U
typeset -i16 x=1#
echo /$x/ # invalid 3-byte
expected-stderr-pattern:
/1#: unexpected ''/
expected-exit: e != 0
---
name: integer-base-one-2d5
description:
check if the use of fake integer base 1 stops at invalid input
category: mksh
stdin:
set -U
typeset -i16 x=1#
echo /$x/ # non-minimalistic
expected-stderr-pattern:
/1#: unexpected ''/
expected-exit: e != 0
---
name: integer-base-one-2d6
description:
check if the use of fake integer base 1 stops at invalid input
category: mksh
stdin:
set -U
typeset -i16 x=1#
echo /$x/ # non-minimalistic
expected-stderr-pattern:
/1#: unexpected ''/
expected-exit: e != 0
---
name: integer-base-one-3A
description:
some sample code for hexdumping
category: mksh
stdin:
{
print 'Hello, World!\\\nこんにちは!'
typeset -Uui16 i=0x100
# change that to 0xFF once we can handle embedded
# NUL characters in strings / here documents
while (( i++ < 0x1FF )); do
print -n "\x${i#16#1}"
done
print
} | {
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z5 hv
typeset -i1 wc=0x0A
dasc=
nl=${wc#1#}
while IFS= read -r line; do
line=$line$nl
while [[ -n $line ]]; do
hv=1#${line::1}
if (( (pos & 15) == 0 )); then
(( pos )) && print "$dasc|"
print -n "${pos#16#} "
dasc=' |'
fi
print -n "${hv#16#} "
if (( (hv < 32) || (hv > 126) )); then
dasc=$dasc.
else
dasc=$dasc${line::1}
fi
(( (pos++ & 15) == 7 )) && print -n -- '- '
line=${line:1}
done
done
if (( (pos & 15) != 1 )); then
while (( pos & 15 )); do
print -n ' '
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
print "$dasc|"
fi
}
expected-stdout:
00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
00000120 FF 0A - |..|
---
name: integer-base-one-3W
description:
some sample code for hexdumping Unicode
category: mksh
stdin:
set -U
{
print 'Hello, World!\\\nこんにちは!'
typeset -Uui16 i=0x100
# change that to 0xFF once we can handle embedded
# NUL characters in strings / here documents
while (( i++ < 0x1FF )); do
print -n "\u${i#16#1}"
done
print
print \\xff # invalid utf-8
print \\xc2 # invalid 2-byte
print \\xef\\xbf\\xc0 # invalid 3-byte
print \\xc0\\x80 # non-minimalistic
print \\xe0\\x80\\x80 # non-minimalistic
print '�' # end of range
} | {
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z7 hv
typeset -i1 wc=0x0A
typeset -i lpos
dasc=
nl=${wc#1#}
while IFS= read -r line; do
line=$line$nl
lpos=0
while (( lpos < ${#line} )); do
wc=1#${line:(lpos++):1}
if (( (wc < 32) || \
((wc > 126) && (wc < 160)) )); then
dch=.
elif (( (wc & 0xFF80) == 0xEF80 )); then
dch=�
else
dch=${wc#1#}
fi
if (( (pos & 7) == 7 )); then
dasc=$dasc$dch
dch=
elif (( (pos & 7) == 0 )); then
(( pos )) && print "$dasc|"
print -n "${pos#16#} "
dasc=' |'
fi
let hv=wc
print -n "${hv#16#} "
(( (pos++ & 7) == 3 )) && \
print -n -- '- '
dasc=$dasc$dch
done
done
if (( pos & 7 )); then
while (( pos & 7 )); do
print -n ' '
(( (pos++ & 7) == 3 )) && print -n -- '- '
done
print "$dasc|"
fi
}
expected-stdout:
00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖרÙÚ|
000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
00000128 EFBE EFEF EFBF EFBF - 000A |����.|
---
name: integer-base-one-4
description:
Check if ksh93-style base-one integers work
category: mksh
stdin:
set -U
echo 1 $(('a'))
(echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
echo 3 $(('…'))
x="'a'"
echo "4 <$x>"
echo 5 $(($x))
echo 6 $((x))
expected-stdout:
1 97
2p 'aa': multi-character character constant
3 8230
4 <'a'>
5 97
6 97
---
name: ulimit-1
description:
Check if we can use a specific syntax idiom for ulimit
category: !no-ulimit
stdin:
if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
#echo expected to fail on this OS
echo okay
else
ulimit -dS $x && echo okay
fi
expected-stdout:
okay
---
name: bashiop-1
description:
Check if GNU bash-like I/O redirection works
Part 1: this is also supported by GNU bash
category: mksh
stdin:
exec 3>&1
function threeout {
echo ras
echo dwa >&2
echo tri >&3
}
threeout &>foo
echo ===
cat foo
expected-stdout:
tri
===
ras
dwa
---
name: bashiop-2a
description:
Check if GNU bash-like I/O redirection works
Part 2: this is *not* supported by GNU bash
category: mksh
stdin:
exec 3>&1
function threeout {
echo ras
echo dwa >&2
echo tri >&3
}
threeout 3&>foo
echo ===
cat foo
expected-stdout:
ras
===
dwa
tri
---
name: bashiop-2b
description:
Check if GNU bash-like I/O redirection works
Part 2: this is *not* supported by GNU bash
category: mksh
stdin:
exec 3>&1
function threeout {
echo ras
echo dwa >&2
echo tri >&3
}
threeout 3>foo &>&3
echo ===
cat foo
expected-stdout:
===
ras
dwa
tri
---
name: bashiop-2c
description:
Check if GNU bash-like I/O redirection works
Part 2: this is supported by GNU bash 4 only
category: mksh
stdin:
echo mir >foo
set -o noclobber
exec 3>&1
function threeout {
echo ras
echo dwa >&2
echo tri >&3
}
threeout &>>foo
echo ===
cat foo
expected-stdout:
tri
===
mir
ras
dwa
---
name: bashiop-3a
description:
Check if GNU bash-like I/O redirection fails correctly
Part 1: this is also supported by GNU bash
category: mksh
stdin:
echo mir >foo
set -o noclobber
exec 3>&1
function threeout {
echo ras
echo dwa >&2
echo tri >&3
}
threeout &>foo
echo ===
cat foo
expected-stdout:
===
mir
expected-stderr-pattern: /.*: can't (create|overwrite) .*/
---
name: bashiop-3b
description:
Check if GNU bash-like I/O redirection fails correctly
Part 2: this is *not* supported by GNU bash
category: mksh
stdin:
echo mir >foo
set -o noclobber
exec 3>&1
function threeout {
echo ras
echo dwa >&2
echo tri >&3
}
threeout &>|foo
echo ===
cat foo
expected-stdout:
tri
===
ras
dwa
---
name: bashiop-4
description:
Check if GNU bash-like I/O redirection works
Part 4: this is also supported by GNU bash,
but failed in some mksh versions
category: mksh
stdin:
exec 3>&1
function threeout {
echo ras
echo dwa >&2
echo tri >&3
}
function blubb {
[[ -e bar ]] && threeout "$bf" &>foo
}
blubb
echo -n >bar
blubb
echo ===
cat foo
expected-stdout:
tri
===
ras
dwa
---
name: mkshiop-1
description:
Check for support of more than 9 file descriptors
category: mksh-no-convfds
stdin:
read -u10 foo 10<<< bar
echo x$foo
expected-stdout:
xbar
---
name: mkshiop-2
description:
Check for support of more than 9 file descriptors
category: mksh
stdin:
exec 12>foo
print -u12 bar
echo baz >&12
cat foo
expected-stdout:
bar
baz
---
name: oksh-shcrash
description:
src/regress/bin/ksh/shcrash.sh,v 1.1
stdin:
deplibs="-lz -lpng /usr/local/lib/libjpeg.la -ltiff -lm -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libglib.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgtk.la -ltiff -ljpeg -lz -lpng -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk_pixbuf.la -lz -lpng /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libglib.la -lm -lm /usr/local/lib/libaudiofile.la -lm -lm -laudiofile -L/usr/local/lib /usr/local/lib/libesd.la -lm -lz -L/usr/local/lib /usr/local/lib/libgnomesupport.la -lm -lz -lm -lglib -L/usr/local/lib /usr/local/lib/libgnome.la -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgtk.la -lICE -lSM -lz -lpng /usr/local/lib/libungif.la /usr/local/lib/libjpeg.la -ltiff -lm -lz -lpng /usr/local/lib/libungif.la -lz /usr/local/lib/libjpeg.la -ltiff -L/usr/local/lib -L/usr/X11R6/lib /usr/local/lib/libgdk_imlib.la -lm -L/usr/local/lib /usr/local/lib/libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lICE -lSM -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/usr/X11R6/lib -lm -lz -lpng -lungif -lz -ljpeg -ltiff -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd -L/usr/local/lib /usr/local/lib/libgnomeui.la -lz -lz /usr/local/lib/libxml.la -lz -lz -lz /usr/local/lib/libxml.la -lm -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libglib.la /usr/local/lib/libgmodule.la -lintl -lglib -lgmodule /usr/local/lib/libgdk.la /usr/local/lib/libgtk.la -L/usr/X11R6/lib -L/usr/local/lib /usr/local/lib/libglade.la -lz -lz -lz /usr/local/lib/libxml.la /usr/local/lib/libglib.la -lm -lm /usr/local/lib/libaudiofile.la -lm -lm -laudiofile /usr/local/lib/libesd.la -lm -lz /usr/local/lib/libgnomesupport.la -lm -lz -lm -lglib /usr/local/lib/libgnome.la -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -lglib -lgmodule /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -lglib -lgmodule /usr/local/lib/libgtk.la -lICE -lSM -lz -lpng /usr/local/lib/libungif.la /usr/local/lib/libjpeg.la -ltiff -lm -lz -lz /usr/local/lib/libgdk_imlib.la /usr/local/lib/libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lm -lz -lungif -lz -ljpeg -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd /usr/local/lib/libgnomeui.la -L/usr/X11R6/lib -L/usr/local/lib /usr/local/lib/libglade-gnome.la /usr/local/lib/libglib.la -lm -lm /usr/local/lib/libaudiofile.la -lm -lm -laudiofile -L/usr/local/lib /usr/local/lib/libesd.la -lm -lz -L/usr/local/lib /usr/local/lib/libgnomesupport.la -lm -lz -lm -lglib -L/usr/local/lib /usr/local/lib/libgnome.la -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgtk.la -lICE -lSM -lz -lpng /usr/local/lib/libungif.la /usr/local/lib/libjpeg.la -ltiff -lm -lz -lpng /usr/local/lib/libungif.la -lz /usr/local/lib/libjpeg.la -ltiff -L/usr/local/lib -L/usr/X11R6/lib /usr/local/lib/libgdk_imlib.la -lm -L/usr/local/lib /usr/local/lib/libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lICE -lSM -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/usr/X11R6/lib -lm -lz -lpng -lungif -lz -ljpeg -ltiff -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd -L/usr/local/lib /usr/local/lib/libgnomeui.la -L/usr/X11R6/lib -L/usr/local/lib"
specialdeplibs="-lgnomeui -lart_lgpl -lgdk_imlib -ltiff -ljpeg -lungif -lpng -lz -lSM -lICE -lgtk -lgdk -lgmodule -lintl -lXext -lX11 -lgnome -lgnomesupport -lesd -laudiofile -lm -lglib"
for deplib in $deplibs; do
case $deplib in
-L*)
new_libs="$deplib $new_libs"
;;
*)
case " $specialdeplibs " in
*" $deplib "*)
new_libs="$deplib $new_libs";;
esac
;;
esac
done
---
name: oksh-varfunction-mod1
description:
$OpenBSD: varfunction.sh,v 1.1 2003/12/15 05:28:40 otto Exp $
Calling
FOO=bar f
where f is a ksh style function, should not set FOO in the current
env. If f is a Bourne style function, FOO should be set. Furthermore,
the function should receive a correct value of FOO. However, differing
from oksh, setting FOO in the function itself must change the value in
setting FOO in the function itself should not change the value in
global environment.
Inspired by PR 2450.
category: mksh
stdin:
function k {
if [ x$FOO != xbar ]; then
echo 1
return 1
fi
x=$(env | grep FOO)
if [ "x$x" != "xFOO=bar" ]; then
echo 2
return 1;
fi
FOO=foo
return 0
}
b () {
if [ x$FOO != xbar ]; then
echo 3
return 1
fi
x=$(env | grep FOO)
if [ "x$x" != "xFOO=bar" ]; then
echo 4
return 1;
fi
FOO=foo
return 0
}
FOO=bar k
if [ $? != 0 ]; then
exit 1
fi
if [ x$FOO != x ]; then
exit 1
fi
FOO=bar b
if [ $? != 0 ]; then
exit 1
fi
if [ x$FOO != xfoo ]; then
exit 1
fi
FOO=barbar
FOO=bar k
if [ $? != 0 ]; then
exit 1
fi
if [ x$FOO != xbarbar ]; then
exit 1
fi
FOO=bar b
if [ $? != 0 ]; then
exit 1
fi
if [ x$FOO != xfoo ]; then
exit 1
fi
---
name: fd-cloexec-1
description:
Verify that file descriptors > 2 are private for Korn shells
category: mksh
file-setup: file 644 "test.sh"
print -u3 Fowl
stdin:
exec 3>&1
"$__progname" test.sh
expected-exit: e != 0
expected-stderr:
test.sh[1]: print: -u: 3: bad file descriptor
---
name: fd-cloexec-2
description:
Verify that file descriptors > 2 are not private for POSIX shells
See Debian Bug #154540, Closes: #499139
category: mksh
file-setup: file 644 "test.sh"
print -u3 Fowl
stdin:
test -n "$POSH_VERSION" || set -o sh
exec 3>&1
"$__progname" test.sh
expected-stdout:
Fowl
---
name: comsub-1
description:
COMSUB are currently parsed by hacking lex.c instead of
recursively (see regression-6): matching parenthesēs bug
Fails on: pdksh mksh bash2 bash3 zsh
Passes on: bash4 ksh93
expected-fail: yes
stdin:
echo $(case 1 in (1) echo yes;; (2) echo no;; esac)
echo $(case 1 in 1) echo yes;; 2) echo no;; esac)
expected-stdout:
yes
yes
---
name: comsub-2
description:
RedHat BZ#496791 – another case of missing recursion
in parsing COMSUB expressions
Fails on: pdksh mksh bash2 bash3¹ bash4¹ zsh
Passes on: ksh93
① bash[34] seem to choke on comment ending with backslash-newline
expected-fail: yes
stdin:
# a comment with " ' \
x=$(
echo yes
# a comment with " ' \
)
echo $x
expected-stdout:
yes
---
name: test-stnze-1
description:
Check that the short form [ $x ] works
stdin:
i=0
[ -n $x ]
rv=$?; echo $((++i)) $rv
[ $x ]
rv=$?; echo $((++i)) $rv
[ -n "$x" ]
rv=$?; echo $((++i)) $rv
[ "$x" ]
rv=$?; echo $((++i)) $rv
x=0
[ -n $x ]
rv=$?; echo $((++i)) $rv
[ $x ]
rv=$?; echo $((++i)) $rv
[ -n "$x" ]
rv=$?; echo $((++i)) $rv
[ "$x" ]
rv=$?; echo $((++i)) $rv
x='1 -a 1 = 2'
[ -n $x ]
rv=$?; echo $((++i)) $rv
[ $x ]
rv=$?; echo $((++i)) $rv
[ -n "$x" ]
rv=$?; echo $((++i)) $rv
[ "$x" ]
rv=$?; echo $((++i)) $rv
expected-stdout:
1 0
2 1
3 1
4 1
5 0
6 0
7 0
8 0
9 1
10 1
11 0
12 0
---
name: test-stnze-2
description:
Check that the short form [[ $x ]] works (ksh93 extension)
category: mksh
stdin:
i=0
[[ -n $x ]]
rv=$?; echo $((++i)) $rv
[[ $x ]]
rv=$?; echo $((++i)) $rv
[[ -n "$x" ]]
rv=$?; echo $((++i)) $rv
[[ "$x" ]]
rv=$?; echo $((++i)) $rv
x=0
[[ -n $x ]]
rv=$?; echo $((++i)) $rv
[[ $x ]]
rv=$?; echo $((++i)) $rv
[[ -n "$x" ]]
rv=$?; echo $((++i)) $rv
[[ "$x" ]]
rv=$?; echo $((++i)) $rv
x='1 -a 1 = 2'
[[ -n $x ]]
rv=$?; echo $((++i)) $rv
[[ $x ]]
rv=$?; echo $((++i)) $rv
[[ -n "$x" ]]
rv=$?; echo $((++i)) $rv
[[ "$x" ]]
rv=$?; echo $((++i)) $rv
expected-stdout:
1 1
2 1
3 1
4 1
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
---
name: event-subst-1a
description:
Check that '!' substitution in interactive mode works
category: mksh-no-smksh
file-setup: file 755 "falsetto"
#! /bin/sh
echo molto bene
exit 42
file-setup: file 755 "!false"
#! /bin/sh
echo si
arguments: !-i!
stdin:
export PATH=.:$PATH
falsetto
echo yeap
!false
expected-exit: 42
expected-stdout:
molto bene
yeap
molto bene
expected-stderr-pattern:
/.*/
---
name: event-subst-1b
description:
Check that '!' substitution in interactive mode works
even when a space separates it from the search command,
which is not what GNU bash provides but required for the
other regression tests below to check
category: mksh-no-smksh
file-setup: file 755 "falsetto"
#! /bin/sh
echo molto bene
exit 42
file-setup: file 755 "!"
#! /bin/sh
echo si
arguments: !-i!
stdin:
export PATH=.:$PATH
falsetto
echo yeap
! false
expected-exit: 42
expected-stdout:
molto bene
yeap
molto bene
expected-stderr-pattern:
/.*/
---
name: event-subst-2
description:
Check that '!' substitution in interactive mode
does not break things
category: mksh-no-smksh
file-setup: file 755 "falsetto"
#! /bin/sh
echo molto bene
exit 42
file-setup: file 755 "!"
#! /bin/sh
echo si
arguments: !-i!
env-setup: !ENV=./Env!
file-setup: file 644 "Env"
PS1=X
stdin:
export PATH=.:$PATH
falsetto
echo yeap
!false
echo meow
! false
echo = $?
if
! false; then echo foo; else echo bar; fi
expected-stdout:
molto bene
yeap
molto bene
meow
molto bene
= 42
foo
expected-stderr-pattern:
/.*/
---
name: event-subst-3
description:
Check that '!' substitution in noninteractive mode is ignored
category: mksh-no-smksh
file-setup: file 755 "falsetto"
#! /bin/sh
echo molto bene
exit 42
file-setup: file 755 "!false"
#! /bin/sh
echo si
stdin:
export PATH=.:$PATH
falsetto
echo yeap
!false
echo meow
! false
echo = $?
if
! false; then echo foo; else echo bar; fi
expected-stdout:
molto bene
yeap
si
meow
= 0
foo
---
name: nounset-1
description:
Check that "set -u" matches (future) SUSv4 requirement
expected-fail: yes
stdin:
(set -u
try() {
local v
eval v=\$$1
if [ -n $v ]; then
echo $1=nz
else
echo $1=zf
fi
}
x=y
(echo $x)
echo =1
(echo $y)
echo =2
(try x)
echo =3
(try y)
echo =4
(try 0)
echo =5
(try 2)
echo =6
(try)
echo =7
(echo at=$@)
echo =8
(echo asterisk=$*)
echo =9
(echo $?)
echo =10
(echo $!)
echo =11
(echo $-)
echo =12
#(echo $_)
#echo =13
(echo $#)
echo =14
(mypid=$$; try mypid)
echo =15
) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
expected-stdout:
y
=1
<stdin>:42: y: parameter not set
=2
x=nz
=3
y: parameter not set
=4
0=nz
=5
2: parameter not set
=6
<stdin>:42: 1: parameter not set
=7
at=
=8
asterisk=
=9
0
=10
<stdin>:42: !: parameter not set
=11
ush
=12
0
=14
mypid=nz
=15
---
name: nameref-1
description:
Testsuite for nameref (bound variables)
category: ksh
stdin:
bar=global
typeset -n ir2=bar
typeset -n ind=ir2
echo !ind: ${!ind}
echo ind: $ind
echo !ir2: ${!ir2}
echo ir2: $ir2
typeset +n ind
echo !ind: ${!ind}
echo ind: $ind
typeset -n ir2=ind
echo !ir2: ${!ir2}
echo ir2: $ir2
set|grep ^ir2|sed 's/^/s1: /'
typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
set -A blub -- e1 e2 e3
typeset -n ind=blub
typeset -n ir2=blub[2]
echo !ind[1]: ${!ind[1]}
echo !ir2: $!ir2
echo ind[1]: ${ind[1]}
echo ir2: $ir2
expected-stdout:
!ind: bar
ind: global
!ir2: bar
ir2: global
!ind: ind
ind: ir2
!ir2: ind
ir2: ir2
s1: ir2=ind
s2: typeset -n ir2
!ind[1]: 1
!ir2: ir2
ind[1]: e2
ir2: e3
---
name: nameref-2da
description:
Testsuite for nameref (bound variables)
Functions, argument given directly, after local
category: ksh
stdin:
function foo {
typeset bar=lokal baz=auch
typeset -n v=bar
echo entering
echo !v: ${!v}
echo !bar: ${!bar}
echo !baz: ${!baz}
echo bar: $bar
echo v: $v
v=123
echo bar: $bar
echo v: $v
echo exiting
}
bar=global
echo bar: $bar
foo bar
echo bar: $bar
expected-stdout:
bar: global
entering
!v: bar
!bar: bar
!baz: baz
bar: lokal
v: lokal
bar: 123
v: 123
exiting
bar: global
---
name: nameref-3
description:
Advanced testsuite for bound variables (ksh93 fails this)
category: mksh
stdin:
typeset -n foo=bar[i]
set -A bar -- b c a
for i in 0 1 2 3; do
print $i $foo .
done
expected-stdout:
0 b .
1 c .
2 a .
3 .
---
name: better-parens-1a
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
if ( (echo fubar) | tr u x); then
echo ja
else
echo nein
fi
expected-stdout:
fxbar
ja
---
name: better-parens-1b
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
echo $( (echo fubar) | tr u x) $?
expected-stdout:
fxbar 0
---
name: better-parens-2a
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
if ((echo fubar) | tr u x); then
echo ja
else
echo nein
fi
expected-stdout:
fxbar
ja
---
name: better-parens-2b
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
echo $((echo fubar) | tr u x) $?
expected-stdout:
fxbar 0
---
name: better-parens-3a
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
if ( (echo fubar) | (tr u x)); then
echo ja
else
echo nein
fi
expected-stdout:
fxbar
ja
---
name: better-parens-3b
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
echo $( (echo fubar) | (tr u x)) $?
expected-stdout:
fxbar 0
---
name: better-parens-4a
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
if ((echo fubar) | (tr u x)); then
echo ja
else
echo nein
fi
expected-stdout:
fxbar
ja
---
name: better-parens-4b
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
echo $((echo fubar) | (tr u x)) $?
expected-stdout:
fxbar 0
---
name: echo-test-1
description:
Test what the echo builtin does (mksh)
category: mksh
stdin:
echo -n 'foo\x40bar'
echo -e '\tbaz'
expected-stdout:
foo@bar baz
---
name: echo-test-2
description:
Test what the echo builtin does (POSIX)
Note: this follows Debian Policy 10.4 which mandates
that -n shall be treated as an option, not XSI which
mandates it shall be treated as string but escapes
shall be expanded.
category: debian
expected-fail: yes
stdin:
test -n "$POSH_VERSION" || set -o sh
echo -n 'foo\x40bar'
echo -e '\tbaz'
expected-stdout:
foo\x40bar-e \tbaz
---
name: utilities-getopts-1
description:
getopts sets OPTIND correctly for unparsed option
stdin:
set -- -a -a -x
while getopts :a optc; do
echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
done
echo done
expected-stdout:
OPTARG=, OPTIND=2, optc=a.
OPTARG=, OPTIND=3, optc=a.
OPTARG=x, OPTIND=4, optc=?.
done
---
name: utilities-getopts-2
description:
Check OPTARG
stdin:
set -- -a Mary -x
while getopts a: optc; do
echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
done
echo done
expected-stdout:
OPTARG=Mary, OPTIND=3, optc=a.
OPTARG=, OPTIND=4, optc=?.
done
expected-stderr-pattern: /.*option.*x/
---
name: wcswidth-1
description:
Check the new wcswidth feature
category: mksh
stdin:
s=何
set +U
print octets: ${#s} .
print 8-bit width: ${%s} .
set -U
print characters: ${#s} .
print columns: ${%s} .
s=�
set +U
print octets: ${#s} .
print 8-bit width: ${%s} .
set -U
print characters: ${#s} .
print columns: ${%s} .
expected-stdout:
octets: 3 .
8-bit width: -1 .
characters: 1 .
columns: 2 .
octets: 3 .
8-bit width: 3 .
characters: 1 .
columns: 1 .
---
name: wcswidth-2
description:
Check some corner cases
category: mksh
stdin:
print % $% .
set -U
x='a b'
print c ${%x} .
set +U
x='a b'
print d ${%x} .
expected-stdout:
% $% .
c -1 .
d -1 .
---
name: wcswidth-3
description:
Check some corner cases
category: mksh
stdin:
print ${%} .
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: wcswidth-4a
description:
Check some corner cases
category: mksh
stdin:
print ${%*} .
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: wcswidth-4b
description:
Check some corner cases
category: mksh
stdin:
print ${%@} .
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: wcswidth-4c
description:
Check some corner cases
category: mksh
stdin:
:
print ${%?} .
expected-stdout:
1 .
---
name: realpath-1
description:
Check proper return values for realpath
category: os:mirbsd
stdin:
wd=$(realpath .)
mkdir dir
:>file
:>dir/file
ln -s dir lndir
ln -s file lnfile
ln -s nix lnnix
ln -s . lnself
i=0
chk() {
typeset x y
x=$(realpath "$wd/$1" 2>&1); y=$?
print $((++i)) "?$1" =${x##*$wd/} !$y
}
chk dir
chk dir/
chk dir/file
chk dir/nix
chk file
chk file/
chk file/file
chk file/nix
chk nix
chk nix/
chk nix/file
chk nix/nix
chk lndir
chk lndir/
chk lndir/file
chk lndir/nix
chk lnfile
chk lnfile/
chk lnfile/file
chk lnfile/nix
chk lnnix
chk lnnix/
chk lnnix/file
chk lnnix/nix
chk lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself
rm lnself
expected-stdout:
1 ?dir =dir !0
2 ?dir/ =dir !0
3 ?dir/file =dir/file !0
4 ?dir/nix =dir/nix !0
5 ?file =file !0
6 ?file/ =file/: Not a directory !20
7 ?file/file =file/file: Not a directory !20
8 ?file/nix =file/nix: Not a directory !20
9 ?nix =nix !0
10 ?nix/ =nix !0
11 ?nix/file =nix/file: No such file or directory !2
12 ?nix/nix =nix/nix: No such file or directory !2
13 ?lndir =dir !0
14 ?lndir/ =dir !0
15 ?lndir/file =dir/file !0
16 ?lndir/nix =dir/nix !0
17 ?lnfile =file !0
18 ?lnfile/ =lnfile/: Not a directory !20
19 ?lnfile/file =lnfile/file: Not a directory !20
20 ?lnfile/nix =lnfile/nix: Not a directory !20
21 ?lnnix =nix !0
22 ?lnnix/ =nix !0
23 ?lnnix/file =lnnix/file: No such file or directory !2
24 ?lnnix/nix =lnnix/nix: No such file or directory !2
25 ?lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself =lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself: Too many levels of symbolic links !62
---
|