zsh-workers
 help / color / mirror / code / Atom feed
* Regression in zsh 5.7: locking failed for /dev/null: permission denied
@ 2019-01-29 18:51 Vincent Lefevre
  2019-01-29 20:09 ` dana
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Lefevre @ 2019-01-29 18:51 UTC (permalink / raw)
  To: zsh-workers

I use the following function, see suggestion from
http://www.zsh.org/mla/workers/2016/msg02070.html

append_file_to_hist()
{
  emulate -LR zsh
  local -a entries

  # 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 ${2:-$HISTFILE}

  # Reset SAVEHIST to avoid attempting to lock /dev/null
  SAVEHIST=0        # fc -p makes this implicitly local
}

When I use it, I get the error:

append_file_to_hist:24: locking failed for /dev/null: permission denied

-- 
Vincent Lefèvre <vincent@vinc17.net> - 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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Regression in zsh 5.7: locking failed for /dev/null: permission denied
  2019-01-29 18:51 Regression in zsh 5.7: locking failed for /dev/null: permission denied Vincent Lefevre
@ 2019-01-29 20:09 ` dana
  2019-01-30  0:15   ` Vincent Lefevre
  0 siblings, 1 reply; 3+ messages in thread
From: dana @ 2019-01-29 20:09 UTC (permalink / raw)
  To: Vincent Lefevre; +Cc: zsh-workers

On 29 Jan 2019, at 12:51, Vincent Lefevre <vincent@vinc17.net> 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...?

dana


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Regression in zsh 5.7: locking failed for /dev/null: permission denied
  2019-01-29 20:09 ` dana
@ 2019-01-30  0:15   ` Vincent Lefevre
  0 siblings, 0 replies; 3+ messages in thread
From: Vincent Lefevre @ 2019-01-30  0:15 UTC (permalink / raw)
  To: zsh-workers

On 2019-01-29 14:09:56 -0600, dana wrote:
> On 29 Jan 2019, at 12:51, Vincent Lefevre <vincent@vinc17.net> 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@vinc17.net> - 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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-30  0:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29 18:51 Regression in zsh 5.7: locking failed for /dev/null: permission denied Vincent Lefevre
2019-01-29 20:09 ` dana
2019-01-30  0:15   ` Vincent Lefevre

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).