Index ALIST by the current shell.
If ALIST isn't a list where every element is a cons, it is returned as is.
Else indexing follows an inheritance logic which works in two ways:
- Fall back on successive ancestors (see `sh-ancestor-alist') as long as
the alist contains no value for the current shell.
The ultimate default is always `sh'.
- If the value thus looked up is a list starting with `sh-append',
we call the function `sh-append' with the rest of the list as
arguments, and use the value. However, the next element of the
list is not used as-is; instead, we look it up recursively
in ALIST to allow the function called to define the value for
one shell to be derived from another shell.
The value thus determined is physically replaced into the alist.
If FUNCTION is non-nil, it is called with one argument,
the value thus obtained, and the result is used instead.