From 0ccf7a03aa45889993716581d675616db633ed33 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 5 Jun 2015 14:55:45 +0100 Subject: ash: add winxp option In some circumstances Windows XP and Windows Server 2003 seem to dislike environment variables with backslashes in paths. The 'winxp' option prevents BusyBox from changing backslashes to slashes in the environment. Although the option can be managed by the 'set' builtin it only works if '-X' is given as the first argument to the shell. --- shell/ash.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 0d188e1e6..afa9f271b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -297,6 +297,7 @@ static const char *const optletters_optnames[] = { #endif #if ENABLE_PLATFORM_MINGW32 ,"\0" "noconsole" + ,"X" "winxp" #endif }; @@ -380,6 +381,7 @@ struct globals_misc { #endif #if ENABLE_PLATFORM_MINGW32 # define noconsole optlist[14 + ENABLE_ASH_BASH_COMPAT + 2*DEBUG] +# define winxp optlist[15 + ENABLE_ASH_BASH_COMPAT + 2*DEBUG] #endif /* trap handler commands */ @@ -13453,7 +13455,11 @@ exitshell(void) } static void +#if ENABLE_PLATFORM_MINGW32 +init(int xp) +#else init(void) +#endif { /* from input.c: */ /* we will never free this */ @@ -13502,8 +13508,7 @@ init(void) struct passwd *pw; for (envp = environ; envp && *envp; envp++) { - end = strchr(*envp, '='); - if (!end) + if (!(end=strchr(*envp, '='))) continue; /* make all variable names uppercase */ @@ -13511,9 +13516,11 @@ init(void) *start = toupper(*start); /* convert backslashes to forward slashes */ - for ( ++end; *end; ++end ) { - if ( *end == '\\' ) { - *end = '/'; + if (!xp) { + for ( ++end; *end; ++end ) { + if ( *end == '\\' ) { + *end = '/'; + } } } } @@ -13739,7 +13746,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) #endif rootpid = getpid(); - init(); + init(IF_PLATFORM_MINGW32(argc >= 2 && strcmp(argv[1], "-X") == 0)); setstackmark(&smark); #if ENABLE_PLATFORM_MINGW32 -- cgit v1.2.3-55-g6feb