LinuxCommandLibrary

mispipe

Run multiple commands, capture standard error separately

TLDR

Pipe two commands and return the exit status of the first command

$ mispipe [command1] [command2]
copy

SYNOPSIS

mispipe [-d directory] [--] command [args...]

PARAMETERS

-d directory
    Directory for saving unread input files. Defaults to $HOME/.mispipe; creates if needed.

--
    Signals end of options, allowing commands starting with '-'.

DESCRIPTION

mispipe is a utility from the moreutils package that helps debug pipelines where a command does not fully consume its standard input.

Typically used as producer | mispipe consumer [args...], it executes the consumer command, feeding it the pipeline input via stdin. If the consumer exits before reaching EOF on stdin (e.g., due to an error or early termination), mispipe captures and saves the unread remainder to a file.

The save location is a subdirectory named after the consumer command (basename only) within a specified directory, defaulting to ~/.mispipe. Existing files are appended to; if nonempty after append, a numbered suffix like .1 is used for new files.

This prevents loss of data in scenarios like piping large logs to a script that crashes midway, or commands that read selectively. It passes through data normally if fully consumed, making it transparent in working pipelines.

Ideal for shell scripting, log processing, or any stdout-heavy workflows where consumer behavior is unpredictable.

CAVEATS

Only triggers on consumer exit before EOF; hanging processes lose data.
Appends to files (overwrites if empty).
Requires write access to directory.
Command basename used for filenames; args ignored.

EXAMPLE

git log --oneline | mispipe head -100
Saves tail end to ~/.mispipe/head[.N] if head exits early.

./faulty-script < large.log | mispipe cat
Captures unread data if script fails midway.

BEHAVIOR NOTES

Fully consumed input: no file written, stdout passed cleanly.
Partial read: saves remainder post-exit.
Signals/errors propagate from consumer.

HISTORY

Created by Joey Hess for moreutils (~2007); enhances pipeline reliability in Unix-like systems.

SEE ALSO

sponge(1), ts(1), combine(1)

Copied to clipboard