Adolfo Perez Alvarez
34cfc3cf12
The `-p` option is only available in OpenBSD. As there's no standard way of ignoring lines by prefix, use `par`, which at least will be installable almost everywhere.
38 lines
426 B
Bash
Executable File
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);
|
|
}'
|