Oh, LaTeX acronym package, you won’t automatically alphabetize my list of acronyms? Strange… Let’s see if Unix will…
$ echo "\acro{SCADA}{Supervisory Control And Data Acquisition}
\acro{PLC}{Programmable Logic Controller}
\acro{RTU}{Remote Terminal Unit}
..." > toSort
$ for i in `cat toSort |sed "s/.*\\acro{\(.*\)}.*{.*}/\1/" | sort`;
do grep "{$i}" toSort; done
\acro{ADC}{analog to digital converter}
\acro{API}{application programming interface}
\acro{APT}{Advanced Persistent Threat}
\acro{ASCII}{American Standard Code for Information Interchange}
...
So, I just had a reason to implement something like a dictionary in Bash. Of course, I could try to determine if such a feature exists already (it does in Bash 4, alas the default on OS X seems to be 3.2), but why not just try to hack something together?
So, that’s ridiculous. Basically, the values are set in code with the dictionary name “OFFSETDICT”, and the key as whatever comes after the name {keyUno, keyTres, …}. Then the value line builds a variable lookup and executes it. That’s pretty lazy of me to write it like that, so here’s a function (a Bash function - so terrible).