7.2 Manipulating colon variables

Function: mbfl_variable_colon_variable_to_array VARNAME

Take VARNAME’s value, a colon separated list of string, and store each string in the array mbfl_FIELDS, starting with a base index of zero.

Example:

VAR=a:b:c:d:e
declare -a mbfl_FIELDS

mbfl_variable_colon_variable_to_array VAR

echo mbfl_slots_number(mbfl_FIELDS)     -| 5
echo mbfl_slot_ref(mbfl_FIELDS, 0)      -| a
echo mbfl_slot_ref(mbfl_FIELDS, 1)      -| b
echo mbfl_slot_ref(mbfl_FIELDS, 2)      -| c
echo mbfl_slot_ref(mbfl_FIELDS, 3)      -| d
echo mbfl_slot_ref(mbfl_FIELDS, 4)      -| e
Function: mbfl_variable_array_to_colon_variable VARNAME

Store each value from the array mbfl_FIELDS (with base index zero) in VARNAME as a colon separated list of strings.

Example:

declare -a mbfl_FIELDS=(a b c d e)

mbfl_variable_array_to_colon_variable VAR
echo $VAR                       -| a:b:c:d:e
Function: mbfl_variable_colon_variable_drop_duplicate VARNAME

Take VARNAME’s value, a colon separated list of string, and remove duplicates. Reset VARNAME to the result.


This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.