I think we need to check if $PAGER is empty here, else there will be error.

if [ -z "$PAGER" ]; then
    echo '$PAGER variable not set'
fi

something like this