miscutils/scmfmt

38 lines
426 B
Bash
Executable File

#!/bin/sh
expand |
sed -n '
/./!d
p
i\
:l
n
p
bl' |
sed -n '
:l
p
n
/./bl
:b
n
/./!bb
i\
bl' |
sed -e '1s/^/./' -e 's/^ /./' |
par -P=. |
awk '
BEGIN { LIMIT = 72 }
NR == 1 || /^[^\.]/ || length($0) < LIMIT {
sub(/^\./, NR == 1 ? "" : " ");
print;
}
/^\./ && length($0) >= LIMIT {
sub(/^\./, " ");
print substr($0, 1, LIMIT)"\\";
for (i = 2*LIMIT - length($0) + 1; i; i--)
printf " ";
print substr($0, LIMIT+1);
}'