Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: BUG? - 4.0.2 - parameter substitution won't double backslashes in values
- X-seq: zsh-workers 16585
- From: Sven Wischnowsky <wischnow@xxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: BUG? - 4.0.2 - parameter substitution won't double backslashes in values
- Date: Thu, 7 Feb 2002 11:44:47 +0100
- In-reply-to: <20020206203926.A10484@xxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20020206203926.A10484@xxxxxxxxxxxxxxxxx>
Derek Peschel wrote:
> I want to write the elements of $dirstack out to a file, separated by
> newlines. If an element in $dirstack contains a newline, I want to write
> a backslash before the newline in the file. Parameter substitution
> managed that:
If what you're really after is being able to dump the value of
$dirstack to a file to be able to restore it from that file later, you
could just use some trickery:
dump_dirstack() {
print -lr 'dirstack=(' "${(q@)dirstack}" ')' > ~/.dirstack
}
# pretty useless wrapper function...
restore_dirstack() {
. ~/.dirstack
}
Or some such.
A generic function to store an array (1st arg) to a file (2nd arg)
would be:
dump_array() {
print -lr "$1=(" "${(P@q)1}" ')' > $2
}
Hope that helps...
Bye
Sven
--
Sven Wischnowsky wischnow@xxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author