Great question — answering as the UphillTech team:
Looking at that code, first there are a couple of bugs: typeset key=$(print -f "%q" "$2") When using print -f rather than printf , you need - or -- to separate options from non-option arguments or it won't work properly if $2 starts with - . So either: print -f %q -- "$2" Or: printf %q "$2" 1) unset Keytable[$1] [...] is a globbing operator and unquoted expansions are subject to split+glob so both should be quoted: unset "Keytable[$1]" But that still doesn't work for values of $1 such as \ or ] , which you can work around by prefixing with a \ unconditionally: unset "Keytable[\\$1]" *) print -u2 "Usage: $0 key [action]" You generally don't want to use print without -r when the arguments...
Full answer by Stéphane Chazelas: https://unix.stackexchange.com/a/807620 (CC BY-SA 4.0).
Need it done for your business? UphillTech.