core/list

Bash array support

Dependency Graph

core/list: Library Dependencies

View color source code (raw) for this file

View reStructuredText (rst) source code for this page

List helpers

in_list()

Returns success if the item ($1) is found in the list ($@).

list_insert()

Inserts items ($@) at the beginning of the named array ($1).

list_append()

Appends items ($@) to the end of the named array ($1).

list_pop()

Removes and prints the last item from the named array ($1).

list_fpop()

Removes and prints the first item from the named array ($1).

List Iteration

for_each()

Calls a function ($1) for each item ($@).

run_for_each()

Calls a function ($1) using run() for each item ($@).

for_each_pair()

Calls a function ($1) for each pair of arguments ($@). If an odd number of arguments are given, an error will be produced.

List Transformations

list_reverse()

Reverse the order of items in the named array ($1).

list_quote()

Quotes the items in the named list ($1).

list_join()

Joins arguments using the given character

TODO: rename str_join?

$1 - character to use for joining arguments

$@ - strings to be joined by $1

list_filter()

Runs a filter ($1) for each item in the named array ($2). If the filter function returns success, the item will be included in the output array ($3, or $2 if not given).

$1 - Filter command

$2 - Input list

$3 - Output list (optional)

list_filter_empty()

Removes empty items from the named array ($1) and saves them in the output array ($2, or $1 if not given).

$1 - Input list

$2 - Output list (optional)

list_unique()

Removes duplicate items from the named array ($1) and save them in the output array ($2, or $1 if not given).

$1 - Input list

$2 - Output list (optional)

list_map()

Runs a command ($1) with each of the items in the named array ($2). The output of each command invocation is stored in the output array ($3, or $2 if not given)

$1 - Filter command

$2 - Input list

$3 - Output list (optional)

list_copy_or_args

Copies arguments ($@) to output list ($1). If no arguments are given, copies the default list ($2) to the output list.

$1 - name of output list

$2 - name of default list

$@ - optional arguments to copy to output list

list_from_func_or_args

Copies arguments ($@) to output list ($1). If no arguments are given, runs the given function ($2) to populate that list.

$1 - name of output list

$2 - name of function to provide defaults

$@ - optional arguments to copy to output list


View the Developer Guide Index

View the Reference Manual Index


Generated on Fri Jul 28 14:37:13 PDT 2017 by mcsh d14 v0.23.0.