| Chet Ramey | 8868eda | 2020-12-06 15:51:17 -0500 | [diff] [blame] | 1 | # This program is free software: you can redistribute it and/or modify |
| 2 | # it under the terms of the GNU General Public License as published by |
| 3 | # the Free Software Foundation, either version 3 of the License, or |
| 4 | # (at your option) any later version. |
| 5 | # |
| 6 | # This program is distributed in the hope that it will be useful, |
| 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 | # GNU General Public License for more details. |
| 10 | # |
| 11 | # You should have received a copy of the GNU General Public License |
| 12 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 13 | # |
| 14 | n() { echo $#; } |
| 15 | |
| 16 | set -- |
| 17 | |
| 18 | n "$@" |
| 19 | |
| 20 | # should be 1 |
| 21 | n "$@"'' |
| 22 | n ''"$@" |
| 23 | n ''"$@"'' |
| 24 | |
| 25 | set -- '' |
| 26 | |
| 27 | n "$@" |
| 28 | # should be 1 |
| 29 | n "$@"'' |
| 30 | n ''"$@" |
| 31 | n ''"$@"'' |
| 32 | |
| 33 | set -- '' '' |
| 34 | |
| 35 | n "$@" |
| 36 | # should be 2 |
| 37 | n ''"$@" |
| 38 | # should be 2 |
| 39 | n "$@"'' |
| 40 | # should be 2 |
| 41 | n ''"$@"'' |
| 42 | |
| 43 | x=x |
| 44 | |
| 45 | set -- |
| 46 | |
| 47 | n ${x+"$@"} |
| 48 | |
| 49 | # should be 1 |
| 50 | n ${x+"$@"''} |
| 51 | n ${x+''"$@"} |
| 52 | n ${x+''"$@"''} |
| 53 | |
| 54 | set -- '' |
| 55 | |
| 56 | n ${x+"$@"} |
| 57 | # should be 1 |
| 58 | n ${x+"$@"''} |
| 59 | n ${x+''"$@"} |
| 60 | n ${x+''"$@"''} |
| 61 | |
| 62 | set -- '' '' |
| 63 | |
| 64 | n ${x+"$@"} |
| 65 | # should be 2 |
| 66 | n ${x+''"$@"} |
| 67 | # should be 2 |
| 68 | n ${x+"$@"''} |
| 69 | # should be 2 |
| 70 | n ${x+''"$@"''} |
| 71 | |
| 72 | |
| 73 | set -- |
| 74 | |
| 75 | n "$@" "$@" |
| 76 | n "$@""$@" |
| 77 | |
| 78 | n ${x+"$@" "$@"} |
| 79 | |
| 80 | set -- '' |
| 81 | |
| 82 | n ${x+"$@" "$@"} |
| 83 | n "$@" "$@" |
| 84 | |
| 85 | set -- '' '' |
| 86 | |
| 87 | n ${x+"$@" "$@"} |
| 88 | n "$@" "$@" |
| 89 | n "$@""$@" |
| 90 | |
| 91 | # new tests |
| 92 | unset -v x |
| 93 | v=$'\177' |
| 94 | |
| 95 | recho ''$'\177''' |
| 96 | recho $'\177''' |
| 97 | recho ''$'\177' |
| 98 | |
| 99 | recho ''$v'' |
| 100 | recho ''$v |
| 101 | recho $v'' |