From ee9670b1eabd3f95512d6715ca9783cfbb668dc5 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 6 Oct 2018 22:53:48 +0200 Subject: [PATCH] Gracefully fail when history file is inaccessible (#2410) If the history file (or its parents) can't be created, running a command will fail entirely. Since saving command history is not an integral part of running a command, it would be nicer if it carried on, just without saving history. This is what shells usually do. This patch removes assertions in the history saving function and instead adds an early return, so if the history isn't saved the command invocation simply carries on. Signed-off-by: Alyssa Ross --- lib/awful/prompt.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/awful/prompt.lua b/lib/awful/prompt.lua index 395e4873..fb49d69a 100644 --- a/lib/awful/prompt.lua +++ b/lib/awful/prompt.lua @@ -110,7 +110,6 @@ -- @see string -- Grab environment we need -local assert = assert local io = io local table = table local math = math @@ -210,8 +209,12 @@ end -- @param id The data.history identifier local function history_save(id) if data.history[id] then - assert(gfs.make_parent_directories(id)) - local f = assert(io.open(id, "w")) + gfs.make_parent_directories(id) + local f = io.open(id, "w") + if not f then + gdebug.print_warning("Failed to write the history to "..id) + return + end for i = 1, math.min(#data.history[id].table, data.history[id].max) do f:write(data.history[id].table[i] .. "\n") end