From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1574 invoked by alias); 19 Nov 2015 19:17:56 -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: 20967 Received: (qmail 20132 invoked from network); 19 Nov 2015 19:17:52 -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,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=chchu1a8Fw0yZ7lGA0hh9FOxphuyWjx25F5wQkYhFeY=; b=U03b6hiupkPAy8rcq8L0ttFLSk+bjbFqi2h25Q1myXTlib0iQTm/HiHkEdR5BAWh1h u4ERFNWL8BXVjqhkh6zTiZBEm+EapX+D9fMr2OqKq8KDNgh0HYRFZHK8eHgrVonX3tEr 912UP8Bi9skZwb5e+bvisiy7cEtDVuEvZytlriJ/F2G86uAfGn3eko2zQFK8yICLESLm D+VCjCuA5sVr6k2AMMFTNhHr3DL7dFQzMTkbKb/lxXI6jymjKj5yfiTlJF5BiqUyNU7d cp9DCZv4a2OI3AkK/iJ7K1ZPLGWX4k29oJxUAZFQGfpGypktyWT+f7NNvsN/FfHNULo7 zHog== 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=chchu1a8Fw0yZ7lGA0hh9FOxphuyWjx25F5wQkYhFeY=; b=GIA7HrP4+02Pnd/aJVNCi840+wG1KGFA68VXf3dbuds4cDKn8bKR3Z13R+pB3RcQPC m49dLLMmY+MprxxkRUABIQUDQ/RJzPqs/ZGACrobCxOmgOCUhxSOp8RUjzskGqWtlSTh kDH5NZ1SxI4ydDa4QO1LbafEwVXgD1iJYHrwgcB62tuQxSscpZ/EDdbWkwJPzhuKNQQd /NqnX6cMWqY+yJL8URB+F1g9mjdKr4Jt2518GThtqka9/ALzECNPaw6ua8MphfIi45mv AmeDxnnqrMcl75FYJjFWIAyx4yFQkRpOEC7jBI6XL4SbyEQwX7Qjh8NC7KEl7/8lXmrO +G5Q== X-Gm-Message-State: ALoCoQk95npbeON3vH28qIwEDvrg6wW22B7yrzAlWIeU+PGA6Y0rWhVxsZY0WUgDB+HApST3n3Po X-Received: by 10.66.248.74 with SMTP id yk10mr13010015pac.17.1447960668013; Thu, 19 Nov 2015 11:17:48 -0800 (PST) From: Bart Schaefer Message-Id: <151119111749.ZM8874@torch.brasslantern.com> Date: Thu, 19 Nov 2015 11:17:49 -0800 In-Reply-To: Comments: In reply to Sebastian Gniazdowski "Read file with escaped newlines into array" (Nov 19, 6:34pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Read file with escaped newlines into array MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Nov 19, 6:34pm, Sebastian Gniazdowski wrote: } } fc -W stores history to a given file. It escapes newlines with \. How } to read such file into array and have "\^M" lines put back together } into single array entries? The best way is probably to use the history mechanism to read it: () { fc -ap -R the_given_file ; the_desired_array=( ${history} ) } Although the docs don't yet say so, the special associative array $history is not implemented as a hash table, so the entries are guaranteed to be in a fixed order from most recent (largest history number) to longest ago. Which is the reverse of the way you'd read them from the file, so you might want ${(Oa)the_desired_array} when referencing.