shada: Fix non-writeable ShaDa directory handling

Before this change,

    nvim -i /etc/shada

segfaults on exit if the file does not exist and user does not have
permissions to create the file at /etc/shada.

Closes #5296
Reported in #5277
https://github.com/neovim/neovim/issues/5277#issuecomment-243937255
This commit is contained in:
ZyX
2016-09-05 10:16:56 +03:00
committed by Justin M. Keyes
parent cd321b7d0f
commit 6127eaef05
3 changed files with 24 additions and 5 deletions

View File

@@ -8,8 +8,8 @@ local mpack = require('mpack')
local tmpname = helpers.tmpname()
local additional_cmd = ''
local function nvim_argv()
local argv = {nvim_prog, '-u', 'NONE', '-i', tmpname, '-N',
local function nvim_argv(shada_file)
local argv = {nvim_prog, '-u', 'NONE', '-i', shada_file or tmpname, '-N',
'--cmd', 'set shortmess+=I background=light noswapfile',
'--cmd', additional_cmd,
'--embed'}
@@ -20,8 +20,8 @@ local function nvim_argv()
end
end
local reset = function()
set_session(spawn(nvim_argv()))
local reset = function(shada_file)
set_session(spawn(nvim_argv(shada_file)))
meths.set_var('tmpname', tmpname)
end