I would like to save to a file shell variables so that I can run a nested zsh and then read these back in. It is becoming a bit of a challenge because this in the output: typeset -i10 -r !=0 typeset -i10 -r '#'=0 typeset -i10 -r '$'=15221 typeset -ar '*' *=() typeset -r -=569Xfy typeset 0=_Dbg_do_shell typeset -i10 -r '?'=0 typeset -ar @ @=() typeset -rx _=-p Failing a better solution, I think what I'll have to do is store IFS='' typeset -p into an array and check each item of the array. But even this is turning out to be a bit challenging. One thing that one needs to do is look for read-only variables and then I guess turn that into a test followed by the typeset. That is typeset -p ARGC 2>/dev/null 1>/&2 && typeset -i10- r ARGC=0 Next one needs to check that the types valid which would weed out the lines above. But then we come to the typeset -ar '*' line which I guess flows onto the next line. At first I thought I could remove any lines that don't start with "typeset", but this is wrong because I could have a line like: typeset ZSH_DEBUG_CMD='if [ -d /etc/profile.d ] then for i in /etc/profile.d/*.sh do if [ -r $i ] then . $i fi done unset i fi' and all of that will read back in fine. Any suggestions? A little bit of context of why I am doing this. Recently in the zsh debugger I've added the ability to go into a nested zsh, and often one wants the existing environment of the debugged program preserved in this nested zsh. Lastly, related on a different topic. I notice there's no option for sourcing a startup file by name. Instead the closest thing is to create a temporary directory and in that create a file called .zshenv and set ZDOTDIR. This works, but strikes me as a bit awkward and more convoluted than adding an option to indicated an additional profile to run. Many POSIX-like shell languages, notably ksh don't provide such an option, bash does and it is called --init-file. And "higher-level" scripting languages which have modules like Perl, Python, or Ruby all do as well.