Debugging lua 5.1, lua 5.2 error.

This commit is contained in:
Brian Sobulefsky 2022-08-23 22:52:03 -07:00 committed by Emmanuel Lepage Vallee
parent fb77f90959
commit e8584f47b4
1 changed files with 8 additions and 0 deletions

View File

@ -60,6 +60,8 @@ end
-- Adding 'mkdir -p' functionality can be considered in the future. -- Adding 'mkdir -p' functionality can be considered in the future.
local function check_directory(directory) local function check_directory(directory)
print("Enter check_directory()")
print(directory)
if directory and type(directory) == "string" then if directory and type(directory) == "string" then
-- Fully qualify a "~/" path or a relative path to $HOME. One might argue -- Fully qualify a "~/" path or a relative path to $HOME. One might argue
@ -73,15 +75,20 @@ local function check_directory(directory)
directory = string.gsub(os.getenv("HOME"), "/*$", "/") .. directory directory = string.gsub(os.getenv("HOME"), "/*$", "/") .. directory
end end
print("After first sanitation -- " .. directory)
-- Assure that we return exactly one trailing slash -- Assure that we return exactly one trailing slash
directory = string.gsub(directory, '/*$', '/') directory = string.gsub(directory, '/*$', '/')
print("After second sanitation -- " .. directory)
if gears.filesystem.dir_writable(directory) then if gears.filesystem.dir_writable(directory) then
print("Returning directory")
return directory return directory
else else
-- Currently returns nil if the requested directory string cannot be used. -- Currently returns nil if the requested directory string cannot be used.
-- This can be swapped to a silent fallback to the default directory if -- This can be swapped to a silent fallback to the default directory if
-- desired. It is debatable which way is better. -- desired. It is debatable which way is better.
print("Returning nil")
return nil return nil
end end
@ -89,6 +96,7 @@ local function check_directory(directory)
-- No directory argument means use the default. Technically an outrageously -- No directory argument means use the default. Technically an outrageously
-- invalid argument (i.e. not even a string) currently falls back to the -- invalid argument (i.e. not even a string) currently falls back to the
-- default as well. -- default as well.
print("Returning default directory")
return get_default_dir() return get_default_dir()
end end