BUG: Fix escaping of more characters on Windows shells.
This commit is contained in:
parent
637596a157
commit
16ec04c2a7
@ -74,6 +74,13 @@ static int kwsysSystem_Shell__CharNeedsQuotesOnUnix(char c)
|
||||
(c == '*') || (c == '^') || (c == '\\'));
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int kwsysSystem_Shell__CharNeedsQuotesOnWindows(char c)
|
||||
{
|
||||
return ((c == '\'') || (c == '#') || (c == '&') ||
|
||||
(c == '<') || (c == '>') || (c == '|') || (c == '^'));
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int kwsysSystem_Shell__CharNeedsQuotes(char c, int isUnix, int flags)
|
||||
{
|
||||
@ -99,14 +106,10 @@ static int kwsysSystem_Shell__CharNeedsQuotes(char c, int isUnix, int flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* On Windows single-quotes must be escaped in some make
|
||||
environments, such as in mingw32-make. */
|
||||
if(flags & kwsysSystem_Shell_Flag_Make)
|
||||
/* On Windows several special characters need quotes to preserve them. */
|
||||
if(kwsysSystem_Shell__CharNeedsQuotesOnWindows(c))
|
||||
{
|
||||
if(c == '\'')
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -207,14 +207,12 @@ ADD_CUSTOM_COMMAND(OUTPUT gen_redirect.c
|
||||
##############################################################################
|
||||
# Test non-trivial command line arguments in custom commands.
|
||||
SET(EXPECTED_ARGUMENTS)
|
||||
# TODO: Check shell operators < > << >> | 2>&1 1>&2 &> ! &
|
||||
SET(CHECK_ARGS
|
||||
c:/posix/path
|
||||
c:\\windows\\path
|
||||
'single-quotes'
|
||||
single'quote
|
||||
\"double-quotes\"
|
||||
double\"quote
|
||||
"\\;semi-colons\\;"
|
||||
"semi\\;colon"
|
||||
`back-ticks`
|
||||
@ -225,15 +223,15 @@ SET(CHECK_ARGS
|
||||
{curly}
|
||||
{lcurly}
|
||||
rcurly}
|
||||
#<angle> # angle-brackets are inconsistent on windows right now
|
||||
#<langle
|
||||
#rangle>
|
||||
<angle>
|
||||
<langle
|
||||
rangle>
|
||||
[square]
|
||||
[lsquare # these have funny behavior due to special cases for
|
||||
rsquare] # windows registry value names in list expansion
|
||||
$dollar-signs$
|
||||
dollar$sign
|
||||
&ersands&
|
||||
&ersands&x # Borland make does not like trailing ampersand
|
||||
one&ersand
|
||||
@two-ats@
|
||||
one@at
|
||||
@ -268,7 +266,6 @@ SET(CHECK_ARGS
|
||||
"'single quotes with space'"
|
||||
"single'quote with space"
|
||||
"\"double-quotes with space\""
|
||||
"double\"quote with space"
|
||||
"\\;semi-colons w s\\;"
|
||||
"semi\\;colon w s"
|
||||
"`back-ticks` w s"
|
||||
@ -279,9 +276,9 @@ SET(CHECK_ARGS
|
||||
"{curly} w s"
|
||||
"{lcurly w s"
|
||||
"rcurly} w s"
|
||||
#"<angle> w s" # angle-brackets are inconsistent on windows right now
|
||||
#"<langle w s"
|
||||
#"rangle> w s"
|
||||
"<angle> w s"
|
||||
"<langle w s"
|
||||
"rangle> w s"
|
||||
"[square] w s"
|
||||
"[lsquare w s" # these have funny behavior due to special cases for
|
||||
"rsquare] w s" # windows registry value names in list expansion
|
||||
@ -316,15 +313,26 @@ SET(CHECK_ARGS
|
||||
"#two-pounds# w s"
|
||||
"one#pound w s"
|
||||
~ ` ! @ \# $ % ^ & _ - + = : "\;" \" ' , . ? "(" ")" { } []
|
||||
# | < > << >> &> 2>&1 1>&2
|
||||
# \\ # Need to test last to avoid ; escape in list.
|
||||
# # Make tools need help when this is the last argument.
|
||||
)
|
||||
IF(NOT MINGW)
|
||||
# * # MinGW programs on windows always expands the wildcard!
|
||||
# / # MSys make converts a leading slash to the mingw home directory
|
||||
LIST(APPEND CHECK_ARGS * /)
|
||||
ENDIF(NOT MINGW)
|
||||
|
||||
# The windows command shell does not support a double quote by itself:
|
||||
# double\"quote
|
||||
# without messing up quoting of arguments following it.
|
||||
|
||||
# Make tools need help with escaping a single backslash
|
||||
# \
|
||||
# at the end of a command because they think it is a continuation
|
||||
# character.
|
||||
|
||||
# We now have special cases for shell operators:
|
||||
# | < > << >> &> 2>&1 1>&2
|
||||
# to allow custom commands to perform redirection.
|
||||
|
||||
FOREACH(arg ${CHECK_ARGS})
|
||||
SET(ARG "${arg}")
|
||||
STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user