#!/bin/bash
# library function only

# an attempt at poppable arrays in bash

# usage of setpop:

# ARRAY=(a b c)
# pop ITEM ARRAY
# echo "$ITEM" # c
# echo "${ARRAY[@]}" # a b

pop() {
	local var_name="$1"
	local ary_name="$2"
	local ary=("${!ary_name}")  # needs list or something
	local last_idx=$((${#ary[@]} - 1))
	local last="${ary[$last_idx]}"
	eval "$ary_name=(\"\${ary[@]}\")"
	eval "$var_name=\$last"
}

# q. what do you think of this hack, friend?
# a. it's a hack, but it's a good hack
#    it's a hack that works
#    it's a hack that's useful
#    it's a hack that's not too hacky

# q. it's actually not working, lol

