file-functions: escapepath weirdness
A cross platform problem this escape function reads
function escapepath(path)
if os_type == "windows" then
local path,count = gsub(path,'"','')
if count % 2 ~= 0 then
print("Unbalanced quotes in path")
exit(0)
else
if match(path," ") then
return '"' .. path .. '"'
end
return path
end
else
path = gsub(path,"\\ ","[PATH-SPACE]")
path = gsub(path," ","\\ ")
return gsub(path,"%[PATH-SPACE%]","\\ ")
end
end
On windows, paths can contain an even number of '"' characters whereas on unix it can contain any number of such delimiter. This seems weird because escapepath is used to escape the paths defined in build.lua which should be platform agnostic.
The defaults are, but we have to watch for users ;)
I don't really understand what is exactly behind the scene. If this is some kind of error recovery, then it should be done on the unix side too, otherwise the same build.lua may break on the unix side.
I don't really understand what is exactly behind the scene. If this is some kind of error recovery, then it should be done on the unix side too, otherwise the same build.lua may break on the unix side.
The point is we can get
some-variable = "../An Awkard Dir"
in the build.lua file, which shows up after we've set the defaults. Now, there are some places I've not got things right with spaces, but this covers a reasonable number of them.
Ah, I see. What puzzled me is that your tests are covering something very different like
some_variable = "../An\" Awkard \"Dir"
other_variable = 'foo"bar"baz'
It does not seem so awkward to deliberately exclude some "exotic" file names, but some kind of note would help. Maybe raising an error would be appropriate.
Looking back, the point is that this is the same as the rule we using in expl3: *nix might allow " chars, but Windows really doesn't, so we don't. I think the logic is correct as-is.