forked from adolfopa/miscutils
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.
This commit is contained in:
52
ts
Executable file
52
ts
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user