#!/bin/bash # (1) Declare association state <-> color_id #--------------------------------------------------------# # (1) Create associative array # declare -A COLCODE; # (2) States # COLCODE[0]=90; COLCODE[1]=32; # (2) Check argument + display led #--------------------------------------------------------# # (1) Check argument # test $# -ge 1 && state="$1" || state="0"; # (2) Display led # echo -e "\e[${COLCODE[$state]}m⏺\e[0m";