Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A way to untie -T vars?
- X-seq: zsh-users 28735
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: Pier Paolo Grassi <pierpaolog@xxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: A way to untie -T vars?
- Date: Sun, 22 Jan 2023 18:14:39 -0800
- Archived-at: <https://zsh.org/users/28735>
- In-reply-to: <CAN=4vMq56vaLYud4uX86c_fJOtuAHALGXvDqEb7fEB1-=Ec5ug@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAKc7PVDEmKnY9TiYwaAgvzXEqNhLwZo46paUPjJOz9HsU3_djg@mail.gmail.com> <CAH+w=7YY5F_ZYJgivw9PSjt8PTQ9R+gHF3jnjbBw-LLkEnc2zg@mail.gmail.com> <CAH+w=7bL4txwLp4zFPeDvb6fbYfJV6-mT+S4oFnrJ7cXPZr_Xw@mail.gmail.com> <CAH+w=7a1RHjYSGnY2=dgZn9n1ZgC2PyJQ12imiDU4gLW4q4saA@mail.gmail.com> <CAN=4vMpo9i5qr-HmH2ymaxaJ6hQLg-gThZkSRJvafUEp1oN0ag@mail.gmail.com> <CAP+y1xAJq6TrkbTOSFNs=jbf7_=sTYnj3Y1=qHoF5W4S1r=Zkg@mail.gmail.com> <CAN=4vMq56vaLYud4uX86c_fJOtuAHALGXvDqEb7fEB1-=Ec5ug@mail.gmail.com>
On Sun, Jan 22, 2023 at 1:58 AM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> If you wanted to turn this into a library function, you would need to
> handle more types.
So ... (gmail is probably going to line-wrap this)
untie () {
emulate -L zsh
while ((ARGC))
do
() {
case ${(tP)1} in
(array-tied) set -- $1 "${(@P)1}"
unset $1
set -A "$@" ;;
(scalar-tied-export) set -- $1 x ;&
(scalar-tied) set -- $1 ${(P)1} $2
unset $1
typeset -g$3 $1=$2 ;;
(*tied*) print -u2 -r "Can't untie ${(qqq)1}: ${(tP)1}" ;;
(*) : "${(qqq)1}: not a tied parameter" ;;
esac
} $1
shift
done
}
The (*) label is for benefit of xtrace, but it could instead print
that message. I couldn't find any other parameter types that needed
handling?
That's "functions -x2" output, by the way, take it up with PWS if you
don't like the placement of the case labels/delimiters.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author