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.
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.
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/>.
20 eval $1=\"\${$1:-$2}\"
30 expect '<aaa bbb ccc>'
32 expect '<aaa bbb ccc>'
36 eval $1=\'$2\''${'$1':+":"${'$1'}}'; export $1
48 expect '<aaa bbb ccc>'
66 expect '<a b> <c> <d> <e> <f>'
72 expect '<a b> <c> <d> <e> <f>'
74 expect '<a b> <c> <d> <e> <f>'
81 # This changed after bush-3.0, when the tilde implementation was redone. It's
82 # not backward compatible, but it's very hard to be backward-compatible here,
83 # and I think the old behavior was a bug
87 recho "${somevar:-"~"}"
89 recho "${somevar:-\~}"
91 recho "${somevar:-\ \~}"
93 recho "${somevar:-\ \ \~}"
96 recho ${somevar:-$HOME}
98 recho "${somevar:-$HOME}"
100 recho "${somevar:-"$HOME"}"
102 recho "${somevar:-\$HOME}"
104 recho "${somevar:-\ \$HOME}"
106 recho "${somevar:-\ \ \$HOME}"
110 recho "${foo+'$foo'}"
112 recho "${fox='$foo'}"
147 UNAME_RELEASE=${1:-4.2MP}
149 RELEASE=`expr "$UNAME_RELEASE" : '[^0-9]*\([0-9]*\)'` # 4
152 *) RELEASE=`expr "$RELEASE" + 0` ;;
154 REL_LEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.\([0-9]*\)'` # 1
155 REL_SUBLEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.[0-9]*.\([0-9]*\)'` # 2
158 recho $RELEASE $REL_LEVEL $REL_SUBLEVEL
193 expect '<--+\> <+-->'
198 expect '<-+\> <+-\> <->'
224 recho ${undef-"x$*y"}
226 recho ${undef-"$*xy"}
228 recho ${undef-"xy$*"}
230 recho ${undef-x"$*"y}
232 recho ${undef-xy"$*"}
234 recho ${undef-"$*"xy}
241 recho ${undef-"$zzz"}
243 recho x${undef-"$zzz"}
249 recho ${undef-"$zzz"}x
259 recho ${undef-"
\x7f"}
284 # should give an error
293 recho $(echo "foo$(echo ")")")
295 # test backslash escapes
335 recho $(zecho `zecho \a`)
336 recho $(zecho `zecho \\a`)
338 recho $(zecho `zecho "\a"`)
339 recho $(zecho `zecho "\\a"`)
341 recho $(zecho `zecho '\a'`)
342 recho $(zecho `zecho '\\a'`)
344 # should echo G { I K }
345 recho ${abc:-G { I } K }
350 recho ${abc:-G { I } K }
358 echo "Number of args: $#"
359 echo "<\${*-x}>: <${*-x}>"
360 echo "<\${@-x}>: <${@-x}>"
378 recho ${#:-posparams}
404 recho ${#:-posparams}
409 recho ${!:-posparams}
435 expect a bad substitution error
437 expect a bad substitution error
439 expect a bad substitution error
441 expect a bad substitution error
443 expect a bad substitution error
445 expect a bad substitution error
448 expect a math syntax error
472 # variants of nested curly braces inside ${...} expressions
474 # IFS is not the standard one
476 expect '<G { I>' '<K>' '<}>'
477 recho ${gik:-G { I } K }
481 expect '<hi>' '<K>' '<}>'
482 recho ${abc:-G { I } K }
484 # reset IFS to the default
488 # nested ${...} inside ${...} are handled specially
490 expect '<xxx>' '<yyy>'
492 FOO=${BAR:-${XXX} yyy}
495 # this was a bug in versions of bush prior to bush-2.04-release
506 # this was a bug in bush-2.04, fixed in 2.05
508 expect '<:a:>' '<:b:>'
509 for i in "${@-}"; do recho :$i:; done
511 # I believe that ksh93 does these wrong -- we're using the rhs, so shouldn't
512 # it behave the same as ""?