libbash: libbash - Developer FAQ

# libbash - Developer FAQ

Welcome to libbash FAQ page!

This page contains list of most known problems you may run into while developing a bash libarary.

## The Questions

### Question 1

How can I use a `local` variable as an `array` ?

### Answer 1

When using a `local` variable, the line:

    local VAR_NAME

is used as a declaration of VAR_NAME. Unless implicitly mentioned otherwise, `declaire` creates a `regular' variable. Because of that, in order to use a local array you must implicitly declaire that it is an array:

    declaire -a local ARR_NAME

### Question 2

Using hashstash (3) hashes, How do I declare a `local` `hash`?

### Answer 2

You can't. The reason for that is that every `hash` created by `hashstash` is created as a hashstash internal variable. I.e. the actual name of the hash is not `HASHNAME` but `__hashstash_HASHNAME`.