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

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).