From 9d9fedf9458da146a7f99a57367e6d02e12cff37 Mon Sep 17 00:00:00 2001 From: Brian Sobulefsky Date: Wed, 24 Aug 2022 00:17:41 -0700 Subject: [PATCH] Likely solution to lua 5.1 and 5.2 bug. --- lib/awful/screenshot.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/awful/screenshot.lua b/lib/awful/screenshot.lua index 4cace492f..b18adf6be 100644 --- a/lib/awful/screenshot.lua +++ b/lib/awful/screenshot.lua @@ -40,7 +40,7 @@ local function get_default_dir() local home_dir = os.getenv("HOME") if home_dir then - home_dir = string.gsub(home_dir, '/*$', '/') .. 'Images/' + home_dir = string.gsub(home_dir, '/*$', '/', 1) .. 'Images/' if gears.filesystem.dir_writable(home_dir) then return home_dir end @@ -70,15 +70,15 @@ local function check_directory(directory) -- is arguably unexpected behavior. if string.find(directory, "^~/") then directory = string.gsub(directory, "^~/", - string.gsub(os.getenv("HOME"), "/*$", "/")) + string.gsub(os.getenv("HOME"), "/*$", "/", 1)) elseif string.find(directory, "^[^/]") then - directory = string.gsub(os.getenv("HOME"), "/*$", "/") .. directory + directory = string.gsub(os.getenv("HOME"), "/*$", "/", 1) .. directory end print("After first sanitation -- " .. directory) -- Assure that we return exactly one trailing slash - directory = string.gsub(directory, '/*$', '/') + directory = string.gsub(directory, '/*$', '/', 1) print("After second sanitation -- " .. directory) if gears.filesystem.dir_writable(directory) then