Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path.join with quoted paths #15

Open
moteus opened this issue Aug 8, 2012 · 1 comment
Open

path.join with quoted paths #15

moteus opened this issue Aug 8, 2012 · 1 comment

Comments

@moteus
Copy link

moteus commented Aug 8, 2012

path.join shold unquot each element and quot result

For example:

IPPARCH="ia32"
IPPBASE=J([[e:\Program Files\Intel\IPP\6.0.2.074]], IPPARCH)
-- here i have IPPBASE= [["e:\Program Files\Intel\IPP\6.0.2.074\ia32"]]
....
incdir=J(IPPBASE, 'include')
-- here i have incdir= [["e:\Program Files\Intel\IPP\6.0.2.074\ia32\include"]]

to support this i implement:

function trim(s) return(s:gsub('^%s+',''):gsub('%s+$','')) end

function path_unquoted(s)
  s = trim(s)
  if s:sub(1,1) == '"' and s:sub(-1,-1) == '"' then
    return (s:sub(2,-2))
  end
  return s
end

function path_quoted(s)
  if s:find("%s") then return '"' .. s .. '"' end
  return s
end

function J(...)
  local t,n = {...}, select('#', ...)
  local r = path_unquoted(t[1])
  for i = 2, #t do r = path.join(r,path_unquoted(t[i])) end
  return path_quoted(r)
end
@stevedonovan
Copy link
Owner

Thanks, that is necessary. Internally I am keeping paths-with-spaces quoted, even on Unix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants