BINS=isutf8 ifdata ifne pee sponge mispipe lckdo parallel
-PERLSCRIPTS=vidir vipe ts combine zrun
-MANS=sponge.1 vidir.1 vipe.1 isutf8.1 ts.1 combine.1 ifdata.1 ifne.1 pee.1 zrun.1 mispipe.1 lckdo.1 parallel.1
+PERLSCRIPTS=vidir vipe ts combine zrun chronic
+MANS=sponge.1 vidir.1 vipe.1 isutf8.1 ts.1 combine.1 ifdata.1 ifne.1 pee.1 zrun.1 chronic.1 mispipe.1 lckdo.1 parallel.1
CFLAGS=-O2 -g -Wall
INSTALL_BIN?=install -s
PREFIX=/usr
This is a collection of the unix tools that nobody thought to write
long ago, when unix was young. Currently it consists of these tools:
-combine
- combine the lines in two files using boolean operations
-ifdata
- get network interface info without parsing ifconfig output
-isutf8
- check if a file or standard input is utf-8
-ifne
- run a command if the standard input is not empty
-lckdo
- execute a program with a lock held (deprecated)
-mispipe
- pipe two commands, returning the exit status of the first
-parallel
- run multiple jobs at once
-pee
- tee standard input to pipes
-sponge
- soak up standard input and write to a file
-ts
- timestamp standard input
-vidir
- edit a directory in your text editor
-vipe
- insert a text editor into a pipe
-zrun
- automatically uncompress arguments to command
+chronic: runs a command quietly unless it fails
+combine: combine the lines in two files using boolean operations
+ifdata: get network interface info without parsing ifconfig output
+isutf8: check if a file or standard input is utf-8
+ifne: run a command if the standard input is not empty
+lckdo: execute a program with a lock held (deprecated)
+mispipe: pipe two commands, returning the exit status of the first
+parallel: run multiple jobs at once
+pee: tee standard input to pipes
+sponge: soak up standard input and write to a file
+ts: timestamp standard input
+vidir: edit a directory in your text editor
+vipe: insert a text editor into a pipe
+zrun: automatically uncompress arguments to command
Its web page is here: http://kitenet.net/~joey/code/moreutils/
--- /dev/null
+#!/usr/bin/perl
+
+=head1 NAME
+
+chronic - runs a command quietly unless it fails
+
+=head1 SYNOPSIS
+
+chronic COMMAND...
+
+=head1 DESCRIPTION
+
+chronic runs a command, and agganges for its standard out and standard
+error to only be displayed if the command fails (exits nonzero or crashes).
+If the command succeeds, any extraneous output will be hidden.
+
+A common use for chronic is for running a cron job. Rather than
+trying to keep the command quiet, and having to deal with mails containing
+accidental output when it succeeds, and not verbose enough output when it
+fails, you can just run it verbosely always, and use chronic to hide
+the successful output.
+
+ 5 0 * * * chronic rsync -v foo bar
+
+=head1 AUTHOR
+
+Copyright 2010 by Joey Hess <joey@kitenet.net>
+
+Original concept and "chronic" name by Chuck Houpt.
+
+Licensed under the GNU GPL version 2 or higher.
+
+=cut
+
+use warnings;
+use strict;
+use IPC::Run qw( start pump finish timeout );
+
+if (! @ARGV) {
+ die "usage: chronic COMMAND...\n";
+}
+
+my ($out, $err);
+my $h = IPC::Run::start \@ARGV, \*STDIN, \$out, \$err;
+$h->finish;
+my $ret=$h->full_result;
+
+if ($ret >> 8) { # child failed
+ showout();
+ exit ($ret >> 8);
+}
+elsif ($ret != 0) { # child killed by signal
+ showout();
+ exit 1;
+}
+else {
+ exit 0;
+}
+
+sub showout {
+ print STDOUT $out;
+ print STDERR $err;
+}
+moreutils (0.43) UNRELEASED; urgency=low
+
+ * chronic: New command, runs a command quietly, unless it fails.
+ * Now depends on IPC::Run, used by chronic.
+
+ -- Joey Hess <joeyh@debian.org> Fri, 29 Oct 2010 15:23:17 -0400
+
moreutils (0.42) unstable; urgency=low
* sponge: Guarantee that output file is always updated atomically,
Package: moreutils
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, libipc-run-perl
Suggests: libtime-duration-perl, libtimedate-perl
Conflicts: lckdo
Replaces: lckdo
to write long ago, when Unix was young.
.
So far, it includes the following utilities:
+ - chronic: runs a command quietly unless it fails
- combine: combine the lines in two files using boolean operations
- ifdata: get network interface info without parsing ifconfig output
- ifne: run a program if the standard input is not empty