+/**\r
+ Fix a string to only have the environment variable name, removing starting at the first space of whatever is quoted and removing the leading and trailing %.\r
+\r
+ @param[in] FileName The filename to start with.\r
+\r
+ @retval NULL FileName was invalid.\r
+ @return The modified FileName.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+FixVarName (\r
+ IN CHAR16 *FileName\r
+ )\r
+{\r
+ CHAR16 *Copy;\r
+ CHAR16 *TempLocation;\r
+\r
+ Copy = FileName;\r
+\r
+ if (FileName[0] == L'%') {\r
+ Copy = FileName+1;\r
+ if ((TempLocation = StrStr(Copy , L"%")) != NULL) {\r
+ TempLocation[0] = CHAR_NULL;\r
+ } \r
+ }\r
+\r
+ return (FixFileName(Copy));\r
+}\r
+\r
+/**\r
+ Remove the unicode file tag from the begining of the file buffer since that will not be\r
+ used by StdIn.\r
+ \r
+ @param[in] Handle Pointer to the handle of the file to be processed.\r
+ \r
+ @retval EFI_SUCCESS The unicode file tag has been moved successfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RemoveFileTag(\r
+ IN SHELL_FILE_HANDLE *Handle\r
+ )\r
+{\r
+ UINTN CharSize;\r
+ CHAR16 CharBuffer;\r
+\r
+ CharSize = sizeof(CHAR16);\r
+ CharBuffer = 0;\r
+ gEfiShellProtocol->ReadFile(*Handle, &CharSize, &CharBuffer);\r
+ if (CharBuffer != gUnicodeFileTag) {\r
+ gEfiShellProtocol->SetFilePosition(*Handle, 0);\r
+ }\r
+ return (EFI_SUCCESS);\r
+}\r
+\r
+/**\r
+ Write the unicode file tag to the specified file.\r
+\r
+ It is the caller's responsibility to ensure that\r
+ ShellInfoObject.NewEfiShellProtocol has been initialized before calling this\r
+ function.\r
+\r
+ @param[in] FileHandle The file to write the unicode file tag to.\r
+\r
+ @return Status code from ShellInfoObject.NewEfiShellProtocol->WriteFile.\r
+**/\r
+EFI_STATUS\r
+WriteFileTag (\r
+ IN SHELL_FILE_HANDLE FileHandle\r
+ )\r
+{\r
+ CHAR16 FileTag;\r
+ UINTN Size;\r
+ EFI_STATUS Status;\r
+\r
+ FileTag = gUnicodeFileTag;\r
+ Size = sizeof FileTag;\r
+ Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (FileHandle, &Size,\r
+ &FileTag);\r
+ ASSERT (EFI_ERROR (Status) || Size == sizeof FileTag);\r
+ return Status;\r
+}\r
+\r
+\r