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 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539
|
# -*- mode: sh -*-
# $MirOS: src/bin/mksh/check.t,v 1.927 2025/12/24 04:51:49 tg Exp $
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
# 2019, 2020, 2021, 2022, 2023, 2024, 2025
# mirabilos <m$(date +%Y)@mirbsd.de>
#
# 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.
#-
# WARNING: this file mixes UTF-8 with raw octets without encoding!
#
# You may also want to test IFS with the script at
# http://www.research.att.com/~gsf/public/ifs.sh
#
# More testsuites at:
# http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
#
# Integrated testsuites from:
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
info-pre: testing begins
expected-stdout:
KSH R59 2025/12/23
description:
Check base version of full shell
stdin:
vsn=${KSH_VERSION%%' +'*}
echo "${vsn#* }"
name: KSH_VERSION
---
expected-stdout:
@(#)MIRBSD
description:
Check this identifies as legacy shell
stdin:
echo "${KSH_VERSION%% *}"
name: KSH_VERSION-modern
category: !shell:legacy-yes
---
expected-stdout:
@(#)LEGACY
description:
Check this identifies as legacy shell
stdin:
echo "${KSH_VERSION%% *}"
name: KSH_VERSION-legacy
category: !shell:legacy-no
---
name: KSH_VERSION-ascii
description:
Check that the shell version tag does not include EBCDIC
category: !shell:ebcdic-yes
stdin:
set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+EBCDIC' ]] && exit 1
done
exit 0
---
name: KSH_VERSION-ebcdic
description:
Check that the shell version tag includes EBCDIC
category: !shell:ebcdic-no
stdin:
set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+EBCDIC' ]] && exit 0
done
exit 1
---
name: KSH_VERSION-binmode
description:
Check that the shell version tag does not include TEXTMODE
category: !shell:textmode-yes
stdin:
set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+TEXTMODE' ]] && exit 1
done
exit 0
---
name: KSH_VERSION-textmode
description:
Check that the shell version tag includes TEXTMODE
category: !shell:textmode-no
stdin:
set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+TEXTMODE' ]] && exit 0
done
exit 1
---
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-exec
description:
Ensure that the test run directory (default /tmp but can be changed
with check.pl flag -T or test.sh $TMPDIR) is not mounted noexec, as
we execute scripts from the scratch directory during several tests.
stdin:
print '#!'"$__progname"'\necho tf' >lq
chmod +x lq
./lq
echo = $?
expected-stdout:
tf
= 0
---
name: selftest-exec-perl
description:
Ensure we can run perl scriptlets in tests as well
stdin:
print '#!'"$__perlname"'\nprint 3x"3"."\\n";' >lq
chmod +x lq
./lq
echo = $?
expected-stdout:
333
= 0
---
name: selftest-exec-a
description:
Ensure using 'exec -a' to change argv[0] works
file-setup: file 644 "pass"
print -r -- "fail, args:"
i=-1
for x in "$0" "$@"; do
print -r -- "$((++i))<$x>"
done
stdin:
exec -a -print "$__progname" pass '\u20AC'
expected-stdout:
pass €
---
name: selftest-env
description:
Just output the environment variables set (always fails)
category: disabled
stdin:
set
---
name: selftest-direct-builtin-call
description:
Check that direct builtin calls work
stdin:
ln -s "$__progname" echo 2>/dev/null || cp "$__progname" echo
./echo -c 'echo foo'
expected-stdout:
-c echo foo
---
name: selftest-pathsep-unix
description:
Check that $PATHSEP is set correctly.
category: !os:os2
stdin:
PATHSEP=.; export PATHSEP
"$__progname" -c 'print -r -- $PATHSEP'
expected-stdout:
:
---
name: selftest-pathsep-dospath
description:
Check that $PATHSEP is set correctly.
category: os:os2
stdin:
PATHSEP=.; export PATHSEP
"$__progname" -c 'print -r -- $PATHSEP'
expected-stdout:
;
---
name: selftest-tools
description:
Check that relevant tools work as expected. If not, e.g. on SerenityOS,
install better tools from ports and prepend /usr/local/bin to $PATH.
stdin:
echo foobarbaz | grep bar
echo = $?
echo abc | sed y/ac/AC/
echo = $?
echo abc | tr ac AC
echo = $?
expected-stdout:
foobarbaz
= 0
AbC
= 0
AbC
= 0
---
name: selftest-tty-absent
description:
Check that a controlling tty is not present as regress:no-ctty was used
(if this test fails for you DO NOT PASS regress:no-ctty and fix every
other test that fails: why u use it if u haz ctty?)
category: regress:no-ctty
env-setup: !ENV=./envf!
file-setup: file 644 "envf"
PS1=X
arguments: !-i!
stdin:
echo ok
expected-stdout:
ok
expected-stderr-pattern:
/^W: .*find tty fd.*\nW: .*have full job control\nXX$/
---
name: selftest-tty-present
description:
Check that a controlling tty is present as regress:no-ctty was not used
need-ctty: yes
env-setup: !ENV=./envf!
file-setup: file 644 "envf"
PS1=X
arguments: !-i!
stdin:
echo ok
expected-stdout:
ok
expected-stderr: !
XX
---
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.
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).
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.
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.
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.
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.
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.
time-limit: 3
stdin:
print '#!'"$__progname"'\necho tf' >lq
chmod +x lq
PATH=$PWD$PATHSEP$PATH
alias lq=lq
lq
echo = now
i=`lq`
print -r -- $i
echo = out
exit 0
expected-stdout:
tf
= now
tf
= out
---
name: alias-10
description:
Check that recursion is detected/avoided in aliases.
Regression, introduced during an old bugfix.
stdin:
alias foo='print hello '
alias bar='foo world'
echo $(bar)
expected-stdout:
hello world
---
name: alias-11
description:
Check that special argument handling still applies with escaped aliases
stdin:
alias local1='\typeset'
alias local2='\\builtin typeset'
function fooa {
local1 x=$1 y=z
print -r -- "$x,$y"
}
function foob {
local2 x=$1 y=z
print -r -- "$x,$y"
}
x=1 y=2; fooa 'bar - baz'
x=1 y=2; foob 'bar - baz'
expected-stdout:
bar - baz,z
bar - baz,z
---
name: alias-12
description:
Something weird from Martijn Dekker
stdin:
alias echo=print
x() { echo a; (echo b); x=$(echo c); }
typeset -f x
alias OPEN='{' CLOSE='};'
{ OPEN echo hi1; CLOSE }
var=`{ OPEN echo hi2; CLOSE }` && echo "$var"
var=$({ OPEN echo hi3; CLOSE }) && echo "$var"
expected-stdout:
x() {
\print a
( \print b )
x=$(\print c )
}
hi1
hi2
hi3
---
name: arith-compound
description:
Check that arithmetic expressions are compound constructs
stdin:
{ ! (( 0$(cat >&2) )) <<<1; } <<<2
expected-stderr:
1
---
name: arith-divnull
description:
Check what happens if dividing by 0
stdin:
echo 1 $((0 ? 2/0 : 666)) .
echo 2 $?
echo 3 $((1 ? 2/0 : 666)) .
echo 4 $?
expected-stdout:
1 666 .
2 0
expected-exit: e != 0
expected-stderr-pattern:
/^[^\n]*: zero divisor$/
---
name: arith-lazy-1
description:
Check that only one side of ternary operator is evaluated
stdin:
x=i+=2
y=j+=2
typeset -i 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
typeset -i 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-lazy-4
description:
Check that preun/postun not done on non-evaluated side of ternary
operator
stdin:
(( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
echo "($n, $m)"
m=0; echo $(( 0 ? ++m : 2 )); echo $m
m=0; echo $(( 0 ? m++ : 2 )); echo $m
expected-stdout:
(1, 0)
2
0
2
0
---
name: arith-lazy-5-arr-n
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((0&&b[a++],a))"
expected-stdout:
0
---
name: arith-lazy-5-arr-p
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((0&&(b[a++]),a))"
expected-stdout:
0
---
name: arith-lazy-5-str-n
description: Check lazy evaluation with side effects
stdin:
a=0 b=a++; ((0&&b)); echo $a
expected-stdout:
0
---
name: arith-lazy-5-str-p
description: Check lazy evaluation with side effects
stdin:
a=0 b=a++; ((0&&(b))); echo $a
expected-stdout:
0
---
name: arith-lazy-5-tern-l-n
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((0?b[a++]:999,a))"
expected-stdout:
0
---
name: arith-lazy-5-tern-l-p
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((0?(b[a++]):999,a))"
expected-stdout:
0
---
name: arith-lazy-5-tern-r-n
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((1?999:b[a++],a))"
expected-stdout:
0
---
name: arith-lazy-5-tern-r-p
description: Check lazy evaluation with side effects
stdin:
a=0; echo "$((1?999:(b[a++]),a))"
expected-stdout:
0
---
name: arith-ternary-prec-1
description:
Check precedence of ternary operator vs assignment
stdin:
typeset -i 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:
typeset -i x=2
echo $((0 ? x+=2 : 20))
expected-stdout:
20
---
name: arith-prec-1
description:
Prove arithmetic expressions with embedded parameter
substitutions cannot be parsed ahead of time
stdin:
a='3 + 4'
print 1 $((2 * a)) .
print 2 $((2 * $a)) .
expected-stdout:
1 14 .
2 10 .
---
name: arith-div-assoc-1
description:
Check associativity of division operator
stdin:
echo $((20 / 2 / 2))
expected-stdout:
5
---
name: arith-div-byzero
description:
Check division by zero errors out
stdin:
x=$(echo $((1 / 0)))
echo =$?:$x.
expected-stdout:
=1:.
expected-stderr-pattern:
/.*divisor/
---
name: arith-div-intmin-by-minusone
description:
Check division overflow wraps around silently
category: shell:legacy-no
stdin:
echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
expected-stdout:
signed:-2147483648r0.
unsigned:0r2147483648.
---
name: arith-assop-assoc-1
description:
Check associativity of assignment-operator operator
stdin:
typeset -i i=1 j=2 k=3
echo $((i += j += k))
echo $i,$j,$k
expected-stdout:
6
6,5,3
---
name: arith-mandatory
description:
Passing of this test is *mandatory* for a valid mksh executable!
category: shell:legacy-no
stdin:
typeset -i sari=0
typeset -Ui uari=0
typeset -i x=0
print -r -- $((x++)):$sari=$uari. #0
let --sari --uari
print -r -- $((x++)):$sari=$uari. #1
sari=2147483647 uari=2147483647
print -r -- $((x++)):$sari=$uari. #2
let ++sari ++uari
print -r -- $((x++)):$sari=$uari. #3
let --sari --uari
let 'sari *= 2' 'uari *= 2'
let ++sari ++uari
print -r -- $((x++)):$sari=$uari. #4
let ++sari ++uari
print -r -- $((x++)):$sari=$uari. #5
sari=-2147483648 uari=-2147483648
print -r -- $((x++)):$sari=$uari. #6
let --sari --uari
print -r -- $((x++)):$sari=$uari. #7
(( sari = -5 >> 1 ))
((# uari = -5 >> 1 ))
print -r -- $((x++)):$sari=$uari. #8
(( sari = -2 ))
((# uari = sari ))
print -r -- $((x++)):$sari=$uari. #9
expected-stdout:
0:0=0.
1:-1=4294967295.
2:2147483647=2147483647.
3:-2147483648=2147483648.
4:-1=4294967295.
5:0=0.
6:-2147483648=2147483648.
7:2147483647=2147483647.
8:-3=2147483645.
9:-2=4294967294.
---
name: arith-unsigned-1
description:
Check if unsigned arithmetics work
category: int:32
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]}
# make sure multiple calculations don't interfere with each other
let '# mca = -4 % -2' ' mcb = -4 % -2'
echo x8 $mca $mcb
expected-stdout:
x1 -1 4294967295
x2 -171510507 4123456789
x3 -171510507 4123456789
x4 1975973142 1975973142
x5 -171510507 4123456789
x6 1975973142 1975973142
x7 right
x8 -4 0
---
name: arith-limit32-1
description:
Check if arithmetics are 32 bit
category: int:32
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: arith-limit64-1
description:
Check if arithmetics are 64 bit
category: int:64
stdin:
# signed vs unsigned
echo x1 $((-1)) $((#-1))
# calculating
typeset -i vs
typeset -Ui vu
vs=9223372036854775807; vu=9223372036854775807
echo x2 $vs $vu
let vs++ vu++
echo x3 $vs $vu
vs=18446744073709551615; vu=18446744073709551615
echo x4 $vs $vu
let vs++ vu++
echo x5 $vs $vu
let vs++ vu++
echo x6 $vs $vu
expected-stdout:
x1 -1 18446744073709551615
x2 9223372036854775807 9223372036854775807
x3 -9223372036854775808 9223372036854775808
x4 -1 18446744073709551615
x5 0 0
x6 1 1
---
name: bksl-nl-ign-1
description:
Check that \newline is not collapsed after #
stdin:
echo hi #there \
echo folks
expected-stdout:
hi
folks
---
name: bksl-nl-ign-2
description:
Check that \newline is not collapsed 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 collapsed 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)
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 collapsed 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 collapsed 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 collapsed 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 collapsed 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 collapsed 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 collapsed 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 collapsed 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 collapsed 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)
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)
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)
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
for i in a b c; do echo $i; eval break; echo bad-$i; done
echo end-4
expected-stdout:
a
end-1
a
end-2
a:x
end-a
b:x
end-b
c:x
end-c
end-3
a
end-4
---
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
for i in a b c; do echo $i; eval continue; echo bad-$i ; done
echo end-4
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
a
b
c
end-4
---
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)
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: cd-pe
description:
Check package for cd -Pe
need-pass: no
info-pre: test is flaky on at least Cygwin, LynxOS, z/OS, Hurd, QNX, ...
# the mv command fails on Cygwin, LynxOS 3.0, z/OS
# Hurd aborts the testsuite (permission denied)
# QNX does not find subdir to cd into
category: !os:cygwin,!os:gnu,!os:lynxos,!os:midipix,!os:msys,!os:nto,!os:os390,!nosymlink
file-setup: file 644 "x"
mkdir noread noread/target noread/target/subdir
ln -s noread link
chmod 311 noread
cd -P$1 .
echo 0=$?
bwd=$PWD
cd -P$1 link/target
echo 1=$?,${PWD#$bwd/}
epwd=$($TSHELL -c pwd 2>/dev/null)
# This unexpectedly succeeds on GNU/Linux and MidnightBSD
#echo pwd=$?,$epwd
# expect: pwd=1,
mv ../../noread ../../renamed
cd -P$1 subdir
echo 2=$?,${PWD#$bwd/}
cd $bwd
chmod 755 noread 2>/dev/null
chmod 755 renamed 2>/dev/null
rm -rf noread link renamed
stdin:
export TSHELL="$__progname"
"$__progname" x
echo "now with -e:"
"$__progname" x e
expected-stdout:
0=0
1=0,noread/target
2=0,noread/target/subdir
now with -e:
0=0
1=0,noread/target
2=1,noread/target/subdir
---
name: env-prompt
description:
Check that prompt not printed when processing ENV
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-pattern:
/^(?:W: [^\n]*(?:find tty fd|have full job control)[^\n]*\n)*XX$/
---
name: expand-ugly
description:
Check that weird ${foo+bar} constructs are parsed correctly
stdin:
print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
chmod +x pfn pfs
(echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1
(echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2
(echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3
(echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4
(echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5
(echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6
(echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7
(echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8
(echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9
(echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10
(echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11
(echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12
(echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13
(echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14
u=x; (echo -n '15 '; ./pfs "foo ${IFS+a"b$u{ {"{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz; echo .) 2>/dev/null || echo failed in 15
l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16
l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17
l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18
l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19
l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20
l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21
l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22
l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23
key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24
key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: “'$key'”
key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26
key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27
(echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28
u=x; (echo -n '29 '; ./pfs foo ${IFS+a"b$u{ {"{ {\}b} c ${IFS+d{}} bar ${IFS-e{}} baz; echo .) 2>/dev/null || echo failed in 29
(echo -n '30 '; ./pfs ${IFS+foo 'b\
ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31)
(echo -n '32 '; ./pfs ${IFS+foo "b\
ar" baz}; echo .) 2>/dev/null || echo failed in 32
(echo -n '33 '; ./pfs "${IFS+foo 'b\
ar' baz}"; echo .) 2>/dev/null || echo failed in 33
(echo -n '34 '; ./pfs "${IFS+foo "b\
ar" baz}"; echo .) 2>/dev/null || echo failed in 34
(echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35
(echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36
(echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37
(echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
(foo() { return 100; }; foo; echo 41 ${#+${#:+${#?}}\ \}\}\}}) 2>/dev/null || echo failed in 41
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> .
41 3 }}}
---
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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>/dev/null || \
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-threecolons-dblq
description:
Check for a particular thing that used to segfault
stdin:
TEST=1234
echo "${TEST:1:2:3}"
echo $? but still living
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: expand-threecolons-unq
description:
Check for a particular thing that used to not error out
stdin:
TEST=1234
echo ${TEST:1:2:3}
echo $? but still living
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: expand-weird-1
description:
Check corner cases of trim expansion vs. $# vs. ${#var} vs. ${var?}
stdin:
set 1 2 3 4 5 6 7 8 9 10 11
echo ${#} # value of $#
echo ${##} # length of $#
echo ${##1} # $# trimmed 1
set 1 2 3 4 5 6 7 8 9 10 11 12
echo ${##1}
(exit 0)
echo $? = ${#?} .
(exit 111)
echo $? = ${#?} .
expected-stdout:
11
2
1
2
0 = 1 .
111 = 3 .
---
name: expand-weird-2
description:
Check more substitution and extension corner cases
stdin:
:& set -C; pid=$$; sub=$!; flg=$-; set -- i; exec 3>x.tmp
#echo "D: !=$! #=$# \$=$$ -=$- ?=$?"
echo >&3 3 = s^${!-word} , ${#-word} , p^${$-word} , f^${--word} , ${?-word} .
echo >&3 4 = ${!+word} , ${#+word} , ${$+word} , ${-+word} , ${?+word} .
echo >&3 5 = s^${!=word} , ${#=word} , p^${$=word} , f^${-=word} , ${?=word} .
echo >&3 6 = s^${!?word} , ${#?word} , p^${$?word} , f^${-?word} , ${??word} .
echo >&3 7 = sl^${#!} , ${##} , pl^${#$} , fl^${#-} , ${#?} .
echo >&3 8 = sw^${%!} , ${%#} , pw^${%$} , fw^${%-} , ${%?} .
echo >&3 9 = ${!!} , s^${!#} , ${!$} , s^${!-} , s^${!?} .
echo >&3 10 = s^${!#pattern} , ${##pattern} , p^${$#pattern} , f^${-#pattern} , ${?#pattern} .
echo >&3 11 = s^${!%pattern} , ${#%pattern} , p^${$%pattern} , f^${-%pattern} , ${?%pattern} .
echo >&3 12 = $# : ${##} , ${##1} .
set --
echo >&3 14 = $# : ${##} , ${##1} .
set -- 1 2 3 4 5
echo >&3 16 = $# : ${##} , ${##1} .
set -- 1 2 3 4 5 6 7 8 9 a b c d e
echo >&3 18 = $# : ${##} , ${##1} .
exec 3>&-
<x.tmp sed \
-e "s/ pl^${#pid} / PID /g" -e "s/ sl^${#sub} / SUB /g" -e "s/ fl^${#flg} / FLG /g" \
-e "s/ pw^${%pid} / PID /g" -e "s/ sw^${%sub} / SUB /g" -e "s/ fw^${%flg} / FLG /g" \
-e "s/ p^$pid / PID /g" -e "s/ s^$sub / SUB /g" -e "s/ f^$flg / FLG /g"
expected-stdout:
3 = SUB , 1 , PID , FLG , 0 .
4 = word , word , word , word , word .
5 = SUB , 1 , PID , FLG , 0 .
6 = SUB , 1 , PID , FLG , 0 .
7 = SUB , 1 , PID , FLG , 1 .
8 = SUB , 1 , PID , FLG , 1 .
9 = ! , SUB , $ , SUB , SUB .
10 = SUB , 1 , PID , FLG , 0 .
11 = SUB , 1 , PID , FLG , 0 .
12 = 1 : 1 , .
14 = 0 : 1 , 0 .
16 = 5 : 1 , 5 .
18 = 14 : 2 , 4 .
---
name: expand-weird-3
description:
Check that trimming works with positional parameters (Debian #48453)
stdin:
A=9999-02
B=9999
echo 1=${A#$B?}.
set -- $A $B
echo 2=${1#$2?}.
expected-stdout:
1=02.
2=02.
---
name: expand-weird-4
description:
Check that tilde expansion is enabled in ${x#~}
and cases that are modelled after it (${x/~/~})
stdin:
HOME=/etc
a="~/x"
echo "<${a#~}> <${a#\~}> <${b:-~}> <${b:-\~}> <${c:=~}><$c> <${a/~}> <${a/x/~}> <${a/x/\~}>"
expected-stdout:
<~/x> </x> <~> <\~> <~><~> <~/x> <~//etc> <~/~>
---
name: expand-bang-1
description:
Check corner case of ${!?} with ! being var vs. op
stdin:
echo ${!?}
expected-exit: 1
expected-stderr-pattern: /not set/
---
name: expand-bang-2
description:
Check corner case of ${!var} vs. ${var op} with var=!
category: !nopiddependent
time-limit: 15
stdin:
echo 1 $! .
echo 2 ${!#} .
echo 3 ${!#[0-9]} .
echo 4 ${!-foo} .
# get an at least three-digit bg pid
while :; do
:&
x=$!
if [[ $x != +([0-9]) ]]; then
echo >&2 "cannot test, pid '$x' not numeric"
echo >&2 report this with as many details as possible
exit 1
fi
[[ $x = [0-9][0-9][0-9]* ]] && break
done
y=${x#?}
t=$!; [[ $t = $x ]]; echo 5 $? .
t=${!#}; [[ $t = $x ]]; echo 6 $? .
t=${!#[0-9]}; [[ $t = $y ]]; echo 7 $? .
t=${!-foo}; [[ $t = $x ]]; echo 8 $? .
t=${!?bar}; [[ $t = $x ]]; echo 9 $? .
expected-stdout:
1 .
2 .
3 .
4 foo .
5 0 .
6 0 .
7 0 .
8 0 .
9 0 .
---
name: expand-number-1
description:
Check that positional arguments do not overflow
stdin:
echo "1 ${12345678901234567890} ."
expected-stdout:
1 .
---
name: expand-slashes-1
description:
Check that side effects in substring replacement are handled correctly
stdin:
foo=n1n1n1n2n3
i=2
n=1
echo 1 ${foo//n$((n++))/[$((++i))]} .
echo 2 $n , $i .
expected-stdout:
1 [3][3][3]n2n3 .
2 2 , 3 .
---
name: expand-slashes-2
description:
Check that side effects in substring replacement are handled correctly
stdin:
foo=n1n1n1n2n3
i=2
n=1
echo 1 ${foo@/n$((n++))/[$((++i))]} .
echo 2 $n , $i .
expected-stdout:
1 [3]n1n1[4][5] .
2 5 , 5 .
---
name: expand-slashes-3
description:
Check that we can access the replaced string
stdin:
foo=n1n1n1n2n3
echo 1 ${foo@/n[12]/[$KSH_MATCH]} .
expected-stdout:
1 [n1][n1][n1][n2]n3 .
---
name: eglob-bad-1
description:
Check that globbing isn't done when glob has syntax error
category: !os:cygwin,!os:lynxos,!os:midipix,!os:msys,!os:os2,!noweirdfilenames
file-setup: file 644 "@(a[b|)c]foo"
stdin:
echo @(a[b|)c]*
expected-stdout:
@(a[b|)c]*
---
name: eglob-bad-2
description:
Check that globbing isn't done when glob has syntax error
(AT&T ksh fails this test)
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.
file-setup: file 644 "abc"
time-limit: 3
stdin:
echo +()c
echo +()x
echo +(*)c
echo +(*)x
expected-stdout:
+()c
+()x
abc
+(*)x
---
name: eglob-subst-1
description:
Check that eglobbing isn't done on substitution results
file-setup: file 644 "abc"
stdin:
x='@(*)'
echo $x
expected-stdout:
@(*)
---
name: eglob-nomatch-1
description:
Check that the pattern doesn't match
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
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
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
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
case 'aab[b[ab[a' in *(a|b[)) echo yes;; *) echo no;; esac
expected-stdout:
no
yes
no
yes
---
name: eglob-trim-1
description:
Eglobbing in trim expressions...
(AT&T ksh fails this - docs say # matches shortest string, ## matches
longest...)
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...
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-trim-3
description:
Check eglobbing works in trims, for Korn Shell
Ensure eglobbing does not work for reduced-feature /bin/sh
stdin:
set +o sh
x=foobar
y=foobaz
z=fooba\?
echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
echo "<${x%ba(r|z)},${y%ba(r|z)}>"
set -o sh
echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
z='foo(bar'
echo "<${z%(*}>"
expected-stdout:
<foo,foo,fooba>
<foo,foo>
<foobar,foobaz,fooba>
<foo>
---
name: eglob-substrpl-1
description:
Check eglobbing works in substs... and they work at all
stdin:
[[ -n $BASH_VERSION ]] && shopt -s extglob
x=1222321_ab/cde_b/c_1221
y=xyz
echo 1: ${x/2} . ${x/}
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//\%1/9}
echo 28: ${x//\\%1/9}
echo 29: ${x//\a/9}
echo 30: ${x//\\a/9}
echo 31: ${x/2/$y}
expected-stdout:
1: 122321_ab/cde_b/c_1221 . 1222321_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_1221
25: 1222321_ab/cde_b/c_1229
26: 1222321_ab/cde_b/c_1221
27: 1222321_ab/cde_b/c_1221
28: 1222321_ab/cde_b/c_1221
29: 1222321_9b/cde_b/c_1221
30: 1222321_ab/cde_b/c_1221
31: 1xyz22321_ab/cde_b/c_1221
---
name: eglob-substrpl-2
description:
Check anchored substring replacement works, corner cases
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
stdin:
HOME=/etc
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:
/etc/tmp
/home/user/tmp
/etc/tmp
/home/user/tmp
/home/user/tmp
/home/user/tmp
---
name: eglob-substrpl-3b
description:
More of this, bash fails it (bash4 passes)
stdin:
HOME=/etc
pfx=/home/user
wd=/home/user/tmp
echo "${wd/#$(echo /home/user)/~}"
echo "${wd/#"$(echo /home/user)"/~}"
echo "${wd/#'$(echo /home/user)'/~}"
expected-stdout:
/etc/tmp
/etc/tmp
/home/user/tmp
---
name: eglob-substrpl-3c
description:
Even more weird cases
stdin:
HOME=/etc
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 20: ${ts//a\/b/$tr}
echo 21: ${ts//a\/b/\$tr}
echo 22: ${ts//$tp/$tr}
echo 23: ${ts//$tp/c/d}
echo 24: ${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}
tp="+($tp)"
echo 30: ${ts/$tp/$tr}
echo 31: ${ts//$tp/$tr}
expected-stdout:
1: $pfx/tmp
2: /etc/tmp
3: $pfx/tmp
4: /etc/tmp
5: /etc/tmp
6: $pfx/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: a/ba/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)
20: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
21: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
22: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
23: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
24: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
25: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
26: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
27: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
28: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
29: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
30: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
31: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
# This is what GNU bash does:
# 30: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
# 31: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
---
name: eglob-utf8-1
description:
UTF-8 mode differences for eglobbing
category: !shell:ebcdic-yes
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 [ matches itself if it's not a valid bracket expr
but does not prevent globbing, while backslash-escaping does
file-setup: dir 755 "[x"
file-setup: file 644 "[x/foo"
stdin:
echo [*
echo *[x
echo [x/*
:>'ab[x'
:>'a[a-z][x'
echo a[a-z][*
echo a[a-z]*
echo a[a\-z]*
expected-stdout:
[x
[x
[x/foo
ab[x
ab[x
a[a-z]*
---
name: glob-bad-2
description:
Check that symbolic links aren't stat()'d
# breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
# breaks on FreeMiNT (cannot unlink dangling symlinks)
# breaks on MSYS, OS/2 (do not support symlinks)
category: !os:mint,!os:msys,!os:svr4.0,!nosymlink
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-bad-3
description:
Check that the slash is parsed before the glob
stdin:
mkdir a 'a[b'
(cd 'a[b'; echo ok >'c]d')
echo nok >abd
echo fail >a/d
cat a[b/c]d
expected-stdout:
ok
---
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"
file-setup: file 644 "!bc"
file-setup: file 644 "^bc"
file-setup: file 644 "+bc"
file-setup: file 644 ",bc"
file-setup: file 644 "0bc"
file-setup: file 644 "1bc"
stdin:
echo [ab-]*
echo [-ab]*
echo [!-ab]*
echo [!ab]*
echo [\!ab]*
echo []ab]*
echo [^ab]*
echo [\^ab]*
echo [+--]*
echo [--1]*
expected-stdout:
-bc abc bbc
-bc abc bbc
!bc +bc ,bc 0bc 1bc ^bc cbc
!bc +bc ,bc -bc 0bc 1bc ^bc cbc
!bc abc bbc
abc bbc
^bc abc bbc
^bc abc bbc
+bc ,bc -bc
-bc 0bc 1bc
---
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 UTF-8 canonical decomposition)
# breaks on Cygwin 1.7 (files are now UTF-16 or something)
# breaks on QNX 6.4.1 (says RT)
category: !os:cygwin,!os:midipix,!os:darwin,!os:msys,!os:nto,!os:os2,!os:os390,!noweirdfilenames
need-pass: no
info-pre: test breaks on non-POSIX filesystems, weird locales, etc.
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"
file-setup: file 644 "@bc"
stdin:
echo [a-c-e]*
echo [a--@]*
expected-stdout:
-bc abc bbc cbc ebc
@bc
---
name: glob-range-6
description:
ksh93 fails this but POSIX probably demands it
file-setup: file 644 "abc"
file-setup: file 644 "cbc"
stdin:
echo *b*
[ '*b*' = *b* ] && echo yep; echo $?
expected-stdout:
abc cbc
2
expected-stderr-pattern: /.*/
---
name: glob-word-1
description:
Check BSD word boundary matches
stdin:
t() { [[ $1 = *[[:\<:]]bar[[:\>:]]* ]]; echo =$?; }
t 'foo bar baz'
t 'foobar baz'
t 'foo barbaz'
t 'bar'
t '_bar'
t 'bar_'
expected-stdout:
=0
=1
=1
=0
=1
=1
---
name: glob-trim-1
description:
Check against a regression from fixing IFS-subst-2
stdin:
x='#foo'
print -r "before='$x'"
x=${x%%#*}
print -r "after ='$x'"
expected-stdout:
before='#foo'
after =''
---
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-4a
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-4an
description:
Check that an error occurs if the heredoc-delimiter is missing.
arguments: !-n!
stdin: !
cat << EOF
hi
there
expected-exit: e > 0
expected-stderr-pattern: /.*/
---
name: heredoc-4b
description:
Check that an error occurs if the heredoc is missing.
stdin: !
cat << EOF
expected-exit: e > 0
expected-stderr-pattern: /.*/
---
name: heredoc-4bn
description:
Check that an error occurs if the heredoc is missing.
arguments: !-n!
stdin: !
cat << EOF
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-9
description:
Check that here strings work.
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
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"A $(echo "foo bar") B"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$b\$b$bar
fnord=42
bar="bar
\$fnord baz"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
echo $(tr r z <<<'bar' 2>/dev/null)
cat <<< "$( : )aa"
IFS=$'\n'
x=(a "b c")
tr ac 12 <<< ${x[*]}
tr ac 34 <<< "${x[*]}"
tr ac 56 <<< ${x[@]}
tr ac 78 <<< "${x[@]}"
expected-stdout:
sbb
sbb
one
onm
$one
$one
-sbb
sbb one
A sbb one B
$o$oone
onm
one
$sabeq onm
one
baz
aa
1
b 2
3
b 4
5 b 6
7 b 8
---
name: heredoc-10
description:
Check direct here document assignment
category: !shell:ebcdic-yes
stdin:
x=u
va=<<EOF
=a $x \x40=
EOF
vb=<<'EOF'
=b $x \x40=
EOF
function foo {
vc=<<-EOF
=c $x \x40=
EOF
}
fnd=$(typeset -f foo)
print -r -- "$fnd"
function foo {
echo blub
}
foo
eval "$fnd"
foo
# rather nonsensical, but…
vd=<<<"=d $x \x40="
ve=<<<'=e $x \x40='
vf=<<<$'=f $x \x40='
# now check
print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
# check append
v=<<-EOF
vapp1
EOF
v+=<<-EOF
vapp2
EOF
print -r -- "| ${v//$'\n'/^} |"
expected-stdout:
function foo {
vc=<<-EOF
=c $x \x40=
EOF
}
blub
| va={=a u \x40=
} vb={=b $x \x40=
} vc={=c u \x40=
} vd={=d u \x40=
} ve={=e $x \x40=
} vf={=f $x @=
} |
| vapp1^vapp2^ |
---
name: heredoc-10-ebcdic
description:
Check direct here document assignment
category: !shell:ebcdic-no
stdin:
x=u
va=<<EOF
=a $x \x7C=
EOF
vb=<<'EOF'
=b $x \x7C=
EOF
function foo {
vc=<<-EOF
=c $x \x7C=
EOF
}
fnd=$(typeset -f foo)
print -r -- "$fnd"
function foo {
echo blub
}
foo
eval "$fnd"
foo
# rather nonsensical, but…
vd=<<<"=d $x \x7C="
ve=<<<'=e $x \x7C='
vf=<<<$'=f $x \x7C='
# now check
print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
# check append
v=<<-EOF
vapp1
EOF
v+=<<-EOF
vapp2
EOF
print -r -- "| ${v//$'\n'/^} |"
expected-stdout:
function foo {
vc=<<-EOF
=c $x \x7C=
EOF
}
blub
| va={=a u \x7C=
} vb={=b $x \x7C=
} vc={=c u \x7C=
} vd={=d u \x7C=
} ve={=e $x \x7C=
} vf={=f $x @=
} |
| vapp1^vapp2^ |
---
name: heredoc-11
description:
Check here documents with no or empty delimiter
stdin:
x=u
va=<<
=a $x \x40=
<<
vb=<<''
=b $x \x40=
function foo {
vc=<<-
=c $x \x40=
<<
vd=<<-''
=d $x \x40=
}
fnd=$(typeset -f foo)
print -r -- "$fnd"
function foo {
echo blub
}
foo
eval "$fnd"
foo
print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
x=y
foo
typeset -f foo
print -r -- "| vc={$vc} vd={$vd} |"
# check append
v=<<-
vapp1
<<
v+=<<-''
vapp2
print -r -- "| ${v//$'\n'/^} |"
expected-stdout:
function foo {
vc=<<-
=c $x \x40=
<<
vd=<<-""
=d $x \x40=
}
blub
| va={=a u \x40=
} vb={=b $x \x40=
} vc={=c u \x40=
} vd={=d $x \x40=
} |
function foo {
vc=<<-
=c $x \x40=
<<
vd=<<-""
=d $x \x40=
}
| vc={=c y \x40=
} vd={=d $x \x40=
} |
| vapp1^vapp2^ |
---
name: heredoc-12
description:
Check here documents can use $* and $@; note shells vary:
• pdksh 5.2.14 acts the same
• dash has 1 and 2 the same but 3 lacks the space
• ksh93, bash4 differ in 2 by using space ipv colon
stdin:
set -- a b
nl='
'
IFS=" $nl"; n=1
cat <<EOF
$n foo $* foo
$n bar "$*" bar
$n baz $@ baz
$n bla "$@" bla
EOF
IFS=":"; n=2
cat <<EOF
$n foo $* foo
$n bar "$*" bar
$n baz $@ baz
$n bla "$@" bla
EOF
IFS=; n=3
cat <<EOF
$n foo $* foo
$n bar "$*" bar
$n baz $@ baz
$n bla "$@" bla
EOF
expected-stdout:
1 foo a b foo
1 bar "a b" bar
1 baz a b baz
1 bla "a b" bla
2 foo a:b foo
2 bar "a:b" bar
2 baz a:b baz
2 bla "a:b" bla
3 foo a b foo
3 bar "a b" bar
3 baz a b baz
3 bla "a b" bla
---
name: heredoc-14
description:
Check that using multiple here documents works
stdin:
foo() {
echo "got $(cat) on stdin"
echo "got $(cat <&4) on fd#4"
echo "got $(cat <&5) on fd#5"
}
bar() {
foo 4<<-a <<-b 5<<-c
four
a
zero
b
five
c
}
x=$(typeset -f bar)
eval "$x"
y=$(typeset -f bar)
[[ $x = "$y" ]]; echo $?
typeset -f bar
bar
expected-stdout:
0
bar() {
\foo 4<<-a <<-b 5<<-c
four
a
zero
b
five
c
}
got zero on stdin
got four on fd#4
got five on fd#5
---
name: heredoc-15
description:
Check high-bit7 separators work
stdin:
u=ä
tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ <<-…
m${u}h
…
echo ok
expected-stdout:
MäH
ok
---
name: heredoc-comsub-1
description:
Tests for here documents in COMSUB, taken from Austin ML
stdin:
text=$(cat <<EOF
here is the text
EOF)
echo = $text =
expected-stdout:
= here is the text =
---
name: heredoc-comsub-2
description:
Tests for here documents in COMSUB, taken from Austin ML
stdin:
unbalanced=$(cat <<EOF
this paren ) is a problem
EOF)
echo = $unbalanced =
expected-stdout:
= this paren ) is a problem =
---
name: heredoc-comsub-3
description:
Tests for here documents in COMSUB, taken from Austin ML
stdin:
balanced=$(cat <<EOF
these parens ( ) are not a problem
EOF)
echo = $balanced =
expected-stdout:
= these parens ( ) are not a problem =
---
name: heredoc-comsub-4
description:
Tests for here documents in COMSUB, taken from Austin ML
stdin:
balanced=$(cat <<EOF
these parens \( ) are a problem
EOF)
echo = $balanced =
expected-stdout:
= these parens \( ) are a problem =
---
name: heredoc-comsub-5
description:
Check heredoc and COMSUB mixture in input
stdin:
prefix() { sed -e "s/^/$1:/"; }
XXX() { echo x-en; }
YYY() { echo y-es; }
prefix A <<XXX && echo "$(prefix B <<XXX
echo line 1
XXX
echo line 2)" && prefix C <<YYY
echo line 3
XXX
echo line 4)"
echo line 5
YYY
XXX
expected-stdout:
A:echo line 3
B:echo line 1
line 2
C:echo line 4)"
C:echo line 5
x-en
---
name: heredoc-comsub-6
description:
Check here documents and here strings can be used
without a specific command, like $(<…) (extension)
stdin:
foo=bar
x=$(<<<EO${foo}F)
echo "3<$x>"
y=$(<<-EOF
hi!
$foo) is not a problem
EOF)
echo "7<$y>"
expected-stdout:
3<EObarF>
7<hi!
bar) is not a problem>
---
name: heredoc-subshell-1
description:
Tests for here documents in subshells, taken from Austin ML
stdin:
(cat <<EOF
some text
EOF)
echo end
expected-stdout:
some text
end
---
name: heredoc-subshell-2
description:
Tests for here documents in subshells, taken from Austin ML
stdin:
(cat <<EOF
some text
EOF
)
echo end
expected-stdout:
some text
end
---
name: heredoc-subshell-3
description:
Tests for here documents in subshells, taken from Austin ML
stdin:
(cat <<EOF; )
some text
EOF
echo end
expected-stdout:
some text
end
---
name: heredoc-weird-1
description:
Tests for here documents, taken from Austin ML
Documents current state in mksh, *NOT* necessarily correct!
stdin:
cat <<END
hello
END\
END
END
echo end
expected-stdout:
hello
ENDEND
end
---
name: heredoc-weird-2
description:
Tests for here documents, taken from Austin ML
stdin:
cat <<' END '
hello
END
echo end
expected-stdout:
hello
end
---
name: heredoc-weird-4
description:
Tests for here documents, taken from Austin ML
Documents current state in mksh, *NOT* necessarily correct!
stdin:
cat <<END
hello\
END
END
echo end
expected-stdout:
helloEND
end
---
name: heredoc-weird-5
description:
Tests for here documents, taken from Austin ML
Documents current state in mksh, *NOT* necessarily correct!
stdin:
cat <<END
hello
\END
END
echo end
expected-stdout:
hello
\END
end
---
name: heredoc-tmpfile-1
description:
Check that heredoc temp files aren't removed too soon or too late.
Heredoc in simple command.
info-pre: next couple of tests sleep for a few seconds each
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 5
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,
please help fix this as it also triggers sometimes on Debian
reproducible-builds package rebuilds or debci tests somehow
need-pass: no
info-post: can fail on slow (<100 MHz) or Cygwin, but ought not to
stdin:
TMPDIR=$PWD
# Background eval so main shell doesn't do parsing
eval '
foo() {
sed -e "s/^/N: /" -e "s/\\.[a-z]*\$//" <<-EOF
hi$1
EOF
}
foo 1
# sleep so eval can die
(sleep 1; foo 3.a) &
(sleep 1; foo 3.b) &
foo 2
' &
sleep 3
echo Left overs: *
expected-stdout:
N: hi1
N: hi2
N: hi3
N: hi3
Left overs: *
---
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: single-quotes-in-braces
description:
Check that single quotes inside unquoted {} are treated as quotes
stdin:
foo=1
echo ${foo:+'blah $foo'}
expected-stdout:
blah $foo
---
name: single-quotes-in-quoted-braces
description:
Check that single quotes inside quoted {} are treated as
normal char
stdin:
foo=1
echo "${foo:+'blah $foo'}"
expected-stdout:
'blah 1'
---
name: single-quotes-in-braces-nested
description:
Check that single quotes inside unquoted {} are treated as quotes,
even if that's inside a double-quoted command expansion
stdin:
foo=1
echo "$( echo ${foo:+'blah $foo'})"
expected-stdout:
blah $foo
---
name: single-quotes-in-brace-pattern
description:
Check that single quotes inside {} pattern are treated as quotes
stdin:
foo=1234
echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
expected-stdout:
1 1 1234 1234
---
name: single-quotes-in-heredoc-braces
description:
Check that single quotes inside {} in heredoc are treated
as normal char
stdin:
foo=1
cat <<EOM
${foo:+'blah $foo'}
EOM
expected-stdout:
'blah 1'
---
name: single-quotes-in-nested-braces
description:
Check that single quotes inside nested unquoted {} are
treated as quotes
stdin:
foo=1
echo ${foo:+${foo:+'blah $foo'}}
expected-stdout:
blah $foo
---
name: single-quotes-in-nested-quoted-braces
description:
Check that single quotes inside nested quoted {} are treated
as normal char
stdin:
foo=1
echo "${foo:+${foo:+'blah $foo'}}"
expected-stdout:
'blah 1'
---
name: single-quotes-in-nested-braces-nested
description:
Check that single quotes inside nested unquoted {} are treated
as quotes, even if that's inside a double-quoted command expansion
stdin:
foo=1
echo "$( echo ${foo:+${foo:+'blah $foo'}})"
expected-stdout:
blah $foo
---
name: single-quotes-in-nested-brace-pattern
description:
Check that single quotes inside nested {} pattern are treated as quotes
stdin:
foo=1234
echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
expected-stdout:
1 1 1234 1234
---
name: single-quotes-in-heredoc-nested-braces
description:
Check that single quotes inside nested {} in heredoc are treated
as normal char
stdin:
foo=1
cat <<EOM
${foo:+${foo:+'blah $foo'}}
EOM
expected-stdout:
'blah 1'
---
name: single-quotes-in-heredoc-trim
description:
In some cases, single quotes inside {} in heredoc are not normal
stdin:
x=notOK
cat <<EOF
1: ${x#not} ${x:+${x#not}}
2: ${x#\n\o\t} ${x:+${x#\n\o\t}}
3: ${x#"not"} ${x:+${x#"not"}}
4: ${x#'not'} ${x:+${x#'not'}}
5: ${x#$'not'} ${x:+${x#$'not'}}
EOF
expected-stdout:
1: OK OK
2: OK OK
3: OK OK
4: OK OK
5: OK OK
---
name: history-basic
description:
See if we can test history at all
need-ctty: yes
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
need-ctty: yes
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
need-ctty: yes
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-multiline
description:
Check correct multiline history, Debian #783978
need-ctty: yes
arguments: !-i!
env-setup: !ENV=./Env!
file-setup: file 644 "Env"
PS1=X
PS2=Y
stdin:
for i in A B C
do
print $i
print $i
done
fc -l
expected-stdout:
A
A
B
B
C
C
1 for i in A B C
do
print $i
print $i
done
expected-stderr-pattern:
/^XYYYYXX$/
---
name: history-e-minus-1
description:
Check if more recent command is executed
need-ctty: yes
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.
need-ctty: yes
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)
need-ctty: yes
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.
need-ctty: yes
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.
need-ctty: yes
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)
need-ctty: yes
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)
need-ctty: yes
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
need-ctty: yes
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
need-ctty: yes
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
need-ctty: yes
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)
need-ctty: yes
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
need-ctty: yes
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
need-ctty: yes
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.
need-ctty: yes
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.
need-ctty: yes
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
need-ctty: yes
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?
need-ctty: yes
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
need-ctty: yes
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)
need-ctty: yes
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)
need-ctty: yes
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
need-ctty: yes
need-pass: no
info-pre: these three tests depend on ed(1) existing and working...
arguments: !-ie!
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
need-ctty: yes
need-pass: no
arguments: !-ie!
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.
(ksh88 fails 'cause it lists the fc command)
category: stdout-ed
need-ctty: yes
need-pass: no
info-post: above three tests need real (non-busybox) ed(1), too
arguments: !-ie!
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
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-stderr-ed
need-ctty: yes
need-pass: no
info-pre: these three tests depend on ed(1) existing and working...
arguments: !-ie!
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-stderr-ed
need-ctty: yes
need-pass: no
arguments: !-ie!
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-stderr-ed
need-ctty: yes
need-pass: no
info-post: above three tests need real (non-busybox) ed(1), too
arguments: !-ie!
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
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:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; 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 s_arg in "$@"; do echo -n "<$s_arg> "; 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 s_arg in "$@"; do echo -n "<$s_arg> "; 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 s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
IFS="$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 s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
IFS="$IFS:"
set --
showargs :"$@"
expected-stdout:
<:> .
---
name: IFS-space-colon-4
description:
Simple test, IFS=<white-space>:
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
IFS="$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 s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
IFS="$IFS:"
set --
showargs "${@:-}"
expected-stdout:
<> .
---
name: IFS-subst-1
description:
Simple test, IFS=<white-space>:
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
IFS="$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: IFS-subst-2
description:
Check leading whitespace after trim does not make a field
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
x="X 1 2"
showargs 1 shift ${x#X}
expected-stdout:
<1> <shift> <1> <2> .
---
name: IFS-subst-3-arr
description:
Check leading IFS non-whitespace after trim does make a field
but leading IFS whitespace does not, nor empty replacements
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
showargs 0 ${-+}
IFS=:
showargs 1 ${-+:foo:bar}
IFS=' '
showargs 2 ${-+ foo bar}
expected-stdout:
<0> .
<1> <> <foo> <bar> .
<2> <foo> <bar> .
---
name: IFS-subst-3-ass
description:
Check non-field semantics
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
showargs 0 x=${-+}
IFS=:
showargs 1 x=${-+:foo:bar}
IFS=' '
showargs 2 x=${-+ foo bar}
expected-stdout:
<0> <x=> .
<1> <x=> <foo> <bar> .
<2> <x=> <foo> <bar> .
---
name: IFS-subst-3-lcl
description:
Check non-field semantics, smaller corner case (LP#1381965)
stdin:
set -x
local regex=${2:-}
exit 1
expected-exit: e != 0
expected-stderr-pattern:
/regex=/
---
name: IFS-subst-4-1
description:
reported by mikeserv
stdin:
pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
a='space divded argument
here'
IFS=\ ; set -- $a
IFS= ; q="$*" ; nq=$*
pfn "$*" $* "$q" "$nq"
[ "$q" = "$nq" ] && echo =true || echo =false
expected-stdout:
<spacedivdedargument
here>
<space>
<divded>
<argument
here>
<spacedivdedargument
here>
<spacedivdedargument
here>
=true
---
name: IFS-subst-4-2
description:
extended testsuite based on problem by mikeserv
stdin:
pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
a='space divded argument
here'
IFS=\ ; set -- $a
IFS= ; q="$@" ; nq=$@
pfn "$*" $* "$q" "$nq"
[ "$q" = "$nq" ] && echo =true || echo =false
expected-stdout:
<spacedivdedargument
here>
<space>
<divded>
<argument
here>
<space divded argument
here>
<space divded argument
here>
=true
---
name: IFS-subst-4-3
description:
extended testsuite based on problem by mikeserv
stdin:
pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
a='space divded argument
here'
IFS=\ ; set -- $a; IFS=
qs="$*"
nqs=$*
qk="$@"
nqk=$@
print -nr -- '= qs '; pfn "$qs"
print -nr -- '=nqs '; pfn "$nqs"
print -nr -- '= qk '; pfn "$qk"
print -nr -- '=nqk '; pfn "$nqk"
print -nr -- '~ qs '; pfn "$*"
print -nr -- '~nqs '; pfn $*
print -nr -- '~ qk '; pfn "$@"
print -nr -- '~nqk '; pfn $@
expected-stdout:
= qs <spacedivdedargument
here>
=nqs <spacedivdedargument
here>
= qk <space divded argument
here>
=nqk <space divded argument
here>
~ qs <spacedivdedargument
here>
~nqs <space>
<divded>
<argument
here>
~ qk <space>
<divded>
<argument
here>
~nqk <space>
<divded>
<argument
here>
---
name: IFS-subst-4-4
description:
extended testsuite based on problem by mikeserv
stdin:
pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
a='space divded argument
here'
IFS=\ ; set -- $a; IFS=
qs="$*"
print -nr -- '= qs '; pfn "$qs"
print -nr -- '~ qs '; pfn "$*"
nqs=$*
print -nr -- '=nqs '; pfn "$nqs"
print -nr -- '~nqs '; pfn $*
qk="$@"
print -nr -- '= qk '; pfn "$qk"
print -nr -- '~ qk '; pfn "$@"
nqk=$@
print -nr -- '=nqk '; pfn "$nqk"
print -nr -- '~nqk '; pfn $@
expected-stdout:
= qs <spacedivdedargument
here>
~ qs <spacedivdedargument
here>
=nqs <spacedivdedargument
here>
~nqs <space>
<divded>
<argument
here>
= qk <space divded argument
here>
~ qk <space>
<divded>
<argument
here>
=nqk <space divded argument
here>
~nqk <space>
<divded>
<argument
here>
---
name: IFS-subst-4-4p
description:
extended testsuite based on problem by mikeserv
stdin:
pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
a='space divded argument
here'
IFS=\ ; set -- $a; IFS=
unset v
qs=${v:-"$*"}
print -nr -- '= qs '; pfn "$qs"
print -nr -- '~ qs '; pfn ${v:-"$*"}
nqs=${v:-$*}
print -nr -- '=nqs '; pfn "$nqs"
print -nr -- '~nqs '; pfn ${v:-$*}
qk=${v:-"$@"}
print -nr -- '= qk '; pfn "$qk"
print -nr -- '~ qk '; pfn ${v:-"$@"}
nqk=${v:-$@}
print -nr -- '=nqk '; pfn "$nqk"
print -nr -- '~nqk '; pfn ${v:-$@}
expected-stdout:
= qs <spacedivdedargument
here>
~ qs <spacedivdedargument
here>
=nqs <spacedivdedargument
here>
~nqs <space>
<divded>
<argument
here>
= qk <space divded argument
here>
~ qk <space>
<divded>
<argument
here>
=nqk <space divded argument
here>
~nqk <space>
<divded>
<argument
here>
---
name: IFS-subst-4-5
description:
extended testsuite based on problem by mikeserv
stdin:
pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
a='space divded argument
here'
IFS=\ ; set -- $a; IFS=,
qs="$*"
print -nr -- '= qs '; pfn "$qs"
print -nr -- '~ qs '; pfn "$*"
nqs=$*
print -nr -- '=nqs '; pfn "$nqs"
print -nr -- '~nqs '; pfn $*
qk="$@"
print -nr -- '= qk '; pfn "$qk"
print -nr -- '~ qk '; pfn "$@"
nqk=$@
print -nr -- '=nqk '; pfn "$nqk"
print -nr -- '~nqk '; pfn $@
expected-stdout:
= qs <space,divded,argument
here>
~ qs <space,divded,argument
here>
=nqs <space,divded,argument
here>
~nqs <space>
<divded>
<argument
here>
= qk <space divded argument
here>
~ qk <space>
<divded>
<argument
here>
=nqk <space divded argument
here>
~nqk <space>
<divded>
<argument
here>
---
name: IFS-subst-4-5p
description:
extended testsuite based on problem by mikeserv
stdin:
pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
a='space divded argument
here'
IFS=\ ; set -- $a; IFS=,
unset v
qs=${v:-"$*"}
print -nr -- '= qs '; pfn "$qs"
print -nr -- '~ qs '; pfn ${v:-"$*"}
nqs=${v:-$*}
print -nr -- '=nqs '; pfn "$nqs"
print -nr -- '~nqs '; pfn ${v:-$*}
qk=${v:-"$@"}
print -nr -- '= qk '; pfn "$qk"
print -nr -- '~ qk '; pfn ${v:-"$@"}
nqk=${v:-$@}
print -nr -- '=nqk '; pfn "$nqk"
print -nr -- '~nqk '; pfn ${v:-$@}
expected-stdout:
= qs <space,divded,argument
here>
~ qs <space,divded,argument
here>
=nqs <space,divded,argument
here>
~nqs <space>
<divded>
<argument
here>
= qk <space divded argument
here>
~ qk <space>
<divded>
<argument
here>
=nqk <space divded argument
here>
~nqk <space>
<divded>
<argument
here>
---
name: IFS-subst-5
description:
extended testsuite based on IFS-subst-3
differs slightly from ksh93:
- omit trailing field in a3zna, a7ina (unquoted $@ expansion)
- has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
differs slightly from bash:
- omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion)
differs slightly from zsh:
- differs in assignment, not expansion; probably zsh bug
- has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
'emulate sh' zsh has extra fields in
- a5ins (IFS_NWS unquoted $*)
- b5ins, matching mksh’s
!!WARNING!! more to come: https://www.austingroupbugs.net/view.php?id=888
stdin:
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
echo '=a1zns'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
echo '=a2zqs'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
echo '=a3zna'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
echo '=a4zqa'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
echo '=a5ins'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
echo '=a6iqs'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
echo '=a7ina'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
echo '=a8iqa'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
echo '=b1zns'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
echo '=b2zqs'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
echo '=b3zna'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
echo '=b4zqa'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
echo '=b5ins'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
echo '=b6iqs'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
echo '=b7ina'
"$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
echo '=b8iqa'
expected-stdout:
[2]
<2>
=a1zns
[2]
<2>
=a2zqs
[2]
< 2 >
=a3zna
[]
[2]
[]
< 2 >
=a4zqa
[2]
<,2,>
=a5ins
[,2,]
<,2,>
=a6iqs
[2]
< 2 >
=a7ina
[]
[2]
[]
< 2 >
=a8iqa
[A]
[B]
[C]
<ABC>
=b1zns
[ABC]
<ABC>
=b2zqs
[A]
[B]
[C]
<A B C>
=b3zna
[A]
[B]
[]
[]
[C]
<A B C>
=b4zqa
[A]
[B]
[]
[]
[C]
<A,B,,,C>
=b5ins
[A,B,,,C]
<A,B,,,C>
=b6iqs
[A]
[B]
[]
[]
[C]
<A B C>
=b7ina
[A]
[B]
[]
[]
[C]
<A B C>
=b8iqa
---
name: IFS-subst-6
description:
Regression wrt. vector expansion in trim
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
IFS=
x=abc
set -- a b
showargs ${x#$*}
expected-stdout:
<c> .
---
name: IFS-subst-7
description:
ksh93 bug wrt. vector expansion in trim
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
IFS="*"
a=abcd
set -- '' c
showargs "$*" ${a##"$*"}
expected-stdout:
<*c> <abcd> .
---
name: IFS-subst-8
description:
https://www.austingroupbugs.net/view.php?id=221
stdin:
n() { echo "$#"; }; n "${foo-$@}"
expected-stdout:
1
---
name: IFS-subst-9
description:
Scalar context for $*/$@ in [[ and case
stdin:
"$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b
"$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b
"$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b
"$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b
"$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b
"$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b
"$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b
"$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b
"$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b
expected-stdout:
1 0
2 0
3 0
4 1
5 1
6 1
7 ok
8 ok
<9> <ab> <a b> .
---
name: IFS-subst-10
description:
Scalar context in ${var=$subst}
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
set -- one "two three" four
unset -v var
save_IFS=$IFS
IFS=
set -- ${var=$*}
IFS=$save_IFS
echo "var=$var"
showargs "$@"
expected-stdout:
var=onetwo threefour
<onetwo threefour> .
---
name: IFS-subst-11
description:
Check leading non-whitespace after trim makes only one field
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
v="foo!one!two!three"
IFS="!"
showargs x ${v:3} y
expected-stdout:
<x> <> <one> <two> <three> <y> .
---
name: IFS-arith-1
description:
https://www.austingroupbugs.net/view.php?id=832
stdin:
${ZSH_VERSION+false} || emulate sh
${BASH_VERSION+set -o posix}
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
IFS=0
showargs $((1230456))
expected-stdout:
<123> <456> .
---
name: integer-base-err-1
description:
Can't have 0 base (causes shell to exit)
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)
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)
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:
/^(?:W: [^\n]*(?:find tty fd|have full job control)[^\n]*\n)*([#\$] )?.*:.*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)
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.
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
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..)
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)
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
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)
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
stdin:
echo $(( zz = 8#100 ))
echo $zz
expected-stdout:
64
64
---
name: integer-base-8
description:
Check that base-36 works (full span)
stdin:
echo 1:$((36#109AZ)).
typeset -i36 x=1691675
echo 2:$x.
typeset -Uui36 x
echo 3:$x.
expected-stdout:
1:1691675.
2:36#109az.
3:36#109AZ.
---
name: integer-base-check-flat
description:
Check behaviour does not match POSuX (except if set -o posix),
because a not type-safe scripting language has *no* business
interpreting the string "010" as octal number eight (dangerous).
stdin:
echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
expected-stdout:
1 :10/10,16: .
2 :10/8,16: .
3 :10/10,16: .
---
name: integer-base-check-numeric-from-1
description:
Check behaviour for base one
category: !shell:ebcdic-yes
stdin:
echo 1:$((1#1))0.
expected-stdout:
1:490.
---
name: integer-base-check-numeric-from-1-ebcdic
description:
Check behaviour for base one
category: !shell:ebcdic-no
stdin:
echo 1:$((1#1))0.
expected-stdout:
1:2410.
---
name: integer-base-check-numeric-from-2
description:
Check behaviour for base two to 36, and that 37 degrades to 10
stdin:
i=1
while (( ++i <= 36 )); do
eval 'echo '$i':$(('$i'#100)).'
done
echo 37:$($__progname -c 'echo $((37#100))').$?:
expected-stdout:
2:4.
3:9.
4:16.
5:25.
6:36.
7:49.
8:64.
9:81.
10:100.
11:121.
12:144.
13:169.
14:196.
15:225.
16:256.
17:289.
18:324.
19:361.
20:400.
21:441.
22:484.
23:529.
24:576.
25:625.
26:676.
27:729.
28:784.
29:841.
30:900.
31:961.
32:1024.
33:1089.
34:1156.
35:1225.
36:1296.
37:100.0:
---
name: integer-base-check-numeric-to-1
description:
Check behaviour for base one
category: !shell:ebcdic-yes
stdin:
i=1
typeset -Uui$i x=0x40
eval "typeset -i10 y=$x"
print $i:$x.$y.
expected-stdout:
1:1#@.64.
---
name: integer-base-check-numeric-to-1-ebcdic
description:
Check behaviour for base one
category: !shell:ebcdic-no
stdin:
i=1
typeset -Uui$i x=0x7C
eval "typeset -i10 y=$x"
print $i:$x.$y.
expected-stdout:
1:1#@.124.
---
name: integer-base-check-numeric-to-2
description:
Check behaviour for base two to 36, and that 37 degrades to 10
stdin:
i=1
while (( ++i <= 37 )); do
typeset -Uui$i x=0x40
eval "typeset -i10 y=$x"
print $i:$x.$y.
done
expected-stdout:
2:2#1000000.64.
3:3#2101.64.
4:4#1000.64.
5:5#224.64.
6:6#144.64.
7:7#121.64.
8:8#100.64.
9:9#71.64.
10:64.64.
11:11#59.64.
12:12#54.64.
13:13#4C.64.
14:14#48.64.
15:15#44.64.
16:16#40.64.
17:17#3D.64.
18:18#3A.64.
19:19#37.64.
20:20#34.64.
21:21#31.64.
22:22#2K.64.
23:23#2I.64.
24:24#2G.64.
25:25#2E.64.
26:26#2C.64.
27:27#2A.64.
28:28#28.64.
29:29#26.64.
30:30#24.64.
31:31#22.64.
32:32#20.64.
33:33#1V.64.
34:34#1U.64.
35:35#1T.64.
36:36#1S.64.
37:64.64.
---
name: integer-arithmetic-span-signed
description:
Check wraparound and size that is defined in mksh
category: shell:legacy-no
stdin:
echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
expected-stdout:
s:-2147483648.-1.0.
u:2147483648.4294967295.0.
---
name: integer-arithmetic-span-32
description:
Check unsigned wraparound and size that should also work in lksh
category: int:32
stdin:
echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
expected-stdout:
u:2147483648.4294967295.0.
---
name: integer-arithmetic-span-64
description:
Check unsigned wraparound and size that should also work in lksh
category: int:64
stdin:
echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
expected-stdout:
u:9223372036854775808.18446744073709551615.0.
---
name: integer-size-FAIL-to-detect
description:
Notify the user that their ints are not 32 or 64 bit
category: int:u
stdin:
:
---
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
stdin:
fail() {
echo "line <$1>"
exit 1
}
trap 'fail $LINENO' INT ERR
false
expected-stdout:
line <6>
expected-exit: 1
---
name: lineno-eval-alias
description:
Check if LINENO is trapped in eval and aliases
stdin:
${ZSH_VERSION+false} || emulate sh; echo $LINENO
echo $LINENO
eval ' echo $LINENO
echo $LINENO
echo $LINENO'
echo $LINENO
expected-stdout:
1
2
3
3
3
6
---
name: unknown-trap
description:
Ensure unknown traps are not a syntax error
stdin:
(
trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
echo =1
trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
echo = $?
) 2>&1 | sed \
-e "s^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROG" \
-e "s^[EW]: ${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROG" \
-e "s/bad signal '\\(.*\\)'\$/bad signal: \\1/"
expected-stdout:
PROG: trap: bad signal: UNKNOWNSIGNAL
foo
=1
PROG: trap: bad signal: UNKNOWNSIGNAL
PROG: trap: bad signal: 999999
PROG: trap: bad signal: FNORD
= 1
trap 2 executed
---
name: uncatchable-trap
description:
Ensure trying to trap SIGKILL is a nop (POSIX says undefined)
stdin:
trap 'echo sighit $? .' KILL EXIT
"$__perlname" -e 'print $=.$/;'
echo meow $? .
(exit 7)
expected-exit: 7
expected-stdout:
60
meow 0 .
sighit 7 .
---
name: read-IFS-1
description:
Simple test, default IFS
stdin:
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-IFS-2
description:
Complex tests, IFS either colon (IFS-NWS) or backslash (tricky)
stdin:
n=0
showargs() { print -nr "$1"; shift; for s_arg in "$@"; do print -nr -- " [$s_arg]"; done; print; }
(IFS=\\ a=\<\\\>; showargs 3 $a)
(IFS=: b=\<:\>; showargs 4 $b)
print -r '<\>' | (IFS=\\ read f g; showargs 5 "$f" "$g")
print -r '<\\>' | (IFS=\\ read f g; showargs 6 "$f" "$g")
print '<\\\n>' | (IFS=\\ read f g; showargs 7 "$f" "$g")
print -r '<\>' | (IFS=\\ read f; showargs 8 "$f")
print -r '<\\>' | (IFS=\\ read f; showargs 9 "$f")
print '<\\\n>' | (IFS=\\ read f; showargs 10 "$f")
print -r '<\>' | (IFS=\\ read -r f g; showargs 11 "$f" "$g")
print -r '<\\>' | (IFS=\\ read -r f g; showargs 12 "$f" "$g")
print '<\\\n>' | (IFS=\\ read -r f g; showargs 13 "$f" "$g")
print -r '<\>' | (IFS=\\ read -r f; showargs 14 "$f")
print -r '<\\>' | (IFS=\\ read -r f; showargs 15 "$f")
print '<\\\n>' | (IFS=\\ read -r f; showargs 16 "$f")
print -r '<:>' | (IFS=: read f g; showargs 17 "$f" "$g")
print -r '<::>' | (IFS=: read f g; showargs 18 "$f" "$g")
print '<:\n>' | (IFS=: read f g; showargs 19 "$f" "$g")
print -r '<:>' | (IFS=: read f; showargs 20 "$f")
print -r '<::>' | (IFS=: read f; showargs 21 "$f")
print '<:\n>' | (IFS=: read f; showargs 22 "$f")
print -r '<:>' | (IFS=: read -r f g; showargs 23 "$f" "$g")
print -r '<::>' | (IFS=: read -r f g; showargs 24 "$f" "$g")
print '<:\n>' | (IFS=: read -r f g; showargs 25 "$f" "$g")
print -r '<:>' | (IFS=: read -r f; showargs 26 "$f")
print -r '<::>' | (IFS=: read -r f; showargs 27 "$f")
print '<:\n>' | (IFS=: read -r f; showargs 28 "$f")
expected-stdout:
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 [<]
---
name: read-ksh-1
description:
If no var specified, REPLY is used
stdin:
echo "abc" > IN
read < IN
echo "[$REPLY]";
expected-stdout:
[abc]
---
name: read-regress-1
description:
Check a regression of read
file-setup: file 644 "foo"
foo bar
baz
blah
stdin:
while read a b c; do
read d
break
done <foo
echo "<$a|$b|$c><$d>"
expected-stdout:
<foo|bar|><baz>
---
name: read-delim-1
description:
Check read with delimiters
stdin:
emit() {
print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
}
emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
emit | while read -d "" foo; do print -r -- "<$foo>"; done
emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
expected-stdout:
<foo bar baz
blah >
<blub blech
myok meck >
<foo bar baz
blah>
<blub blech
myok meck>
<foo bar baz
blah blub bl>
<ch
myok m>
---
name: read-ext-1
description:
Check read with number of bytes specified, and -A
stdin:
print 'foo\nbar' >x1
print -n x >x2
print 'foo\\ bar baz' >x3
x1a=u; read x1a <x1
x1b=u; read -N-1 x1b <x1
x2a=u; read x2a <x2; r2a=$?
x2b=u; read -N2 x2c <x2; r2b=$?
x2c=u; read -n2 x2c <x2; r2c=$?
x3a=u; read -A x3a <x3
print -r "x1a=<$x1a>"
print -r "x1b=<$x1b>"
print -r "x2a=$r2a<$x2a>"
print -r "x2b=$r2b<$x2b>"
print -r "x2c=$r2c<$x2c>"
print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
expected-stdout:
x1a=<foo>
x1b=<foo
bar>
x2a=1<x>
x2b=1<u>
x2c=0<x>
x3a=<foo bar|baz|>
---
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 - cannot 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 \( )
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-10
description:
The following:
set -- `false`
echo $?
should print 0 according to POSIX (dash, bash, ksh93, posh)
but not 0 according to the getopt(1) manual page, ksh88, and
Bourne sh (such as /bin/sh on Solaris).
We honour POSIX except when -o sh is set.
category: shell:legacy-no
stdin:
showf() {
[[ -o posix ]]; FPOSIX=$((1-$?))
[[ -o sh ]]; FSH=$((1-$?))
echo -n "FPOSIX=$FPOSIX FSH=$FSH "
}
set +o posix +o sh
showf
set -- `false`
echo rv=$?
set -o sh
showf
set -- `false`
echo rv=$?
set -o posix
showf
set -- `false`
echo rv=$?
set -o posix -o sh
showf
set -- `false`
echo rv=$?
expected-stdout:
FPOSIX=0 FSH=0 rv=0
FPOSIX=0 FSH=1 rv=1
FPOSIX=1 FSH=0 rv=0
FPOSIX=1 FSH=1 rv=0
---
name: regression-10-legacy
description:
The following:
set -- `false`
echo $?
should print 0 according to POSIX (dash, bash, ksh93, posh)
but not 0 according to the getopt(1) manual page, ksh88, and
Bourne sh (such as /bin/sh on Solaris).
category: shell:legacy-yes
stdin:
showf() {
[[ -o posix ]]; FPOSIX=$((1-$?))
[[ -o sh ]]; FSH=$((1-$?))
echo -n "FPOSIX=$FPOSIX FSH=$FSH "
}
set +o posix +o sh
showf
set -- `false`
echo rv=$?
set -o sh
showf
set -- `false`
echo rv=$?
set -o posix
showf
set -- `false`
echo rv=$?
set -o posix -o sh
showf
set -- `false`
echo rv=$?
expected-stdout:
FPOSIX=0 FSH=0 rv=1
FPOSIX=0 FSH=1 rv=1
FPOSIX=1 FSH=0 rv=0
FPOSIX=1 FSH=1 rv=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>/dev/null) | 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).
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 assignments 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
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?
# prints 0600…
category: !os:skyos
stdin:
# on MiNT, the first umask call seems to fail
umask 022
# now, the test proper
umask 222
umask
expected-stdout:
0222
---
name: regression-35
description:
Temporary files used for heredocs 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
stdin:
time -p sleep 1
expected-stderr-pattern: /^real +(?![0.]*$)[0-9]+(?:\.[0-9]+)?$/m
---
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:
Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
them exit 0. The POSIX behaviour is needed by BSD make.
stdin:
set -e
echo `false; echo hi` $(<this-file-does-not-exist)
echo $?
expected-stdout:
0
expected-stderr-pattern: /this-file-does-not-exist/
---
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 read-only parameters.
stdin:
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
done >env; chmod +x env; PATH=.$PATHSEP$PATH
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-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.
stdin:
alias x='echo hi'
FOO="`x` "
echo "[$FOO]"
x
expected-stdout:
[hi ]
hi
---
name: regression-47
description:
Check that aliases are fully read.
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
typeset -i BLAH
set | grep FOO
set | grep BAR
set | grep BLAH
expected-stdout:
X
BAR
BLAH
---
name: regression-50
description:
Check that aliases do not use continuation prompt after trailing
semi-colon.
file-setup: file 644 "envf"
PS1=Y
PS2=X
env-setup: !ENV=./envf!
need-ctty: yes
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
file-setup: file 644 "envf"
PS1=P
file-setup: file 644 "abc"
stuff
env-setup: !ENV=./envf!
need-ctty: yes
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
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
}
function kfunc {
echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
while getopts K oc; do
case $oc in
(K)
echo kfunc: K option
;;
(*)
echo bfunc: odd option "($oc)"
;;
esac
done
echo kfunc: 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"
kfunc -KKK blah
echo "line 5: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 6: 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"
kfunc -KKK blah
echo "line 50: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 60: 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
kfunc: enter (args: -KKK blah; OPTIND=1)
kfunc: K option
kfunc: K option
kfunc: K option
kfunc: leave
line 5: OPTIND=3
line 6: ret=0, optc=k, OPTIND=4
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
kfunc: enter (args: -KKK blah; OPTIND=1)
kfunc: K option
kfunc: K option
kfunc: K option
kfunc: leave
line 50: OPTIND=2
line 60: ret=1, optc=?, OPTIND=2
---
name: regression-54
description:
Check that ; is not required before the then in if (( ... )) then ...
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...)
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.
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
set -A xxx
typeset -i xxx[1]
---
name: regression-58
description:
Check if trap exit is ok (exit not mistaken for signal name)
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.
stdin:
matrix() {
local a b c d e f g h
test a -nt b; a=$?
test b -nt a; b=$?
test a -ot b; c=$?
test b -ot a; d=$?
test a -nt a; e=$?
test b -nt b; f=$?
test a -ot a; g=$?
test b -ot b; h=$?
echo $1 $a $b $c $d / $e $f $g $h .
}
matrix a
:>a
matrix b
sleep 2 # mtime granularity for OS/2 and FAT
:>b
matrix c
sleep 2
echo dummy >a # Debian GNU/Hurd #955270
matrix d
rm a
matrix e
expected-stdout:
a 1 1 1 1 / 1 1 1 1 .
b 0 1 1 0 / 1 1 1 1 .
c 1 0 0 1 / 1 1 1 1 .
d 0 1 1 0 / 1 1 1 1 .
e 1 0 0 1 / 1 1 1 1 .
---
name: regression-63
description:
Check if typeset, export, and readonly work
stdin:
{
echo FNORD-0
FNORD_A=1
FNORD_B=2
FNORD_C=3
FNORD_D=4
FNORD_E=5
FNORD_F=6
FNORD_G=7
FNORD_H=8
integer FNORD_E FNORD_F FNORD_G FNORD_H
export FNORD_C FNORD_D FNORD_G FNORD_H
readonly FNORD_B FNORD_D FNORD_F FNORD_H
echo FNORD-1
export
echo FNORD-2
export -p
echo FNORD-3
readonly
echo FNORD-4
readonly -p
echo FNORD-5
typeset
echo FNORD-6
typeset -p
echo FNORD-7
typeset -
echo FNORD-8
} | grep FNORD
fnord=(42 23)
typeset -p fnord
echo FNORD-9
expected-stdout:
FNORD-0
FNORD-1
FNORD_C
FNORD_D
FNORD_G
FNORD_H
FNORD-2
export FNORD_C=3
export FNORD_D=4
export FNORD_G=7
export FNORD_H=8
FNORD-3
FNORD_B
FNORD_D
FNORD_F
FNORD_H
FNORD-4
readonly FNORD_B=2
readonly FNORD_D=4
readonly FNORD_F=6
readonly FNORD_H=8
FNORD-5
typeset FNORD_A
typeset -r FNORD_B
typeset -x FNORD_C
typeset -x -r FNORD_D
typeset -i FNORD_E
typeset -i -r FNORD_F
typeset -i -x FNORD_G
typeset -i -x -r FNORD_H
FNORD-6
typeset FNORD_A=1
typeset -r FNORD_B=2
typeset -x FNORD_C=3
typeset -x -r FNORD_D=4
typeset -i FNORD_E=5
typeset -i -r FNORD_F=6
typeset -i -x FNORD_G=7
typeset -i -x -r FNORD_H=8
FNORD-7
FNORD_A=1
FNORD_B=2
FNORD_C=3
FNORD_D=4
FNORD_E=5
FNORD_F=6
FNORD_G=7
FNORD_H=8
FNORD-8
set -A fnord
typeset fnord[0]=42
typeset fnord[1]=23
FNORD-9
---
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: regression-66
description:
Check that quoting is sane
category: !nojsig
stdin:
ac_space=' '
ac_newline='
'
set | grep ^ac_ |&
set -A lines
while IFS= read -pr line; do
if [[ $line = *space* ]]; then
lines[0]=$line
else
lines[1]=$line
fi
done
for line in "${lines[@]}"; do
print -r -- "$line"
done
expected-stdout:
ac_space=' '
ac_newline=$'\n'
---
name: regression-67
description:
Check that we can both break and use source on the same line
stdin:
for s in s; do break; done; print -s s
---
name: regression-68
description:
Check that all common arithmetic operators work as expected
stdin:
echo 1 $(( a = 5 )) .
echo 2 $(( ++a )) , $(( a++ )) , $(( a )) .
echo 3 $(( --a )) , $(( a-- )) , $(( a )) .
echo 4 $(( a == 5 )) , $(( a == 6 )) .
echo 5 $(( a != 5 )) , $(( a != 6 )) .
echo 6 $(( a *= 3 )) .
echo 7 $(( a /= 5 )) .
echo 8 $(( a %= 2 )) .
echo 9 $(( a += 9 )) .
echo 10 $(( a -= 4 )) .
echo 11 $(( a <<= 1 )) .
echo 12 $(( a >>= 1 )) .
echo 13 $(( a &= 4 )) .
echo 14 $(( a ^= a )) .
echo 15 $(( a |= 5 )) .
echo 16 $(( 5 << 1 )) , $(( 5 << 0 )) .
echo 17 $(( 5 >> 1 )) , $(( 5 >> 0 )) .
echo 18 $(( 5 <= 6 )) , $(( 5 <= 5 )) , $(( 5 <= 4 )) .
echo 19 $(( 5 >= 6 )) , $(( 5 >= 5 )) , $(( 5 >= 4 )) .
echo 20 $(( 5 < 6 )) , $(( 5 < 5 )) , $(( 5 < 4 )) .
echo 21 $(( 5 > 6 )) , $(( 5 > 5 )) , $(( 5 > 4 )) .
echo 22 $(( 0 && 0 )) , $(( 0 && 1 )) , $(( 1 && 0 )) , $(( 1 && 1 )) .
echo 23 $(( 0 || 0 )) , $(( 0 || 1 )) , $(( 1 || 0 )) , $(( 1 || 1 )) .
echo 24 $(( 5 * 3 )) , $(( 5 * 0 )) .
echo 25 $(( 7 / 2 )) .
echo 26 $(( 5 % 5 )) , $(( 5 % 4 )) , $(( 5 % 1 )) :
echo 27 $(( 5 + 2 )) , $(( 5 + 0 )) , $(( 5 + -2 )) .
echo 28 $(( 5 - 2 )) , $(( 5 - 0 )) , $(( 5 - -2 )) .
echo 29 $(( 6 & 4 )) , $(( 6 & 8 )) .
echo 30 $(( 4 ^ 2 )) , $(( 4 ^ 4 )) .
echo 31 $(( 4 | 2 )) , $(( 4 | 4 )) , $(( 4 | 0 )) .
echo 32 $(( 0 ? 1 : 2 )) , $(( 3 ? 4 : 5 )) .
echo 33 $(( 5 , 2 , 3 )) .
echo 34 $(( ~0 )) , $(( ~1 )) , $(( ~~1 )) , $(( ~~2 )) .
echo 35 $(( !0 )) , $(( !1 )) , $(( !!1 )) , $(( !!2 )) .
echo 36 $(( (5) )) .
expected-stdout:
1 5 .
2 6 , 6 , 7 .
3 6 , 6 , 5 .
4 1 , 0 .
5 0 , 1 .
6 15 .
7 3 .
8 1 .
9 10 .
10 6 .
11 12 .
12 6 .
13 4 .
14 0 .
15 5 .
16 10 , 5 .
17 2 , 5 .
18 1 , 1 , 0 .
19 0 , 1 , 1 .
20 1 , 0 , 0 .
21 0 , 0 , 1 .
22 0 , 0 , 0 , 1 .
23 0 , 1 , 1 , 1 .
24 15 , 0 .
25 3 .
26 0 , 1 , 0 :
27 7 , 5 , 3 .
28 3 , 5 , 7 .
29 4 , 0 .
30 6 , 0 .
31 6 , 4 , 4 .
32 2 , 4 .
33 3 .
34 -1 , -2 , 1 , 2 .
35 1 , 0 , 1 , 1 .
36 5 .
---
name: regression-68-nolksh
description:
Things POSIX/C arithmetics don’t guarantee
category: shell:legacy-no
stdin:
echo '1(26)' , $(( 5 % -1 )) , $(( 5 % -2 )) .
expected-stdout:
1(26) , 0 , 1 .
---
name: regression-69
description:
Check that all non-lksh arithmetic operators work as expected
category: shell:legacy-no
stdin:
a=5 b=0x80000005
echo 1 $(( a ^<= 1 )) , $(( b ^<= 1 )) .
echo 2 $(( a ^>= 2 )) , $(( b ^>= 2 )) .
echo 3 $(( 5 ^< 1 )) , $(( 5 ^< 0 )) .
echo 4 $(( 5 ^> 1 )) , $((# 5 ^> 1 )) .
echo 5 $(( 5 ^> 0 )) , $((# 5 ^> 0 )) .
expected-stdout:
1 10 , 11 .
2 -2147483646 , -1073741822 .
3 10 , 5 .
4 -2147483646 , 2147483650 .
5 5 , 5 .
---
name: export-1
description:
Check allexport works, basic
stdin:
qa=1
set -A qb 2 3
set -a
qc=4
set -A qd 5 6
export -p | grep '^export q'
expected-stdout:
export qc=4
export qd[0]=5
export qd[1]=6
---
name: readonly-0
description:
Ensure readonly is honoured for assignments and unset
stdin:
"$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
echo =
"$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
echo =
"$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
expected-stdout:
0 x .
=
aborted, 2
=
1 x .
expected-stderr-pattern:
/read-only/
---
name: readonly-1
description:
https://www.austingroupbugs.net/view.php?id=367 for export
stdin:
"$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
expected-stdout:
aborted, 2
expected-stderr-pattern:
/read-only/
---
name: readonly-2a
description:
Check that getopts works as intended, for readonly-2b to be valid
stdin:
"$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
expected-stdout:
0 a .
1 ? .
---
name: readonly-2b
description:
https://www.austingroupbugs.net/view.php?id=367 for getopts
stdin:
"$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
expected-stdout:
2 .
expected-stderr-pattern:
/read-only/
---
name: readonly-3
description:
https://www.austingroupbugs.net/view.php?id=367 for read
stdin:
echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
expected-stdout:
0 x .
2 .
expected-stderr-pattern:
/read-only/
---
name: readonly-4
description:
Do not permit bypassing readonly for first array item
stdin:
set -A arr -- foo bar
readonly arr
arr=baz
print -r -- "${arr[@]}"
expected-exit: e != 0
expected-stderr-pattern:
/read[ -]?only/
---
name: readonly-5
description:
Ensure readonly is idempotent
stdin:
readonly x=1
readonly x
---
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
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.
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 its environment correctly
stdin:
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
done >env; chmod +x env; PATH=.$PATHSEP$PATH
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:
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
done >env; chmod +x env; PATH=.$PATHSEP$PATH
env >bar1
FOO=bar exec; env >bar2
cmp -s bar1 bar2
---
name: exec-function-environment-1
description:
Check assignments in function calls and whether they affect
the current execution environment
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-
x-3- z-
---
name: exec-execs
description:
Ensure that exec never returns
need-ctty: yes
env-setup: !ENV=./envf!
file-setup: file 644 "envf"
PS1=X
arguments: !-i!
stdin:
oldPATH=$PATH
PATH=$PWD
exec bla
PATH=$oldPATH
echo fail
expected-stderr-pattern:
/X+.*: bla: (?:inaccessible or )?not found\n/
expected-exit: 127
---
name: exec-execs-not-in-posix
description:
Ensure that exec returns in POSIX mode
need-ctty: yes
env-setup: !ENV=./envf!
file-setup: file 644 "envf"
PS1=X
arguments: !-i!-o!posix!
stdin:
oldPATH=$PATH
PATH=$PWD
exec bla; echo fail=$?
echo ok=$?
expected-stdout:
ok=127
expected-stderr-pattern:
/X+.*: bla: (?:inaccessible or )?not found\n/
---
name: exec-modern
description:
Check that exec can execute any command that makes it
through syntax and parser
stdin:
echo '#!'"$__progname" >f
echo 'echo >&3 FAIL' >>f
echo '#!'"$__progname" >lq
echo 'echo tf' >>lq
chmod +x lq f
PATH=$PWD
exec 3>&2 2>&1
foo() { echo two; }
echo =1
(exec echo one; ./f)
echo =2
(exec foo; ./f)
echo =3
(exec ls; ./f)
echo =4
(exec lq; ./f)
expected-stdout-pattern:
/=1\none\n=2\ntwo\n=3\n.*: ls: (?:inaccessible or )?not found\n=4\ntf\n/
---
name: exec-ksh88
description:
Check that exec only executes after a PATH search
(POSIX Issue 8 uses utility ipv command for the synopsis)
cf. https://www.austingroupbugs.net/view.php?id=1157
arguments: !-o!posix!
stdin:
echo '#!'"$__progname" >f
echo 'echo >&3 FAIL' >>f
echo '#!'"$__progname" >lq
echo 'echo tf' >>lq
chmod +x lq f
PATH=$PWD
exec 3>&2 2>&1
foo() { echo two; }
echo =1
(exec echo one; ./f)
echo =2
(exec foo; ./f)
echo =3
(exec ls; ./f)
echo =4
(exec lq; ./f)
expected-stdout-pattern:
/=1\n.*: echo: (?:inaccessible or )?not found\n=2\n.*: foo: (?:inaccessible or )?not found\n=3\n.*: ls: (?:inaccessible or )?not found\n=4\ntf\n/
---
name: xxx-what-do-you-call-this-1
stdin:
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}
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: xxx-variable-syntax-4
description:
Not all kinds of trims are currently impossible, check those who do
stdin:
foo() {
echo "<$*> X${*:+ }X"
}
foo a b
foo "" c
foo ""
foo "" ""
IFS=:
foo a b
foo "" c
foo ""
foo "" ""
IFS=
foo a b
foo "" c
foo ""
foo "" ""
expected-stdout:
<a b> X X
< c> X X
<> XX
< > X X
<a:b> X X
<:c> X X
<> XX
<:> X X
<ab> X X
<c> X X
<> XX
<> XX
---
name: xxx-substitution-eval-order
description:
Check order of evaluation of expressions
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-substitution-eval-order-2
description:
Check some corner cases
stdin:
unset var
i=42
: ${var+${q[i=777]}} required to be lazy by POSIX
echo 1=$i
var=meow
i=42
: ${var+${q[i=777]}} eval since var is now set
echo 2=$i
unset var
i=42
: ${var#${q[i=777]}} pattern is needed even if var is empty
echo 3=$i
var=meow
i=42
: ${var#${q[i=777]}}
echo 4=$i
expected-stdout:
1=42
2=777
3=777
4=777
---
name: xxx-set-option-1
description:
Check option parsing in set
stdin:
set -vsA foo -- A 1 3 2
echo ${foo[*]}
expected-stderr:
echo ${foo[*]}
expected-stdout:
1 2 3 A
---
name: xxx-exec-1
description:
Check that exec exits for built-ins
need-ctty: yes
arguments: !-i!
stdin:
exec echo hi
echo still here
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 $?
need-ctty: yes
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
trap 'echo trap: $?' ERR
(exit 4)
echo exit: $?
expected-stdout:
blank: 1
subshell: 2
include: 3
trap: 4
exit: 4
---
name: xxx-stat-1
description:
Check that tests on files are consistent
(fails when run as root, unfortunately)
category: disabled
stdin:
mkdir a
echo x >a/b
test -e a/b; echo 1e $? .
test -f a/b; echo 1f $? .
chmod 0 a
test -e a/b; echo 2e $? .
test -f a/b; echo 2f $? .
chmod 700 a
test -e a/b; echo 3e $? .
test -f a/b; echo 3f $? .
expected-stdout:
1e 0 .
1f 0 .
2e 1 .
2f 1 .
3e 0 .
3f 0 .
---
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 omitted.
ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error.
stdin:
unset foo
x=
echo x${foo?$x}
expected-exit: 1
expected-stderr-pattern: !/not set/
---
name: xxx-param-subst-qmark-namespec
description:
Check special names are output correctly
stdin:
prgsub() {
sed \
-e "s^${__progname%.exe}\.*e*x*e*: PROG: " \
-e "s^[EW]: ${__progname%.exe}\.*e*x*e*: PROG: " \
-e 's/^qmark_foo: /E: &/' \
-e "s/^/$1: /g"
}
doit() {
"$__progname" -c "$@" >o1 2>o2
rv=$?
echo RETVAL: $rv
prgsub STDOUT <o1
prgsub STDERR <o2
}
doit 'echo ${1x}'
doit 'echo "${1x}"'
doit 'echo ${1?}'
doit 'echo ${19?}'
doit 'echo ${!:?}'
doit -u 'echo ${*:?}' qmark_foo ""
expected-stdout:
RETVAL: 1
STDERR: PROG: ${1x}: bad substitution
RETVAL: 1
STDERR: PROG: ${1x}: bad substitution
RETVAL: 1
STDERR: PROG: 1: parameter null or not set
RETVAL: 1
STDERR: PROG: 19: parameter null or not set
RETVAL: 1
STDERR: PROG: !: parameter null or not set
RETVAL: 1
STDERR: E: qmark_foo: ${*:?}: bad substitution
---
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~ ~
export e=~ f=d~
command command export g=~ h=d~
echo ". $e . $f ."
echo ". $g . $h ."
set -o posix
unset A e f g h
echo ${A=a=}~ b=~ c=d~ ~
export e=~ f=d~
command command export g=~ h=d~
echo ". $e . $f ."
echo ". $g . $h ."
expected-stdout:
a=/sweet b=/sweet c=d~ /sweet
. /sweet . d~ .
. /sweet . d~ .
a=~ b=~ c=d~ /sweet
. /sweet . d~ .
. /sweet . d~ .
---
name: tilde-expand-2
description:
Check tilde expansion works
env-setup: !HOME=/sweet!
stdin:
:>'c=a'
typeset c=[ab]
:>'d=a'
x=typeset; $x d=[ab]
echo "<$c>" "<$d>"
wd=$PWD
cd /
plus=$(print -r -- ~+)
minus=$(print -r -- ~-)
nix=$(print -r -- ~)
[[ $plus = / ]]; echo one $? .
[[ $minus = "$wd" ]]; echo two $? .
[[ $nix = /sweet ]]; echo nix $? .
expected-stdout:
<[ab]> <a>
one 0 .
two 0 .
nix 0 .
---
name: tilde-expand-3
description:
Check mostly Austin 351 stuff
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
set "1 b=2" "3 d=4"
export a=$1 \c=$2
showargs 1 "$a" "$b" "$c" "$d"
unset a b c d
HOME=/tmp
export \a=~ b=~
command export c=~
builtin export d=~
\\builtin export e=~
showargs 2 "$a" "$b" "$c" "$d" "$e" ksh
unset a b c d e
set -o posix
export \a=~ b=~
command export c=~
builtin export d=~
\\builtin export e=~
showargs 3 "$a" "$b" "$c" "$d" "$e" posix
unset a b c d e
set +o posix
export a=$1
showargs 4 "$a" "$b" ksh
unset a b
showargs 5 a=$1 ksh
export \a=$1
showargs 6 "$a" "$b" ksh
unset a b
set -o posix
export a=$1
showargs 7 "$a" "$b" posix
unset a b
showargs 8 a=$1 posix
export \a=$1
showargs 9 "$a" "$b" posix
unset a b
set +o posix
command echo 10 ksh a=~
command command export a=~
showargs 11 "$a"
unset a
set -o posix
command echo 12 posix a=~
command command export a=~
showargs 13 "$a"
unset a
# unspecified whether /tmp or ~
var=export; command $var a=~
showargs 14 "$a"
echo 'echo "<$foo>"' >bar
"$__progname" bar
var=foo
export $var=1
"$__progname" bar
export $var=~
"$__progname" bar
# unspecified
command -- export a=~
showargs 18 "$a"
set -A bla
typeset bla[1]=~:~
typeset -g gbl=~ g2=$1
local lcl=~ l2=$1
readonly ro=~ r2=$1
showargs 19 "${bla[1]}" a=~ "$gbl" "$lcl" "$ro" "$g2" "$l2" "$r2"
set +o posix
echo "20 some arbitrary stuff "=~
set -o posix
echo "21 some arbitrary stuff "=~
expected-stdout:
<1> <1 b=2> <> <3> <4> .
<2> </tmp> </tmp> </tmp> </tmp> </tmp> <ksh> .
<3> <~> </tmp> </tmp> <~> </tmp> <posix> .
<4> <1 b=2> <> <ksh> .
<5> <a=1> <b=2> <ksh> .
<6> <1> <2> <ksh> .
<7> <1 b=2> <> <posix> .
<8> <a=1> <b=2> <posix> .
<9> <1> <2> <posix> .
10 ksh a=/tmp
<11> </tmp> .
12 posix a=~
<13> </tmp> .
<14> <~> .
<>
<1>
<~>
<18> <~> .
<19> </tmp:/tmp> <a=~> </tmp> </tmp> </tmp> <1 b=2> <1 b=2> <1 b=2> .
20 some arbitrary stuff =/tmp
21 some arbitrary stuff =~
---
name: exit-err-1
description:
Check some "exit on error" conditions
stdin:
print '#!'"$__progname"'\nexec "$1"' >env
print '#!'"$__progname"'\nexit 1' >false
chmod +x env false
PATH=.$PATHSEP$PATH
set -ex
env false && echo something
echo END
expected-stdout:
END
expected-stderr:
+ env false
+ echo END
---
name: exit-err-2
description:
Check some "exit on error" edge conditions (POSIXly)
stdin:
print '#!'"$__progname"'\nexec "$1"' >env
print '#!'"$__progname"'\nexit 1' >false
print '#!'"$__progname"'\nexit 0' >true
chmod +x env false
PATH=.$PATHSEP$PATH
set -ex
if env true; then
env false && echo something
fi
echo END
expected-stdout:
END
expected-stderr:
+ env true
+ 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
trap 'echo ERR' ERR
set -e
cd /XXXXX 2>/dev/null
echo DONE
exit 0
expected-stdout:
ERR
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-err-7
description:
"set -e" regression (LP#1104543)
stdin:
set -e
bla() {
[ -x $PWD/nonexistant ] && $PWD/nonexistant
}
echo x
bla
echo y$?
expected-stdout:
x
expected-exit: 1
---
name: exit-err-8
description:
"set -e" regression (Debian #700526)
stdin:
set -e
_db_cmd() { return $1; }
db_input() { _db_cmd 30; }
db_go() { _db_cmd 0; }
db_input || :
db_go
exit 0
---
name: exit-err-9
description:
"set -e" versus bang pipelines
stdin:
set -e
! false | false
echo 1 ok
! false && false
echo 2 wrong
expected-stdout:
1 ok
expected-exit: 1
---
name: exit-err-10
description:
Debian #269067 (cf. regression-38 but with eval)
arguments: !-e!
stdin:
eval false || true
echo = $? .
expected-stdout:
= 0 .
---
name: exit-err-11
description:
Fix -e inside eval, from Martijn Dekker; expected-stdout from ksh93
stdin:
"$__progname" -c 'eval '\''echo ${-//[!eh]}; false; echo phantom e'\''; echo x$?'
echo = $?
"$__progname" -ec 'eval '\''echo ${-//[!eh]}; false; echo phantom e'\''; echo x$?'
echo = $?
expected-stdout:
h
phantom e
x0
= 0
eh
= 1
---
name: exit-enoent-1
description:
SUSv4 says that the shell should exit with 127 in some situations
stdin:
(echo; echo :) >x
"$__progname" ./x >/dev/null 2>&1; r=$?; echo 0 $r .
echo exit 42 >x
"$__progname" ./x >/dev/null 2>&1; r=$?; echo 42 $r .
rm -f x
"$__progname" ./x >/dev/null 2>&1; r=$?; echo notexist $r .
expected-stdout:
0 0 .
42 42 .
notexist 127 .
---
name: exit-enoent-2
description:
SUSv4 says that the shell should exit with 126 in some situations
# fails because x permissions handled wrong
category: !os:skyos,!noxperms
stdin:
(echo; echo :) >x
"$__progname" -c ./x >/dev/null 2>&1; r=$?; echo 0 $r .
echo exit 42 >x
"$__progname" -c ./x >/dev/null 2>&1; r=$?; echo 42 $r .
rm -f x
"$__progname" -c ./x >/dev/null 2>&1; r=$?; echo notexist $r .
expected-stdout:
0 126 .
42 126 .
notexist 127 .
---
name: exit-eval-1
description:
Check eval vs substitution exit codes (ksh93 alike)
stdin:
(exit 12)
eval $(false)
echo A $?
(exit 12)
eval ' $(false)'
echo B $?
(exit 12)
eval " $(false)"
echo C $?
(exit 12)
eval "eval $(false)"
echo D $?
(exit 12)
eval 'eval '"$(false)"
echo E $?
IFS="$IFS:"
(exit 12)
eval $(echo :; false)
echo F $?
echo -n "G "
(exit 12)
eval 'echo $?'
echo H $?
expected-stdout:
A 0
B 1
C 0
D 0
E 0
F 0
G 12
H 0
---
name: exit-stdout-1
description:
cf. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990265, Austin ML
# SIGPIPE seems hosed on BeOS and SkyOS
category: !os:beos,!os:skyos
stdin:
if test -c /dev/full && test -w /dev/full; then
if pwd >/dev/full 2>e; then
cat e
echo fail
else
echo pass
fi
else
echo skip
fi
case " $(echo $( (set -o posix) >/dev/null 2>&1 && set -o posix >/dev/null 2>&1; kill -l)) " in
(*' PIPE '*)
:>s
{ trap '' PIPE; sleep 1; pwd 2>e; echo $? >s; } | :
case x$(cat s) in
(x)
cat e
echo fail else ;;
(x0)
cat e
echo fail 0 ;;
(*)
echo pass ;;
esac
;;
(*)
echo skip ;;
esac
expected-stdout-pattern:
/^(pass|skip)\n(pass|skip)\n$/
---
name: exit-stdout-2
description:
same, except for external utility / direct builtin call
category: !os:beos,!os:skyos
stdin:
ln -s "$__progname" pwd 2>/dev/null || cp "$__progname" pwd
if test -c /dev/full && test -w /dev/full; then
if ./pwd >/dev/full 2>e; then
cat e
echo fail
else
echo pass
fi
else
echo skip
fi
case " $(echo $( (set -o posix) >/dev/null 2>&1 && set -o posix >/dev/null 2>&1; kill -l)) " in
(*' PIPE '*)
:>s
{ trap '' PIPE; sleep 1; ./pwd 2>e; echo $? >s; } | :
case x$(cat s) in
(x)
cat e
echo fail else ;;
(x0)
cat e
echo fail 0 ;;
(*)
echo pass ;;
esac
;;
(*)
echo skip ;;
esac
expected-stdout-pattern:
/^(pass|skip)\n(pass|skip)\n$/
---
name: exit-trap-1
description:
Check that "exit" with no arguments behaves SUSv4 conformant.
stdin:
trap 'echo hi; exit' EXIT
exit 9
expected-stdout:
hi
expected-exit: 9
---
name: exit-trap-2
description:
Check that ERR and EXIT traps are run just like GNU bash does.
ksh93 runs ERtrap after “parameter null or not set” (which mksh
used to do) but (bug) continues “and out”, exit 0, in +e eval-undef.
file-setup: file 644 "xe"
v=; unset v
trap 'echo EXtrap' EXIT
trap 'echo ERtrap' ERR
set $1
echo "and run $2"
eval $2
echo and out
file-setup: file 644 "xt"
v=; unset v
trap 'echo EXtrap' EXIT
trap 'echo ERtrap' ERR
set $1
echo 'and run true'
true
echo and out
file-setup: file 644 "xf"
v=; unset v
trap 'echo EXtrap' EXIT
trap 'echo ERtrap' ERR
set $1
echo 'and run false'
false
echo and out
file-setup: file 644 "xu"
v=; unset v
trap 'echo EXtrap' EXIT
trap 'echo ERtrap' ERR
set $1
echo 'and run ${v?}'
${v?}
echo and out
stdin:
runtest() {
rm -f rc
(
"$__progname" "$@"
echo $? >rc
) 2>&1 | sed \
-e 's/parameter not set/parameter null or not set/' \
-e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
-e 's/^x[etfu]: /E: &/' \
-e "s^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROG"
}
xe=-e
echo : $xe
runtest xe $xe true
echo = eval-true $(<rc) .
runtest xe $xe false
echo = eval-false $(<rc) .
runtest xe $xe '${v?}'
echo = eval-undef $(<rc) .
runtest xt $xe
echo = noeval-true $(<rc) .
runtest xf $xe
echo = noeval-false $(<rc) .
runtest xu $xe
echo = noeval-undef $(<rc) .
xe=+e
echo : $xe
runtest xe $xe true
echo = eval-true $(<rc) .
runtest xe $xe false
echo = eval-false $(<rc) .
runtest xe $xe '${v?}'
echo = eval-undef $(<rc) .
runtest xt $xe
echo = noeval-true $(<rc) .
runtest xf $xe
echo = noeval-false $(<rc) .
runtest xu $xe
echo = noeval-undef $(<rc) .
expected-stdout:
: -e
and run true
and out
EXtrap
= eval-true 0 .
and run false
ERtrap
EXtrap
= eval-false 1 .
and run ${v?}
E: xe: v: parameter null or not set
EXtrap
= eval-undef 1 .
and run true
and out
EXtrap
= noeval-true 0 .
and run false
ERtrap
EXtrap
= noeval-false 1 .
and run ${v?}
E: xu: v: parameter null or not set
EXtrap
= noeval-undef 1 .
: +e
and run true
and out
EXtrap
= eval-true 0 .
and run false
ERtrap
ERtrap
and out
EXtrap
= eval-false 0 .
and run ${v?}
E: xe: v: parameter null or not set
EXtrap
= eval-undef 1 .
and run true
and out
EXtrap
= noeval-true 0 .
and run false
ERtrap
and out
EXtrap
= noeval-false 0 .
and run ${v?}
E: xu: v: parameter null or not set
EXtrap
= noeval-undef 1 .
---
name: exit-trap-3
description:
Check that the EXIT trap is run in many places, Debian #910276
stdin:
fkt() {
trap -- "echo $1 >&2" EXIT
}
fkt shell_exit
$(fkt fn_exit)
$(trap -- "echo comsub_exit >&2" EXIT)
(trap -- "echo subshell_exit >&2" EXIT)
expected-stderr:
fn_exit
comsub_exit
subshell_exit
shell_exit
---
name: exit-trap-interactive
description:
Check that interactive shell doesn't exit via EXIT trap on syntax error
arguments: !-i!
stdin:
trap -- EXIT
echo Syntax error <
echo 'After error 1'
trap 'echo Exit trap' EXIT
echo Syntax error <
echo 'After error 2'
trap 'echo Exit trap' EXIT
exit
echo 'After exit'
expected-stdout:
After error 1
After error 2
Exit trap
expected-stderr-pattern:
/syntax error: unexpected 'newline'/
---
name: test-stlt-1
description:
Check that test also can handle string1 < string2 etc.
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-str-pattern
description:
Check that [[ x = $y ]] can take extglobs, like ksh93
stdin:
[[ -n $BASH_VERSION ]] && shopt -s extglob
function one {
n=$1 x=$2 y=$3 z=${4:-$3}
[[ $x = $y ]]; a=$?
[[ $x = "$y" ]]; b=$?
eval '[[ $x = '"$z"' ]]; c=$?'
eval '[[ $x = "'"$z"'" ]]; d=$?'
echo $n $a $b $c $d .
}
x='a\'
[[ $x = a\ ]]; echo 01 $? .
[[ $x = a\\ ]]; echo 02 $? .
one 03 'a\' 'a\' 'a\\'
one 04 'a\b' 'a\b'
one 05 'a\b' 'a\\b'
one 06 'foo' 'f+(o)'
one 07 'f+(o)' 'f+(o)'
one 08 'f+(o' 'f+(o' 'f+\(o'
one 09 foo 'f+(o' 'f+\(o'
one 10 abcde 'a\*e'
one 11 'a*e' 'a\*e'
one 12 'a\*e' 'a\*e'
echo extras:
x='f+(o'
z='f+(o'
eval '[[ $x = "'"$z"'" ]]; echo 14 $? "(08:4)" .'
x=foo
eval '[[ $x = "'"$z"'" ]]; echo 15 $? "(09:4)" .'
expected-stdout:
01 1 .
02 0 .
03 0 0 0 0 .
04 1 0 1 0 .
05 0 1 0 0 .
06 0 1 0 1 .
07 1 0 1 0 .
08 0 0 0 1 .
09 1 1 1 1 .
10 1 1 1 1 .
11 0 1 0 1 .
12 1 0 1 0 .
extras:
14 0 (08:4) .
15 1 (09:4) .
---
name: test-precedence-1
description:
Check a weird precedence case (and POSIX echo)
stdin:
test \( -f = -f \)
rv=$?
echo $rv
expected-stdout:
0
---
name: test-option-1
description:
Test the test -o operator
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: test-varset-1
description:
Test the test -v operator
stdin:
[[ -v a ]]
rv=$?; echo $((++i)) $rv
a=
[[ -v a ]]
rv=$?; echo $((++i)) $rv
unset a
[[ -v a ]]
rv=$?; echo $((++i)) $rv
a=x
[[ -v a ]]
rv=$?; echo $((++i)) $rv
nameref b=a
[[ -v b ]]
rv=$?; echo $((++i)) $rv
unset a
[[ -v b ]]
rv=$?; echo $((++i)) $rv
x[1]=y
[[ -v x ]]
rv=$?; echo $((++i)) $rv
[[ -v x[0] ]]
rv=$?; echo $((++i)) $rv
[[ -v x[1] ]]
rv=$?; echo $((++i)) $rv
[[ -v x[2] ]]
rv=$?; echo $((++i)) $rv
expected-stdout:
1 1
2 0
3 1
4 0
5 0
6 1
7 1
8 1
9 0
10 1
---
name: test-varset-2
description:
test -v works only on scalars
stdin:
[[ -v x[*] ]]
echo ok
expected-exit: e != 0
expected-stderr-pattern:
/unexpected '\*'/
---
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)
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: test-numeq
description:
Check numeric -eq works (R40d regression); spotted by Martijn Dekker
stdin:
tst() {
eval "$2"
case $? in
(0) echo yepp 0 \#"$*" ;;
(1) echo nope 1 \#"$*" ;;
(2) echo terr 2 \#"$*" ;;
(*) echo wtf\? $? \#"$*" ;;
esac
}
tst 1 'test 2 -eq 2'
tst 2 'test 2 -eq 2a'
tst 3 'test 2 -eq 3'
tst 4 'test 2 -ne 2'
tst 5 'test 2 -ne 2a'
tst 6 'test 2 -ne 3'
tst 7 'test \! 2 -eq 2'
tst 8 'test \! 2 -eq 2a'
tst 9 'test \! 2 -eq 3'
expected-stdout:
yepp 0 #1 test 2 -eq 2
terr 2 #2 test 2 -eq 2a
nope 1 #3 test 2 -eq 3
nope 1 #4 test 2 -ne 2
terr 2 #5 test 2 -ne 2a
yepp 0 #6 test 2 -ne 3
nope 1 #7 test \! 2 -eq 2
terr 2 #8 test \! 2 -eq 2a
yepp 0 #9 test \! 2 -eq 3
expected-stderr-pattern:
/bad number/
---
name: mkshrc-1
description:
Check that ~/.mkshrc works correctly.
Part 1: verify user environment is not read (internal)
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)
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)
file-setup: file 644 ".mkshrc"
FNORD=42
need-ctty: yes
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
file-setup: file 644 ".mkshrc"
FNORD=42
env-setup: !HOME=.!ENV=nonexistant!
stdin:
echo x $FNORD
expected-stdout:
x
---
name: sh-mode-1
description:
Check that sh mode turns braceexpand off
and that that works correctly
stdin:
set -o braceexpand
set +o sh
[[ -o sh ]] && echo sh
[[ -o !sh ]] && echo nosh
[[ -o braceexpand ]] && echo brex
[[ -o !braceexpand ]] && echo nobrex
echo {a,b,c}
set +o braceexpand
echo {a,b,c}
set -o braceexpand
echo {a,b,c}
set -o sh
echo {a,b,c}
[[ -o sh ]] && echo sh
[[ -o !sh ]] && echo nosh
[[ -o braceexpand ]] && echo brex
[[ -o !braceexpand ]] && echo nobrex
set -o braceexpand
echo {a,b,c}
[[ -o sh ]] && echo sh
[[ -o !sh ]] && echo nosh
[[ -o braceexpand ]] && echo brex
[[ -o !braceexpand ]] && echo nobrex
:
expected-stdout:
nosh
brex
a b c
{a,b,c}
a b c
{a,b,c}
sh
nobrex
a b c
sh
brex
---
name: sh-mode-1-exec-a
description:
Was part of sh-mode-1 but exclude where selftest-exec-a fails
or better fix that
category: !os:beos
stdin:
[[ $(exec -a -set "$__progname" -o) = *login+(' ')on* ]]; echo $?
expected-stdout:
0
---
name: sh-mode-2a
description:
Check that posix or sh mode is *not* automatically turned on
category: !binsh
stdin:
for shell in {,-}{,r}{,k,mk}sh {,-}{,R}{,K,MK}SH.EXE; do
ln -s "$__progname" ./$shell 2>/dev/null || cp "$__progname" ./$shell
print -- $shell $(./$shell +l -c '
[[ -o sh || -o posix ]] && echo sh
[[ -o !sh && -o !posix ]] && echo nosh
[[ -o restricted ]] && echo lim || echo ok
')
done
expected-stdout:
sh nosh ok
ksh nosh ok
mksh nosh ok
rsh nosh lim
rksh nosh lim
rmksh nosh lim
-sh nosh ok
-ksh nosh ok
-mksh nosh ok
-rsh nosh lim
-rksh nosh lim
-rmksh nosh lim
SH.EXE nosh ok
KSH.EXE nosh ok
MKSH.EXE nosh ok
RSH.EXE nosh lim
RKSH.EXE nosh lim
RMKSH.EXE nosh lim
-SH.EXE nosh ok
-KSH.EXE nosh ok
-MKSH.EXE nosh ok
-RSH.EXE nosh lim
-RKSH.EXE nosh lim
-RMKSH.EXE nosh lim
---
name: sh-mode-2b
description:
Check that posix or sh mode *is* automatically turned on
category: binsh
stdin:
for shell in {,-}{,r}{,k,mk}sh {,-}{,R}{,K,MK}SH.EXE; do
ln -s "$__progname" ./$shell 2>/dev/null || cp "$__progname" ./$shell
print -- $shell $(./$shell +l -c '
[[ -o sh || -o posix ]] && echo sh
[[ -o !sh && -o !posix ]] && echo nosh
[[ -o restricted ]] && echo lim || echo ok
')
done
expected-stdout:
sh sh ok
ksh nosh ok
mksh nosh ok
rsh sh lim
rksh nosh lim
rmksh nosh lim
-sh sh ok
-ksh nosh ok
-mksh nosh ok
-rsh sh lim
-rksh nosh lim
-rmksh nosh lim
SH.EXE sh ok
KSH.EXE nosh ok
MKSH.EXE nosh ok
RSH.EXE sh lim
RKSH.EXE nosh lim
RMKSH.EXE nosh lim
-SH.EXE sh ok
-KSH.EXE nosh ok
-MKSH.EXE nosh ok
-RSH.EXE sh lim
-RKSH.EXE nosh lim
-RMKSH.EXE nosh lim
---
name: sh-options
description:
Check that "set +o" DTRT per POSIX
stdin:
t() {
[[ -o vi ]]; a=$?
[[ -o pipefail ]]; b=$?
echo $((++i)) $a $b .
}
set -e
set -o vi
set +o pipefail
set +e
t
x=$(set +o)
set +o vi
set -o pipefail
t
eval "$x"
t
expected-stdout:
1 0 1 .
2 1 0 .
3 0 1 .
---
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: !nojsig
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: pipeline-3
description:
Check that PIPESTATUS does what it's supposed to
stdin:
echo 1 $PIPESTATUS .
echo 2 ${PIPESTATUS[0]} .
echo 3 ${PIPESTATUS[1]} .
(echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
echo 6 ${PIPESTATUS[0]} .
set | grep PIPESTATUS
echo 8 $(set | grep PIPESTATUS) .
expected-stdout:
1 0 .
2 0 .
3 .
x
5 42 , 12 , 12 , 23 , 42 , .
6 0 .
PIPESTATUS[0]=0
8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
---
name: pipeline-4
description:
Check that "set -o pipefail" does what it's supposed to
stdin:
echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
expected-stdout:
1 42 .
2 0 .
3 42 .
4 0 .
5 0 .
6 1 .
7 42 .
8 0 .
9 42 .
---
name: persist-history-1
description:
Check if persistent history saving works
category: !no-histfile
need-ctty: yes
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-1
description:
Check that typeset -g works correctly
stdin:
set -A arrfoo 65
foo() {
typeset -g -Uui16 arrfoo[*]
}
echo before ${arrfoo[0]} .
foo
echo after ${arrfoo[0]} .
set -A arrbar 65
bar() {
echo inside before ${arrbar[0]} .
arrbar[0]=97
echo inside changed ${arrbar[0]} .
typeset -g -Uui16 arrbar[*]
echo inside typeset ${arrbar[0]} .
arrbar[0]=48
echo inside changed ${arrbar[0]} .
}
echo before ${arrbar[0]} .
bar
echo after ${arrbar[0]} .
expected-stdout:
before 65 .
after 16#41 .
before 65 .
inside before 65 .
inside changed 97 .
inside typeset 16#61 .
inside changed 16#30 .
after 16#30 .
---
name: typeset-2
description:
Check that typeset -p on arrays works correctly
stdin:
set -A x -- a b c
echo =
typeset -p x
echo =
typeset -p x[1]
expected-stdout:
=
set -A x
typeset x[0]=a
typeset x[1]=b
typeset x[2]=c
=
typeset x[1]=b
---
name: typeset-padding-1
description:
Check if left/right justification works as per TFM
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
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: typeset-padding-3
description:
Check for a regression in which UTF-8 wasn’t left-padded right
stdin:
set -U
nl=$'\n'
typeset -L20 x='. ak'
typeset -R20 y='. ak'
print -r -- "<$x> (1$nl<12345678910 345678920$nl<$y> 1)"
typeset -L20 x='. aẞ'
typeset -R20 y='. aẞ'
print -r -- "<$x> (2$nl<12345678910 345678920$nl<$y> 2)"
expected-stdout:
<. ak > (1
<12345678910 345678920
< . ak> 1)
<. aẞ > (2
<12345678910 345678920
< . aẞ> 2)
---
name: typeset-unset
description:
Check that typeset -p correctly distinguishes unset and empty
stdin:
unset u
typeset -p u
echo 1 ${u-a} ${u:-b} .
x1=$(typeset -p u)
export u
typeset -p u
echo 2 ${u-a} ${u:-b} .
x2=$(typeset -p u)
u=
typeset -p u
echo 3 ${u-a} ${u:-b} .
x3=$(typeset -p u)
unset u
eval "$x1"
echo 4 ${u-a} ${u:-b} .
unset u
eval "$x2"
echo 5 ${u-a} ${u:-b} .
unset u
eval "$x3"
echo 6 ${u-a} ${u:-b} .
expected-stdout:
1 a b .
typeset -x u
2 a b .
typeset -x u=''
3 b .
4 a b .
5 a b .
6 b .
---
name: utf8bom-1
description:
Check that the UTF-8 Byte Order Mark is not ignored any more
# breaks on Mac OSX (HFS+ non-standard UTF-8 canonical decomposition)
category: !os:darwin,!shell:ebcdic-yes,!noweirdfilenames
stdin:
mkdir foo
print '#!/bin/sh\necho ohne' >foo/fnord
print '#!/bin/sh\necho mit' >foo/fnord
print 'fnord\nfnord\nfnord\nfnord' >foo/bar
print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
set -A anzahl -- foo/*
echo got ${#anzahl[*]} files
chmod +x foo/*
export PATH=$(pwd)/foo$PATHSEP$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:
got 4 files
mit
=
mit
ohne
mit
ohne
=
mit
ohne
mit
ohne
=
mit
ohne
mit
ohne
=
mit
ohne
mit
ohne
=
: mit
---
name: utf8opt-1
description:
Check that the utf8-mode flag *is* set at non-interactive startup
env-setup: !PS1=!PS2=!LC_CTYPE=@utflocale@!
stdin:
if [[ $- = *U* ]]; then
echo is set
else
echo is not set
fi
expected-stdout:
is set
---
name: utf8opt-2
description:
Check that the utf8-mode flag is set at interactive startup.
need-pass: no
info-pre: if your OS fails this, contact the mksh developer
category: !noutf8
need-ctty: yes
arguments: !-i!
env-setup: !PS1=!PS2=!LC_CTYPE=@utflocale@!
stdin:
if [[ $- = *U* ]]; then
echo is set
else
echo is not set
fi
expected-stdout:
is set
expected-stderr-pattern:
/(# )*/
---
name: utf8opt-3a
description:
Ensure ±U on the command line is honoured
(these two tests may pass falsely depending on CPPFLAGS)
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"
echo $((++i)) done
expected-stdout:
1 on
2 off
3 done
---
name: utf8opt-3b
description:
Ensure ±U on the command line is honoured, interactive shells
need-ctty: yes
stdin:
export i=0
code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
let i++; "$__progname" -U -ic "$code"
let i++; "$__progname" +U -ic "$code"
echo $((++i)) done
expected-stdout:
1 on
2 off
3 done
---
name: utf8bug-1
description:
Ensure trailing combining characters are not lost
stdin:
set -U
a=a
b=$'\u0301'
x=$a$b
print -r -- "<e$x>"
x=$a
x+=$b
print -r -- "<e$x>"
b=$'\u0301'b
x=$a
x+=$b
print -r -- "<e$x>"
expected-stdout:
<eá>
<eá>
<eáb>
---
name: aliases-1
description:
Check if built-in shell aliases are okay
stdin:
alias
typeset -f
expected-stdout:
autoload='\\builtin typeset -fu'
functions='\\builtin typeset -f'
hash='\\builtin alias -t'
history='\\builtin fc -l'
integer='\\builtin typeset -i'
local='\\builtin typeset'
login='\\builtin exec login'
nameref='\\builtin typeset -n'
nohup='nohup '
r='\\builtin fc -e -'
type='\\builtin whence -v'
---
name: aliases-2b
description:
Check if “set -o sh” does not influence built-in aliases
arguments: !-o!sh!
stdin:
alias
typeset -f
expected-stdout:
autoload='\\builtin typeset -fu'
functions='\\builtin typeset -f'
hash='\\builtin alias -t'
history='\\builtin fc -l'
integer='\\builtin typeset -i'
local='\\builtin typeset'
login='\\builtin exec login'
nameref='\\builtin typeset -n'
nohup='nohup '
r='\\builtin fc -e -'
type='\\builtin whence -v'
---
name: aliases-3b
description:
Check if running as sh does not influence built-in aliases
stdin:
cp "$__progname" sh
./sh -c 'alias; typeset -f'
rm -f sh
expected-stdout:
autoload='\\builtin typeset -fu'
functions='\\builtin typeset -f'
hash='\\builtin alias -t'
history='\\builtin fc -l'
integer='\\builtin typeset -i'
local='\\builtin typeset'
login='\\builtin exec login'
nameref='\\builtin typeset -n'
nohup='nohup '
r='\\builtin fc -e -'
type='\\builtin whence -v'
---
name: aliases-cmdline
description:
Check that aliases work from the command line (Debian #517009)
Note that due to the nature of the lexing process, defining
aliases in COMSUBs then immediately using them, and things
like 'alias foo=bar && foo', still fail.
stdin:
"$__progname" -c $'alias a="echo OK"\na'
expected-stdout:
OK
---
name: aliases-funcdef-1
description:
Check if POSIX functions take precedences over aliases
stdin:
alias foo='echo makro'
foo() {
echo funktion
}
foo
expected-stdout:
makro
---
name: aliases-funcdef-2
description:
Check if POSIX functions take precedences over aliases
stdin:
alias foo='echo makro'
foo () {
echo funktion
}
foo
expected-stdout:
makro
---
name: aliases-funcdef-3
description:
Check if aliases take precedences over Korn functions
stdin:
alias foo='echo makro'
function foo {
echo funktion
}
foo
expected-stdout:
makro
---
name: aliases-funcdef-4
description:
Functions should only take over if actually being defined
stdin:
alias local
:|| local() { :; }
alias local
expected-stdout:
local='\\builtin typeset'
local='\\builtin typeset'
---
name: arrays-1
description:
Check if Korn Shell arrays work as expected
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-2a
description:
Check if bash-style arrays work as expected
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-2b
description:
Check if bash-style arrays work as expected, with newlines
stdin:
print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
chmod +x pfp
test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
v="e f"
foo=(a
bc
d \$v "$v" '$v' g
)
./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
foo=(a\
bc
d \$v "$v" '$v' g
)
./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
foo=(a\
bc\\
d \$v "$v" '$v'
g)
./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
expected-stdout:
7|a|bc|d|$v|e f|$v|g|
7|a|bc|d|$v|e f|$v|g|
6|abc\|d|$v|e f|$v|g||
---
name: arrays-3
description:
Check if array bounds are uint32_t
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
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]}|"
# we don't want this at all:
# 5|a|$v|c d||$v|b|
set -A arr "[5]=meh"
echo "<${arr[0]}><${arr[5]}>"
expected-stdout:
5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b||
<[5]=meh><>
---
name: arrays-5
description:
Check if bash-style arrays with specified indices work as expected
(taken out temporarily to fix arrays-4; see also arrays-9a comment)
category: disabled
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[*]} .
# Check that we do not break this by globbing
:>b=blah
bleh=5
typeset -a arr
arr+=([bleh]=blah)
echo "<${arr[0]}><${arr[5]}>"
expected-stdout:
5|a|$v|c d||$v|b|
k= 128 129 130 .
v= foo bar baz .
<><blah>
---
name: arrays-6
description:
Check if we can get the array keys (indices) for indexed arrays,
Korn shell style
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
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: arz
!arz[0]: arz[0]
!arz[1]: arz[1]
!arz: arz
!arz[0]: arz[0]
!arz[1]: arz[1]
!arz: arz
!arz[0]: arz[0]
!arz[1]: arz[1]
---
name: arrays-8
description:
Check some behavioural rules for 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: arrays-9a
description:
Check that we can concatenate arrays
stdin:
unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
# unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
expected-stdout:
1 0 1 : bar baz .
2 0 1 2 : foo bar baz .
# 3 0 2 3 5 : bar foo baz quux .
---
name: arrays-9b
description:
Check that we can concatenate parameters too
stdin:
unset foo; foo=bar; foo+=baz; echo 1 $foo .
unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
expected-stdout:
1 barbaz .
2 16#a20 .
---
name: arrassign-basic
description:
Check basic whitespace conserving properties of wdarrassign
stdin:
a=($(echo a b))
b=($(echo "a b"))
c=("$(echo "a b")")
d=("$(echo a b)")
a+=($(echo c d))
b+=($(echo "c d"))
c+=("$(echo "c d")")
d+=("$(echo c d)")
echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
expected-stdout:
.a:a.b.c.d:
.b:a.b.c.d:
.c:a b.c d..:
.d:a b.c d..:
---
name: arrassign-eol
description:
Commands after array assignments are not permitted
stdin:
foo=(a b) env
expected-exit: e != 0
expected-stderr-pattern:
/syntax error: unexpected 'env'/
---
name: arrassign-fnc-none
description:
Check locality of array access inside a function
stdin:
function fn {
x+=(f)
echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
}
function rfn {
if [[ -n $BASH_VERSION ]]; then
y=()
else
set -A y
fi
y+=(f)
echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
}
x=(m m)
y=(m m)
echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
expected-stdout:
.f0:m.m..:
.fn:m.m.f.:
.f1:m.m.f.:
.fn:m.m.f.f:
.f2:m.m.f.f:
.rf0:m.m..:
.rfn:f...:
.rf1:f...:
.rfn:f...:
.rf2:f...:
---
name: arrassign-fnc-local
description:
Check locality of array access inside a function
with the bash/mksh/ksh93 local/typeset keyword
(note: ksh93 has no local; typeset works only in FKSH)
stdin:
function fn {
typeset x
x+=(f)
echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
}
function rfn {
if [[ -n $BASH_VERSION ]]; then
y=()
else
set -A y
fi
typeset y
y+=(f)
echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
}
function fnr {
typeset z
if [[ -n $BASH_VERSION ]]; then
z=()
else
set -A z
fi
z+=(f)
echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
}
x=(m m)
y=(m m)
z=(m m)
echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
fnr
echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
fnr
echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
expected-stdout:
.f0:m.m..:
.fn:f...:
.f1:m.m..:
.fn:f...:
.f2:m.m..:
.rf0:m.m..:
.rfn:f...:
.rf1:...:
.rfn:f...:
.rf2:...:
.f0r:m.m..:
.fnr:f...:
.f1r:m.m..:
.fnr:f...:
.f2r:m.m..:
---
name: arrassign-fnc-global
description:
Check locality of array access inside a function
with the bash4/mksh/yash/zsh typeset -g keyword
stdin:
function fn {
typeset -g x
x+=(f)
echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
}
function rfn {
set -A y
typeset -g y
y+=(f)
echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
}
function fnr {
typeset -g z
set -A z
z+=(f)
echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
}
x=(m m)
y=(m m)
z=(m m)
echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
fnr
echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
fnr
echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
expected-stdout:
.f0:m.m..:
.fn:m.m.f.:
.f1:m.m.f.:
.fn:m.m.f.f:
.f2:m.m.f.f:
.rf0:m.m..:
.rfn:f...:
.rf1:f...:
.rfn:f...:
.rf2:f...:
.f0r:m.m..:
.fnr:f...:
.f1r:f...:
.fnr:f...:
.f2r:f...:
---
name: strassign-fnc-none
description:
Check locality of string access inside a function
stdin:
function fn {
x+=f
echo ".fn:$x:"
}
function rfn {
y=
y+=f
echo ".rfn:$y:"
}
x=m
y=m
echo ".f0:$x:"
fn
echo ".f1:$x:"
fn
echo ".f2:$x:"
echo ".rf0:$y:"
rfn
echo ".rf1:$y:"
rfn
echo ".rf2:$y:"
expected-stdout:
.f0:m:
.fn:mf:
.f1:mf:
.fn:mff:
.f2:mff:
.rf0:m:
.rfn:f:
.rf1:f:
.rfn:f:
.rf2:f:
---
name: strassign-fnc-local
description:
Check locality of string access inside a function
with the bash/mksh/ksh93 local/typeset keyword
(note: ksh93 has no local; typeset works only in FKSH)
stdin:
function fn {
typeset x
x+=f
echo ".fn:$x:"
}
function rfn {
y=
typeset y
y+=f
echo ".rfn:$y:"
}
function fnr {
typeset z
z=
z+=f
echo ".fnr:$z:"
}
x=m
y=m
z=m
echo ".f0:$x:"
fn
echo ".f1:$x:"
fn
echo ".f2:$x:"
echo ".rf0:$y:"
rfn
echo ".rf1:$y:"
rfn
echo ".rf2:$y:"
echo ".f0r:$z:"
fnr
echo ".f1r:$z:"
fnr
echo ".f2r:$z:"
expected-stdout:
.f0:m:
.fn:f:
.f1:m:
.fn:f:
.f2:m:
.rf0:m:
.rfn:f:
.rf1::
.rfn:f:
.rf2::
.f0r:m:
.fnr:f:
.f1r:m:
.fnr:f:
.f2r:m:
---
name: strassign-fnc-global
description:
Check locality of string access inside a function
with the bash4/mksh/yash/zsh typeset -g keyword
stdin:
function fn {
typeset -g x
x+=f
echo ".fn:$x:"
}
function rfn {
y=
typeset -g y
y+=f
echo ".rfn:$y:"
}
function fnr {
typeset -g z
z=
z+=f
echo ".fnr:$z:"
}
x=m
y=m
z=m
echo ".f0:$x:"
fn
echo ".f1:$x:"
fn
echo ".f2:$x:"
echo ".rf0:$y:"
rfn
echo ".rf1:$y:"
rfn
echo ".rf2:$y:"
echo ".f0r:$z:"
fnr
echo ".f1r:$z:"
fnr
echo ".f2r:$z:"
expected-stdout:
.f0:m:
.fn:mf:
.f1:mf:
.fn:mff:
.f2:mff:
.rf0:m:
.rfn:f:
.rf1:f:
.rfn:f:
.rf2:f:
.f0r:m:
.fnr:f:
.f1r:f:
.fnr:f:
.f2r:f:
---
name: unset-fnc-local-ksh
description:
Check that “unset” removes a previous “local”
(ksh93 syntax compatible version); apparently,
there are shells which fail this?
stdin:
function f {
echo f0: $x
typeset x
echo f1: $x
x=fa
echo f2: $x
unset x
echo f3: $x
x=fb
echo f4: $x
}
x=o
echo before: $x
f
echo after: $x
expected-stdout:
before: o
f0: o
f1:
f2: fa
f3: o
f4: fb
after: fb
---
name: unset-fnc-local-sh
description:
Check that “unset” removes a previous “local”
(Debian Policy §10.4 sh version); apparently,
there are shells which fail this?
stdin:
f() {
echo f0: $x
local x
echo f1: $x
x=fa
echo f2: $x
unset x
echo f3: $x
x=fb
echo f4: $x
}
x=o
echo before: $x
f
echo after: $x
expected-stdout:
before: o
f0: o
f1:
f2: fa
f3: o
f4: fb
after: fb
---
name: varexpand-substr-1
description:
Check if bash-style substring expansion works
when using positive numerics
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
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:
Match bash5
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 q${x:${y:2:1}:2}q'
expected-stdout:
vcdefghix
wcdefghix
xcdefghix
zabcdefghix
qdeq
expected-stderr-pattern:
/x:}.*bad substitution/
---
name: varexpand-substr-4
description:
Check corner cases for substring expansion
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
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
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
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-special-hash
description:
Check special ${var@x} expansion for x=hash
category: !shell:ebcdic-yes
perl-setup: open XF,">xf" or die; print XF "a"x1000000 or die; close XF or die;
stdin:
typeset -i8 foo=10
bar=baz
unset baz
print ${foo@#} ${bar@#} ${baz@#} .
set -e
set -A vec -- '' a abc 'message digest' abcdefghijklmnopqrstuvwxyz \
abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq \
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 \
12345678901234567890123456789012345678901234567890123456789012345678901234567890 \
$(<xf)
print ${vec[0]@#} ${vec[1]@#} ${vec[2]@#} ${vec[3]@#} ${vec[4]@#} \
${vec[5]@#} ${vec[6]@#} ${vec[7]@#} ${vec[8]@#} .
expected-stdout:
D2F7C7B5 FE93FA63 03010102 .
03010102 4ACF470E 92FC2A8B E5030FFA ED69F029 9C0E532B C155BDD9 BE5117B7 2A9728CB .
---
name: varexpand-special-hash-ebcdic
description:
Check special ${var@x} expansion for x=hash
category: !shell:ebcdic-no
stdin:
typeset -i8 foo=10
bar=baz
unset baz
print ${foo@#} ${bar@#} ${baz@#} .
expected-stdout:
7819D62A E1FC0712 00000000 .
---
name: varexpand-special-quote
description:
Check special ${var@Q} expansion for quoted strings
stdin:
set +U
i=x
j=a\ b
k=$'c
d\xA0''e€f'
print -r -- "<i=$i j=$j k=$k>"
s="u=${i@Q} v=${j@Q} w=${k@Q}"
print -r -- "s=\"$s\""
eval "$s"
typeset -p u v w
set -o asis
typeset -p w
set -U
typeset -p w
expected-stdout:
<i=x j=a b k=c
de€f>
s="u=x v='a b' w=$'c\nde\202f'"
typeset u=x
typeset v='a b'
typeset w=$'c\nde\202f'
typeset w=$'c\nde€f'
typeset w=$'c\nd\240e€f'
---
name: varexpand-special-caret
description:
Check special ${var@^} expansion for quoted strings
stdin:
if (( 1#1 == 49 )); then
CSI=$'\x9B' # ISO-8859-1
else
CSI=$'\x3B' # EBCDIC
fi
s=$'a\cbc d\te f\c?g h'$CSI$'0mi j\u009B''0mk l^m\n'
set +U +o asis
# this works because check.t is iconv’d to EBCDIC copying to OS/390
print -r -- "raw <$s> ."
print -r -- "Ai <${s@^}> ."
set -o asis
print -r -- "Aa <${s@^}> ."
set -U +o asis
print -r -- "Ui <${s@^}> ."
set -o asis
print -r -- "Ua <${s@^}> ."
expected-stdout:
raw <ac d e fg h0mi j0mk l^m\n> .
Ai <a^Bc d^Ie f^?g h^![0mi j^![0mk l\^m\\n> .
Aa <a^Bc d^Ie f^?g h0mi j0mk l\^m\\n> .
Ui <a^Bc d^Ie f^?g h\x9B0mi j^+[0mk l\^m\\n> .
Ua <a^Bc d^Ie f^?g h\x9B0mi j^+[0mk l\^m\\n> .
---
name: varexpand-null-1
description:
Ensure empty strings expand emptily
stdin:
print s ${a} . ${b} S
print t ${a#?} . ${b%?} T
print r ${a=} . ${b/c/d} R
print q
print s "${a}" . "${b}" S
print t "${a#?}" . "${b%?}" T
print r "${a=}" . "${b/c/d}" R
expected-stdout:
s . S
t . T
r . R
q
s . S
t . T
r . R
---
name: varexpand-null-2
description:
Ensure empty strings, when quoted, are expanded as empty strings
stdin:
print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
chmod +x pfs
./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
echo .
expected-stdout:
<1> <> <2> <> <+> <> <3> <> <+> <> .
---
name: varexpand-null-3
description:
Ensure concatenating behaviour matches other shells
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
showargs 0 ""$@
x=; showargs 1 "$x"$@
set A; showargs 2 "${@:+}"
n() { echo "$#"; }
unset e
set -- a b
n """$@"
n "$@"
n "$@"""
n "$e""$@"
n "$@"
n "$@""$e"
set --
n """$@"
n "$@"
n "$@"""
n "$e""$@"
n "$@"
n "$@""$e"
expected-stdout:
<0> <> .
<1> <> .
<2> <> .
2
2
2
2
2
2
1
0
1
1
0
1
---
name: varexpand-funny-chars
description:
Check some characters
stdin:
x=$'<\x00>'; typeset -p x
x=$'<\x01>'; typeset -p x
x=$'<\u0000>'; typeset -p x
x=$'<\u0001>'; typeset -p x
expected-stdout:
typeset x='<'
typeset x=$'<\001>'
typeset x='<'
typeset x=$'<\001>'
---
name: print-funny-chars
description:
Check print builtin's capability to output designated characters
stdin:
{
print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
print '<\x00>'
print '<\x01>'
print '<\u0000>'
print '<\u0001>'
} | {
# integer-base-one-3Ar
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z5 hv=2147483647
dasc=
if read -arN -1 line; then
typeset -i1 line
i=0
while (( i < ${#line[*]} )); do
hv=${line[i++]}
if (( (pos & 15) == 0 )); then
(( pos )) && print -r -- "$dasc|"
print -n "${pos#16#} "
dasc=' |'
fi
print -n "${hv#16#} "
if (( (hv < 32) || (hv > 126) )); then
dasc=$dasc.
else
dasc=$dasc${line[i-1]#1#}
fi
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
fi
while (( pos & 15 )); do
print -n ' '
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
(( hv == 2147483647 )) || print -r -- "$dasc|"
}
expected-stdout:
00000000 3C 64 E4 DB C3 9B E2 82 - AC C3 9B 40 3E 0A 3C 00 |<d.........@>.<.|
00000010 3E 0A 3C 01 3E 0A 3C 00 - 3E 0A 3C 01 3E 0A |>.<.>.<.>.<.>.|
---
name: print-bksl-c
description:
Check print builtin's \c escape
stdin:
print '\ca'; print b
expected-stdout:
ab
---
name: print-cr
description:
Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
stdin:
echo '#!'"$__progname" >foo
cat >>foo <<-'EOF'
print -n -- '220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT\r\n220->> Bitte keine Werbung einwerfen! <<\r\r\n220 Who do you wanna pretend to be today'
print \?
EOF
chmod +x foo
echo "[$(./foo)]"
./foo | while IFS= read -r line; do
print -r -- "{$line}"
done
print -n -- '<220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT\r>\n<220->> Bitte keine Werbung einwerfen! <<\r\r>\n<220 Who do you wanna pretend to be today'
print -n \?
print \>
expected-stdout:
[220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
220->> Bitte keine Werbung einwerfen! <<
220 Who do you wanna pretend to be today?
]
{220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
}
{220->> Bitte keine Werbung einwerfen! <<
}
{220 Who do you wanna pretend to be today?
}
<220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
>
<220->> Bitte keine Werbung einwerfen! <<
>
<220 Who do you wanna pretend to be today?
>
---
name: print-crlf
description:
Check that CR+LF is shown and read as-is
category: shell:textmode-no
stdin:
cat >foo <<-'EOF'
x='bar
' #
echo .${#x} #
if test x"$KSH_VERSION" = x""; then #
printf '<%s>' "$x" #
else #
print -nr -- "<$x>" #
fi #
EOF
echo "[$("$__progname" foo)]"
"$__progname" foo | while IFS= read -r line; do
print -r -- "{$line}"
done
expected-stdout:
[.5
<bar
>]
{.5}
{<bar
}
---
name: print-crlf-textmode
description:
Check that CR+LF is treated as newline
category: shell:textmode-yes
stdin:
cat >foo <<-'EOF'
x='bar
' #
echo .${#x} #
if test x"$KSH_VERSION" = x""; then #
printf '<%s>' "$x" #
else #
print -nr -- "<$x>" #
fi #
EOF
echo "[$("$__progname" foo)]"
"$__progname" foo | while IFS= read -r line; do
print -r -- "{$line}"
done
expected-stdout:
[.4
<bar
>]
{.4}
{<bar}
---
name: print-lf
description:
Check that LF-only is shown and read as-is
stdin:
cat >foo <<-'EOF'
x='bar
' #
echo .${#x} #
if test x"$KSH_VERSION" = x""; then #
printf '<%s>' "$x" #
else #
print -nr -- "<$x>" #
fi #
EOF
echo "[$("$__progname" foo)]"
"$__progname" foo | while IFS= read -r line; do
print -r -- "{$line}"
done
expected-stdout:
[.4
<bar
>]
{.4}
{<bar}
---
name: print-nul-chars
description:
Check handling of NUL characters for print and COMSUB
stdin:
x=$(print '<\0>')
print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
${#x} "$x" '<\0>'
expected-stdout-pattern:
/^4 3 2 <> <\0>$/
---
name: print-array
description:
Check that print -A works as expected
stdin:
print -An 0x20AC 0xC3 0xBC 8#101
set -U
print -A 0x20AC 0xC3 0xBC 8#102
expected-stdout:
üA€Ã¼B
---
name: print-escapes
description:
Check backslash expansion by the print builtin
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' | {
# integer-base-one-3As
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z5 hv=2147483647
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 -r -- "$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
while (( pos & 15 )); do
print -n ' '
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
(( hv == 2147483647 )) || print -r -- "$dasc|"
}
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 55 5C 56 5C 57 5C |\Q\R\S\T \U\V\W\|
00000070 58 5C 59 5C 5A 5C 5B 5C - 5C 5D 5C 5E 5C 5F 5C 60 |X\Y\Z\[\\]\^\_\`|
00000080 07 08 20 20 5C 64 1B 0C - 5C 67 5C 68 5C 69 5C 6A |.. \d..\g\h\i\j|
00000090 5C 6B 5C 6C 5C 6D 0A 5C - 6F 5C 70 20 5C 71 0D 5C |\k\l\m.\o\p \q.\|
000000A0 73 09 5C 75 0B 5C 77 5C - 78 5C 79 5C 7A 5C 7B 5C |s.\u.\w\x\y\z\{\|
000000B0 7C 5C 7D 5C 7E 20 E2 82 - AC 64 20 EF BF BD 20 12 ||\}\~ ...d ... .|
000000C0 33 20 78 20 53 20 53 34 - 0A |3 x S S4.|
---
name: dollar-doublequoted-strings
description:
Check that a $ preceding "…" is ignored
stdin:
echo $"Localise me!"
cat <<<$"Me too!"
V=X
aol=aol
cat <<-$"aol"
I do not take a $V for a V!
aol
expected-stdout:
Localise me!
Me too!
I do not take a $V for a V!
---
name: dollar-quoted-strings
description:
Check backslash expansion by $'…' strings
stdin:
print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
chmod +x pfn
./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \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' | {
# integer-base-one-3As
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z5 hv=2147483647
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 -r -- "$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
while (( pos & 15 )); do
print -n ' '
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
(( hv == 2147483647 )) || print -r -- "$dasc|"
}
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 - 82 80 A6 0A 61 0A 62 0A |5...........a.b.|
---
name: dollar-quotes-in-heredocs-strings
description:
They are, however, not parsed in here documents, here strings
(outside of string delimiters) or regular strings, but in
parameter substitutions.
stdin:
cat <<EOF
dollar = strchr(s, '$'); /* ' */
foo " bar \" baz
EOF
cat <<$'a\tb'
a\tb
a b
cat <<<"dollar = strchr(s, '$'); /* ' */"
cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
x="dollar = strchr(s, '$'); /* ' */"
cat <<<"$x"
cat <<<$'a\E[0m\tb'
unset nl; print -r -- "x${nl:=$'\n'}y"
echo "1 foo\"bar"
# cf & HEREDOC
cat <<EOF
2 foo\"bar
EOF
# probably never reached for here strings?
cat <<<"3 foo\"bar"
cat <<<"4 foo\\\"bar"
cat <<<'5 foo\"bar'
# old scripts use this (e.g. ncurses)
echo "^$"
# make sure this works, outside of quotes
cat <<<'7'$'\t''.'
expected-stdout:
dollar = strchr(s, '$'); /* ' */
foo " bar \" baz
a\tb
dollar = strchr(s, '$'); /* ' */
dollar = strchr(s, '$'); /* ' */
dollar = strchr(s, '$'); /* ' */
a[0m b
x
y
1 foo"bar
2 foo\"bar
3 foo"bar
4 foo\"bar
5 foo\"bar
^$
7 .
---
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:
/\.: missing argument.*\n.*source: missing argument/
---
name: dot-errorlevel
description:
Ensure dot resets $?
stdin:
:>dotfile
(exit 42)
. ./dotfile
echo 1 $? .
expected-stdout:
1 0 .
---
name: dot-args
description:
Ensure dot can take arguments
file-setup: file 644 "t"
print -r -- "$#,${1-},${2-},${3-}"
stdin:
"$__progname" -c '. ./t a b'
"$__progname" -c 'source t c d'
expected-stdout:
2,a,b,
2,c,d,
---
name: alias-function-no-conflict
description:
make aliases not conflict with function definitions
stdin:
# POSIX function can be defined, but alias overrides it
alias foo='echo bar'
foo
foo() {
echo baz
}
foo
unset -f foo
foo 2>/dev/null || echo rab
# alias overrides ksh function
alias korn='echo bar'
korn
function korn {
echo baz
}
korn
# alias temporarily overrides POSIX function
bla() {
echo bfn
}
bla
alias bla='echo bal'
bla
unalias bla
bla
expected-stdout:
bar
bar
bar
bar
bar
bfn
bal
bfn
---
name: bash-function-parens
description:
ensure the keyword function is ignored when preceding
POSIX style function declarations (bashism)
stdin:
mk() {
echo '#!'"$__progname"
echo "$1 {"
echo ' echo "bar='\''$0'\'\"
echo '}'
print -r -- "${2:-foo}"
}
mk 'function foo' >f-korn
mk 'foo ()' >f-dash
mk 'function foo ()' >f-bash
print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
chmod +x f-*
u=$(./f-argh)
x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
expected-stdout:
korn: bar='foo'
dash: bar='./f-dash'
bash: bar='./f-bash'
---
name: extfunc-1
description:
check that extended mksh functions are handled (beta)
stdin:
function () one {
echo "one,$#,$*."
}
# line 4 (next is 5)
function (x) two {
echo "two($x),$#,$*."
}
i=7
function (
a
b=$((++i))
c=
) three {
echo "three($i|$a,$b,$c),$#,$*."
}
one
one ii
# line 18 (next is 19)
two 2>tf
two ii $?
[[ $(<tf) = *'[19]: missing argument'* ]] && echo twopass || echo twofail
echo threebefore=$i
three eins zwo drei vier
echo threemid=$i
three allein
echo threeafter=$i
# line 27 (next is 28)
(PS4='<$LINENO>'; set -x; two miau) 2>tf
[[ $(<tf) = $'<28>two miau\n<5>local x=miau ; shift 1\n'* ]] && echo lastpass || echo lastfail
HOME=/etc
function (v=~/fsta* w="~/fsta*") four {
echo "four($v)($w),$#,$*."
}
four
expected-stdout:
one,0,.
one,1,ii.
two(ii),1,2.
twopass
threebefore=7
three(7|eins,zwo,drei),1,vier.
threemid=7
three(8|allein,8,),0,.
threeafter=8
two(miau),0,.
lastpass
four(/etc/fsta*)(~/fsta*),0,.
---
name: integer-base-one-1
description:
check if the use of fake integer base 1 works
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
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
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
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
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
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
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
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
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
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
stdin:
set -U
typeset -i16 x=1#
echo /$x/ # non-minimalistic
expected-stderr-pattern:
/1#: unexpected ''/
expected-exit: e != 0
---
name: integer-base-one-3As
description:
some sample code for hexdumping
not NUL safe; input lines must be NL terminated
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 '\0z'
} | {
# integer-base-one-3As
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z5 hv=2147483647
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 -r -- "$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
while (( pos & 15 )); do
print -n ' '
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
(( hv == 2147483647 )) || print -r -- "$dasc|"
}
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 7A 0A - |.z.|
---
name: integer-base-one-3Ws
description:
some sample code for hexdumping UCS-2
not NUL safe; input lines must be NL terminated
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
print '\0z' # embedded NUL
} | {
# integer-base-one-3Ws
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}
let hv=wc
if (( (wc < 32) || \
((wc > 126) && (wc < 160)) )); then
dch=.
elif (( (wc & ~0x7F) == 0xEF80 )); then
dch=�
# OPTU-8 value mapping, to keep test
#(( hv = 0xEF80 | (hv & 0x7F) ))
else
dch=${wc#1#}
fi
if (( (pos & 7) == 7 )); then
dasc=$dasc$dch
dch=
elif (( (pos & 7) == 0 )); then
(( pos )) && print -r -- "$dasc|"
print -n "${pos#16#} "
dasc=' |'
fi
print -n "${hv#16#} "
(( (pos++ & 7) == 3 )) && \
print -n -- '- '
dasc=$dasc$dch
done
done
while (( pos & 7 )); do
print -n ' '
(( (pos++ & 7) == 3 )) && print -n -- '- '
done
(( hv == 2147483647 )) || print -r -- "$dasc|"
}
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 007A 000A |����.z.|
---
name: integer-base-one-3Ar
description:
some sample code for hexdumping; NUL and binary safe
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 '\0z'
} | {
# integer-base-one-3Ar
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z5 hv=2147483647
dasc=
if read -arN -1 line; then
typeset -i1 line
i=0
while (( i < ${#line[*]} )); do
hv=${line[i++]}
if (( (pos & 15) == 0 )); then
(( pos )) && print -r -- "$dasc|"
print -n "${pos#16#} "
dasc=' |'
fi
print -n "${hv#16#} "
if (( (hv < 32) || (hv > 126) )); then
dasc=$dasc.
else
dasc=$dasc${line[i-1]#1#}
fi
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
fi
while (( pos & 15 )); do
print -n ' '
(( (pos++ & 15) == 7 )) && print -n -- '- '
done
(( hv == 2147483647 )) || print -r -- "$dasc|"
}
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 00 7A 0A - |..z.|
---
name: integer-base-one-3Wr
description:
some sample code for hexdumping UCS-2; NUL and binary safe
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
print '\0z' # embedded NUL
} | {
# integer-base-one-3Wr
typeset -Uui16 -Z11 pos=0
typeset -Uui16 -Z7 hv=2147483647
dasc=
if read -arN -1 line; then
typeset -i1 line
i=0
while (( i < ${#line[*]} )); do
hv=${line[i++]}
if (( (hv < 32) || \
((hv > 126) && (hv < 160)) )); then
dch=.
elif (( (hv & ~0x7F) == 0xEF80 )); then
dch=�
# OPTU-8 value mapping, to keep test
#(( hv = 0xEF80 | (hv & 0x7F) ))
else
dch=${line[i-1]#1#}
fi
if (( (pos & 7) == 7 )); then
dasc=$dasc$dch
dch=
elif (( (pos & 7) == 0 )); then
(( pos )) && print -r -- "$dasc|"
print -n "${pos#16#} "
dasc=' |'
fi
print -n "${hv#16#} "
(( (pos++ & 7) == 3 )) && \
print -n -- '- '
dasc=$dasc$dch
done
fi
while (( pos & 7 )); do
print -n ' '
(( (pos++ & 7) == 3 )) && print -n -- '- '
done
(( hv == 2147483647 )) || print -r -- "$dasc|"
}
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 0000 007A 000A |����..z.|
---
name: integer-base-one-4
description:
Check if ksh93-style base-one integers work
category: !smksh
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: integer-base-one-5A
description:
Check to see that we’re NUL and UCS safe
category: !shell:ebcdic-yes
stdin:
set +U
print 'a\0b\xfdz' >x
read -a y <x
set -U
typeset -Uui16 y
print ${y[*]} .
expected-stdout:
16#61 16#0 16#62 16#FD 16#7A .
---
name: integer-base-one-5E
description:
Check to see that we’re NUL and UCS safe
category: !shell:ebcdic-no
stdin:
set +U
print 'a\0b\xfdz' >x
read -a y <x
set -U
typeset -Uui16 y
print ${y[*]} .
expected-stdout:
16#81 16#0 16#82 16#FD 16#A9 .
---
name: integer-base-one-5W
description:
Check to see that we’re NUL and UCS safe
stdin:
set -U
print 'a\0b€c' >x
read -a y <x
set +U
typeset -Uui16 y
print ${y[*]} .
expected-stdout:
16#61 16#0 16#62 16#20AC 16#63 .
---
name: ulimit-1
description:
Check that ulimit as used in dot.mksh works or is stubbed
stdin:
ulimit -c 0
---
name: ulimit-2
description:
Check if we can use a specific syntax idiom for ulimit
XXX Haiku works, but only for -n and -V
category: !os:haiku,!os:syllable
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: ulimit-3
description:
Check that there are no duplicate limits (if this fails,
immediately contact with system information the developers)
stdin:
[[ -z $(set | grep ^opt) ]]; mis=$?
set | grep ^opt | sed 's/^/unexpectedly set in environment: /'
opta='<used for showing all limits>'
optH='<used to set hard limits>'
optS='<used to set soft limits>'
ulimit -a >tmpf
set -o noglob
while IFS= read -r line; do
x=${line:1:1}
if [[ -z $x || ${#x}/${%x} != 1/1 ]]; then
print -r -- "weird line: $line"
(( mis |= 1 ))
continue
fi
set -- $line
nameref v=opt$x
if [[ -n $v ]]; then
print -r -- "duplicate -$x \"$2\" already seen as \"$v\""
(( mis |= 2 ))
fi
v=$2
done <tmpf
if (( mis & 2 )); then
echo failed
elif (( mis & 1 )); then
echo inconclusive
else
echo done
fi
expected-stdout:
done
---
name: redir-1
description:
Check some of the most basic invariants of I/O redirection
stdin:
i=0
function d {
print o$i.
print -u2 e$((i++)).
}
d >a 2>b
echo =1=
cat a
echo =2=
cat b
echo =3=
d 2>&1 >c
echo =4=
cat c
echo =5=
expected-stdout:
=1=
o0.
=2=
e0.
=3=
e1.
=4=
o1.
=5=
---
name: bashiop-1
description:
Check if GNU bash-like I/O redirection works
Part 1: this is also supported by GNU bash
stdin:
exec 3>&1
function threeout {
echo ras
echo dwa >&2
echo tri >&3
}
threeout &>foo
echo === "$("$__progname" -c "echo $(: &>/dev/null) ok")"
cat foo
expected-stdout:
tri
=== ok
ras
dwa
---
name: bashiop-2a
description:
Check if GNU bash-like I/O redirection works
Part 2: this is *not* supported by GNU bash
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
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
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
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: /.*: foo: (create: |cannot overwrite existing file).*/
---
name: bashiop-3b
description:
Check if GNU bash-like I/O redirection fails correctly
Part 2: this is *not* supported by GNU bash
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
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: bashiop-5
description:
Check if GNU bash-like I/O redirection is only supported
in !POSIX !sh mode as it breaks existing scripts' syntax
stdin:
:>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
:>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
:>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
expected-stdout:
1 = foo echo bar .
2 = bar .
3 = bar .
---
name: oksh-eval
description:
Check expansions.
stdin:
a=
for n in ${a#*=}; do echo 1hu ${n} .; done
for n in "${a#*=}"; do echo 1hq ${n} .; done
for n in ${a##*=}; do echo 2hu ${n} .; done
for n in "${a##*=}"; do echo 2hq ${n} .; done
for n in ${a%=*}; do echo 1pu ${n} .; done
for n in "${a%=*}"; do echo 1pq ${n} .; done
for n in ${a%%=*}; do echo 2pu ${n} .; done
for n in "${a%%=*}"; do echo 2pq ${n} .; done
expected-stdout:
1hq .
2hq .
1pq .
2pq .
---
name: oksh-and-list-error-1
description:
Test exit status of rightmost element in 2 element && list in -e mode
stdin:
true && false
echo "should not print"
arguments: !-e!
expected-exit: e != 0
---
name: oksh-and-list-error-2
description:
Test exit status of rightmost element in 3 element && list in -e mode
stdin:
true && true && false
echo "should not print"
arguments: !-e!
expected-exit: e != 0
---
name: oksh-or-list-error-1
description:
Test exit status of || list in -e mode
stdin:
false || false
echo "should not print"
arguments: !-e!
expected-exit: e != 0
---
name: oksh-longline-crash
description:
This used to cause a core dump
stdin:
ulimit -c 0
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-seterror-1
description:
The -e flag should be ignored when executing a compound list
followed by an if statement.
stdin:
if true; then false && false; fi
true
arguments: !-e!
expected-exit: e == 0
---
name: oksh-seterror-2
description:
The -e flag should be ignored when executing a compound list
followed by an if statement.
stdin:
if true; then if true; then false && false; fi; fi
true
arguments: !-e!
expected-exit: e == 0
---
name: oksh-seterror-3
description:
The -e flag should be ignored when executing a compound list
followed by an elif statement.
stdin:
if true; then :; elif true; then false && false; fi
arguments: !-e!
expected-exit: e == 0
---
name: oksh-seterror-4
description:
The -e flag should be ignored when executing a pipeline
beginning with '!'
stdin:
for i in 1 2 3
do
false && false
true || false
done
arguments: !-e!
expected-exit: e == 0
---
name: oksh-seterror-5
description:
The -e flag should be ignored when executing a pipeline
beginning with '!'
stdin:
! true | false
true
arguments: !-e!
expected-exit: e == 0
---
name: oksh-seterror-6
description:
When trapping ERR and EXIT, both traps should run in -e mode
when an error occurs.
stdin:
trap 'echo EXIT' EXIT
trap 'echo ERR' ERR
set -e
false
echo DONE
exit 0
arguments: !-e!
expected-exit: e != 0
expected-stdout:
ERR
EXIT
---
name: oksh-seterror-7
description:
The -e flag within a command substitution should be honored
stdin:
echo $( set -e; false; echo foo )
arguments: !-e!
expected-stdout:
---
name: oksh-input-comsub
description:
A command substitution using input redirection should exit with
failure if the input file does not exist.
stdin:
var=$(< non-existent)
expected-exit: e != 0
expected-stderr-pattern: /non-existent/
---
name: oksh-empty-for-list
description:
A for list which expands to zero items should not execute the body.
stdin:
set foo bar baz ; for out in ; do echo $out ; done
---
name: for-without-list
description:
LP#2002250
stdin:
set -- a b
for x
do
echo $x
shift $#
done
expected-stdout:
a
b
---
name: oksh-varfunction-mod1
description:
(Inspired by PR 2450 on OpenBSD.) 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, (new) also not. 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.
stdin:
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
done >env; chmod +x env; PATH=.$PATHSEP$PATH
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 != x ]; 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 != xbarbar ]; then
exit 1
fi
---
name: fd-cloexec-1
description:
Verify that file descriptors > 2 are private for Korn shells
AT&T ksh93 does this still, which means we must keep it as well
# broken on Xenix and BeOS
category: !os:beos,!os:sco_xenix
stdin:
cat >cld <<-EOF
#!$__perlname
open(FH, ">&9") or die "E: open \$!";
syswrite(FH, "Fowl\\n", 5) or die "E: write \$!";
EOF
chmod +x cld
exec 9>&1
./cld
expected-exit: e != 0
expected-stderr-pattern:
/E: open /
---
name: fd-cloexec-2
description:
Verify that file descriptors > 2 are not private for POSIX shells
See Debian Bug #154540, Closes: #499139
category: !os:beos,!os:sco_xenix
stdin:
cat >cld <<-EOF
#!$__perlname
open(FH, ">&9") or die "E: open \$!";
syswrite(FH, "Fowl\\n", 5) or die "E: write \$!";
EOF
chmod +x cld
./cld 9>&2
echo >&2 =
test -n "$POSH_VERSION" || set -o posix
exec 9>&1
./cld
expected-stdout:
Fowl
expected-stderr:
Fowl
=
---
name: fd-cloexec-3
description:
Another check for close-on-exec
stdin:
print '#!'"$__progname" >ts
cat >>ts <<'EOF'
s=ERR
read -rN-1 -u$1 s 2>/dev/null; e=$?
print -r -- "($1, $((!e)), $s)"
EOF
chmod +x ts
print foo >tx
runtest() {
s=$1; shift
print -r -- $("$__progname" "$@" -c "$s") "$@" .
}
runtest 'exec 3<tx; ./ts 3 3<&3; ./ts 3'
runtest 'exec 3<tx; ./ts 3 3<&3; ./ts 3' -o posix
runtest 'exec 3<tx; ./ts 3 3<&3; ./ts 3' -o sh
runtest 'exec 3<tx; ./ts 4 4<&3; ./ts 4 4<&3'
runtest 'exec 3<tx; ./ts 3 3<&3; ./ts 3 3<&3'
expected-stdout:
(3, 1, foo) (3, 0, ERR) .
(3, 1, foo) (3, 1, ) -o posix .
(3, 1, foo) (3, 1, ) -o sh .
(4, 1, foo) (4, 1, ) .
(3, 1, foo) (3, 1, ) .
---
name: comsub-1a
description:
COMSUB are now parsed recursively, so this works
see also regression-6: matching parenthesēs bug
Fails on: pdksh bash2 bash3 zsh
Passes on: bash4 ksh93 mksh(20110313+)
stdin:
echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
expected-stdout:
1 yes .
2 yes .
3 234 .
4 678 .
5 1 .
6 1 .
---
name: comsub-1b
description:
COMSUB are now parsed recursively, so this works
Fails on: pdksh bash2 bash3 bash4 zsh
Passes on: ksh93 mksh(20110313+)
stdin:
echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
(( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
(( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
expected-stdout:
1 11 .
2 21 .
3 1 .
4 1 .
5 11 .
6 21 .
---
name: comsub-2
description:
RedHat BZ#496791 – another case of missing recursion
in parsing COMSUB expressions
Fails on: pdksh bash2 bash3¹ bash4¹ zsh
Passes on: ksh93 mksh(20110305+)
① bash[34] seem to choke on comment ending with backslash-newline
stdin:
# a comment with " ' \
x=$(
echo yes
# a comment with " ' \
)
echo $x
expected-stdout:
yes
---
name: comsub-3
description:
Extended test for COMSUB explaining why a recursive parser
is a must (a non-recursive parser cannot pass all three of
these test cases, especially the ‘#’ is difficult)
stdin:
print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.$PATHSEP$PATH
echo $(typeset -i10 x=16#20; echo $x)
echo $(typeset -Uui16 x=16#$(id -u)
) .
echo $(c=1; d=1
typeset -Uui16 a=36#foo; c=2
typeset -Uui16 b=36 #foo; d=2
echo $a $b $c $d)
expected-stdout:
32
.
16#4F68 16#24 2 1
---
name: comsub-4
description:
Check the tree dump functions for !MKSH_SMALL functionality
category: !smksh
stdin:
x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
typeset -f x
expected-stdout:
x() {
case $1 in
(u)
\echo x
;|
(*)
\echo $1
;;
esac
}
---
name: comsub-5
description:
Check COMSUB works with aliases (does not expand them twice)
and reentrancy safety
stdin:
print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
chmod +x pfn
alias echo='echo a'
foo() {
echo moo
./pfn "$(echo foo)"
}
./pfn "$(echo b)"
typeset -f foo >x
cat x
foo
. ./x
typeset -f foo
foo
expected-stdout:
a b
foo() {
\echo a moo
./pfn "$(\echo a foo )"
}
a moo
a foo
foo() {
\echo a moo
./pfn "$(\echo a foo )"
}
a moo
a foo
---
name: comsub-torture
description:
Check the tree dump functions work correctly
stdin:
if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
while IFS= read -r line; do
if [[ $line = '#1' ]]; then
lastf=0
continue
elif [[ $line = EOFN* ]]; then
fbody=$fbody$'\n'$line
continue
elif [[ $line != '#'* ]]; then
fbody=$fbody$'\n\t'$line
continue
fi
if (( lastf )); then
x="inline_${nextf}() {"$fbody$'\n}\n'
print -nr -- "$x"
print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
print -nr -- "$x"
print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
print -nr -- "$x"
print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
fi
lastf=1
fbody=
nextf=${line#?}
done <<'EOD'
#1
#TCOM
vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
#TPAREN_TPIPE_TLIST
(echo $foo | tr -dc 0-9; echo)
#TAND_TOR
cmd && echo ja || echo nein
#TSELECT
select file in *; do echo "<$file>" ; break ; done
#TFOR_TTIME
time for i in {1,2,3} ; do echo $i ; done
#TCASE
case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
#TIF_TBANG_TDBRACKET_TELIF
if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
#TWHILE
i=1; while (( i < 10 )); do echo $i; let ++i; done
#TUNTIL
i=10; until (( !--i )) ; do echo $i; done
#TCOPROC
cat * |& ls
#TFUNCT_TBRACE_TASYNC
function korn { echo eins; echo zwei ; }
bourne () { logger * & }
function ( a b='x$y\z'$(echo w)$((++i)) c ) extended { :; }
#IOREAD_IOCAT
tr x u 0<foo >>bar
#IOWRITE_IOCLOB_IOHERE_noIOSKIP
cat >|bar <<'EOFN'
foo
EOFN
#IOWRITE_noIOCLOB_IOHERE_IOSKIP
cat 1>bar <<-EOFI
foo
EOFI
#IORDWR_IODUP
sh 1<>/dev/console 0<&1 2>&1
#COMSUB_EXPRSUB_FUNSUB_VALSUB
echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
#QCHAR_OQUOTE_CQUOTE
echo fo\ob\"a\`r\'b\$az
echo "fo\ob\"a\`r\'b\$az"
echo 'fo\ob\"a\`r'\''b\$az'
#OSUBST_CSUBST_OPAT_SPAT_CPAT
[[ ${foo#bl\(u\)b} = @(bar|baz) ]]
#heredoc_closed
x=$(cat <<EOFN
note there must be no space between EOFN and )
EOFN); echo $x
#heredoc_space
x=$(cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN ); echo $x
#patch_motd
x=$(sysctl -n kern.version | sed 1q)
[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x
.
wq
EOF)" = @(?) ]] && rm -f /etc/motd
if [[ ! -s /etc/motd ]]; then
install -c -o root -g wheel -m 664 /dev/null /etc/motd
print -- "$x\n" >/etc/motd
fi
#wdarrassign
case x in
x) a+=b; c+=(d e)
esac
#0
EOD
expected-stdout:
inline_TCOM() {
vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
}
inline_TCOM() {
vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4"
}
function comsub_TCOM { x=$(
vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
); }
function comsub_TCOM {
x=$(vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" )
}
function reread_TCOM { x=$((
vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
)|tr u x); }
function reread_TCOM {
x=$( ( vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" ) | \tr u x )
}
inline_TPAREN_TPIPE_TLIST() {
(echo $foo | tr -dc 0-9; echo)
}
inline_TPAREN_TPIPE_TLIST() {
( \echo $foo | \tr -dc 0-9
\echo )
}
function comsub_TPAREN_TPIPE_TLIST { x=$(
(echo $foo | tr -dc 0-9; echo)
); }
function comsub_TPAREN_TPIPE_TLIST {
x=$( ( \echo $foo | \tr -dc 0-9 ; \echo ) )
}
function reread_TPAREN_TPIPE_TLIST { x=$((
(echo $foo | tr -dc 0-9; echo)
)|tr u x); }
function reread_TPAREN_TPIPE_TLIST {
x=$( ( ( \echo $foo | \tr -dc 0-9 ; \echo ) ) | \tr u x )
}
inline_TAND_TOR() {
cmd && echo ja || echo nein
}
inline_TAND_TOR() {
\cmd && \echo ja || \echo nein
}
function comsub_TAND_TOR { x=$(
cmd && echo ja || echo nein
); }
function comsub_TAND_TOR {
x=$(\cmd && \echo ja || \echo nein )
}
function reread_TAND_TOR { x=$((
cmd && echo ja || echo nein
)|tr u x); }
function reread_TAND_TOR {
x=$( ( \cmd && \echo ja || \echo nein ) | \tr u x )
}
inline_TSELECT() {
select file in *; do echo "<$file>" ; break ; done
}
inline_TSELECT() {
select file in *
do
\echo "<$file>"
\break
done
}
function comsub_TSELECT { x=$(
select file in *; do echo "<$file>" ; break ; done
); }
function comsub_TSELECT {
x=$(select file in * ; do \echo "<$file>" ; \break ; done )
}
function reread_TSELECT { x=$((
select file in *; do echo "<$file>" ; break ; done
)|tr u x); }
function reread_TSELECT {
x=$( ( select file in * ; do \echo "<$file>" ; \break ; done ) | \tr u x )
}
inline_TFOR_TTIME() {
time for i in {1,2,3} ; do echo $i ; done
}
inline_TFOR_TTIME() {
time for i in {1,2,3}
do
\echo $i
done
}
function comsub_TFOR_TTIME { x=$(
time for i in {1,2,3} ; do echo $i ; done
); }
function comsub_TFOR_TTIME {
x=$(time for i in {1,2,3} ; do \echo $i ; done )
}
function reread_TFOR_TTIME { x=$((
time for i in {1,2,3} ; do echo $i ; done
)|tr u x); }
function reread_TFOR_TTIME {
x=$( ( time for i in {1,2,3} ; do \echo $i ; done ) | \tr u x )
}
inline_TCASE() {
case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
}
inline_TCASE() {
case $foo in
(1)
\echo eins
;&
(2)
\echo zwei
;|
(*)
\echo kann net bis drei zählen
;;
esac
}
function comsub_TCASE { x=$(
case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
); }
function comsub_TCASE {
x=$(case $foo in (1) \echo eins ;& (2) \echo zwei ;| (*) \echo kann net bis drei zählen ;; esac )
}
function reread_TCASE { x=$((
case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
)|tr u x); }
function reread_TCASE {
x=$( ( case $foo in (1) \echo eins ;& (2) \echo zwei ;| (*) \echo kann net bis drei zählen ;; esac ) | \tr u x )
}
inline_TIF_TBANG_TDBRACKET_TELIF() {
if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
}
inline_TIF_TBANG_TDBRACKET_TELIF() {
if ! [[ 1 = 1 ]]
then
\echo eins
elif [[ 1 = 2 ]]
then
\echo zwei
else
\echo drei
fi
}
function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
); }
function comsub_TIF_TBANG_TDBRACKET_TELIF {
x=$(if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi )
}
function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
)|tr u x); }
function reread_TIF_TBANG_TDBRACKET_TELIF {
x=$( ( if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi ) | \tr u x )
}
inline_TWHILE() {
i=1; while (( i < 10 )); do echo $i; let ++i; done
}
inline_TWHILE() {
i=1
while {
\\builtin let " i < 10 "
}
do
\echo $i
\let ++i
done
}
function comsub_TWHILE { x=$(
i=1; while (( i < 10 )); do echo $i; let ++i; done
); }
function comsub_TWHILE {
x=$(i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done )
}
function reread_TWHILE { x=$((
i=1; while (( i < 10 )); do echo $i; let ++i; done
)|tr u x); }
function reread_TWHILE {
x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done ) | \tr u x )
}
inline_TUNTIL() {
i=10; until (( !--i )) ; do echo $i; done
}
inline_TUNTIL() {
i=10
until {
\\builtin let " !--i "
}
do
\echo $i
done
}
function comsub_TUNTIL { x=$(
i=10; until (( !--i )) ; do echo $i; done
); }
function comsub_TUNTIL {
x=$(i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done )
}
function reread_TUNTIL { x=$((
i=10; until (( !--i )) ; do echo $i; done
)|tr u x); }
function reread_TUNTIL {
x=$( ( i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done ) | \tr u x )
}
inline_TCOPROC() {
cat * |& ls
}
inline_TCOPROC() {
\cat * |&
\ls
}
function comsub_TCOPROC { x=$(
cat * |& ls
); }
function comsub_TCOPROC {
x=$(\cat * |& \ls )
}
function reread_TCOPROC { x=$((
cat * |& ls
)|tr u x); }
function reread_TCOPROC {
x=$( ( \cat * |& \ls ) | \tr u x )
}
inline_TFUNCT_TBRACE_TASYNC() {
function korn { echo eins; echo zwei ; }
bourne () { logger * & }
function ( a b='x$y\z'$(echo w)$((++i)) c ) extended { :; }
}
inline_TFUNCT_TBRACE_TASYNC() {
function korn {
\echo eins
\echo zwei
}
bourne() {
\logger * &
}
function (a b="x\$y\\z"$(\echo w )$((++i)) c) extended {
\:
}
}
function comsub_TFUNCT_TBRACE_TASYNC { x=$(
function korn { echo eins; echo zwei ; }
bourne () { logger * & }
function ( a b='x$y\z'$(echo w)$((++i)) c ) extended { :; }
); }
function comsub_TFUNCT_TBRACE_TASYNC {
x=$(function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * & } ; function (a b="x\$y\\z"$(\echo w )$((++i)) c) extended { \: ; } )
}
function reread_TFUNCT_TBRACE_TASYNC { x=$((
function korn { echo eins; echo zwei ; }
bourne () { logger * & }
function ( a b='x$y\z'$(echo w)$((++i)) c ) extended { :; }
)|tr u x); }
function reread_TFUNCT_TBRACE_TASYNC {
x=$( ( function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * & } ; function (a b="x\$y\\z"$(\echo w )$((++i)) c) extended { \: ; } ) | \tr u x )
}
inline_IOREAD_IOCAT() {
tr x u 0<foo >>bar
}
inline_IOREAD_IOCAT() {
\tr x u <foo >>bar
}
function comsub_IOREAD_IOCAT { x=$(
tr x u 0<foo >>bar
); }
function comsub_IOREAD_IOCAT {
x=$(\tr x u <foo >>bar )
}
function reread_IOREAD_IOCAT { x=$((
tr x u 0<foo >>bar
)|tr u x); }
function reread_IOREAD_IOCAT {
x=$( ( \tr x u <foo >>bar ) | \tr u x )
}
inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
cat >|bar <<'EOFN'
foo
EOFN
}
inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
\cat >|bar <<"EOFN"
foo
EOFN
}
function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
cat >|bar <<'EOFN'
foo
EOFN
); }
function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
x=$(\cat >|bar <<"EOFN"
foo
EOFN
)
}
function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
cat >|bar <<'EOFN'
foo
EOFN
)|tr u x); }
function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
x=$( ( \cat >|bar <<"EOFN" ) | \tr u x
foo
EOFN
)
}
inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
cat 1>bar <<-EOFI
foo
EOFI
}
inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
\cat >bar <<-EOFI
foo
EOFI
}
function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
cat 1>bar <<-EOFI
foo
EOFI
); }
function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
x=$(\cat >bar <<-EOFI
foo
EOFI
)
}
function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
cat 1>bar <<-EOFI
foo
EOFI
)|tr u x); }
function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
x=$( ( \cat >bar <<-EOFI ) | \tr u x
foo
EOFI
)
}
inline_IORDWR_IODUP() {
sh 1<>/dev/console 0<&1 2>&1
}
inline_IORDWR_IODUP() {
\sh 1<>/dev/console <&1 2>&1
}
function comsub_IORDWR_IODUP { x=$(
sh 1<>/dev/console 0<&1 2>&1
); }
function comsub_IORDWR_IODUP {
x=$(\sh 1<>/dev/console <&1 2>&1 )
}
function reread_IORDWR_IODUP { x=$((
sh 1<>/dev/console 0<&1 2>&1
)|tr u x); }
function reread_IORDWR_IODUP {
x=$( ( \sh 1<>/dev/console <&1 2>&1 ) | \tr u x )
}
inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
}
inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
\echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;}
}
function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
); }
function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
x=$(\echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} )
}
function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
)|tr u x); }
function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
x=$( ( \echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} ) | \tr u x )
}
inline_QCHAR_OQUOTE_CQUOTE() {
echo fo\ob\"a\`r\'b\$az
echo "fo\ob\"a\`r\'b\$az"
echo 'fo\ob\"a\`r'\''b\$az'
}
inline_QCHAR_OQUOTE_CQUOTE() {
\echo fo\ob\"a\`r\'b\$az
\echo "fo\ob\"a\`r\'b\$az"
\echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
}
function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
echo fo\ob\"a\`r\'b\$az
echo "fo\ob\"a\`r\'b\$az"
echo 'fo\ob\"a\`r'\''b\$az'
); }
function comsub_QCHAR_OQUOTE_CQUOTE {
x=$(\echo fo\ob\"a\`r\'b\$az ; \echo "fo\ob\"a\`r\'b\$az" ; \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
}
function reread_QCHAR_OQUOTE_CQUOTE { x=$((
echo fo\ob\"a\`r\'b\$az
echo "fo\ob\"a\`r\'b\$az"
echo 'fo\ob\"a\`r'\''b\$az'
)|tr u x); }
function reread_QCHAR_OQUOTE_CQUOTE {
x=$( ( \echo fo\ob\"a\`r\'b\$az ; \echo "fo\ob\"a\`r\'b\$az" ; \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" ) | \tr u x )
}
inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
[[ ${foo#bl\(u\)b} = @(bar|baz) ]]
}
inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
[[ ${foo#bl\(u\)b} = @(bar|baz) ]]
}
function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
[[ ${foo#bl\(u\)b} = @(bar|baz) ]]
); }
function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
}
function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
[[ ${foo#bl\(u\)b} = @(bar|baz) ]]
)|tr u x); }
function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
x=$( ( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | \tr u x )
}
inline_heredoc_closed() {
x=$(cat <<EOFN
note there must be no space between EOFN and )
EOFN); echo $x
}
inline_heredoc_closed() {
x=$(\cat <<EOFN
note there must be no space between EOFN and )
EOFN
)
\echo $x
}
function comsub_heredoc_closed { x=$(
x=$(cat <<EOFN
note there must be no space between EOFN and )
EOFN); echo $x
); }
function comsub_heredoc_closed {
x=$(x=$(\cat <<EOFN
note there must be no space between EOFN and )
EOFN
) ; \echo $x )
}
function reread_heredoc_closed { x=$((
x=$(cat <<EOFN
note there must be no space between EOFN and )
EOFN); echo $x
)|tr u x); }
function reread_heredoc_closed {
x=$( ( x=$(\cat <<EOFN
note there must be no space between EOFN and )
EOFN
) ; \echo $x ) | \tr u x )
}
inline_heredoc_space() {
x=$(cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN ); echo $x
}
inline_heredoc_space() {
x=$(\cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN
)
\echo $x
}
function comsub_heredoc_space { x=$(
x=$(cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN ); echo $x
); }
function comsub_heredoc_space {
x=$(x=$(\cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN
) ; \echo $x )
}
function reread_heredoc_space { x=$((
x=$(cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN ); echo $x
)|tr u x); }
function reread_heredoc_space {
x=$( ( x=$(\cat <<EOFN\
note the space between EOFN and ) is actually part of the here document marker
EOFN
) ; \echo $x ) | \tr u x )
}
inline_patch_motd() {
x=$(sysctl -n kern.version | sed 1q)
[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x
.
wq
EOF)" = @(?) ]] && rm -f /etc/motd
if [[ ! -s /etc/motd ]]; then
install -c -o root -g wheel -m 664 /dev/null /etc/motd
print -- "$x\n" >/etc/motd
fi
}
inline_patch_motd() {
x=$(\sysctl -n kern.version | \sed 1q )
[[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x
.
wq
EOF
)" = @(?) ]] && \rm -f /etc/motd
if [[ ! -s /etc/motd ]]
then
\install -c -o root -g wheel -m 664 /dev/null /etc/motd
\print -- "$x\n" >/etc/motd
fi
}
function comsub_patch_motd { x=$(
x=$(sysctl -n kern.version | sed 1q)
[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x
.
wq
EOF)" = @(?) ]] && rm -f /etc/motd
if [[ ! -s /etc/motd ]]; then
install -c -o root -g wheel -m 664 /dev/null /etc/motd
print -- "$x\n" >/etc/motd
fi
); }
function comsub_patch_motd {
x=$(x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x
.
wq
EOF
)" = @(?) ]] && \rm -f /etc/motd ; if [[ ! -s /etc/motd ]] ; then \install -c -o root -g wheel -m 664 /dev/null /etc/motd ; \print -- "$x\n" >/etc/motd ; fi )
}
function reread_patch_motd { x=$((
x=$(sysctl -n kern.version | sed 1q)
[[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x
.
wq
EOF)" = @(?) ]] && rm -f /etc/motd
if [[ ! -s /etc/motd ]]; then
install -c -o root -g wheel -m 664 /dev/null /etc/motd
print -- "$x\n" >/etc/motd
fi
)|tr u x); }
function reread_patch_motd {
x=$( ( x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF
1,/^\$/d
0a
$x
.
wq
EOF
)" = @(?) ]] && \rm -f /etc/motd ; if [[ ! -s /etc/motd ]] ; then \install -c -o root -g wheel -m 664 /dev/null /etc/motd ; \print -- "$x\n" >/etc/motd ; fi ) | \tr u x )
}
inline_wdarrassign() {
case x in
x) a+=b; c+=(d e)
esac
}
inline_wdarrassign() {
case x in
(x)
a+=b
\\builtin set -A c+ -- d e
;;
esac
}
function comsub_wdarrassign { x=$(
case x in
x) a+=b; c+=(d e)
esac
); }
function comsub_wdarrassign {
x=$(case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac )
}
function reread_wdarrassign { x=$((
case x in
x) a+=b; c+=(d e)
esac
)|tr u x); }
function reread_wdarrassign {
x=$( ( case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac ) | \tr u x )
}
---
name: comsub-torture-io
description:
Check the tree dump functions work correctly with I/O redirection
stdin:
if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
while IFS= read -r line; do
if [[ $line = '#1' ]]; then
lastf=0
continue
elif [[ $line = EOFN* ]]; then
fbody=$fbody$'\n'$line
continue
elif [[ $line != '#'* ]]; then
fbody=$fbody$'\n\t'$line
continue
fi
if (( lastf )); then
x="inline_${nextf}() {"$fbody$'\n}\n'
print -nr -- "$x"
print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
print -nr -- "$x"
print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
print -nr -- "$x"
print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
fi
lastf=1
fbody=
nextf=${line#?}
done <<'EOD'
#1
#TCOM
vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
#TPAREN_TPIPE_TLIST
(echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
#TAND_TOR
cmd >&3 && >&3 echo ja || echo >&3 nein
#TSELECT
select file in *; do echo "<$file>" ; break >&3 ; done >&3
#TFOR_TTIME
for i in {1,2,3} ; do time >&3 echo $i ; done >&3
#TCASE
case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
#TIF_TBANG_TDBRACKET_TELIF
if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
#TWHILE
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
#TUNTIL
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
#TCOPROC
cat * >&3 |& >&3 ls
#TFUNCT_TBRACE_TASYNC
function korn { echo eins; echo >&3 zwei ; }
bourne () { logger * >&3 & }
#COMSUB_EXPRSUB
echo $(true >&3) $((1+ 2))
#0
EOD
expected-stdout:
inline_TCOM() {
vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
}
inline_TCOM() {
vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3
}
function comsub_TCOM { x=$(
vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
); }
function comsub_TCOM {
x=$(vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 )
}
function reread_TCOM { x=$((
vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
)|tr u x); }
function reread_TCOM {
x=$( ( vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 ) | \tr u x )
}
inline_TPAREN_TPIPE_TLIST() {
(echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
}
inline_TPAREN_TPIPE_TLIST() {
( \echo $foo | \tr -dc 0-9 >&3
\echo >&3 ) >&3
}
function comsub_TPAREN_TPIPE_TLIST { x=$(
(echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
); }
function comsub_TPAREN_TPIPE_TLIST {
x=$( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 )
}
function reread_TPAREN_TPIPE_TLIST { x=$((
(echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
)|tr u x); }
function reread_TPAREN_TPIPE_TLIST {
x=$( ( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 ) | \tr u x )
}
inline_TAND_TOR() {
cmd >&3 && >&3 echo ja || echo >&3 nein
}
inline_TAND_TOR() {
\cmd >&3 && \echo ja >&3 || \echo nein >&3
}
function comsub_TAND_TOR { x=$(
cmd >&3 && >&3 echo ja || echo >&3 nein
); }
function comsub_TAND_TOR {
x=$(\cmd >&3 && \echo ja >&3 || \echo nein >&3 )
}
function reread_TAND_TOR { x=$((
cmd >&3 && >&3 echo ja || echo >&3 nein
)|tr u x); }
function reread_TAND_TOR {
x=$( ( \cmd >&3 && \echo ja >&3 || \echo nein >&3 ) | \tr u x )
}
inline_TSELECT() {
select file in *; do echo "<$file>" ; break >&3 ; done >&3
}
inline_TSELECT() {
select file in *
do
\echo "<$file>"
\break >&3
done >&3
}
function comsub_TSELECT { x=$(
select file in *; do echo "<$file>" ; break >&3 ; done >&3
); }
function comsub_TSELECT {
x=$(select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 )
}
function reread_TSELECT { x=$((
select file in *; do echo "<$file>" ; break >&3 ; done >&3
)|tr u x); }
function reread_TSELECT {
x=$( ( select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 ) | \tr u x )
}
inline_TFOR_TTIME() {
for i in {1,2,3} ; do time >&3 echo $i ; done >&3
}
inline_TFOR_TTIME() {
for i in {1,2,3}
do
time \echo $i >&3
done >&3
}
function comsub_TFOR_TTIME { x=$(
for i in {1,2,3} ; do time >&3 echo $i ; done >&3
); }
function comsub_TFOR_TTIME {
x=$(for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 )
}
function reread_TFOR_TTIME { x=$((
for i in {1,2,3} ; do time >&3 echo $i ; done >&3
)|tr u x); }
function reread_TFOR_TTIME {
x=$( ( for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 ) | \tr u x )
}
inline_TCASE() {
case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
}
inline_TCASE() {
case $foo in
(1)
\echo eins >&3
;&
(2)
\echo zwei >&3
;|
(*)
\echo kann net bis drei zählen >&3
;;
esac >&3
}
function comsub_TCASE { x=$(
case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
); }
function comsub_TCASE {
x=$(case $foo in (1) \echo eins >&3 ;& (2) \echo zwei >&3 ;| (*) \echo kann net bis drei zählen >&3 ;; esac >&3 )
}
function reread_TCASE { x=$((
case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
)|tr u x); }
function reread_TCASE {
x=$( ( case $foo in (1) \echo eins >&3 ;& (2) \echo zwei >&3 ;| (*) \echo kann net bis drei zählen >&3 ;; esac >&3 ) | \tr u x )
}
inline_TIF_TBANG_TDBRACKET_TELIF() {
if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
}
inline_TIF_TBANG_TDBRACKET_TELIF() {
if ! [[ 1 = 1 ]] >&3
then
\echo eins
elif [[ 1 = 2 ]] >&3
then
\echo zwei
else
\echo drei
fi >&3
}
function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
); }
function comsub_TIF_TBANG_TDBRACKET_TELIF {
x=$(if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 )
}
function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
)|tr u x); }
function reread_TIF_TBANG_TDBRACKET_TELIF {
x=$( ( if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 ) | \tr u x )
}
inline_TWHILE() {
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
}
inline_TWHILE() {
i=1
while {
\\builtin let " i < 10 "
} >&3
do
\echo $i
\let ++i
done >&3
}
function comsub_TWHILE { x=$(
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
); }
function comsub_TWHILE {
x=$(i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 )
}
function reread_TWHILE { x=$((
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
)|tr u x); }
function reread_TWHILE {
x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 ) | \tr u x )
}
inline_TUNTIL() {
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
}
inline_TUNTIL() {
i=10
until {
\\builtin let " !--i "
} >&3
do
\echo $i
done >&3
}
function comsub_TUNTIL { x=$(
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
); }
function comsub_TUNTIL {
x=$(i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 )
}
function reread_TUNTIL { x=$((
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
)|tr u x); }
function reread_TUNTIL {
x=$( ( i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 ) | \tr u x )
}
inline_TCOPROC() {
cat * >&3 |& >&3 ls
}
inline_TCOPROC() {
\cat * >&3 |&
\ls >&3
}
function comsub_TCOPROC { x=$(
cat * >&3 |& >&3 ls
); }
function comsub_TCOPROC {
x=$(\cat * >&3 |& \ls >&3 )
}
function reread_TCOPROC { x=$((
cat * >&3 |& >&3 ls
)|tr u x); }
function reread_TCOPROC {
x=$( ( \cat * >&3 |& \ls >&3 ) | \tr u x )
}
inline_TFUNCT_TBRACE_TASYNC() {
function korn { echo eins; echo >&3 zwei ; }
bourne () { logger * >&3 & }
}
inline_TFUNCT_TBRACE_TASYNC() {
function korn {
\echo eins
\echo zwei >&3
}
bourne() {
\logger * >&3 &
}
}
function comsub_TFUNCT_TBRACE_TASYNC { x=$(
function korn { echo eins; echo >&3 zwei ; }
bourne () { logger * >&3 & }
); }
function comsub_TFUNCT_TBRACE_TASYNC {
x=$(function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 & } )
}
function reread_TFUNCT_TBRACE_TASYNC { x=$((
function korn { echo eins; echo >&3 zwei ; }
bourne () { logger * >&3 & }
)|tr u x); }
function reread_TFUNCT_TBRACE_TASYNC {
x=$( ( function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 & } ) | \tr u x )
}
inline_COMSUB_EXPRSUB() {
echo $(true >&3) $((1+ 2))
}
inline_COMSUB_EXPRSUB() {
\echo $(\true >&3 ) $((1+ 2))
}
function comsub_COMSUB_EXPRSUB { x=$(
echo $(true >&3) $((1+ 2))
); }
function comsub_COMSUB_EXPRSUB {
x=$(\echo $(\true >&3 ) $((1+ 2)) )
}
function reread_COMSUB_EXPRSUB { x=$((
echo $(true >&3) $((1+ 2))
)|tr u x); }
function reread_COMSUB_EXPRSUB {
x=$( ( \echo $(\true >&3 ) $((1+ 2)) ) | \tr u x )
}
---
name: funsub-1
description:
Check that non-subenvironment command substitution works
stdin:
set -e
foo=bar
echo "ob $foo ."
echo "${
echo "ib $foo :"
foo=baz
echo "ia $foo :"
false
}" .
echo "oa $foo ."
expected-stdout:
ob bar .
ib bar :
ia baz : .
oa baz .
---
name: funsub-2
description:
You can now reliably use local and return in funsubs
stdin:
x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
expected-stdout:
1:ya x2,2,0.
2:ya x2,1,0.
3:ya,1,3.
---
name: funsub-3
description:
… not exit though, like in ksh93
stdin:
function foo {
if [[ $1 = 2 ]]; then
print -u2 ERR
exit 42
fi
print -r -- "<$1>"
}
for i in 1 2 3; do
print $i ${ foo $i;} || {
print SUB=$?
exit 1
}
done
print END=$?
expected-stdout:
1 <1>
2
3 <3>
END=0
expected-stderr:
ERR
---
name: valsub-1
description:
Check that "value substitutions" work as advertised
stdin:
x=1
y=2
z=3
REPLY=4
echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
x=${|
local y
echo "start: x<$x> y<$y> z<$z> R<$REPLY>"
x=5
y=6
z=7
REPLY=8
echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
}
echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
# ensure trailing newlines are kept
t=${|REPLY=$'foo\n\n';}
typeset -p t
echo -n this used to segfault
echo ${|true;}$(true).
expected-stdout:
before: x<1> y<2> z<3> R<4>
start: x<1> y<> z<3> R<>
end: x<5> y<6> z<7> R<8>
after: x<8> y<2> z<7> R<4>
typeset t=$'foo\n\n'
this used to segfault.
---
name: valsub-2
description:
Can use exit here, in contrast to funsubs
stdin:
function foo {
if [[ $1 = 2 ]]; then
print -u2 ERR
exit 42
fi
REPLY="<$1>"
}
for i in 1 2 3; do
print $i ${|foo $i;} || {
print SUB=$?
exit 1
}
done
print END=$?
expected-exit: 42
expected-stdout:
1 <1>
expected-stderr:
ERR
---
name: funsub-valsub-1
description:
This is what AT&T ksh93 does for shift
stdin:
"$__progname" -c 'echo a. "$@"; : "${ shift;}"; echo b. "$@"' sh1 1a 1b
"$__progname" -c 'echo a. "$@"; : "${|shift;}"; echo b. "$@"' sh2 2a 2b
"$__progname" -c 'echo a. "$@"; : "${|shift;shift;}"; echo b. "$@"' sh3 3a 3b
echo >&2 =1
"$__progname" -c 'echo a. "$@"; : "${|shift;shift;shift;}"; echo b. "$@"' sh4 4a 4b
echo >&2 =2
expected-stdout:
a. 1a 1b
b. 1b
a. 2a 2b
b. 2b
a. 3a 3b
b.
a. 4a 4b
expected-stderr-pattern:
/^=1\n[^\n]*nothing to shift[^\n]*\n=2$/
---
name: event-subst-3
description:
Check that '!' substitution in noninteractive mode is ignored
file-setup: file 755 "falsetto"
#! /bin/sh
echo molto bene
exit 42
file-setup: file 755 "!false"
#! /bin/sh
echo si
stdin:
export PATH=.$PATHSEP$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: event-subst-0
description:
Check that '!' substitution in interactive mode is ignored
need-ctty: yes
arguments: !-i!
file-setup: file 755 "falsetto"
#! /bin/sh
echo molto bene
exit 42
file-setup: file 755 "!false"
#! /bin/sh
echo si
stdin:
export PATH=.$PATHSEP$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
expected-stderr-pattern:
/.*/
---
name: nounset-1
description:
Check that "set -u" matches (future) SUSv4 requirement
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^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROGl" \
-e "s^[EW]: ${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROGl" \
-e "s^${__progname%.exe}\.*e*x*e*: PROGn: " \
-e "s^[EW]: ${__progname%.exe}\.*e*x*e*: PROGn: "
exit ${PIPESTATUS[0]}
expected-stdout:
y
=1
PROGl: y: parameter not set
=2
x=nz
=3
PROGn: y: parameter not set
=4
0=nz
=5
PROGn: 2: parameter not set
=6
PROGl: 1: parameter not set
=7
at=
=8
asterisk=
=9
0
=10
PROGl: !: parameter not set
=11
ush
=12
0
=14
mypid=nz
=15
---
name: nameref-1
description:
Testsuite for nameref (bound variables)
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]: blub[1]
!ir2: ir2
ind[1]: e2
ir2: e3
---
name: nameref-2da
description:
Testsuite for nameref (bound variables)
Functions, argument given directly, after local
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)
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: nameref-4
description:
Ensure we don't run in an infinite loop
time-limit: 3
stdin:
baz() {
typeset -n foo=fnord fnord=foo
foo[0]=bar
}
set -A foo bad
echo sind $foo .
baz
echo blah $foo .
expected-stdout:
sind bad .
blah bad .
expected-stderr-pattern:
/fnord: expression recurses on parameter/
---
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-1c
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
x=$( (echo fubar)|tr u x); echo $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-2c
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
x=$((echo fubar)|tr u x); echo $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-3c
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
x=$( (echo fubar)|(tr u x)); echo $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: better-parens-4c
description:
Check support for ((…)) and $((…)) vs (…) and $(…)
stdin:
x=$((echo fubar)|(tr u x)); echo $x $?
expected-stdout:
fxbar 0
---
name: better-parens-5
description:
Another corner case
stdin:
( (echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
((echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
expected-stdout:
fo o$bAr bAz$blA" m$eh
fo o$bAr bAz$blA" m$eh
---
name: echo-test-1
description:
Test what the echo builtin does (mksh)
category: !shell:ebcdic-yes
stdin:
echo -n 'foo\x40bar'
echo -e '\tbaz'
expected-stdout:
foo@bar baz
---
name: echo-test-1-ebcdic
description:
Test what the echo builtin does (mksh)
category: !shell:ebcdic-no
stdin:
echo -n 'foo\x7Cbar'
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.
stdin:
test -n "$POSH_VERSION" || set -o posix
echo -n 'foo\x40bar'
echo -e '\tbaz'
expected-stdout:
foo\x40bar-e \tbaz
---
name: echo-test-3-mnbsd
description:
Test what the echo builtin does, and test a compatibility flag.
category: mnbsdash
stdin:
"$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
"$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
"$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
expected-stdout:
1=@foo.
2=\x40foo-e \x2E
3=\x40bar.
---
name: echo-test-3-normal
description:
Test what the echo builtin does, and test a compatibility flag.
category: !mnbsdash,!shell:ebcdic-yes
stdin:
"$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
"$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
"$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
expected-stdout:
1=@foo.
2=\x40foo-e \x2E
3=\x40foo-e \x2E
---
name: echo-test-3-ebcdic
description:
Test what the echo builtin does, and test a compatibility flag.
category: !mnbsdash,!shell:ebcdic-no
stdin:
"$__progname" -c 'echo -n 1=\\x7C$1; echo -e \\x4B' -- foo bar
"$__progname" -o posix -c 'echo -n 2=\\x7C$1; echo -e \\x4B' -- foo bar
"$__progname" -o sh -c 'echo -n 3=\\x7C$1; echo -e \\x4B' -- foo bar
expected-stdout:
1=@foo.
2=\x7Cfoo-e \x4B
3=\x7Cfoo-e \x4B
---
name: env-intvars
description:
Check that importing integers fails except for numbers
stdin:
print '#!'"$__perlname"'\n($k, $v) = split(/=/, shift(@ARGV),' \
'2);\n$ENV{$k} = $v;\nexec { $ARGV[0] } @ARGV or die $!;' \
>env; chmod +x env; PATH=.$PATHSEP$PATH
unset foo bar
print 1 $foo , $(typeset -p bar) .
print 2 $(foo=123 "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
$(env 'bar[123]=baz' "$__progname" -c 'typeset -p bar') .
print 3 $(foo='abc[$(echo >&2 fowled)0]' "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
$(env 'bar[$(echo >&2 fowled)0]=baz' "$__progname" -c 'typeset -p bar') .
print 4 $(foo=0123 "$__progname" +o posix -c 'integer foo; print -- $foo' 2>&1) , \
$(env 'bar[0123]=baz' "$__progname" +o posix -c 'typeset -p bar') .
# ksh93 does not do this:
print 5 $(foo=0123 "$__progname" -o posix -c 'integer foo; print -- $foo' 2>&1) .
# at import time FPOSIX is not yet set
print 6 $(foo=0x123 "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
$(env 'bar[0x123]=baz' "$__progname" -c 'typeset -p bar') .
print 7 $(foo=12#123 "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
$(env 'bar[12#123]=baz' "$__progname" -c 'typeset -p bar') .
print 8 $(foo=1+1 "$__progname" -c 'integer foo; print -- $foo' 2>&1) , \
$(env 'bar[1+1]=baz' "$__progname" -c 'typeset -p bar') .
print 9 $(a=1 b=2 c=a "$__progname" -c 'typeset -p c; c=b; typeset -p c; integer c; typeset -p c') .
print 0 $(a=1 b=2 c=a "$__progname" -c 'typeset -p c; typeset -p c; integer c; typeset -p c') .
expected-stdout:
1 , .
2 123 , set -A bar typeset -x bar[123]=baz .
3 0 , .
4 123 , set -A bar typeset -x bar[123]=baz .
5 8#123 .
6 16#123 , set -A bar typeset -x bar[291]=baz .
7 12#123 , set -A bar typeset -x bar[171]=baz .
8 0 , .
9 typeset -x c=a typeset -x c=b typeset -i -x c=2 .
0 typeset -x c=a typeset -x c=a typeset -i -x c=0 .
---
name: utilities-getopts-1
description:
getopts sets OPTIND correctly for unparsed option
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: /.*-x.*option/
---
name: utilities-getopts-3
description:
Check unsetting OPTARG
stdin:
set -- -x arg -y
getopts x:y opt && echo "${OPTARG-unset}"
getopts x:y opt && echo "${OPTARG-unset}"
expected-stdout:
arg
unset
---
name: wcswidth-1
description:
Check the new wcswidth feature
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
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
stdin:
print ${%} .
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: wcswidth-4a
description:
Check some corner cases
stdin:
print ${%*} .
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: wcswidth-4b
description:
Check some corner cases
stdin:
print ${%@} .
expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
name: wcswidth-4c
description:
Check some corner cases
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
---
name: realpath-2
description:
Ensure that exactly two leading slashes are not collapsed
POSIX guarantees this exception, e.g. for UNC paths on Cygwin
category: os:mirbsd
stdin:
ln -s /bin t1
ln -s //bin t2
ln -s ///bin t3
realpath /bin
realpath //bin
realpath ///bin
realpath /usr/bin
realpath /usr//bin
realpath /usr///bin
realpath t1
realpath t2
realpath t3
rm -f t1 t2 t3
cd //usr/bin
pwd
cd ../lib
pwd
realpath //usr/include/../bin
expected-stdout:
/bin
//bin
/bin
/usr/bin
/usr/bin
/usr/bin
/bin
//bin
/bin
//usr/bin
//usr/lib
//usr/bin
---
name: crash-1
description:
Crashed during March 2011, fixed on vernal equinōx ☺
category: os:mirbsd,os:openbsd
stdin:
export MALLOC_OPTIONS=FGJRSX
"$__progname" -c 'x=$(tr z r <<<baz); echo $x'
expected-stdout:
bar
---
name: crash-2
stdin:
<<<`$((`
expected-exit: e != 0
expected-stderr-pattern: /.*: no closing quote$/
---
name: debian-117-1
description:
Check test - bug#465250
stdin:
test \( ! -e \) ; echo $?
expected-stdout:
1
---
name: debian-117-2
description:
Check test - bug#465250
stdin:
test \( -e \) ; echo $?
expected-stdout:
0
---
name: debian-117-3
description:
Check test - bug#465250
stdin:
test ! -e ; echo $?
expected-stdout:
1
---
name: debian-117-4
description:
Check test - bug#465250
stdin:
test -e ; echo $?
expected-stdout:
0
---
name: case-zsh
description:
Check that zsh case variants work
stdin:
case 'b' in
a) echo a ;;
b) echo b ;;
c) echo c ;;
*) echo x ;;
esac
echo =
case 'b' in
a) echo a ;&
b) echo b ;&
c) echo c ;&
*) echo x ;&
esac
echo =
case 'b' in
a) echo a ;|
b) echo b ;|
c) echo c ;|
*) echo x ;|
esac
expected-stdout:
b
=
b
c
x
=
b
x
---
name: case-braces
description:
Check that case end tokens are not mixed up (Debian #220272)
stdin:
i=0
for value in 'x' '}' 'esac'; do
print -n "$((++i))($value)bourne "
case $value in
}) echo brace ;;
*) echo no ;;
esac
print -n "$((++i))($value)korn "
case $value {
esac) echo esac ;;
*) echo no ;;
}
done
expected-stdout:
1(x)bourne no
2(x)korn no
3(})bourne brace
4(})korn no
5(esac)bourne no
6(esac)korn esac
---
name: command-shift
description:
Check that 'command shift' works
stdin:
function snc {
echo "before 0='$0' 1='$1' 2='$2'"
shift
echo "after 0='$0' 1='$1' 2='$2'"
}
function swc {
echo "before 0='$0' 1='$1' 2='$2'"
command shift
echo "after 0='$0' 1='$1' 2='$2'"
}
echo = without command
snc 一 二
echo = with command
swc 一 二
echo = done
expected-stdout:
= without command
before 0='snc' 1='一' 2='二'
after 0='snc' 1='二' 2=''
= with command
before 0='swc' 1='一' 2='二'
after 0='swc' 1='二' 2=''
= done
---
name: command-set
description:
Same but with set
stdin:
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
showargs 1 "$@"
set -- foo bar baz
showargs 2 "$@"
command set -- miau 'meow nyao'
showargs 3 "$@"
expected-stdout:
<1> .
<2> <foo> <bar> <baz> .
<3> <miau> <meow nyao> .
---
name: command-readonly
description:
These should not exit on error when prefixed
stdin:
exec 2>/dev/null
"$__progname" -c 'readonly v; export v=foo || echo ok'
echo ef=$?
"$__progname" -c 'readonly v; command export v=foo || echo ok'
echo en=$?
"$__progname" -c 'readonly v; readonly v=foo || echo ok'
echo rf=$?
"$__progname" -c 'readonly v; command readonly v=foo || echo ok'
echo rn=$?
expected-stdout:
ef=2
ok
en=0
rf=2
ok
rn=0
---
name: command-dot-regression
description:
Check a regression in fixing the above does not appear
stdin:
cat >test.mksh <<\EOF
set -- one two
shift
for s_arg in "$#" "$@"; do echo -n "<$s_arg> "; done; echo .
EOF
"$__progname" -c '. ./test.mksh' dummy oh dear this is not good
echo =
"$__progname" -c 'command . ./test.mksh' dummy oh dear this is not good
expected-stdout:
<1> <two> .
=
<1> <two> .
---
name: command-pvV-posix-priorities
description:
For POSIX compatibility, command -v should find aliases and reserved
words, and command -p[vV] should find aliases, reserved words, and
builtins over external commands.
stdin:
# extra checks prep
mkdir mrr
:>mrr/miau
chmod +x mrr/miau
# priorities
PATH=/bin:/usr/bin
alias foo="bar baz"
alias '[ab]=:'
bar() { :; }
for word in 'if' 'foo' 'bar' 'set' 'true' '[ab]'; do
command -v "$word"
command -pv "$word"
command -V "$word"
command -pV "$word"
done
# extra checks
alias '[ab]'
whence '[ab]'
PATH=mrr
case $(command -v miau) {
(mrr/miau) echo fail ;;
(!(/*|[A-Z]:/*)) echo fail2 ;;
($PWD/mrr/miau) echo ok ;;
(/*|[A-Z]:/*) echo pwd bad? ;;
(*) echo not reached ;;
}
expected-stdout:
if
if
if is a reserved word
if is a reserved word
alias foo='bar baz'
alias foo='bar baz'
foo is an alias for 'bar baz'
foo is an alias for 'bar baz'
bar
bar
bar is a function
bar is a function
set
set
set is a special shell builtin
set is a special shell builtin
true
true
true is a shell builtin
true is a shell builtin
alias '[ab]'=:
alias '[ab]'=:
'[ab]' is an alias for :
'[ab]' is an alias for :
'[ab]'=:
:
ok
---
name: whence-preserve-tradition
description:
This regression test is to ensure that the POSIX compatibility
changes for 'command' (see previous test) do not affect traditional
'whence' behaviour.
category: os:mirbsd
stdin:
PATH=/bin:/usr/bin
alias foo="bar baz"
bar() { :; }
for word in 'if' 'foo' 'bar' 'set' 'true'; do
whence "$word"
whence -p "$word"
whence -v "$word"
whence -pv "$word"
done
expected-stdout:
if
if is a reserved word
if not found
'bar baz'
foo is an alias for 'bar baz'
foo not found
bar
bar is a function
bar not found
set
set is a special shell builtin
set not found
true
/bin/true
true is a shell builtin
true is a tracked alias for /bin/true
---
name: duffs-device
description:
Check that the compiler did not optimise-break them
(lex.c has got a similar one in SHEREDELIM)
category: !shell:ebcdic-yes
stdin:
set +U
s=
typeset -i1 i=0
while (( ++i < 256 )); do
s+=${i#1#}
done
s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
typeset -p s
set -o asis
typeset -p s
set -U
typeset -p s
expected-stdout:
typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237 \202�\220\200\200.'
typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177 €�𐀀.'
typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377 €�\357\277\276\357\277\277\360\220\200\200.'
---
name: duffs-device-ebcdic
description:
Check that the compiler did not optimise-break them
category: !shell:ebcdic-no
stdin:
set +U
s=
typeset -i1 i=0
while (( ++i < 256 )); do
s+=${i#1#}
done
#s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.' #XXX
typeset -p s
expected-stdout:
typeset s=$'\001\002\003\004\t\006\007\010\011\012\v\f\r\016\017\020\021\022\023\024\n\b\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\E\050\051\052\053\054\055\056\a\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077 .<(+|&!$*);^-/Ѧ,%_>?`:#@\175="abcdefghijklmnopqrƤ~stuvwxyz[ޮݨ]{ABCDEFGHI}JKLMNOPQR\\STUVWXYZ0123456789\377'
---
name: stateptr-underflow
description:
This check overflows an Xrestpos stored in a short in R40
info-pre: takes very long on retro systems
category: !system:fast-no
stdin:
function Lb64decode {
[[ -o utf8-mode ]]; local u=$?
set +U
local c s="$*" t=
[[ -n $s ]] || { s=$(cat;print .); s=${s%.}; }
local -i i=-1 n=${#s} p=0 v x
local -i16 o
while ((# ++i < n )); do
c=${s:i:1}
case $c {
(=) break ;;
([A-Z]) ((# v = 1#$c - 65 )) ;;
([a-z]) ((# v = 1#$c - 71 )) ;;
([0-9]) ((# v = 1#$c + 4 )) ;;
(+) v=62 ;;
(/) v=63 ;;
(*) continue ;;
}
((# x = (x << 6) | v ))
case $((p++)) {
(0) continue ;;
(1) ((# o = (x >> 4) & 255 )) ;;
(2) ((# o = (x >> 2) & 255 )) ;;
(3) ((# o = x & 255 ))
p=0
;;
}
t=$t\\x${o#16#}
done
print -n $t
(( u )) || set -U
}
i=-1
s=
while (( ++i < 12120 )); do
s+=a
done
Lb64decode $s >/dev/null
---
name: xtrace-1
description:
Check that "set -x" doesn't redirect too quickly
stdin:
print '#!'"$__progname" >bash
cat >>bash <<'EOF'
echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
Copyright (C) 2002 Free Software Foundation, Inc.'
EOF
chmod +x bash
"$__progname" -xc 'foo=$(./bash --version 2>&1 | sed q); echo "=$foo="'
expected-stdout:
=GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
expected-stderr-pattern:
/.*/
---
name: xtrace-2
description:
Check that "set -x" is off during PS4 expansion
stdin:
f() {
print -n "(f1:$-)"
set -x
print -n "(f2:$-)"
}
PS4='[(p:$-)$(f)] '
print "(o0:$-)"
set -x -o inherit-xtrace
print "(o1:$-)"
set +x
print "(o2:$-)"
expected-stdout:
(o0:sh)
(o1:shx)
(o2:sh)
expected-stderr:
[(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'
[(p:sh)(f1:sh)(f2:sh)] set +x
---
name: fksh-flags
description:
Check that FKSH functions have their own shell flags
category: shell:legacy-no
stdin:
[[ $KSH_VERSION = Version* ]] && set +B
function foo {
set +f
set -e
echo 2 "${-/s}" .
}
set -fh
echo 1 "${-/s}" .
foo
echo 3 "${-/s}" .
expected-stdout:
1 fh .
2 eh .
3 fh .
---
name: fksh-flags-legacy
description:
Check that even FKSH functions share the shell flags
category: shell:legacy-yes
stdin:
[[ $KSH_VERSION = Version* ]] && set +B
foo() {
set +f
set -e
echo 2 "${-/s}" .
}
set -fh
echo 1 "${-/s}" .
foo
echo 3 "${-/s}" .
expected-stdout:
1 fh .
2 eh .
3 eh .
---
name: fsh-flags
description:
Check that !FKSH functions share the shell flags
stdin:
[[ $KSH_VERSION = Version* ]] && set +B
foo() {
set +f
set -e
echo 2 "${-/s}" .
}
set -fh
echo 1 "${-/s}" .
foo
echo 3 "${-/s}" .
expected-stdout:
1 fh .
2 eh .
3 eh .
---
name: read-timeout-1
description:
Check timeout functionality
category: have:select:1
time-limit: 5
stdin:
sleep 2 | {
read -t1 foo
echo 1 $? "<$foo>"
}
: | {
read -t1 foo
echo 2 $? "<$foo>"
}
echo bla | {
read -t1 foo
echo 3 $? "<$foo>"
}
expected-stdout:
1 142 <>
2 1 <>
3 0 <bla>
---
name: read-timeout-slow
description:
Check timeout parser
info-pre: takes 15, at most 20, seconds
category: have:select:1
time-limit: 20
stdin:
(sleep 14; echo foo) | {
read -t12.3 foo
echo 1 $? "<$foo>"
} >o1 &
(sleep 11; echo foo) | {
read -t12.3 foo
echo 2 $? "<$foo>"
} > o2 &
wait
cat o1
cat o2
expected-stdout:
1 142 <>
2 0 <foo>
---
name: time-stayalive
description:
check time syntax element or builtin do not exit the shell on error
stdin:
set -e
ln -s "$__progname" time 2>/dev/null || cp "$__progname" time
if time -f true; then echo 3 meh $? .; else echo 3 ok $? .; fi
if command time -f true; then echo 4 meh $? .; else echo 4 ok $? .; fi
if ./time -f true; then echo 5 meh $? .; else echo 5 ok $? .; fi
echo 6 out .; echo >&2 6 err .
time true
expected-stdout:
3 ok 1 .
4 ok 1 .
5 ok 1 .
6 out .
expected-stderr-pattern: /^(?:.*unknown option.*\n){3}6 err \.\n.*s real.*system$/
---
name: optional-printf-builtin
description:
printf(1) minimal tests
category: printf-builtin
stdin:
t() {
o=$(\\builtin printf "$@"; echo .)
r=$?
print -r -- "$((++n)) ${o%.} : $r"
}
t '<%s>' a b\ c
t '%s - %c %s %d %i %o %u %x %X %b' 3
t '%% %c %s %d %i %o %u %x %X' 72 73 74 75 76 77 78 79
t '\\\a\b\f\n\r\t\v\01234'
let n+=2
t '%b foo %s bar' '\\\a\b\f\n\r\t\v\01234\cdefg'
let ++n
t '<%d>' 1 +2 -3 0x1a 0X1B 010 -011 +012 \'1 \"2
t '<%d|%d><%+d|%+d><% d|% d><%+ d|%+ d>' 1 -1 1 -1 1 -1 1 -1
t '<%o|%#o><%x|%#x><%X|%#X>' 8 9 10 11 12 13
#XXX replace with below
t '|%3d|%-3d|%+3d|%-+3d|%03d|%-03d|%3d|%.3d|notyet|' \
1 2 3 4 5 6 7777 8
#t '|%3d|%-3d|%+3d|%-+3d|%03d|%-03d|%3d|%.3d|%5.3d|' \
# 1 2 3 4 5 6 7777 8 9
#12 | 1|2 | +3|+4 |005|6 |7777|008| 009| : 0
expected-stdout:
1 <a><b c> : 0
2 3 - 0 0 0 0 0 0 : 0
3 % 7 73 74 75 114 77 4e 4F : 0
4 \
34 : 0
7 \
S4 : 0
9 <1><2><-3><26><27><8><-9><10><49><50> : 0
10 <1|-1><+1|-1>< 1|-1><+1|-1> : 0
11 <10|011><a|0xb><C|0XD> : 0
12 | 1|2 | +3|+4 |005|6 |7777|008|notyet| : 0
---
name: exit-trap-noninteractive
description:
Check that !interactive shell does exit via EXIT trap on syntax error
info-post: that was the last test
file-setup: file 644 "t1"
<
echo in=$?
file-setup: file 644 "t2"
trap -- EXIT
<
echo in=$?
file-setup: file 644 "t3"
trap "echo tEXITrap" EXIT
<
echo in=$?
stdin:
exec 2>se
echo "A 1["$("$__progname" t1; echo "]=$?")" 2["$("$__progname" t2; echo "]=$?")" 3["$("$__progname" t3; echo "]=$?")
echo "B 1["$("$__progname" -c '. ./t1; echo xd=$?'; echo "]=$?")" 2["$("$__progname" -c '. ./t2; echo xd=$?'; echo "]=$?")" 3["$("$__progname" -c '. ./t3; echo xd=$?'; echo "]=$?")
echo "C 1["$("$__progname" -c 'command . ./t1; echo xd=$?'; echo "]=$?")" 2["$("$__progname" -c 'command . ./t2; echo xd=$?'; echo "]=$?")" 3["$("$__progname" -c 'command . ./t3; echo xd=$?'; echo "]=$?")
exec 2>&1
cnt=0
while IFS= read -r line; do
[[ $line = *'syntax error'*'syntax error'* ]] && exit 4
[[ $line = *'syntax error'* ]] || exit 5
let ++count
done <se
(( count != 9 )) || echo 'stderr ok'
expected-stdout:
A 1[]=1 2[]=1 3[tEXITrap ]=1
B 1[]=1 2[]=1 3[tEXITrap ]=1
C 1[]=1 2[]=1 3[tEXITrap ]=1
stderr ok
---
|