1*4887Schin######################################################################## 2*4887Schin# # 3*4887Schin# This software is part of the ast package # 4*4887Schin# Copyright (c) 1982-2007 AT&T Knowledge Ventures # 5*4887Schin# and is licensed under the # 6*4887Schin# Common Public License, Version 1.0 # 7*4887Schin# by AT&T Knowledge Ventures # 8*4887Schin# # 9*4887Schin# A copy of the License is available at # 10*4887Schin# http://www.opensource.org/licenses/cpl1.0.txt # 11*4887Schin# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) # 12*4887Schin# # 13*4887Schin# Information and Software Systems Research # 14*4887Schin# AT&T Research # 15*4887Schin# Florham Park NJ # 16*4887Schin# # 17*4887Schin# David Korn <dgk@research.att.com> # 18*4887Schin# # 19*4887Schin######################################################################## 20*4887Schinfunction err_exit 21*4887Schin{ 22*4887Schin print -u2 -n "\t" 23*4887Schin print -u2 -r ${Command}[$1]: "${@:2}" 24*4887Schin let Errors+=1 25*4887Schin} 26*4887Schinalias err_exit='err_exit $LINENO' 27*4887Schin 28*4887SchinCommand=${0##*/} 29*4887Schininteger Errors=0 j=4 30*4887Schinbase=/home/dgk/foo//bar 31*4887Schinstring1=$base/abcabcabc 32*4887Schinif [[ ${string1:0} != "$string1" ]] 33*4887Schinthen err_exit "string1:0" 34*4887Schinfi 35*4887Schinif [[ ${string1: -1} != "c" ]] 36*4887Schinthen err_exit "string1: -1" 37*4887Schinfi 38*4887Schinif [[ ${string1:0:1000} != "$string1" ]] 39*4887Schinthen err_exit "string1:0" 40*4887Schinfi 41*4887Schinif [[ ${string1:1} != "${string1#?}" ]] 42*4887Schinthen err_exit "string1:1" 43*4887Schinfi 44*4887Schinif [[ ${string1:1:4} != home ]] 45*4887Schinthen err_exit "string1:1:4" 46*4887Schinfi 47*4887Schinif [[ ${string1: -5:4} != bcab ]] 48*4887Schinthen err_exit "string1: -5:4" 49*4887Schinfi 50*4887Schinif [[ ${string1:1:j} != home ]] 51*4887Schinthen err_exit "string1:1:j" 52*4887Schinfi 53*4887Schinif [[ ${string1:(j?1:0):j} != home ]] 54*4887Schinthen err_exit "string1:(j?1:0):j" 55*4887Schinfi 56*4887Schinif [[ ${string1%*zzz*} != "$string1" ]] 57*4887Schinthen err_exit "string1%*zzz*" 58*4887Schinfi 59*4887Schinif [[ ${string1%%*zzz*} != "$string1" ]] 60*4887Schinthen err_exit "string1%%*zzz*" 61*4887Schinfi 62*4887Schinif [[ ${string1#*zzz*} != "$string1" ]] 63*4887Schinthen err_exit "string1#*zzz*" 64*4887Schinfi 65*4887Schinif [[ ${string1##*zzz*} != "$string1" ]] 66*4887Schinthen err_exit "string1##*zzz*" 67*4887Schinfi 68*4887Schinif [[ ${string1%+(abc)} != "$base/abcabc" ]] 69*4887Schinthen err_exit "string1%+(abc)" 70*4887Schinfi 71*4887Schinif [[ ${string1%%+(abc)} != "$base/" ]] 72*4887Schinthen err_exit "string1%%+(abc)" 73*4887Schinfi 74*4887Schinif [[ ${string1%/*} != "$base" ]] 75*4887Schinthen err_exit "string1%/*" 76*4887Schinfi 77*4887Schinif [[ "${string1%/*}" != "$base" ]] 78*4887Schinthen err_exit '"string1%/*"' 79*4887Schinfi 80*4887Schinif [[ ${string1%"/*"} != "$string1" ]] 81*4887Schinthen err_exit 'string1%"/*"' 82*4887Schinfi 83*4887Schinif [[ ${string1%%/*} != "" ]] 84*4887Schinthen err_exit "string1%%/*" 85*4887Schinfi 86*4887Schinif [[ ${string1#*/bar} != /abcabcabc ]] 87*4887Schinthen err_exit "string1#*bar" 88*4887Schinfi 89*4887Schinif [[ ${string1##*/bar} != /abcabcabc ]] 90*4887Schinthen err_exit "string1#*bar" 91*4887Schinfi 92*4887Schinif [[ "${string1#@(*/bar|*/foo)}" != //bar/abcabcabc ]] 93*4887Schinthen err_exit "string1#@(*/bar|*/foo)" 94*4887Schinfi 95*4887Schinif [[ ${string1##@(*/bar|*/foo)} != /abcabcabc ]] 96*4887Schinthen err_exit "string1##@(*/bar|*/foo)" 97*4887Schinfi 98*4887Schinif [[ ${string1##*/@(bar|foo)} != /abcabcabc ]] 99*4887Schinthen err_exit "string1##*/@(bar|foo)" 100*4887Schinfi 101*4887Schinfoo=abc 102*4887Schinif [[ ${foo#a[b*} != abc ]] 103*4887Schinthen err_exit "abc#a[b*} != abc" 104*4887Schinfi 105*4887Schinif [[ ${foo//[0-9]/bar} != abc ]] 106*4887Schinthen err_exit '${foo//[0-9]/bar} not expanding correctly' 107*4887Schinfi 108*4887Schinfoo='(abc)' 109*4887Schinif [[ ${foo#'('} != 'abc)' ]] 110*4887Schinthen err_exit "(abc)#( != abc)" 111*4887Schinfi 112*4887Schinif [[ ${foo%')'} != '(abc' ]] 113*4887Schinthen err_exit "(abc)%) != (abc" 114*4887Schinfi 115*4887Schinfoo=a123b456c 116*4887Schinif [[ ${foo/[0-9]?/""} != a3b456c ]] 117*4887Schinthen err_exit '${foo/[0-9]?/""} not expanding correctly' 118*4887Schinfi 119*4887Schinif [[ ${foo//[0-9]/""} != abc ]] 120*4887Schinthen err_exit '${foo//[0-9]/""} not expanding correctly' 121*4887Schinfi 122*4887Schinif [[ ${foo/#a/b} != b123b456c ]] 123*4887Schinthen err_exit '${foo/#a/b} not expanding correctly' 124*4887Schinfi 125*4887Schinif [[ ${foo/#?/b} != b123b456c ]] 126*4887Schinthen err_exit '${foo/#?/b} not expanding correctly' 127*4887Schinfi 128*4887Schinif [[ ${foo/%c/b} != a123b456b ]] 129*4887Schinthen err_exit '${foo/%c/b} not expanding correctly' 130*4887Schinfi 131*4887Schinif [[ ${foo/%?/b} != a123b456b ]] 132*4887Schinthen err_exit '${foo/%?/b} not expanding correctly' 133*4887Schinfi 134*4887Schinwhile read -r pattern string expected 135*4887Schindo if (( expected )) 136*4887Schin then if [[ $string != $pattern ]] 137*4887Schin then err_exit "$pattern does not match $string" 138*4887Schin fi 139*4887Schin if [[ ${string##$pattern} != "" ]] 140*4887Schin then err_exit "\${$string##$pattern} not null" 141*4887Schin fi 142*4887Schin if [ "${string##$pattern}" != '' ] 143*4887Schin then err_exit "\"\${$string##$pattern}\" not null" 144*4887Schin fi 145*4887Schin if [[ ${string/$pattern} != "" ]] 146*4887Schin then err_exit "\${$string/$pattern} not null" 147*4887Schin fi 148*4887Schin else if [[ $string == $pattern ]] 149*4887Schin then err_exit "$pattern matches $string" 150*4887Schin fi 151*4887Schin fi 152*4887Schindone <<- \EOF 153*4887Schin +(a)*+(a) aabca 1 154*4887Schin !(*.o) foo.o 0 155*4887Schin !(*.o) foo.c 1 156*4887SchinEOF 157*4887Schinxx=a/b/c/d/e 158*4887Schinyy=${xx#*/} 159*4887Schinif [[ $yy != b/c/d/e ]] 160*4887Schinthen err_exit '${xx#*/} != a/b/c/d/e when xx=a/b/c/d/e' 161*4887Schinfi 162*4887Schinif [[ ${xx//\//\\} != 'a\b\c\d\e' ]] 163*4887Schinthen err_exit '${xx//\//\\} not working' 164*4887Schinfi 165*4887Schinx=[123]def 166*4887Schinif [[ "${x//\[(*)\]/\{\1\}}" != {123}def ]] 167*4887Schinthen err_exit 'closing brace escape not working' 168*4887Schinfi 169*4887Schinunset foo 170*4887Schinfoo=one/two/three 171*4887Schinif [[ ${foo//'/'/_} != one_two_three ]] 172*4887Schinthen err_exit 'single quoting / in replacements failed' 173*4887Schinfi 174*4887Schinif [[ ${foo//"/"/_} != one_two_three ]] 175*4887Schinthen err_exit 'double quoting / in replacements failed' 176*4887Schinfi 177*4887Schinif [[ ${foo//\//_} != one_two_three ]] 178*4887Schinthen err_exit 'escaping / in replacements failed' 179*4887Schinfi 180*4887Schinfunction myexport 181*4887Schin{ 182*4887Schin nameref var=$1 183*4887Schin if (( $# > 1 )) 184*4887Schin then export $1=$2 185*4887Schin fi 186*4887Schin if (( $# > 2 )) 187*4887Schin then print $(myexport "$1" "$3" ) 188*4887Schin return 189*4887Schin fi 190*4887Schin typeset val 191*4887Schin val=$(export | grep "^$1=") 192*4887Schin print ${val#"$1="} 193*4887Schin 194*4887Schin} 195*4887Schinexport dgk=base 196*4887Schinif [[ $(myexport dgk fun) != fun ]] 197*4887Schinthen err_exit 'export inside function not working' 198*4887Schinfi 199*4887Schinval=$(export | grep "^dgk=") 200*4887Schinif [[ ${val#dgk=} != base ]] 201*4887Schinthen err_exit 'export not restored after function call' 202*4887Schinfi 203*4887Schinif [[ $(myexport dgk fun fun2) != fun2 ]] 204*4887Schinthen err_exit 'export inside function not working with recursive function' 205*4887Schinfi 206*4887Schinval=$(export | grep "^dgk=") 207*4887Schinif [[ ${val#dgk=} != base ]] 208*4887Schinthen err_exit 'export not restored after recursive function call' 209*4887Schinfi 210*4887Schinif [[ $(dgk=try3 myexport dgk) != try3 ]] 211*4887Schinthen err_exit 'name=value not added to export list with function call' 212*4887Schinfi 213*4887Schinval=$(export | grep "^dgk=") 214*4887Schinif [[ ${val#dgk=} != base ]] 215*4887Schinthen err_exit 'export not restored name=value function call' 216*4887Schinfi 217*4887Schinunset zzz 218*4887Schinif [[ $(myexport zzz fun) != fun ]] 219*4887Schinthen err_exit 'export inside function not working for zzz' 220*4887Schinfi 221*4887Schinif [[ $(export | grep "zzz=") ]] 222*4887Schinthen err_exit 'zzz exported after function call' 223*4887Schinfi 224*4887Schinset -- foo/bar bam/yes last/file/done 225*4887Schinif [[ ${@/*\/@(*)/${.sh.match[1]}} != 'bar yes done' ]] 226*4887Schinthen err_exit '.sh.match not working with $@' 227*4887Schinfi 228*4887Schinif [[ ${@/*\/@(*)/\1} != 'bar yes done' ]] 229*4887Schinthen err_exit '\1 not working with $@' 230*4887Schinfi 231*4887Schinvar=(foo/bar bam/yes last/file/done) 232*4887Schinif [[ ${var[@]/*\/@(*)/${.sh.match[1]}} != 'bar yes done' ]] 233*4887Schinthen err_exit '.sh.match not working with ${var[@]}' 234*4887Schinfi 235*4887Schinif [[ ${var[@]/*\/@(*)/\1} != 'bar yes done' ]] 236*4887Schinthen err_exit '\1 not working with ${var[@]}' 237*4887Schinfi 238*4887Schinvar='abc_d2ef.462abc %%' 239*4887Schinif [[ ${var/+(\w)/Q} != 'Q.462abc %%' ]] 240*4887Schinthen err_exit '${var/+(\w)/Q} not workding' 241*4887Schinfi 242*4887Schinif [[ ${var//+(\w)/Q} != 'Q.Q %%' ]] 243*4887Schinthen err_exit '${var//+(\w)/Q} not workding' 244*4887Schinfi 245*4887Schinif [[ ${var//+(\S)/Q} != 'Q Q' ]] 246*4887Schinthen err_exit '${var//+(\S)/Q} not workding' 247*4887Schinfi 248*4887Schinif [[ "$(LC_ALL=debug $SHELL <<- \+EOF+ 249*4887Schin x=a<2bc><3xyz>g 250*4887Schin print ${#x} 251*4887Schin +EOF+)" != 4 252*4887Schin ]] 253*4887Schinthen err_exit '${#x} not working with multibyte locales' 254*4887Schinfi 255*4887Schinfoo='foo+bar+' 256*4887Schin[[ $(print -r -- ${foo//+/'|'}) != 'foo|bar|' ]] && err_exit "\${foobar//+/'|'}" 257*4887Schin[[ $(print -r -- ${foo//+/"|"}) != 'foo|bar|' ]] && err_exit '${foobar//+/"|"}' 258*4887Schin[[ $(print -r -- "${foo//+/'|'}") != 'foo|bar|' ]] && err_exit '"${foobar//+/'"'|'"'}"' 259*4887Schin[[ $(print -r -- "${foo//+/"|"}") != 'foo|bar|' ]] && err_exit '"${foobar//+/"|"}"' 260*4887Schinunset x 261*4887Schinx=abcedfg 262*4887Schin: ${x%@(d)f@(g)} 263*4887Schin[[ ${.sh.match[0]} == dfg ]] || err_exit '.sh.match[0] not dfg' 264*4887Schin[[ ${.sh.match[1]} == d ]] || err_exit '.sh.match[1] not d' 265*4887Schin[[ ${.sh.match[2]} == g ]] || err_exit '.sh.match[2] not g' 266*4887Schinx=abcedddfg 267*4887Schin: ${x%%+(d)f@(g)} 268*4887Schin[[ ${.sh.match[1]} == ddd ]] || err_exit '.sh.match[1] not ddd' 269*4887Schinunset a b 270*4887Schina='\[abc @(*) def\]' 271*4887Schinb='[abc 123 def]' 272*4887Schin[[ ${b//$a/\1} == 123 ]] || err_exit "\${var/pattern} not working with \[ in pattern" 273*4887Schinunset X 274*4887Schin$SHELL -c '[[ ! ${X[@]:0:300} ]]' 2> /dev/null || err_exit '${X[@]:0:300} with X undefined fails' 275*4887Schin$SHELL -c '[[ ${@:0:300} == "$0" ]]' 2> /dev/null || err_exit '${@:0:300} with no arguments fails' 276*4887Schini=20030704 277*4887Schin[[ ${i#{6}(?)} == 04 ]] || err_exit '${i#{6}(?)} not working' 278*4887Schin[[ ${i#{6,6}(?)} == 04 ]] || err_exit '${i#{6,6}(?)} not working' 279*4887SchinLC_ALL=posix 280*4887Schini=" ." 281*4887Schin[[ $(printf "<%s>\n" ${i#' '}) == '<.>' ]] || err_exit 'printf "<%s>\n" ${i#' '} failed' 282*4887Schinunset x 283*4887Schinx=foo 284*4887Schin[[ "${x%o}(1)" == "fo(1)" ]] || err_exit 'print ${}() treated as pattern' 285*4887Schinunset i pattern string 286*4887Schinstring=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz 287*4887Schininteger i 288*4887Schinfor((i=0; i < ${#string}; i++)) 289*4887Schindo pattern+='@(?)' 290*4887Schindone 291*4887Schin[[ $(string=$string $SHELL -c ": \${string/$pattern/}; print \${.sh.match[26]}") == Z ]] || err_exit -u2 'sh.match[26] not Z' 292*4887Schin: ${string/$pattern/} 293*4887Schin(( ${#.sh.match[@]} == 53 )) || err_exit '.sh.match has wrong number of elements' 294*4887Schin[[ ${.sh.match[@]:2:4} == 'B C D E' ]] || err_exit '${.sh.match[@]:2:4} incorrect' 295*4887Schin 296*4887SchinD=$';' E=$'\\\\' Q=$'"' S=$'\'' M='nested pattern substitution failed' 297*4887Schin 298*4887Schinx='-(-)-' 299*4887Schin[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M 300*4887Schinx='-(-)-)-' 301*4887Schin[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M 302*4887Schinx='-(-()-)-' 303*4887Schin[[ ${x/*%(())*/\1} == '()' ]] || err_exit $M 304*4887Schinx='-(-\)-)-' 305*4887Schin[[ ${x/*%(())*/\1} == '(-\)' ]] || err_exit $M 306*4887Schinx='-(-\\)-)-' 307*4887Schin[[ ${x/*%(())*/\1} == '(-\\)' ]] || err_exit $M 308*4887Schinx='-(-(-)-' 309*4887Schin[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M 310*4887Schinx='-(-(-)-)-' 311*4887Schin[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M 312*4887Schinx='-(-[-]-)-' 313*4887Schin[[ ${x/*%(()[])*/\1} == '(-[-]-)' ]] || err_exit $M 314*4887Schinx='-[-(-)-]-' 315*4887Schin[[ ${x/*%(()[])*/\1} == '(-)' ]] || err_exit $M 316*4887Schinx='-(-[-)-]-' 317*4887Schin[[ ${x/*%(()[])*/\1} == '-(-[-)-]-' ]] || err_exit $M 318*4887Schinx='-(-[-]-)-' 319*4887Schin[[ ${x/*%([]())*/\1} == '[-]' ]] || err_exit $M 320*4887Schinx='-[-(-)-]-' 321*4887Schin[[ ${x/*%([]())*/\1} == '[-(-)-]' ]] || err_exit $M 322*4887Schinx='-(-[-)-]-' 323*4887Schin[[ ${x/*%([]())*/\1} == '-(-[-)-]-' ]] || err_exit $M 324*4887Schin 325*4887Schinx='-((-))-' 326*4887Schin[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M 327*4887Schinx='-((-))-' 328*4887Schin[[ ${x/~(-g)*%(())*/\1} == '((-))-' ]] || err_exit $M 329*4887Schinx='-((-))-' 330*4887Schin[[ ${x/~(-g:*)*%(())*/\1} == '(-)' ]] || err_exit $M 331*4887Schinx='-((-))-' 332*4887Schin[[ ${x/~(+g)*%(())*/\1} == '(-)' ]] || err_exit $M 333*4887Schinx='-((-))-' 334*4887Schin[[ ${x/~(+g:*)*%(())*/\1} == '(-)' ]] || err_exit $M 335*4887Schinx='-((-))-' 336*4887Schin[[ ${x/*(?)*%(())*(?)*/:\1:\2:\3:} == ':-(:(-):)-:' ]] || err_exit $M 337*4887Schinx='-((-))-' 338*4887Schin[[ ${x/~(-g)*(?)*%(())*(?)*/:\1:\2:\3:} == '::((-))::-' ]] || err_exit $M 339*4887Schinx='-((-))-' 340*4887Schin[[ ${x/~(-g:*(?))*%(())*(?)*/:\1:\2:\3:} == '::(-):)-:' ]] || err_exit $M 341*4887Schinx='-((-))-' 342*4887Schin[[ ${x/~(+g)*(?)*%(())*(?)*/:\1:\2:\3:} == ':-(:(-):)-:' ]] || err_exit $M 343*4887Schinx='-((-))-' 344*4887Schin[[ ${x/~(+g:*(?))*%(())*(?)*/:\1:\2:\3:} == ':-(:(-):)-:' ]] || err_exit $M 345*4887Schinx='call(a+b,x/(c/d),(0));' 346*4887Schin[[ ${x/+([[:alnum:]])*([[:space:]])(*%(()))*/:\1:\2:\3:} == ':call::(a+b,x/(c/d),(0)):' ]] || err_exit $M 347*4887Schin 348*4887Schinx='-(-;-)-' 349*4887Schin[[ ${x/*%(()D${D})*/\1} == '-(-;-)-' ]] || err_exit $M 350*4887Schinx='-(-);-' 351*4887Schin[[ ${x/*%(()D${D})*/\1} == '(-)' ]] || err_exit $M 352*4887Schinx='-(-)\;-' 353*4887Schin[[ ${x/*%(()D${D})*/\1} == '(-)' ]] || err_exit $M 354*4887Schinx='-(-\;-)-' 355*4887Schin[[ ${x/*%(()D${D}E${E})*/\1} == '(-\;-)' ]] || err_exit $M 356*4887Schinx='-(-)\;-' 357*4887Schin[[ ${x/*%(()D${D}E${E})*/\1} == '(-)' ]] || err_exit $M 358*4887Schinx='-(-(-)\;-)-' 359*4887Schin[[ ${x/*%(()D${D}E${E})*/\1} == '(-)' ]] || err_exit $M 360*4887Schin 361*4887Schinx='-(-")"-)-' 362*4887Schin[[ ${x/*%(()Q${Q})*/\1} == '(-")"-)' ]] || err_exit $M 363*4887Schinx='-(-\")"-)-' 364*4887Schin[[ ${x/*%(()Q${Q})*/\1} == '(-\")"-)' ]] || err_exit $M 365*4887Schinx='-(-\")\"-)-' 366*4887Schin[[ ${x/*%(()Q${Q})*/\1} == '(-\")\"-)' ]] || err_exit $M 367*4887Schinx=$'-(-\\\'")\\\'-)-' 368*4887Schin[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'(-\\\'")\\\'-)' ]] || err_exit $M 369*4887Schinx=$'-(-\\\'")"-)-' 370*4887Schin[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'-(-\\\'")"-)-' ]] || err_exit $M 371*4887Schinx=$'-(-\\\'")"\'-)-' 372*4887Schin[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'(-\\\'")"\'-)' ]] || err_exit $M 373*4887Schinx=$'-(-\\"\')\'\\"-)-' 374*4887Schin[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M 375*4887Schinx=$'-(-\')\\\'\'-)-' 376*4887Schin[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'-(-\')\\\'\'-)-' ]] || err_exit $M 377*4887Schinx=$'-(-\'")\'-)-' 378*4887Schin[[ ${x/*%(()L${S}Q${Q})*/\1} == $'(-\'")\'-)' ]] || err_exit $M 379*4887Schinx=$'-(-\\\'")"-)-' 380*4887Schin[[ ${x/*%(()L${S}Q${Q})*/\1} == $'-(-\\\'")"-)-' ]] || err_exit $M 381*4887Schinx=$'-(-\\\'")"\'-)-' 382*4887Schin[[ ${x/*%(()L${S}Q${Q})*/\1} == $'(-\\\'")"\'-)' ]] || err_exit $M 383*4887Schinx=$'-(-\\"\')\'\\"-)-' 384*4887Schin[[ ${x/*%(()L${S}Q${Q})*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M 385*4887Schinx=$'-(-\')\\\'\'-)-' 386*4887Schin[[ ${x/*%(()L${S}Q${Q})*/\1} == $'-(-\')\\\'\'-)-' ]] || err_exit $M 387*4887Schinx='-(-")"-)-' 388*4887Schin[[ ${x/*%(()Q${Q})*/\1} == '(-")"-)' ]] || err_exit $M 389*4887Schinx='-(-\")"-)-' 390*4887Schin[[ ${x/*%(()Q${Q})*/\1} == '(-\")"-)' ]] || err_exit $M 391*4887Schinx='-(-\")\"-)-' 392*4887Schin[[ ${x/*%(()Q${Q})*/\1} == '(-\")\"-)' ]] || err_exit $M 393*4887Schin 394*4887Schinx='-(-\)-)-' 395*4887Schin[[ ${x/*%(()E${E})*/\1} == '(-\)-)' ]] || err_exit $M 396*4887Schinx='-(-\\)-)-' 397*4887Schin[[ ${x/*%(()E${E})*/\1} == '(-\\)' ]] || err_exit $M 398*4887Schinx='-(-\")"-)-' 399*4887Schin[[ ${x/*%(()E${E}Q${Q})*/\1} == '(-\")' ]] || err_exit $M 400*4887Schinx='-(-\")\"-)-' 401*4887Schin[[ ${x/*%(()E${E}Q${Q})*/\1} == '(-\")' ]] || err_exit $M 402*4887Schinx=$'-(-\'")"-)-' 403*4887Schin[[ ${x/*%(()E${E}Q${S}Q${Q})*/\1} == $'-(-\'")"-)-' ]] || err_exit $M 404*4887Schinx=$'-(-\\\'")"-)-' 405*4887Schin[[ ${x/*%(()E${E}Q${S}Q${Q})*/\1} == $'(-\\\'")"-)' ]] || err_exit $M 406*4887Schinx=$'-(-\\"\')\'\\"-)-' 407*4887Schin[[ ${x/*%(()E${E}Q${S}Q${Q})*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M 408*4887Schinx=$'-(-\\\'")"-)-' 409*4887Schin[[ ${x/*%(()E${E}L${S}Q${Q})*/\1} == $'(-\\\'")"-)' ]] || err_exit $M 410*4887Schinx=$'-(-\\"\')\'\\"-)-' 411*4887Schin[[ ${x/*%(()E${E}L${S}Q${Q})*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M 412*4887Schinx=$'-(-\\"\')\\\'\\"-)-' 413*4887Schin[[ ${x/*%(()E${E}L${S}Q${Q})*/\1} == $'(-\\"\')\\\'\\"-)' ]] || err_exit $M 414*4887Schinx=$'-(-\\"\')\\\'\\"\'-)-' 415*4887Schin[[ ${x/*%(()E${E}L${S}Q${Q})*/\1} == $'-(-\\"\')\\\'\\"\'-)-' ]] || err_exit $M 416*4887Schin 417*4887Schinx='-(-;-)-' 418*4887Schin[[ ${x/*%(()D\;)*/\1} == '-(-;-)-' ]] || err_exit $M 419*4887Schinx='-(-);-' 420*4887Schin[[ ${x/*%(()D\;)*/\1} == '(-)' ]] || err_exit $M 421*4887Schinx='-(-)\;-' 422*4887Schin[[ ${x/*%(()D\;)*/\1} == '(-)' ]] || err_exit $M 423*4887Schinx='-(-\;-)-' 424*4887Schin[[ ${x/*%(()D\;E\\)*/\1} == '(-\;-)' ]] || err_exit $M 425*4887Schinx='-(-);-' 426*4887Schin[[ ${x/*%(()D\;E\\)*/\1} == '(-)' ]] || err_exit $M 427*4887Schinx='-(-)\;-' 428*4887Schin[[ ${x/*%(()D\;E\\)*/\1} == '(-)' ]] || err_exit $M 429*4887Schinx='-(-(-)\;-)-' 430*4887Schin[[ ${x/*%(()D\;E\\)*/\1} == '(-)' ]] || err_exit $M 431*4887Schin 432*4887Schinx='-(-")"-)-' 433*4887Schin[[ ${x/*%(()Q\")*/\1} == '(-")"-)' ]] || err_exit $M 434*4887Schinx='-(-\")"-)-' 435*4887Schin[[ ${x/*%(()Q\")*/\1} == '(-\")"-)' ]] || err_exit $M 436*4887Schinx='-(-\")\"-)-' 437*4887Schin[[ ${x/*%(()Q\")*/\1} == '(-\")\"-)' ]] || err_exit $M 438*4887Schinx=$'-(-\\\'")\\\'-)-' 439*4887Schin[[ ${x/*%(()Q\'Q\")*/\1} == $'(-\\\'")\\\'-)' ]] || err_exit $M 440*4887Schinx=$'-(-\\\'")"-)-' 441*4887Schin[[ ${x/*%(()Q\'Q\")*/\1} == $'-(-\\\'")"-)-' ]] || err_exit $M 442*4887Schinx=$'-(-\\\'")"\'-)-' 443*4887Schin[[ ${x/*%(()Q\'Q\")*/\1} == $'(-\\\'")"\'-)' ]] || err_exit $M 444*4887Schinx=$'-(-\\"\')\'\\"-)-' 445*4887Schin[[ ${x/*%(()Q\'Q\")*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M 446*4887Schinx=$'-(-\')\\\'\'-)-' 447*4887Schin[[ ${x/*%(()Q\'Q\")*/\1} == $'-(-\')\\\'\'-)-' ]] || err_exit $M 448*4887Schinx=$'-(-\'")\'-)-' 449*4887Schin[[ ${x/*%(()L\'Q\")*/\1} == $'(-\'")\'-)' ]] || err_exit $M 450*4887Schinx=$'-(-\\\'")"-)-' 451*4887Schin[[ ${x/*%(()L\'Q\")*/\1} == $'-(-\\\'")"-)-' ]] || err_exit $M 452*4887Schinx=$'-(-\\\'")"\'-)-' 453*4887Schin[[ ${x/*%(()L\'Q\")*/\1} == $'(-\\\'")"\'-)' ]] || err_exit $M 454*4887Schinx=$'-(-\\"\')\'\\"-)-' 455*4887Schin[[ ${x/*%(()L\'Q\")*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M 456*4887Schinx=$'-(-\')\\\'\'-)-' 457*4887Schin[[ ${x/*%(()L\'Q\")*/\1} == $'-(-\')\\\'\'-)-' ]] || err_exit $M 458*4887Schinx='-(-")"-)-' 459*4887Schin[[ ${x/*%(()Q\")*/\1} == '(-")"-)' ]] || err_exit $M 460*4887Schinx='-(-\")"-)-' 461*4887Schin[[ ${x/*%(()Q\")*/\1} == '(-\")"-)' ]] || err_exit $M 462*4887Schinx='-(-\")\"-)-' 463*4887Schin[[ ${x/*%(()Q\")*/\1} == '(-\")\"-)' ]] || err_exit $M 464*4887Schin 465*4887Schinx='-(-\)-)-' 466*4887Schin[[ ${x/*%(()E\\)*/\1} == '(-\)-)' ]] || err_exit $M 467*4887Schinx='-(-\\)-)-' 468*4887Schin[[ ${x/*%(()E\\)*/\1} == '(-\\)' ]] || err_exit $M 469*4887Schinx='-(-\")"-)-' 470*4887Schin[[ ${x/*%(()E\\Q\")*/\1} == '(-\")' ]] || err_exit $M 471*4887Schinx='-(-\")\"-)-' 472*4887Schin[[ ${x/*%(()E\\Q\")*/\1} == '(-\")' ]] || err_exit $M 473*4887Schinx=$'-(-\'")"-)-' 474*4887Schin[[ ${x/*%(()E\\Q\'Q\")*/\1} == $'-(-\'")"-)-' ]] || err_exit $M 475*4887Schinx=$'-(-\\\'")"-)-' 476*4887Schin[[ ${x/*%(()E\\Q\'Q\")*/\1} == $'(-\\\'")"-)' ]] || err_exit $M 477*4887Schinx=$'-(-\\"\')\'\\"-)-' 478*4887Schin[[ ${x/*%(()E\\Q\'Q\")*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M 479*4887Schinx=$'-(-\\\'")"-)-' 480*4887Schin[[ ${x/*%(()E\\L\'Q\")*/\1} == $'(-\\\'")"-)' ]] || err_exit $M 481*4887Schinx=$'-(-\\"\')\'\\"-)-' 482*4887Schin[[ ${x/*%(()E\\L\'Q\")*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M 483*4887Schinx=$'-(-\\"\')\\\'\\"-)-' 484*4887Schin[[ ${x/*%(()E\\L\'Q\")*/\1} == $'(-\\"\')\\\'\\"-)' ]] || err_exit $M 485*4887Schinx=$'-(-\\"\')\\\'\\"\'-)-' 486*4887Schin[[ ${x/*%(()E\\L\'Q\")*/\1} == $'-(-\\"\')\\\'\\"\'-)-' ]] || err_exit $M 487*4887Schin 488*4887Schinpattern=00 489*4887Schinvar=100 490*4887Schin[[ $( print $(( ${var%%00} )) ) == 1 ]] || err_exit "arithmetic with embeddded patterns fails" 491*4887Schin[[ $( print $(( ${var%%$pattern} )) ) == 1 ]] || err_exit "arithmetic with embeddded pattern variables fails" 492*4887Schinif [[ ax == @(a)* ]] && [[ ${.sh.match[1]:0:${#.sh.match[1]}} != a ]] 493*4887Schinthen err_exit '${.sh.match[1]:1:${#.sh.match[1]}} not expanding correctly' 494*4887Schinfi 495*4887Schin 496*4887Schinstring='foo(d:\nt\box\something)bar' 497*4887Schinexpected='d:\nt\box\something' 498*4887Schin[[ ${string/*\(+([!\)])\)*/\1} == "$expected" ]] || err_exit "substring expansion failed '${string/*\(+([!\)])\)*/\1}' returned -- '$expected' expected" 499*4887Schinif [[ $($SHELL -c $'export LC_ALL=en_US.UTF-8; print -r "\342\202\254\342\202\254\342\202\254\342\202\254w\342\202\254\342\202\254\342\202\254\342\202\254" | wc -m' 2>/dev/null) == 10 ]] 500*4887Schinthen LC_ALL=en_US.UTF-8 $SHELL -c b1=$'"\342\202\254\342\202\254\342\202\254\342\202\254w\342\202\254\342\202\254\342\202\254\342\202\254"; [[ ${b1:4:1} == w ]]' || err_exit 'Multibyte ${var:offset:len} not working correctly' 501*4887Schinfi 502*4887Schin{ $SHELL -c 'unset x;[[ ${SHELL:$x} == $SHELL ]]';} 2> /dev/null || err_exit '${var:$x} fails when x is not set' 503*4887Schin{ $SHELL -c 'x=;[[ ${SHELL:$x} == $SHELL ]]';} 2> /dev/null || err_exit '${var:$x} fails when x is null' 504*4887Schinexit $((Errors)) 505