[Seems like a plausible idea. My ideas: * Come up with an example of how it gets rid of the "echo yes | " workarounds? * Think about the consequences more? Not that I see many downsides, although having to quote < and ( is kind of hairy (probably OK as long as we document it in a comment at dotest, though). * Any portability problems with eval? It is in the Single Unix Specification, so it probably is OK to assume it, but I don't know whether it would be a big headache. * Ask devel-cvs and see if anyone there has ideas. -kingdon] From: oberon [Derek Price] To: Jim Kingdon Subject: eval's in sanity.sh? Date: Fri, 16 Apr 1999 00:59:23 -0300 Hey Jim, why aren't we using eval statements in the dotest* functions in sanity.sh? I put them in on a hunch that I wouldn't have to change anything to make it work and I was close. New (\) escapes were needed in only two places and all the tests still pass, local and remote. In addition, it means that output redirection, wildcard expansion, parens, and quoted arguments can be used as dotest* arguments (actually, it should mean the full power of shell, but I can't think of anything else that may have been disabled. `` was, but not so as you'd notice...). I have seen quite a few tests where this seems to have been worked around (many release and some unedit tests to allow "echo yes |${testcvs} ..."). Anyway, here's the patch in the hopes that you'll check it in. Derek P.S. I switched to the exmh mail handler. I checked on the tab thing, but let me know if you encounter any other problems. Index: ChangeLog =================================================================== RCS file: /cvsroot/ccvs/src/ChangeLog,v retrieving revision 1.12 diff -c -r1.12 ChangeLog *** ChangeLog 1999/04/16 04:08:25 1.12 --- ChangeLog 1999/04/16 04:52:38 *************** *** 1,3 **** --- 1,12 ---- + 1999-04-15 Derek Price + + + * sanity.sh (dotest, dotest_lit, dotest_fail, dotest_status, + dotest_sort): Added eval to each of the dotest* functions + so that the COMMAND parameter is eval'd rather than just + executed. This allows output redirection, wildcard expansion, + and quoted arguments to be used in COMMAND if desired. + 1999-04-13 Derek Price Index: sanity.sh =================================================================== RCS file: /cvsroot/ccvs/src/sanity.sh,v retrieving revision 1.13 diff -c -r1.13 sanity.sh *** sanity.sh 1999/04/16 04:08:26 1.13 --- sanity.sh 1999/04/16 04:13:43 *************** *** 434,440 **** dotest () { rm -f ${TESTDIR}/dotest.ex? 2>&1 ! if $2 >${TESTDIR}/dotest.tmp 2>&1; then : so far so good else status=$? --- 434,440 ---- dotest () { rm -f ${TESTDIR}/dotest.ex? 2>&1 ! if eval "$2" >${TESTDIR}/dotest.tmp 2>&1; then : so far so good else status=$? *************** *** 449,455 **** dotest_lit () { rm -f ${TESTDIR}/dotest.ex? 2>&1 ! if $2 >${TESTDIR}/dotest.tmp 2>&1; then : so far so good else status=$? --- 449,455 ---- dotest_lit () { rm -f ${TESTDIR}/dotest.ex? 2>&1 ! if eval "$2" >${TESTDIR}/dotest.tmp 2>&1; then : so far so good else status=$? *************** *** 473,479 **** dotest_fail () { rm -f ${TESTDIR}/dotest.ex? 2>&1 ! if $2 >${TESTDIR}/dotest.tmp 2>&1; then status=$? cat ${TESTDIR}/dotest.tmp >>${LOGFILE} echo "exit status was $status" >>${LOGFILE} --- 473,479 ---- dotest_fail () { rm -f ${TESTDIR}/dotest.ex? 2>&1 ! if eval "$2" >${TESTDIR}/dotest.tmp 2>&1; then status=$? cat ${TESTDIR}/dotest.tmp >>${LOGFILE} echo "exit status was $status" >>${LOGFILE} *************** *** 488,494 **** # Like dotest except second argument is the required exitstatus. dotest_status () { ! $3 >${TESTDIR}/dotest.tmp 2>&1 status=$? if test "$status" = "$2"; then : so far so good --- 488,494 ---- # Like dotest except second argument is the required exitstatus. dotest_status () { ! eval "$3" >${TESTDIR}/dotest.tmp 2>&1 status=$? if test "$status" = "$2"; then : so far so good *************** *** 504,510 **** dotest_sort () { rm -f ${TESTDIR}/dotest.ex? 2>&1 ! if $2 >${TESTDIR}/dotest.tmp1 2>&1; then : so far so good else status=$? --- 504,510 ---- dotest_sort () { rm -f ${TESTDIR}/dotest.ex? 2>&1 ! if eval "$2" >${TESTDIR}/dotest.tmp1 2>&1; then : so far so good else status=$? *************** *** 4366,4372 **** } EOF # Use dotest_fail because exit status from `cvs diff' must be 1. ! dotest_fail rcslib-diffrgx-3 "${testcvs} diff -c -F.*( rgx.c" \ "Index: rgx\.c =================================================================== RCS file: ${TESTDIR}/cvsroot/first-dir/rgx\.c,v --- 4366,4372 ---- } EOF # Use dotest_fail because exit status from `cvs diff' must be 1. ! dotest_fail rcslib-diffrgx-3 "${testcvs} diff -c -F.*\( rgx.c" \ "Index: rgx\.c =================================================================== RCS file: ${TESTDIR}/cvsroot/first-dir/rgx\.c,v *************** *** 13109,13115 **** # ISO8601 format. There are many, many, other variations # specified by ISO8601 which we should be testing too. ! dotest rcs-3 "${testcvs} -q log -d 1996-12-11<" " RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v Working file: file1 head: 1\.3 --- 13122,13128 ---- # ISO8601 format. There are many, many, other variations # specified by ISO8601 which we should be testing too. ! dotest rcs-3 "${testcvs} -q log -d 1996-12-11\<" " RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v Working file: file1 head: 1\.3