3 ms·
Bash Associative Arrays [1] are handy! Some examples of how I've used them: - my site builder (for evalapply.org): inject metadata into page templates. e.g. ht
by adityaathalye 2y ago
Bash Associative Arrays [1] are handy! Some examples of how I've used them:
- my site builder (for evalapply.org): inject metadata into page templates. e.g. https://github.com/adityaathalye/shite/blob/b4163b566f0708fd015a0a78b2bc69ca733210bb/bin/templating.sh#L92 https://github.com/adityaathalye/shite/blob/b4163b566f0708fd...
- oxo game (tic-tac-toe): reverse index lookup table for board positions: https://github.com/adityaathalye/oxo/blob/7681e75edaeec5aa1fe63bc510af1f5dbd9c74c0/oxo_logic.sh#L70 https://github.com/adityaathalye/oxo/blob/7681e75edaeec5aa1f...
- personal machine setup: associate name of installed application to its apt source name, so we can check for the app, and then install package https://github.com/adityaathalye/bash-toolkit/blob/f856edd30139c4adf51d0c22ead81d773369b4b2/machine-setup.sh#L9 https://github.com/adityaathalye/bash-toolkit/blob/f856edd30...
[1] I'd say "hashmap" is acceptable, colloquially. However, I don't think Bash computes hashes of the keys.
(edit: fix formatting snafu)