Skip to main content



"Easton"


An old man named Rex Fay owns a very large chunk of downtown Easton, and has shuttered up many of the shops. He's had a number of nasty run-ins with the locals and has even gone as far as barricading the streets with concrete blocks.

#mywork #photog #photography #rural #town



Modern shell #scripting is weird. :P #programming #bash #linux

#!/usr/bin/env bash

function parse_options () {
    declare -n result="$1"
    shift 1
    result['verbosity']='4'
    result['memory']='24G'
    result['volumes']=''
    result['device']='/dev/st0'
    result['write-rate']='250M'

    local opt
    local OPTARG
    while getopts 'vm:n:i:' opt
    do
        case $opt in
            v)
                result['verbosity']=6
                ;;
            m)
                result['memory']="$OPTARG"
                ;;
            n)
                result['volumes']="$OPTARG"
                ;;
            i)
                result['device']="$OPTARG"
                ;;
            r)
                result['write-rate']="$OPTARG"
                ;;
        esac
    done

    if [[ -z "${result['volumes']}" ]]; then
        echo "-i VOLUMES is required"
        exit 1
    fi
    return 0
}


declare -A CONFIG
parse_options CONFIG "$@" || exit 1

exec mbuffer \
    -v "${CONFIG['verbosity']}" \
    -m "${CONFIG['memory']}" \
    -n "${CONFIG['volumes']}" \
    -p 30 \
    -s 65536 \
    -A 'sh /usr/local/bin/tape_wait.sh' \
    -f \
    -R "${CONFIG['write-rate']}" \
    -i "${CONFIG['device']}"

reshared this

in reply to Neil E. Hodges

what's weird is everything that could go wrong without all that. I'm not sure it's particularly modern though
in reply to Neil E. Hodges

Buffers? I see no buffers. It's a relatively trivial little script to translate one command-line API into another. I would use typeset instead of declare to make it portable to Korn Shell, and get rid of the unnecessary local OPTARG. I would get rid of the unnecessary local-reference trick with result -- it is not a sin to modify a well named global variable in a shell script. It could easily be translated into entirely POSIX-compatible syntax by using multiple global variables.

As for using another language, well that would be both silly, and far more complex. The shell is always already there and quite capable.





I want a #Fedi server that looks and works like #phpBB, with federation support. :3c #Fediverse #Mastodon



First time I've poked around in a #JVM heap dump in a long time. :P #Java #Kotlin







Note to self: feeding an executor's output back into itself is a great way to cause a deadlock. :3












What is the best kind of glaze for #HamRadio? :3c

Blurry Moon reshared this.







Superhero movies don't appeal to me in the least. :/







What's the best #Gemini browser right now?

reshared this

in reply to Neil E. Hodges

using Lagrange, with no means of comparison. Does the job as far as I'm concerned.






Sometimes a good trip is one where you just zone out for a while without the distractions of modern-day life. :3