On Sat, Oct 15, 2016 at 10:50 PM, konsolebox <konsole...@gmail.com> wrote: > > My version would be this: > > function array_pop { declare -n __a=$1 __v=$2; __v=${__a[-1]}; unset > '__a[-1]'; } >
Here's another version which avoids local or nameref variables, pop() { [[ -v $1 ]] || return set -- "$1[-1]" "$2" eval set -- \"\$@\" \"\$\{"$1"\}\" printf -v "$2" '%s' "$3" unset "$1" }