improve scripts portability and correctness - iomenu - interactive terminal-based selection menu
 (HTM) git clone git://bitreich.org/iomenu git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/iomenu
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit cee77319ba6cc232295cf29688ba6eb3c58be246
 (DIR) parent f4ee636cedac29de2e5f6ff200f01db97379642c
 (HTM) Author: Josuah Demangeon <me@josuah.net>
       Date:   Sat,  9 May 2020 20:57:56 +0200
       
       improve scripts portability and correctness
       
       Diffstat:
         A bin/column-t                        |      21 +++++++++++++++++++++
         M bin/io-fstab                        |      10 +++++-----
         M bin/io-man                          |       2 +-
         M bin/io-net                          |       2 +-
         M bin/io-passwd                       |       4 ++--
         M bin/io-xdg-open                     |       2 ++
       
       6 files changed, 32 insertions(+), 9 deletions(-)
       ---
 (DIR) diff --git a/bin/column-t b/bin/column-t
       @@ -0,0 +1,21 @@
       +#!/usr/bin/awk -f
       +# format text in aligned two-space separated columns: portable column -t
       +
       +{
       +        for (f = 1; f <= NF; f++) {
       +                l = length($f)
       +                if (l > len[f])
       +                        len[f] = l
       +                field[NR"|"f] = $f
       +        }
       +        if (--f > count)
       +                count = f
       +}
       +
       +END {
       +        for (row = 1; row <= NR; row++) {
       +                for (f = 1; f < count; f++)
       +                        printf("%-"len[f]"s  ", field[row"|"f])
       +                printf("%s\n", field[row"|"f])
       +        }
       +}
 (DIR) diff --git a/bin/io-fstab b/bin/io-fstab
       @@ -2,8 +2,8 @@
        # display mounts and fstab in iomenu
        
        {
       -        printf '#/etc/fstab\n'
       -        column -ts ' ' </etc/fstab
       -        printf '#mount\n'
       -        mount | column -ts ' '
       -} | iomenu -#
       +        echo "#/etc/fstab"
       +        column-t -F '[ \t]' /etc/fstab
       +        echo "#mount"
       +        mount | column-t -F '[ \t]'
       +} | exec iomenu -#
 (DIR) diff --git a/bin/io-man b/bin/io-man
       @@ -4,4 +4,4 @@
        man -k ' ' | sed -r '
                s/ - /                          - /
                s/(.{25}[^ ]* ) * - /\1- /
       -' | iomenu | sed -r 's,[(,].*,,' | xargs man
       +' | iomenu | sed -r 's,[(,].*,,' | tr '\n' '\0' | xargs -0r man
 (DIR) diff --git a/bin/io-net b/bin/io-net
       @@ -1,4 +1,4 @@
        #!/bin/sh -e
        # searchable netstat results with iomenu
        
       -netstat "$@" | sed 's/^[AP]/#&/' | iomenu -'#'
       +netstat -n "$@" | sed 's/^[AP]/#&/' | iomenu -'#'
 (DIR) diff --git a/bin/io-passwd b/bin/io-passwd
       @@ -3,7 +3,7 @@
        
        {
                printf '#/etc/passwd\n'
       -        column -ts : < /etc/passwd
       +        column-t -F : < /etc/passwd
                printf '#/etc/group\n'
       -        column -ts : < /etc/group
       +        column-t -F : < /etc/group
        } | iomenu -'#'
 (DIR) diff --git a/bin/io-xdg-open b/bin/io-xdg-open
       @@ -5,6 +5,8 @@
        
        LC_COLLATE=C
        
       +touch "$HOME/.cache/find"
       +
        if        test -f "$HOME/.cache/find" && test $# = 0
        then        exec "$0" "$HOME"
        elif        test $# = 0