From 7dcf64ef11e35fee1f88e4bfdf50f71103be6735 Mon Sep 17 00:00:00 2001 From: Adolfo Perez Alvarez Date: Tue, 4 Oct 2022 14:16:59 +0000 Subject: [PATCH] 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. --- Makefile | 2 +- newp | 5 +++++ newp.1 | 19 +++++++++++++++++++ ts | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ts.1 | 22 ++++++++++++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100755 newp create mode 100644 newp.1 create mode 100755 ts create mode 100644 ts.1 diff --git a/Makefile b/Makefile index 5ca3d2a..b9e615b 100644 --- a/Makefile +++ b/Makefile @@ -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} diff --git a/newp b/newp new file mode 100755 index 0000000..6c59f2a --- /dev/null +++ b/newp @@ -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 diff --git a/newp.1 b/newp.1 new file mode 100644 index 0000000..25b7235 --- /dev/null +++ b/newp.1 @@ -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 diff --git a/ts b/ts new file mode 100755 index 0000000..fac46b4 --- /dev/null +++ b/ts @@ -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 diff --git a/ts.1 b/ts.1 new file mode 100644 index 0000000..3299756 --- /dev/null +++ b/ts.1 @@ -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