187 lines · 3.6 KB · Text
RawDownload
#!/bin/rcecho T.errmsg:  check some error messages >[1=2] ls >foo.glopawk 'BEGIN{	awk = ENVIRON["awk"]}{	pat = $0	prog = ""	while (getline x > 0 && x != "")		prog = prog "\n" x	print "\n"awk" ''"prog"'' <foo.glop >/dev/null >[2]foo"	print "grep ''"pat"'' foo >/dev/null || echo ''BAD: T.errmsg: "pat"'' >[1=2]"}' >foo.rc <<'!!!!'parsing error/(/ illegal break, continue, next or nextfile from BEGINBEGIN { nextfile } nextfile is illegal inside a functionfunction foo() { nextfile } duplicate argumentfunction f(i,j,i) { return i } No closing ] for class/[\ No closing ] for classBEGIN { s = "[x"; if (1 ~ s) print "foo"} no matching parenthesis/((.)/ division by zeroBEGIN { print 1/0 } division by zero in /=BEGIN { x = 1; print x /= 0 } division by zero in %=BEGIN { x = 1; print x %= 0 } division by zero in modBEGIN { print 1%0 } can''t read value.* array name.BEGIN { x[1] = 0; split("a b c", y, x) } can''t read value.* functionfunction f(){}; {split($0, x, f)} can''t assign.* a functionfunction f(){}; {f = split($0, x)} can''t assign to x; it.s an array name.{x = split($0, x)} is a function, not an arrayfunction f(){}; {split($0, f)} function f called with 1 args, uses only 0BEGIN { f(f) }function f() { print "x" } x is an array, not a function{ split($0, x) }; function x() {} illegal nested functionfunction x() { function g() {} } return not in function{ return } break illegal outside{ break } continue illegal outside{ continue } non-terminated string{ print "abc} next is illegal inside a functionBEGIN { f() }function f() { next } not enough args in printf\(%s\)BEGIN { printf("%s") } weird printf conversionBEGIN { printf("%z", "foo")} function f has .* arguments, limit .*function f(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,	c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,	e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10) {}BEGIN { f(123) } bailing out])} bailing out{ print }} bailing out{ print }}} bailing out] bailing out[ bailing outa & b extra \){ x = 1) } illegal statement{ print ))} illegal statement{{ print } illegal statement{{{ print } illegal .*next.* from BEGINBEGIN { next } illegal .*next.* from ENDEND {	next; print NR } can''t open file ./nonexistentdir/fooBEGIN { print "abc" >"./nonexistentdir/foo" } you can''t define function f more than oncefunction f() { print 1 }function f() { print 2 } function mp called with 1 args, uses only 0function mp(){ cnt++;}BEGIN {	mp(xx) } index.*doesn.t permit regular expressionsBEGIN { index("abc", /a/) } log argument out of domainBEGIN { print log(-1) } exp result out of rangeBEGIN {print exp(1000)} null file name in print or getlineBEGIN { print >foo } function has too many argumentsBEGIN { length("abc", "def") } calling undefined function fooBEGIN { foo() }!!!! rc ./foo.rc echo xxx >foo0$awk '{print x}' 'x=ab' foo0 >foo1 >[2]foo2grep 'newline in string' foo2 >/dev/null || echo 'BAD: T.errmsg: newline in string' >[1=2] $awk -safe 'BEGIN{"date" | getline}' >foo >[2]foo2grep 'cmd | getline is unsafe' foo2 >/dev/null || echo 'BAD: T.errmsg: cmd|getline unsafe' >[1=2] $awk -safe 'BEGIN{print >"foo"}' >foo >[2]foo2grep 'print > is unsafe' foo2 >/dev/null || echo 'BAD: T.errmsg: print > unsafe' >[1=2] $awk -safe 'BEGIN{print >> "foo"}' >foo >[2]foo2grep 'print >> is unsafe' foo2 >/dev/null || echo 'BAD: T.errmsg: print >> unsafe' >[1=2] $awk -safe 'BEGIN{print | "foo"}' >foo >[2]foo2grep 'print | is unsafe' foo2 >/dev/null || echo 'BAD: T.errmsg: print | unsafe' >[1=2]