CHAR16 *NewCommandLine1;\r
CHAR16 *NewCommandLine2;\r
CHAR16 *Temp;\r
+ CHAR16 *Temp2;\r
UINTN ItemSize;\r
CHAR16 *ItemTemp;\r
SCRIPT_FILE *CurrentScriptFile;\r
}\r
}\r
\r
- //\r
- // Quick out if none were found...\r
- //\r
- if (NewSize == StrSize(OriginalCommandLine)) {\r
- ASSERT(Temp == NULL);\r
- Temp = StrnCatGrow(&Temp, NULL, OriginalCommandLine, 0);\r
- return (Temp);\r
- }\r
-\r
//\r
// now do the replacements...\r
//\r
ShellCopySearchAndReplace(NewCommandLine1, NewCommandLine2, NewSize, AliasListNode->Alias, AliasListNode->CommandString, TRUE, FALSE);\r
StrCpy(NewCommandLine1, NewCommandLine2);\r
}\r
+\r
+ //\r
+ // Remove non-existant environment variables in scripts only\r
+ //\r
+ for (Temp = NewCommandLine1 ; Temp != NULL ; ) {\r
+ Temp = StrStr(Temp, L"%");\r
+ if (Temp == NULL) {\r
+ break;\r
+ }\r
+ while (*(Temp - 1) == L'^') {\r
+ Temp = StrStr(Temp + 1, L"%");\r
+ if (Temp == NULL) {\r
+ break;\r
+ }\r
+ }\r
+ if (Temp == NULL) {\r
+ break;\r
+ }\r
+ \r
+ Temp2 = StrStr(Temp + 1, L"%");\r
+ if (Temp2 == NULL) {\r
+ break;\r
+ }\r
+ while (*(Temp2 - 1) == L'^') {\r
+ Temp2 = StrStr(Temp2 + 1, L"%");\r
+ if (Temp2 == NULL) {\r
+ break;\r
+ }\r
+ }\r
+ if (Temp2 == NULL) {\r
+ break;\r
+ }\r
+ \r
+ Temp2++;\r
+ CopyMem(Temp, Temp2, StrSize(Temp2));\r
+ }\r
+\r
}\r
\r
+ //\r
+ // Now cleanup any straggler intentionally ignored "%" characters\r
+ //\r
+ ShellCopySearchAndReplace(NewCommandLine1, NewCommandLine2, NewSize, L"^%", L"%", TRUE, FALSE);\r
+ StrCpy(NewCommandLine1, NewCommandLine2);\r
+ \r
FreePool(NewCommandLine2);\r
FreePool(ItemTemp);\r
\r