path.isabsolute() now recognizes quoted shell variables

This commit is contained in:
Jason Perkins 2012-03-19 18:57:45 -04:00
parent 8436afcd24
commit a2aa2f83e1
2 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,7 @@
/**
* \file path_isabsolute.c
* \brief Determines if a path is absolute or relative.
* \author Copyright (c) 2002-2009 Jason Perkins and the Premake project
* \author Copyright (c) 2002-2012 Jason Perkins and the Premake project
*/
#include "premake.h"
@ -10,7 +10,11 @@
int path_isabsolute(lua_State* L)
{
const char* path = luaL_checkstring(L, 1);
if (path[0] == '/' || path[0] == '\\' || path[0] == '$' || (path[0] != '\0' && path[1] == ':'))
if (path[0] == '/' ||
path[0] == '\\' ||
path[0] == '$' ||
(path[0] == '"' && path[1] == '$') ||
(path[0] != '\0' && path[1] == ':'))
{
lua_pushboolean(L, 1);
return 1;

View File

@ -34,7 +34,7 @@
test.isequal("$(HOME)/user", path.getabsolute("$(HOME)/user"))
end
function suite.getabsolute_OnMultipleEnvVar()
function suite.getabsolute_OnMultipleEnvVar()
test.isequal("$(HOME)/$(USER)", path.getabsolute("$(HOME)/$(USER)"))
end
@ -43,6 +43,10 @@
test.isequal(expected, path.getabsolute("home/$(USER)"))
end
function suite.getabsolute_OnLeadingEnvVarQuoted()
test.isequal('"$(HOME)/user"', path.getabsolute('"$(HOME)/user"'))
end
--
-- path.getbasename() tests