From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1960 invoked by alias); 15 Dec 2014 17:56:55 -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: 19545 Received: (qmail 2299 invoked from network); 15 Dec 2014 17:56:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7fc86d0000066b7-53-548f1e7b607a Date: Mon, 15 Dec 2014 17:46:32 +0000 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: An example of writing a custom history file? Message-id: <20141215174632.29e30bbe@pwslap01u.europe.root.pri> In-reply-to: References: <141214185332.ZM24112@torch.brasslantern.com> <141215003717.ZM24212@torch.brasslantern.com> <141215081440.ZM25053@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGLMWRmVeSWpSXmKPExsVy+t/xa7rVcv0hBi/+6VvsOLmS0YHRY9XB D0wBjFFcNimpOZllqUX6dglcGTt6J7MV3OOsaGjawNTAuJy9i5GTQ0LARGLpvGPMELaYxIV7 69m6GLk4hASWMkps/dHKCuEsYpKYfeEcI4SzjVFicl8bkMPBwSKgKvF/twVIN5uAocTUTbMZ QWwRAVGJ5Ss2g20QFrCUOLXsGhuIzStgL7F70iQmEJtTIFhi2qTlzBAztzNLnF+8E6yIX0Bf 4urfT0wQJ9lLzLxyhhGiWVDix+R7LCA2s4CWxOZtTawQtrzE5jVvwV4QElCXuHF3N/sERqFZ SFpmIWmZhaRlASPzKkbR1NLkguKk9FwjveLE3OLSvHS95PzcTYyQsP26g3HpMatDjAIcjEo8 vD8Se0OEWBPLiitzDzFKcDArifC6y/SHCPGmJFZWpRblxxeV5qQWH2Jk4uCUamAMXqG6jnd7 Zm7bsjZlLvd17XrG5zS5Szg1enmEy3f8mOLr3bNnkc1ngx7+X8orjodf2p9wPCbujeyFlinK WRUFu3ZnuFYFd3RkbOP64VCtd/XBaW4u8/drb1bNSrtxtdvw2vmk+5uXpVf/93NhPdq5mEXv 4nMNgdaNF0sCIy+de6RRNjUi0UqJpTgj0VCLuag4EQC7xtPZOQIAAA== On Mon, 15 Dec 2014 12:05:30 -0500 Rocky Bernstein wrote: > Making the change suggested, adding 1000 doesn't change the behavior - no > file is written. Again, here is the entire 12-line program: > > #!/usr/bin/zsh > fc -ap /tmp/example_history 1000 > > local line > # Read lines and add them to history > while vared -h -p "hey: " line > do > [[ $line == 'quit' ]] && exit 0 > # The -s option below adds the line to the history > print -s $line > line='' > done I'm not entirely following everything you're attempting to do, but the feature you're using is for temporarily switching a history file during a shell session. So if you're running this as a script (rather than a shell function), as the #! and the word "program" would imply, (i) you're not really trying out that aspect of the feature --- though there's no reason the basic feature shouldn't work (ii) you don't get the "autopop" behaviour at the end of function scope that the -a additional option to fc -p implies. Try using "fc -P" at the end to pop by hand, as if this actually were a function (but with the save line number argument suggested by Bart). pws