Rift Star on GitHubv0.3.0

Rift / Guide

Exit codes

Rift follows diff: 0 for identical files, 1 for different files, 2 for an error.

StatusMeaning
0The files are identical.
1The files differ.
2An error: an unreadable file, a budget too small, a duplicate key in key mode, an invalid option, or -i in a build without the terminal view. The message goes to standard error.

The three cases on the generated pair, with the status printed after each run:

exit status of three runs
$ rift a.sql a.sql > /dev/null; echo "identical: exit $?"
$ rift a.sql b.sql > /dev/null; echo "differ: exit $?"
$ rift a.sql missing.sql > /dev/null; echo "missing file: exit $?"
identical: exit 0
differ: exit 1
rift: open missing.sql: No such file or directory (os error 2)
missing file: exit 2

In scripts

A difference is not a failure, so set -e stops a script on status 1. Test the status you care about:

rift a.sql b.sql > changes.patch
status=$?
[ "$status" -le 1 ] || exit "$status"

When the reader quits early

If standard output closes before Rift finishes, as in rift a b | head, Rift stops without a message and exits 141. That is the status a shell reports for diff killed by SIGPIPE, so ${PIPESTATUS[0]} in bash holds 141 for both. This applies to the unified diff, --summary and --key output.

Key mode can stop late

A run in key mode can stop with status 2 after it printed some changes, for example when a key occurs twice. The message on standard error says the output is incomplete. Check the status before you use the output.

Git

rift git-diff, new in 0.3.0, is the one exception: it exits 0 whether or not the files differ, because git treats any other status as a failure. It also exits 0, silently, when git's pager quits before the diff ends. See git integration.