summaryrefslogtreecommitdiff
path: root/spt
diff options
context:
space:
mode:
authorDavid Wührer <def@gmx.at>2024-05-18 21:04:34 +0200
committerDavid Wührer <def@gmx.at>2024-05-18 21:04:34 +0200
commit77cfffee6177fb0421fa0fce15d6a1875bde4816 (patch)
tree251428cdd482ea50cfb019dbd3c3bafd79d2fd14 /spt
parent75b23ce1ff0daab363725a2a5755ea80bbeaa68e (diff)
manuals, sum-down, radix
Diffstat (limited to 'spt')
-rwxr-xr-xspt55
1 files changed, 0 insertions, 55 deletions
diff --git a/spt b/spt
deleted file mode 100755
index e237d93..0000000
--- a/spt
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash
-
-###
-# Single pass tabulate.
-#
-# Turn grid-aligned tables into tab-separated values
-# using the first line as a template.
-# Pre-existing tabs are preserved,
-# which is probably not good.
-##
-# TODO:
-# - Optionally require more than one space for column separation.
-
-shopt -s extglob
-
-spitline(){
- declare -i prevtab=0
- for tabstop in ${tabstops[@]}
- do
- # Strip trailing spaces.
- field=${line:$prevtab:$((tabstop-prevtab))}
- field=${field%%*( )}
- printf '%s\t' "$field"
- prevtab=$tabstop
- done
- printf '%s\n' "${line:$prevtab}"
-}
-
-##
-# First line:
-##
-# The tab stops are where stretches of empty space end.
-IFS=$'\n'
-read -r firstline
-declare -i skip=1
-for ((i=0;i<${#firstline};i++))
-do
- case ${firstline:$i:1} in
- \ )
- skip=0
- ;; *)
- [[ $skip -eq 0 ]] && tabstops+=($i)
- skip=1
- esac
-done
-#echo >&2 ${tabstops[@]}
-line=$firstline
-spitline
-
-##
-# All other lines:
-declare -i prevtab
-while read -r line
-do spitline
-done