From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id ff415f63 for ; Wed, 30 Jan 2019 00:16:16 +0000 (UTC) Received: (qmail 17110 invoked by alias); 30 Jan 2019 00:16:02 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44025 Received: (qmail 11389 invoked by uid 1010); 30 Jan 2019 00:16:02 -0000 X-Qmail-Scanner-Diagnostics: from joooj.vinc17.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.100.2/25112. spamassassin: 3.4.2. Clear:RC:0(155.133.131.76):SA:0(-1.9/5.0):. Processed in 2.316778 secs); 30 Jan 2019 00:16:02 -0000 X-Envelope-From: vincent@vinc17.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Date: Wed, 30 Jan 2019 01:15:54 +0100 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: Re: Regression in zsh 5.7: locking failed for /dev/null: permission denied Message-ID: <20190130001554.GA15909@zira.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org References: <20190129185124.GA1618@zira.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/1.11.2+93 (3119b5a1) vl-114617 (2019-01-19) On 2019-01-29 14:09:56 -0600, dana wrote: > On 29 Jan 2019, at 12:51, Vincent Lefevre wrote: > >I use the following function, see suggestion from > >http://www.zsh.org/mla/workers/2016/msg02070.html > >... > >When I use it, I get the error: > > > >append_file_to_hist:24: locking failed for /dev/null: permission denied > > I didn't look *super* hard, but i don't see anything obvious in the changes > between 5.6.2 and 5.7 that would have affected that. More importantly, i get > the same error on 5.4.2/Ubuntu and 5.6.2/Homebrew. > > So i'm not sure it's actually a regression...? Sorry, after more tests and search, I forgot that in the past I provided $HISTFILE as a second argument, though it should be defaulted to this file. The function was actually buggy, as HISTFILE is changed by fc -pa. I've now fixed it: append_file_to_hist() { emulate -LR zsh local -a entries local histfile=${2:-$HISTFILE} # Implementation issue: read -r ignores backslash-newline # folding, but without -r embedded backslashes are stripped, # which seems a bigger problem. Fix up $entries later. IFS=$'\n' read -r -d '' -A entries <$1 (( $#entries )) || return # Must supply a file name here to set HISTSIZE and SAVEHIST fc -pa /dev/null $#entries $(( SAVEHIST + $#entries )) while (( $#entries )) do if [[ "$entries[1]" == *\\ ]] then entries[1,2]=( ${entries[1]%\\}$'\n'${entries[2]} ) else print -r -S $entries[1] shift 1 entries fi done fc -A $histfile # Reset SAVEHIST to avoid attempting to lock /dev/null SAVEHIST=0 # fc -p makes this implicitly local } -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)