Skip to content

Commit f401e76

Browse files
krekre
authored andcommitted
PR bin/60099 -- add new dollar_star_unquoted test case
The added test does some (there could me more) testing of uses of unquoted $* in field splitting contexts (which are the words of a simple command and the words after "in" in the "for" reserved word, more or less). Right now, one of the new sub-tests (#6 as committed) will fail - this illustrates the problem, it expect correct execution. That will be corrected, eventually. I do not intend to mark this as "expected fail" - it isn't something which should be failing or is impossible to correct, it just happens to fail now.
1 parent fd89440 commit f401e76

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

tests/bin/sh/t_expand.sh

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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 $
22
#
33
# Copyright (c) 2007, 2009 The NetBSD Foundation, Inc.
44
# All rights reserved.
@@ -1289,6 +1289,55 @@ dollar_at_in_field_split_context_body() {
12891289
results
12901290
}
12911291

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+
12921341
atf_test_case embedded_nl
12931342
embedded_nl_head() {
12941343
atf_set descr 'Test literal \n in xxx string in ${var-xxx}'
@@ -1628,6 +1677,7 @@ atf_init_test_cases() {
16281677
atf_add_test_case dollar_star_in_quoted_word
16291678
atf_add_test_case dollar_star_in_word
16301679
atf_add_test_case dollar_star_in_word_empty_ifs
1680+
atf_add_test_case dollar_star_unquoted
16311681
atf_add_test_case dollar_star_with_empty_ifs
16321682
atf_add_test_case embedded_nl
16331683
atf_add_test_case error

0 commit comments

Comments
 (0)