|
1 | | -# $NetBSD: t_expand.sh,v 1.23 2023/03/06 05:54:54 kre Exp $ |
| 1 | +# $NetBSD: t_expand.sh,v 1.24 2026/03/18 14:30:21 kre Exp $ |
2 | 2 | # |
3 | 3 | # Copyright (c) 2007, 2009 The NetBSD Foundation, Inc. |
4 | 4 | # All rights reserved. |
@@ -1289,6 +1289,55 @@ dollar_at_in_field_split_context_body() { |
1289 | 1289 | results |
1290 | 1290 | } |
1291 | 1291 |
|
| 1292 | +atf_test_case dollar_star_unquoted |
| 1293 | +dollar_star_unquoted_head() { |
| 1294 | + atf_set descr 'Test unquoted $* in various contexts' |
| 1295 | +} |
| 1296 | +dollar_star_unquoted_body() { |
| 1297 | + reset dollar_star_unquoted_body |
| 1298 | + |
| 1299 | + check 'set -- ; set -- $* ; printf %d "$#"' 0 0 # 1 |
| 1300 | + check 'set -- a ; set -- $* ; printf %d "$#"' 1 0 # 2 |
| 1301 | + check 'set -- a b ; set -- $* ; printf %d "$#"' 2 0 # 3 |
| 1302 | + check 'set -- "" ; printf %d+ "$#"; set -- x$* ; printf %d "$#"' \ |
| 1303 | + 1+1 0 # 4 |
| 1304 | + check 'set -- "" "" ; printf %d+ "$#"; set -- x$*y ; printf %d "$#"' \ |
| 1305 | + 2+2 0 # 5 |
| 1306 | + |
| 1307 | + # expect the following sub-test to fail currently, PR bin/60099 |
| 1308 | + check 'set -- a b+ c +d e; IFS=+; set -- $* ; printf %d "$#"' \ |
| 1309 | + 6 0 # 6 |
| 1310 | + |
| 1311 | + # The following tests test unspecified POSIX behaviour |
| 1312 | + # (empty fields MAY be omitted from $* unquoted in this context) |
| 1313 | + # They are included to detect unexpected changes in how |
| 1314 | + # the NetBSD shell works, failures using other shells |
| 1315 | + # should be investigated, but are not necessarily wrong. |
| 1316 | + check 'set -- a "" b ; set -- $* ; printf %d "$#"' 2 0 # 7 |
| 1317 | + check 'set -- a b "" ; set -- $* ; printf %d "$#"' 2 0 # 8 |
| 1318 | + check 'set -- "" a b ; set -- $* ; printf %d "$#"' 2 0 # 9 |
| 1319 | + check 'set -- "" a "" b "" ; set -- $* ; printf %d "$#"' 2 0 #10 |
| 1320 | + check 'set -- "" "" a b ; set -- $* ; printf %d "$#"' 2 0 #11 |
| 1321 | + check 'set -- a b "" "" ; set -- $* ; printf %d "$#"' 2 0 #12 |
| 1322 | + |
| 1323 | + check 'set -- "" ; printf %d+ "$#"; set -- $* ; printf %d "$#"' \ |
| 1324 | + 1+0 0 #13 |
| 1325 | + check 'set -- "" "" ; printf %d+ "$#"; set -- $* ; printf %d "$#"' \ |
| 1326 | + 2+0 0 #14 |
| 1327 | + check 'set -- "" "" ; printf %d+ "$#"; set -- x$* ; printf %d "$#"' \ |
| 1328 | + 2+1 0 #15 |
| 1329 | + check \ |
| 1330 | + 'set -- "" "" "" ; printf %d+ "$#"; set -- x$*y ; printf %d "$#"' \ |
| 1331 | + 3+2 0 #16 |
| 1332 | + check \ |
| 1333 | + 'set -- "" "" "" "";printf %d+ "$#";set -- x$*y ;printf %d "$#"' \ |
| 1334 | + 4+2 0 #17 |
| 1335 | + check 'set "" ""; for i in $* ; do printf %s\\n "z${i}z"; done' \ |
| 1336 | + '' 0 #18 |
| 1337 | + |
| 1338 | + results |
| 1339 | +} |
| 1340 | + |
1292 | 1341 | atf_test_case embedded_nl |
1293 | 1342 | embedded_nl_head() { |
1294 | 1343 | atf_set descr 'Test literal \n in xxx string in ${var-xxx}' |
@@ -1628,6 +1677,7 @@ atf_init_test_cases() { |
1628 | 1677 | atf_add_test_case dollar_star_in_quoted_word |
1629 | 1678 | atf_add_test_case dollar_star_in_word |
1630 | 1679 | atf_add_test_case dollar_star_in_word_empty_ifs |
| 1680 | + atf_add_test_case dollar_star_unquoted |
1631 | 1681 | atf_add_test_case dollar_star_with_empty_ifs |
1632 | 1682 | atf_add_test_case embedded_nl |
1633 | 1683 | atf_add_test_case error |
|
0 commit comments