I have been waffling for several days about whether to post this.
Argument in favor:
I really like this command! A lot!
Argument against:
I don't understand why, since it doesn't actually do anything.
It's called do-over and it's just a glorified loop. You say
something like
do-over command args....
and it replies
Hit <enter> to start
When you hit enter, it runs command args , and then it prompts
again:
Job completed in 12.3s
Hit <enter> to re start
If someone else were showing me this, I would ask:
Why is this better than hitting the up-arrow and then enter?
or possibly
Why is this better than while read x; do command...; done ?
I have no answer to these questions. But I have done a lot of both of
those other things, and I like this better, although I don't know why.
#!/usr/bin/perl
use Time::HiRes qw(time);
print STDERR "Hit <enter> to start\n";
while (1) {
my $x = <STDIN>;
last unless $x;
print STDERR scalar(localtime()), "\n";
my $start = time();
print STDERR "running @ARGV\n";
system(@ARGV);
my $elapsed = time() - $start;
printf STDERR "Job completed in %.1fs\n", $elapsed;
print STDERR "Hit enter to restart\n";
}
|