/* This function will correctly stack and unstack nested scripts. */
SCRIPT_FILE* EFIAPI ShellCommandSetNewScript(IN SCRIPT_FILE *Script OPTIONAL)
/* This function will correctly stack and unstack nested scripts. */
SCRIPT_FILE* EFIAPI ShellCommandSetNewScript(IN SCRIPT_FILE *Script OPTIONAL)
{
  SCRIPT_FILE_LIST  *Node;
  if (Script == NULL) {
    if (IsListEmpty (&mScriptList.Link)) {
      return (NULL);
    }
    Node = (SCRIPT_FILE_LIST *)GetFirstNode (&mScriptList.Link);
    RemoveEntryList (&Node->Link);
    DeleteScriptFileStruct (Node->Data);
    FreePool (Node);
  } else {
    Node = AllocateZeroPool (sizeof (SCRIPT_FILE_LIST));
    if (Node == NULL) {
      return (NULL);
    }
    Node->Data = Script;
    InsertHeadList (&mScriptList.Link, &Node->Link);
  }
  return (ShellCommandGetCurrentScriptFile ());
}