miscutils/ts
Adolfo Perez Alvarez 7dcf64ef11 Add newp (new post) and ts (shell test) tools
newp is a dump shortcut that will create a new ms article.

ts is a tool similar to cram or tush.
2022-10-04 14:22:52 +00:00

53 lines
596 B
Bash
Executable File

#!/bin/ksh
function tsrun
{
typeset err out ret
err=$(mktemp /tmp/XXXXXXXXXX)
out=$(mktemp /tmp/XXXXXXXXXX)
trap "rm $err $out" EXIT
eval "$@" >$out 2>$err
ret=$?
sed 's/^/| /' $out
sed 's/^/@ /' $err
print '? '$ret
}
function tseval
{
typeset ln
while read ln
do
case ${ln%% *} in
$)
print "$ln"
tsrun "${ln#$}"
;;
!(?|@|\|))
print "$ln"
;;
esac
done
}
(( $# == 0 )) && exit 64
if [[ $1 = -b ]]
then
(( $# == 1 )) && exit 64
shift
for fn
do
cp $fn $fn~
(rm $fn && tseval >$fn) <$fn
done
else
for fn
do
tseval <$fn | diff -u $fn -
done
fi