Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Regression in zsh 5.7: locking failed for /dev/null: permission denied
On 2019-01-29 14:09:56 -0600, dana wrote:
> On 29 Jan 2019, at 12:51, Vincent Lefevre <vincent@xxxxxxxxxx> 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 <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author