function push {
eval "$1='$2|${!1}'"
}
function pop {
local sta=${!1}
local ret="$(cut -d '|' -f1 <<<$sta)"
if [ ${#ret} -ne 0 ]; then
local len=${#sta}
eval "$1='${sta:${#ret}+1}'"
eval "$2='$ret'"
else
eval "$2=''"
fi
}
No comments:
Post a Comment