14887Schin######################################################################## 24887Schin# # 34887Schin# This software is part of the ast package # 4*12068SRoger.Faulkner@Oracle.COM# Copyright (c) 1982-2010 AT&T Intellectual Property # 54887Schin# and is licensed under the # 64887Schin# Common Public License, Version 1.0 # 78462SApril.Chin@Sun.COM# by AT&T Intellectual Property # 84887Schin# # 94887Schin# A copy of the License is available at # 104887Schin# http://www.opensource.org/licenses/cpl1.0.txt # 114887Schin# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) # 124887Schin# # 134887Schin# Information and Software Systems Research # 144887Schin# AT&T Research # 154887Schin# Florham Park NJ # 164887Schin# # 174887Schin# David Korn <dgk@research.att.com> # 184887Schin# # 194887Schin######################################################################## 204887Schinfunction err_exit 214887Schin{ 224887Schin print -u2 -n "\t" 234887Schin print -u2 -r ${Command}[$Line]: "$@" 244887Schin ((Errors++)) 254887Schin} 264887Schin 274887Schininteger Errors=0 284887SchinCommand=${0##*/} 294887Schin 304887Schin# {...} expansion tests -- ignore if not supported 314887Schin 324887Schin[[ $(print a{0,1}z) == "a0z a1z" ]] || exit 0 334887Schin 344887Schininteger Line=$LINENO+1 354887Schinset -- \ 364887Schin 'ff{c,b,a}' 'ffc ffb ffa' \ 374887Schin 'f{d,e,f}g' 'fdg feg ffg' \ 384887Schin '{l,n,m}xyz' 'lxyz nxyz mxyz' \ 394887Schin '{abc\,def}' '{abc,def}' \ 408462SApril.Chin@Sun.COM '{"abc,def"}' '{abc,def}' \ 418462SApril.Chin@Sun.COM "{'abc,def'}" '{abc,def}' \ 424887Schin '{abc}' '{abc}' \ 434887Schin '\{a,b,c,d,e}' '{a,b,c,d,e}' \ 444887Schin '{x,y,\{a,b,c}}' 'x} y} {a} b} c}' \ 454887Schin '{x\,y,\{abc\},trie}' 'x,y {abc} trie' \ 464887Schin '/usr/{ucb/{ex,edit},lib/{ex,how_ex}}' '/usr/ucb/ex /usr/ucb/edit /usr/lib/ex /usr/lib/how_ex' \ 474887Schin 'XXXX\{a,b,c\}' 'XXXX{a,b,c}' \ 484887Schin '{}' '{}' \ 494887Schin '{ }' '{ }' \ 504887Schin '}' '}' \ 514887Schin '{' '{' \ 524887Schin 'abcd{efgh' 'abcd{efgh' \ 534887Schin 'foo {1,2} bar' 'foo 1 2 bar' \ 544887Schin '`print -r -- foo {1,2} bar`' 'foo 1 2 bar' \ 554887Schin '$(print -r -- foo {1,2} bar)' 'foo 1 2 bar' \ 564887Schin '{1..10}' '1 2 3 4 5 6 7 8 9 10' \ 574887Schin '{0..10,braces}' '0..10 braces' \ 584887Schin '{{0..10},braces}' '0 1 2 3 4 5 6 7 8 9 10 braces' \ 594887Schin 'x{{0..10},braces}y' 'x0y x1y x2y x3y x4y x5y x6y x7y x8y x9y x10y xbracesy' \ 604887Schin '{3..3}' '3' \ 614887Schin 'x{3..3}y' 'x3y' \ 624887Schin '{10..1}' '10 9 8 7 6 5 4 3 2 1' \ 634887Schin '{10..1}y' '10y 9y 8y 7y 6y 5y 4y 3y 2y 1y' \ 644887Schin 'x{10..1}y' 'x10y x9y x8y x7y x6y x5y x4y x3y x2y x1y' \ 654887Schin '{a..f}' 'a b c d e f' \ 664887Schin '{f..a}' 'f e d c b a' \ 674887Schin '{a..A}' '{a..A}' \ 684887Schin '{A..a}' '{A..a}' \ 694887Schin '{f..f}' 'f' \ 704887Schin '{1..f}' '{1..f}' \ 714887Schin '{f..1}' '{f..1}' \ 724887Schin '0{1..9} {10..20}' '01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20' \ 734887Schin '{-1..-10}' '-1 -2 -3 -4 -5 -6 -7 -8 -9 -10' \ 744887Schin '{-19..0}' '-19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0' \ 754887Schin '{0..10}' '0 1 2 3 4 5 6 7 8 9 10' \ 764887Schin '{0..10..1}' '0 1 2 3 4 5 6 7 8 9 10' \ 774887Schin '{0..10..2}' '0 2 4 6 8 10' \ 784887Schin '{0..10..3}' '0 3 6 9' \ 794887Schin '{0..10..0}' '{0..10..0}' \ 804887Schin '{0..10..-1}' '0' \ 814887Schin '{10..0}' '10 9 8 7 6 5 4 3 2 1 0' \ 824887Schin '{10..0..-1}' '10 9 8 7 6 5 4 3 2 1 0' \ 834887Schin '{10..0..-2}' '10 8 6 4 2 0' \ 844887Schin '{10..0..-3}' '10 7 4 1' \ 854887Schin '{10..0..0}' '{10..0..0}' \ 864887Schin '{10..0..1}' '10' \ 874887Schin '{a..z..2}' 'a c e g i k m o q s u w y' \ 884887Schin '{y..b..-3}' 'y v s p m j g d' \ 894887Schin '{0..0x1000..0x200}' '0 512 1024 1536 2048 2560 3072 3584 4096' \ 904887Schin '{a,b}{0..2}{z,y}' 'a0z a0y a1z a1y a2z a2y b0z b0y b1z b1y b2z b2y' \ 914887Schin '{0..0100..8%03o}' '000 010 020 030 040 050 060 070 100' \ 924887Schin '{0..0100..040%020o}' '00000000000000000000 00000000000000000040 00000000000000000100' \ 934887Schin '{0..7%03..2u}' '000 001 010 011 100 101 110 111' \ 944887Schin '{0..10%llu}' '{0..10%llu}' \ 954887Schin '{0..10%s}' '{0..10%s}' \ 964887Schin '{0..10%dl}' '{0..10%dl}' \ 974887Schin '{a,b}{0..3%02..2u}{y,z}' 'a00y a00z a01y a01z a10y a10z a11y a11z b00y b00z b01y b01z b10y b10z b11y b11z' \ 984887Schin 994887Schinwhile (($#>1)) 1004887Schindo ((Line++)) 1014887Schin pattern=$1 1024887Schin shift 1034887Schin expected=$1 1044887Schin shift 1054887Schin got=$(eval print -r -- "$pattern") 1064887Schin [[ $got == $expected ]] || err_exit "'$pattern' failed -- expected '$expected' got '$got'" 1074887Schin #print -r -- " '$pattern' '$got' \\" 1084887Schindone 1094887Schin 1104887Schin# ~(N) no expand glob pattern option 1114887Schinset -- ~(N)/dev/null 1124887Schin[[ $# == 1 && $1 == /dev/null ]] || err_exit "~(N)/dev/null not matching /dev/null" 1134887Schinset -- ~(N)/dev/non_existant_file 1144887Schin[[ $# == 0 ]] || err_exit "~(N)/dev/nonexistant not empty" 1154887Schinset -- ""~(N)/dev/non_existant_file 1164887Schin[[ $# == 1 && ! $1 ]] || err_exit '""~(N)/dev/nonexistant not null argument' 1174887Schinset -- ~(N)/dev/non_existant_file"" 1184887Schin[[ $# == 1 && ! $1 ]] || err_exit '~(N)/dev/nonexistent"" not null argument' 1194887Schinfor i in ~(N)/dev/non_existent_file 1204887Schindo err_exit "~(N)/dev/non_existent_file in for loop is $i" 1214887Schindone 1224887Schinfor i in ""~(N)/dev/non_existent_file 1234887Schindo [[ ! $i ]] || err_exit '""~(N)/dev/non_existent_file not null' 1244887Schindone 1254887Schinexit $((Errors)) 126