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. --- README.md | 1 + shell/ash.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 90a89521a..5d7a98407 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,4 @@ Then just `make`. - Don't do wild things with Windows drive or UNC notation. - Wildcard expansion is disabled by default, though it can be turned on at compile time. This only affects command line arguments to the binary: the BusyBox shell has full support for wildcards. - Handling of users, groups and permissions is totally bogus. The system only admits to knowing about the current user and always returns the same hardcoded uid, gid and permission values. + - Windows XP and Windows Server 2003 don't seem to like how busybox-w32 handles environment variables. The -X shell option (which must be the first argument) might help. 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