Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Regression in zsh 5.7: locking failed for /dev/null: permission denied



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@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