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:
Adolfo Perez Alvarez 2022-10-04 14:16:59 +00:00
parent 7c59191590
commit 7dcf64ef11
5 changed files with 99 additions and 1 deletions

View File

@ -1,7 +1,7 @@
prefix=$$HOME/opt/pkg/miscutils
target_bin=${prefix}/bin
target_man=${prefix}/share/man/man1
bin=bwrap hppt mkgmap newp rot rr scmfmt upcasetl unpage
bin=bwrap hppt mkgmap newp rot rr scmfmt ts upcasetl unpage
install:
install -d ${target_bin} ${target_man}
install -c ${bin} ${target_bin}

5
newp Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
[ $# -eq 0 ] && echo '?' && exit 1
fname=$(date +%Y%m%d)-$(echo $* | tr 'A-Z\t ' a-z- | tr -s -).ms
printf ".TL\n%s\n.AU\nadolfopa@{sdf,sdfeu,twenex}.org\n\n" "$*" >$fname
${EDITOR:-ed} $fname

19
newp.1 Normal file
View File

@ -0,0 +1,19 @@
.Dd Jun 1, 2022
.Dt NEWP 1
.Os
.Sh NAME
.Nm newp
.Nd Create a new phlog post
.Sh SYNOPSIS
.Nm
.Ar word ...
.Sh DESCRIPTION
.Nm
creates a new ms phlog post.
The file name will contain the current date and
.Ar word ...
separated by dashes.
.Sh EXIT STATUS
.Ex -std
.Sh AUTHORS
.An Adolfo Perez Alvarez Aq Mt adolfopa@sdf.org

52
ts Executable file
View 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

22
ts.1 Normal file
View File

@ -0,0 +1,22 @@
.Dd Jul 1, 2022
.Dt TS 1
.Os
.Sh NAME
.Nm ts
.Nd Run shell tests
.Sh SYNOPSIS
.Nm
.Op Fl b
.Ar test ...
.Sh DESCRIPTION
.Nm
runs the shell tests passed as arguments.
If the
.Fl b
flag is specified, the test is blessed \(em i.e. it is evaluated and the test
file is overwritten with the result.
.Pp
.Sh EXIT STATUS
.Ex -std
.Sh AUTHORS
.An Adolfo Perez Alvarez Aq Mt adolfopa@sdf.org