From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28595 invoked by alias); 28 Aug 2015 19:43:40 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20478 Received: (qmail 934 invoked from network); 28 Aug 2015 19:43:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=qB2NU85WFlWy+43KhyrTsnEST2r/D9h5S7UPPHQJMfI=; b=ORKXk58kL9JJ0FHcKjbt6b+9VHAf2c4riXcnj3U/cTcpBjQj7I+V9mro+pYRj/ARca O/qQHHt2a8LOyTTFI8KxX9FBBj9eiYmUJCNb8PyBx14GERCF5qdk3MWETHt17Zw1y6f5 Df5P3hQOf//qMNKm9l2pARjdqK9aIG4oLrbQ4FsGmF9GkdG0m3zFKaJAnDYB15JxKzS7 wDZRozyPHxrCTi9fCyUeQqM7vWfoO1bHyydxJXxTxqEw0LQwHs0yoypPK4ILDjrvddjj A8gu4VVWKHUFo2x/424lc1fqiztJu1dntVAGfKzvy/+M9SSWmMq6klP8XVIRcXxrCkKT 3nig== X-Gm-Message-State: ALoCoQkPUspSLJ17HC2fPXKWb0k7RMB/yqZ//MWdtG6L2YO4Z0oHiwD70xs4ltyz6auxJs4gsks1 X-Received: by 10.182.97.97 with SMTP id dz1mr6549173obb.17.1440791017172; Fri, 28 Aug 2015 12:43:37 -0700 (PDT) From: Bart Schaefer Message-Id: <150828124334.ZM7129@torch.brasslantern.com> Date: Fri, 28 Aug 2015 12:43:34 -0700 In-Reply-To: <55E0AE60.9090706@eastlink.ca> Comments: In reply to Ray Andrews "Re: string to array space problem in filenames" (Aug 28, 11:54am) References: <20150821215037.6b010cf7@ntlworld.com> <55DFC1E6.5090400@eastlink.ca> <55E0AE60.9090706@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Ray Andrews , zsh-users@zsh.org Subject: Re: string to array space problem in filenames MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Aug 28, 11:54am, Ray Andrews wrote: } } At this point I'm hoping for a generic answer. Directory strings, } separated by spaces, are written to a file, which is then read into an } array and passed to 'select' Unfortunately there are three different places where you might need to protect the spaces. (1) when writing to the file (2) when reading from the file (3) when passing to select. You've shown us one of them (more on that in a moment): } echo -n " $PWD" >>! ~/.mydirstack; What about the other two steps? Your first problem here is trying to maintain .mydirstack all as one line (echo -n) with spaces between the fields. You would be much better served by writing one file name per line and then splitting the file on newlines when reading it back. Out: echo "$PWD" >>| ~/.mydirstack In: mydirstack=( ${(f)"$(<~/.mydirstack)"} ) Then you should be able to do select dir in "${mydirstack[@]}"; do something with $dir; done If you insist on storing it all on one line, then you need to quote the spaces on the way out: echo -n " ${(q)PWD}" >>! ~/.mydirstack; And remove the quotes again sometime after reading it back in, but that is where what you have told us fails to go far enough.