#!/bin/mksh # © 2022 mirabilos Ⓕ MirOS unset LANGUAGE export LC_ALL=C nl=$'\n' ln=0 s=0 while IFS= read -r line; do ((# ++ln )) if [[ $s = 0 ]]; then if [[ $line != *([\ \ ])']* ]]; then print -r -- "$line" continue fi set -A cl s=1 fi if [[ $s = 1 ]]; then if [[ $line != *([\ \ ])']* ]]; then for x in "${cl[@]}"; do print -r -- "$x" done s=0 print -r -- "$line" continue fi cs=$line cn=- s=2 else cs+=$nl$line if [[ $line = *([\ \ ])''[1-9]*([0-9])'' ]]; then if [[ $cn != - ]]; then print -ru2 "E: #$ln: no $cn set: $line" exit 1 fi cn=${line##*''} cn=${cn%%''*} fi if [[ $line = *([\ \ ])''* ]]; then if [[ $cn = - ]]; then if [[ -n ${cl[0]} ]]; then print -ru2 "E: #$ln: no 0 already used" exit 1 fi cn=0 fi cl[cn]=$cs s=1 fi fi done