#!/bin/sh . ./test.sh test "prints error on trailing newlines" { echo "bar" echo "baz" printf "\n" } > foo [ "$(ltn foo 2>&1)" = "foo: Trailing newlines" ] test "return error status on trailing newlines" { echo "bar" echo "baz" printf "\n" } > foo ! ltn foo 2>/dev/null test "print error on trailing newlines in multiple files" { echo "bar" echo "baz" printf "\n" } > foo { echo "bar" echo "baz" printf "\n" } > bar { echo "bar" echo "baz" } > baz printf "" > fiz [ "$(ltn ./* 2>&1)" = "./bar: Trailing newlines ./fiz: Trailing newlines ./foo: Trailing newlines" ] test "return error status on trailing newlines in multiple files" { echo "bar" echo "baz" printf "\n" } > foo { echo "bar" echo "baz" printf "\n" } > bar { echo "bar" echo "baz" } > baz ! ltn foo ./* 2>/dev/null test "prints error on trailing newlines from standard input" [ "$( (echo foo; printf "\n") | ltn 2>&1)" = ": Trailing newlines" ] test "returns error status on trailing newlines from standard input" ! ( echo foo; printf "\n" ) | ltn >/dev/null 2>&1 test "returns success status on empty file" echo > foo ltn foo ./* 2>/dev/null test "returns success status on empty standard input" echo | ltn