#!/bin/sh
# Pager for diff output. comview expects raw unified diff, not ANSI-colored text.
# In non-interactive contexts, pass input through unchanged so agents/scripts do not block.
if [ -t 1 ] && command -v comview >/dev/null 2>&1; then
    perl -pe 's/\x1b\[[0-?]*[ -\/]*[@-~]//g' | comview
elif [ -t 1 ]; then
    exec less -FRX
else
    exec cat
fi

