| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: t_fsplit.sh,v 1.2 2016/03/08 14:26:54 christos Exp $ | | 1 | # $NetBSD: t_fsplit.sh,v 1.3 2016/03/10 22:30:57 christos Exp $ |
2 | # | | 2 | # |
3 | # Copyright (c) 2007-2016 The NetBSD Foundation, Inc. | | 3 | # Copyright (c) 2007-2016 The NetBSD Foundation, Inc. |
4 | # All rights reserved. | | 4 | # All rights reserved. |
5 | # | | 5 | # |
6 | # Redistribution and use in source and binary forms, with or without | | 6 | # Redistribution and use in source and binary forms, with or without |
7 | # modification, are permitted provided that the following conditions | | 7 | # modification, are permitted provided that the following conditions |
8 | # are met: | | 8 | # are met: |
9 | # 1. Redistributions of source code must retain the above copyright | | 9 | # 1. Redistributions of source code must retain the above copyright |
10 | # notice, this list of conditions and the following disclaimer. | | 10 | # notice, this list of conditions and the following disclaimer. |
11 | # 2. Redistributions in binary form must reproduce the above copyright | | 11 | # 2. Redistributions in binary form must reproduce the above copyright |
12 | # notice, this list of conditions and the following disclaimer in the | | 12 | # notice, this list of conditions and the following disclaimer in the |
13 | # documentation and/or other materials provided with the distribution. | | 13 | # documentation and/or other materials provided with the distribution. |
14 | # | | 14 | # |
| @@ -26,26 +26,29 @@ | | | @@ -26,26 +26,29 @@ |
26 | # | | 26 | # |
27 | | | 27 | |
28 | # The standard | | 28 | # The standard |
29 | # http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html | | 29 | # http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html |
30 | # explains (section 2.6) that Field splitting should be performed on the | | 30 | # explains (section 2.6) that Field splitting should be performed on the |
31 | # result of variable expansions. | | 31 | # result of variable expansions. |
32 | # In particular this means that in ${x-word}, 'word' must be expanded as if | | 32 | # In particular this means that in ${x-word}, 'word' must be expanded as if |
33 | # the "${x-" and "}" were absent from the input line. | | 33 | # the "${x-" and "}" were absent from the input line. |
34 | # | | 34 | # |
35 | # So: sh -c 'set ${x-a b c}; echo $#' should give 3. | | 35 | # So: sh -c 'set ${x-a b c}; echo $#' should give 3. |
36 | # and: sh -c 'set -- ${x-}' echo $#' shold give 0 | | 36 | # and: sh -c 'set -- ${x-}' echo $#' shold give 0 |
37 | # | | 37 | # |
38 | | | 38 | |
| | | 39 | # the implementation of "sh" to test |
| | | 40 | : ${TEST_SH:="/bin/sh"} |
| | | 41 | |
39 | nl=' | | 42 | nl=' |
40 | ' | | 43 | ' |
41 | | | 44 | |
42 | check() | | 45 | check() |
43 | { | | 46 | { |
44 | TEST=$((${TEST} + 1)) | | 47 | TEST=$((${TEST} + 1)) |
45 | | | 48 | |
46 | case "$#" in | | 49 | case "$#" in |
47 | (2) ;; | | 50 | (2) ;; |
48 | (*) atf_fail "Internal test error, $# args to check test ${TEST}";; | | 51 | (*) atf_fail "Internal test error, $# args to check test ${TEST}";; |
49 | esac | | 52 | esac |
50 | | | 53 | |
51 | result=$( ${TEST_SH} -c "unset x; $1" ) | | 54 | result=$( ${TEST_SH} -c "unset x; $1" ) |