zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@berkom.de>
To: zsh-workers@sunsite.dk
Subject: Re: BUG? - 4.0.2 - parameter substitution won't double backslashes in values
Date: Thu, 7 Feb 2002 11:44:47 +0100	[thread overview]
Message-ID: <15458.23199.580619.840108@wischnow.berkom.de> (raw)
In-Reply-To: <20020206203926.A10484@eskimo.eskimo.com>


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@berkom.de


      parent reply	other threads:[~2002-02-07 10:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-07  4:39 Derek Peschel
2002-02-07 10:33 ` Peter Stephenson
2002-02-07 13:19   ` Derek Peschel
2002-02-07 19:20     ` Bart Schaefer
2002-02-07 20:22       ` Derek Peschel
2002-02-07 21:00         ` Bart Schaefer
2002-02-08  9:29           ` Derek Peschel
2002-02-08 21:35             ` Bart Schaefer
2002-02-07 10:44 ` Sven Wischnowsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15458.23199.580619.840108@wischnow.berkom.de \
    --to=wischnow@berkom.de \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).