]> err.no Git - util-linux/commitdiff
scriptreplay: new implementation is out-of-sync
authorKarel Zak <kzak@redhat.com>
Wed, 30 Jul 2008 10:39:04 +0000 (12:39 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 13 Aug 2008 17:15:45 +0000 (19:15 +0200)
Reproduction steps:

1. Run "script -t 2>timing".
2. When the prompt comes up, hit return.
3. New prompt. Wait several seconds, then type "true" and hit return.
4. Repeat (3) as desired, then exit scripted shell.
5. Run "scriptreplay timing".

You'll find on the replay that, rather than waiting several seconds
between the prompt and true, the wait will actually occur after the
first "t" of true.

Reported-by: Micah Cowan <micah@cowan.name>
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/scriptreplay.c

index 6c351a35a1a6a9c301a7fcd57995cc6983461a50..8a254de9d3076b11b8767cb0c6ead93e656c6fec 100644 (file)
@@ -121,6 +121,7 @@ main(int argc, char *argv[])
        double divi;
        int c;
        unsigned long line;
+       size_t oldblk = 0;
 
        /* Because we use space as a separator, we can't afford to use any
         * locale which tolerates a space in a number.  In any case, script.c
@@ -170,7 +171,9 @@ main(int argc, char *argv[])
                if (delay > SCRIPT_MIN_DELAY)
                        delay_for(delay);
 
-               emit(sfile, sname, blk);
+               if (oldblk)
+                       emit(sfile, sname, oldblk);
+               oldblk = blk;
        }
 
        fclose(sfile);