PATCH: bad sed expression

David Relson relson at osagesoftware.com
Sun Jan 5 16:53:29 CET 2003


At 10:37 AM 1/5/03, Clint Adams wrote:

> > Can you explain a bit more fully?  My linux box with bash 2.05 is happy
> > with either form of the sed expression.  What environment are you running
> > on and which sed expression words and which fails for you?
>
>Yes.  I'm trying to run ../../../bogofilter/tests/t.systest.d/t.grftest -v
>so $0 is set to "../../../bogofilter/tests/t.systest.d/t.grftest".
>When this gets passed to sed, the first match to the RE "./t." is
>"r/te", and thus "../../../bogofilter/tests/t.systest.d/t.grftest"
>becomes "../../../bogofiltests/t.systest.d/t.grftest", which is a
>non-existent path.  By making the RE "\./t\.", "./t.blah" will become
>"blah", but "../../../bogofilter/tests/t.systest.d/t.grftest" will be
>unchanged.  This is probably not a good idea either, so perhaps the RE
>should be ".*/t\."

I wrote the original sed expression (without the backslashes) so that the 
output from script t.abctest would be left in abctest.MMDD.  This worked 
fine when all the t.*test scripts were in bogofilter/tests.  Things aren't 
so good now that these scripts are in t.systest.d.  For one thing, I've 
come to the realization that tests/t.systest.d should be named 
tests/bogofilter because the two t.*tests are regression tests of 
bogofilter's classification.  Perhaps when we create the 1.0.0 branch we 
can change the directory name.

What might work is to use the basename command, as in

         NAME="./`basename $0 | sed s@\./t\.@@`"

It does the right thing on my machine.  Let me know how it works for you.

>On the other hand, maybe all that branching is unnecessary and you could
>use something like

Possibly.  The goal for the branching is to have "make check" clean up 
after itself and to have manually run tests leave their results on disk so 
that they can be looked at.  The while look is to protect against conflicts 
of two simultaneous checks.


>Index: tests/t.frame
>===================================================================
>RCS file: /cvsroot/bogofilter/bogofilter/tests/t.frame,v
>retrieving revision 1.16.2.1
>diff -u -r1.16.2.1 t.frame
>--- tests/t.frame       2 Jan 2003 14:58:20 -0000       1.16.2.1
>+++ tests/t.frame       5 Jan 2003 15:36:20 -0000
>@@ -13,22 +13,15 @@
>  : ${relpath=..}
>
>  if [ -z "$RUN_FROM_MAKE" ] ; then
>-   NAME=`echo $0 | sed s at ./t.@@`
>-   DATE=`date +"%Y%m%d"`
>-   TMPDIR="$NAME.$DATE"
>-   rm -rf $TMPDIR
>-   mkdir  $TMPDIR
>     SUPPRESS_DELETE="NO"
>-else
>-#   SUPPRESS_DELETE=NO
>+fi
>+
>      while : ; do
>         TMPDIR=./checks.$$.`date +"%Y%m%dT%H%M%S"`
>-       if test x$SUPPRESS_DELETE = xNO ; then TMPDIR=./outputs.`date 
>+"%m%d"` ; fi
>         [ -d $TMPDIR ] || mkdir $TMPDIR
>          [ -d $TMPDIR ] && break
>         sleep 1
>      done
>-fi
>
>  if test "x$SUPPRESS_DELETE" = "x" ; then
>      trap "rm -r -f core ${TMPDIR}" 0





More information about the bogofilter-dev mailing list