2 Main file for endfor and for shell level 1 functions.
4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellLevel1CommandsLib.h"
16 #include <Library/PrintLib.h>
19 Determine if a valid string is a valid number for the 'for' command.
21 @param[in] Number The pointer to the string representation of the number to test.
23 @retval TRUE The number is valid.
24 @retval FALSE The number is not valid.
28 ShellIsValidForNumber (
29 IN CONST CHAR16
*Number
32 if (Number
== NULL
|| *Number
== CHAR_NULL
) {
36 if (*Number
== L
'-') {
40 if (StrLen(Number
) == 0) {
44 if (StrLen(Number
) >= 7) {
45 if ((StrStr(Number
, L
" ") == NULL
) || (((StrStr(Number
, L
" ") != NULL
) && (StrStr(Number
, L
" ") - Number
) >= 7))) {
50 if (!ShellIsDecimalDigitCharacter(*Number
)) {
58 Function for 'endfor' command.
60 @param[in] ImageHandle Handle to the Image (NULL if Internal).
61 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
65 ShellCommandRunEndFor (
66 IN EFI_HANDLE ImageHandle
,
67 IN EFI_SYSTEM_TABLE
*SystemTable
72 SCRIPT_FILE
*CurrentScriptFile
;
74 Status
= CommandInit();
75 ASSERT_EFI_ERROR(Status
);
77 if (!gEfiShellProtocol
->BatchIsActive()) {
78 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_NO_SCRIPT
), gShellLevel1HiiHandle
, L
"EndFor");
79 return (SHELL_UNSUPPORTED
);
82 if (gEfiShellParametersProtocol
->Argc
> 1) {
83 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel1HiiHandle
);
84 return (SHELL_INVALID_PARAMETER
);
87 Found
= MoveToTag(GetPreviousNode
, L
"for", L
"endfor", NULL
, ShellCommandGetCurrentScriptFile(), FALSE
, FALSE
, FALSE
);
90 CurrentScriptFile
= ShellCommandGetCurrentScriptFile();
95 STRING_TOKEN (STR_SYNTAX_NO_MATCHING
),
96 gShellLevel1HiiHandle
,
99 CurrentScriptFile
!=NULL
100 && CurrentScriptFile
->CurrentCommand
!=NULL
101 ? CurrentScriptFile
->CurrentCommand
->Line
:0);
102 return (SHELL_NOT_FOUND
);
104 return (SHELL_SUCCESS
);
112 CHAR16
*ReplacementName
;
113 CHAR16
*CurrentValue
;
114 BOOLEAN RemoveSubstAlias
;
117 #define SIZE_OF_SHELL_FOR_INFO OFFSET_OF (SHELL_FOR_INFO, Set)
118 #define SHELL_FOR_INFO_SIGNATURE SIGNATURE_32 ('S', 'F', 'I', 's')
121 Update the value of a given alias on the list. If the alias is not there then add it.
123 @param[in] Alias The alias to test for.
124 @param[in] CommandString The updated command string.
125 @param[in, out] List The list to search.
127 @retval EFI_SUCCESS The operation was completed successfully.
128 @retval EFI_OUT_OF_RESOURCES There was not enough free memory.
132 InternalUpdateAliasOnList(
133 IN CONST CHAR16
*Alias
,
134 IN CONST CHAR16
*CommandString
,
135 IN OUT LIST_ENTRY
*List
142 // assert for NULL parameter
144 ASSERT(Alias
!= NULL
);
147 // check for the Alias
149 for ( Node
= (ALIAS_LIST
*)GetFirstNode(List
), Found
= FALSE
150 ; !IsNull(List
, &Node
->Link
)
151 ; Node
= (ALIAS_LIST
*)GetNextNode(List
, &Node
->Link
)
153 ASSERT(Node
->CommandString
!= NULL
);
154 ASSERT(Node
->Alias
!= NULL
);
155 if (StrCmp(Node
->Alias
, Alias
)==0) {
156 FreePool(Node
->CommandString
);
157 Node
->CommandString
= NULL
;
158 Node
->CommandString
= StrnCatGrow(&Node
->CommandString
, NULL
, CommandString
, 0);
164 Node
= AllocateZeroPool(sizeof(ALIAS_LIST
));
166 return (EFI_OUT_OF_RESOURCES
);
168 ASSERT(Node
->Alias
== NULL
);
169 Node
->Alias
= StrnCatGrow(&Node
->Alias
, NULL
, Alias
, 0);
170 ASSERT(Node
->CommandString
== NULL
);
171 Node
->CommandString
= StrnCatGrow(&Node
->CommandString
, NULL
, CommandString
, 0);
172 InsertTailList(List
, &Node
->Link
);
174 return (EFI_SUCCESS
);
178 Find out if an alias is on the given list.
180 @param[in] Alias The alias to test for.
181 @param[in] List The list to search.
183 @retval TRUE The alias is on the list.
184 @retval FALSE The alias is not on the list.
188 InternalIsAliasOnList(
189 IN CONST CHAR16
*Alias
,
190 IN CONST LIST_ENTRY
*List
196 // assert for NULL parameter
198 ASSERT(Alias
!= NULL
);
201 // check for the Alias
203 for ( Node
= (ALIAS_LIST
*)GetFirstNode(List
)
204 ; !IsNull(List
, &Node
->Link
)
205 ; Node
= (ALIAS_LIST
*)GetNextNode(List
, &Node
->Link
)
207 ASSERT(Node
->CommandString
!= NULL
);
208 ASSERT(Node
->Alias
!= NULL
);
209 if (StrCmp(Node
->Alias
, Alias
)==0) {
217 Remove an alias from the given list.
219 @param[in] Alias The alias to remove.
220 @param[in, out] List The list to search.
224 InternalRemoveAliasFromList(
225 IN CONST CHAR16
*Alias
,
226 IN OUT LIST_ENTRY
*List
232 // assert for NULL parameter
234 ASSERT(Alias
!= NULL
);
237 // check for the Alias
239 for ( Node
= (ALIAS_LIST
*)GetFirstNode(List
)
240 ; !IsNull(List
, &Node
->Link
)
241 ; Node
= (ALIAS_LIST
*)GetNextNode(List
, &Node
->Link
)
243 ASSERT(Node
->CommandString
!= NULL
);
244 ASSERT(Node
->Alias
!= NULL
);
245 if (StrCmp(Node
->Alias
, Alias
)==0) {
246 RemoveEntryList(&Node
->Link
);
247 FreePool(Node
->Alias
);
248 FreePool(Node
->CommandString
);
257 Function to determine whether a string is decimal or hex representation of a number
258 and return the number converted from the string.
260 @param[in] String String representation of a number
263 @retval (UINTN)(-1) An error ocurred.
268 IN CONST CHAR16
*String
273 if (!EFI_ERROR(ShellConvertStringToUint64(String
, &RetVal
, FALSE
, TRUE
))) {
274 return ((UINTN
)RetVal
);
276 return ((UINTN
)(-1));
280 Function for 'for' command.
282 @param[in] ImageHandle Handle to the Image (NULL if Internal).
283 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
288 IN EFI_HANDLE ImageHandle
,
289 IN EFI_SYSTEM_TABLE
*SystemTable
293 SHELL_STATUS ShellStatus
;
294 SCRIPT_FILE
*CurrentScriptFile
;
296 CHAR16
*ArgSetWalker
;
300 SHELL_FOR_INFO
*Info
;
304 EFI_SHELL_FILE_INFO
*Node
;
305 EFI_SHELL_FILE_INFO
*FileList
;
310 ShellStatus
= SHELL_SUCCESS
;
317 // initialize the shell lib (we must be in non-auto-init...)
319 Status
= ShellInitialize();
320 ASSERT_EFI_ERROR(Status
);
322 Status
= CommandInit();
323 ASSERT_EFI_ERROR(Status
);
325 if (!gEfiShellProtocol
->BatchIsActive()) {
326 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_NO_SCRIPT
), gShellLevel1HiiHandle
, L
"For");
327 return (SHELL_UNSUPPORTED
);
330 if (gEfiShellParametersProtocol
->Argc
< 4) {
331 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellLevel1HiiHandle
);
332 return (SHELL_INVALID_PARAMETER
);
335 CurrentScriptFile
= ShellCommandGetCurrentScriptFile();
336 ASSERT(CurrentScriptFile
!= NULL
);
338 if ((CurrentScriptFile
->CurrentCommand
!= NULL
) && (CurrentScriptFile
->CurrentCommand
->Data
== NULL
)) {
342 // Make sure that an End exists.
344 if (!MoveToTag(GetNextNode
, L
"endfor", L
"for", NULL
, CurrentScriptFile
, TRUE
, TRUE
, FALSE
)) {
349 STRING_TOKEN (STR_SYNTAX_NO_MATCHING
),
350 gShellLevel1HiiHandle
,
353 CurrentScriptFile
->CurrentCommand
->Line
);
354 return (SHELL_DEVICE_ERROR
);
360 if (gEfiShellParametersProtocol
->Argv
[1][0] != L
'%' || gEfiShellParametersProtocol
->Argv
[1][2] != CHAR_NULL
361 ||!((gEfiShellParametersProtocol
->Argv
[1][1] >= L
'a' && gEfiShellParametersProtocol
->Argv
[1][1] <= L
'z')
362 ||(gEfiShellParametersProtocol
->Argv
[1][1] >= L
'A' && gEfiShellParametersProtocol
->Argv
[1][1] <= L
'Z'))
364 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_INV_VAR
), gShellLevel1HiiHandle
, gEfiShellParametersProtocol
->Argv
[1]);
365 return (SHELL_INVALID_PARAMETER
);
368 if (gUnicodeCollation
->StriColl(
371 gEfiShellParametersProtocol
->Argv
[2]) == 0) {
372 for (LoopVar
= 0x3 ; LoopVar
< gEfiShellParametersProtocol
->Argc
; LoopVar
++) {
373 ASSERT((ArgSet
== NULL
&& ArgSize
== 0) || (ArgSet
!= NULL
));
374 if (StrStr(gEfiShellParametersProtocol
->Argv
[LoopVar
], L
"*") != NULL
375 ||StrStr(gEfiShellParametersProtocol
->Argv
[LoopVar
], L
"?") != NULL
376 ||StrStr(gEfiShellParametersProtocol
->Argv
[LoopVar
], L
"[") != NULL
377 ||StrStr(gEfiShellParametersProtocol
->Argv
[LoopVar
], L
"]") != NULL
) {
379 Status
= ShellOpenFileMetaArg ((CHAR16
*)gEfiShellParametersProtocol
->Argv
[LoopVar
], EFI_FILE_MODE_READ
, &FileList
);
380 if (EFI_ERROR(Status
) || FileList
== NULL
|| IsListEmpty(&FileList
->Link
)) {
381 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, L
" \"", 0);
382 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, gEfiShellParametersProtocol
->Argv
[LoopVar
], 0);
383 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, L
"\"", 0);
385 for (Node
= (EFI_SHELL_FILE_INFO
*)GetFirstNode(&FileList
->Link
)
386 ; !IsNull(&FileList
->Link
, &Node
->Link
)
387 ; Node
= (EFI_SHELL_FILE_INFO
*)GetNextNode(&FileList
->Link
, &Node
->Link
)
389 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, L
" \"", 0);
390 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, Node
->FullName
, 0);
391 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, L
"\"", 0);
393 ShellCloseFileMetaArg(&FileList
);
396 Parameter
= gEfiShellParametersProtocol
->Argv
[LoopVar
];
397 if (Parameter
[0] == L
'\"' && Parameter
[StrLen(Parameter
)-1] == L
'\"') {
398 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, L
" ", 0);
399 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, Parameter
, 0);
401 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, L
" \"", 0);
402 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, Parameter
, 0);
403 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, L
"\"", 0);
407 if (ArgSet
== NULL
) {
408 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
411 // set up for an 'in' for loop
413 NewSize
= StrSize(ArgSet
);
414 NewSize
+= sizeof(SHELL_FOR_INFO
)+StrSize(gEfiShellParametersProtocol
->Argv
[1]);
415 Info
= AllocateZeroPool(NewSize
);
416 ASSERT(Info
!= NULL
);
417 Info
->Signature
= SHELL_FOR_INFO_SIGNATURE
;
418 CopyMem(Info
->Set
, ArgSet
, StrSize(ArgSet
));
419 NewSize
= StrSize(gEfiShellParametersProtocol
->Argv
[1]);
420 CopyMem(Info
->Set
+(StrSize(ArgSet
)/sizeof(Info
->Set
[0])), gEfiShellParametersProtocol
->Argv
[1], NewSize
);
421 Info
->ReplacementName
= Info
->Set
+StrSize(ArgSet
)/sizeof(Info
->Set
[0]);
422 Info
->CurrentValue
= (CHAR16
*)Info
->Set
;
427 if (InternalIsAliasOnList(Info
->ReplacementName
, &CurrentScriptFile
->SubstList
)) {
428 Info
->RemoveSubstAlias
= FALSE
;
430 Info
->RemoveSubstAlias
= TRUE
;
432 CurrentScriptFile
->CurrentCommand
->Data
= Info
;
434 } else if (gUnicodeCollation
->StriColl(
437 gEfiShellParametersProtocol
->Argv
[2]) == 0) {
438 for (LoopVar
= 0x3 ; LoopVar
< gEfiShellParametersProtocol
->Argc
; LoopVar
++) {
439 ASSERT((ArgSet
== NULL
&& ArgSize
== 0) || (ArgSet
!= NULL
));
440 if (ArgSet
== NULL
) {
441 // ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
443 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, L
" ", 0);
445 ArgSet
= StrnCatGrow(&ArgSet
, &ArgSize
, gEfiShellParametersProtocol
->Argv
[LoopVar
], 0);
446 // ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
448 if (ArgSet
== NULL
) {
449 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
452 // set up for a 'run' for loop
454 Info
= AllocateZeroPool(sizeof(SHELL_FOR_INFO
)+StrSize(gEfiShellParametersProtocol
->Argv
[1]));
455 ASSERT(Info
!= NULL
);
456 Info
->Signature
= SHELL_FOR_INFO_SIGNATURE
;
457 CopyMem(Info
->Set
, gEfiShellParametersProtocol
->Argv
[1], StrSize(gEfiShellParametersProtocol
->Argv
[1]));
458 Info
->ReplacementName
= Info
->Set
;
459 Info
->CurrentValue
= NULL
;
460 ArgSetWalker
= ArgSet
;
461 if (ArgSetWalker
[0] != L
'(') {
466 STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT
),
467 gShellLevel1HiiHandle
,
469 CurrentScriptFile
->CurrentCommand
->Line
);
470 ShellStatus
= SHELL_INVALID_PARAMETER
;
472 TempSpot
= StrStr(ArgSetWalker
, L
")");
473 if (TempSpot
!= NULL
) {
474 TempString
= TempSpot
+1;
475 if (*(TempString
) != CHAR_NULL
) {
476 while(TempString
!= NULL
&& *TempString
== L
' ') {
479 if (StrLen(TempString
) > 0) {
484 if (TempSpot
== NULL
) {
489 STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT
),
490 gShellLevel1HiiHandle
,
491 CurrentScriptFile
->CurrentCommand
->Line
);
492 ShellStatus
= SHELL_INVALID_PARAMETER
;
494 *TempSpot
= CHAR_NULL
;
496 while (ArgSetWalker
!= NULL
&& ArgSetWalker
[0] == L
' ') {
499 if (!ShellIsValidForNumber(ArgSetWalker
)) {
504 STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT
),
505 gShellLevel1HiiHandle
,
507 CurrentScriptFile
->CurrentCommand
->Line
);
508 ShellStatus
= SHELL_INVALID_PARAMETER
;
510 if (ArgSetWalker
[0] == L
'-') {
511 Info
->Current
= 0 - (INTN
)ReturnUintn(ArgSetWalker
+1);
513 Info
->Current
= (INTN
)ReturnUintn(ArgSetWalker
);
515 ArgSetWalker
= StrStr(ArgSetWalker
, L
" ");
516 while (ArgSetWalker
!= NULL
&& ArgSetWalker
[0] == L
' ') {
519 if (ArgSetWalker
== NULL
|| *ArgSetWalker
== CHAR_NULL
|| !ShellIsValidForNumber(ArgSetWalker
)){
524 STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT
),
525 gShellLevel1HiiHandle
,
527 CurrentScriptFile
->CurrentCommand
->Line
);
528 ShellStatus
= SHELL_INVALID_PARAMETER
;
530 if (ArgSetWalker
[0] == L
'-') {
531 Info
->End
= 0 - (INTN
)ReturnUintn(ArgSetWalker
+1);
533 Info
->End
= (INTN
)ReturnUintn(ArgSetWalker
);
535 if (Info
->Current
< Info
->End
) {
541 ArgSetWalker
= StrStr(ArgSetWalker
, L
" ");
542 while (ArgSetWalker
!= NULL
&& ArgSetWalker
[0] == L
' ') {
545 if (ArgSetWalker
!= NULL
&& *ArgSetWalker
!= CHAR_NULL
) {
546 if (ArgSetWalker
== NULL
|| *ArgSetWalker
== CHAR_NULL
|| !ShellIsValidForNumber(ArgSetWalker
)){
551 STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT
),
552 gShellLevel1HiiHandle
,
554 CurrentScriptFile
->CurrentCommand
->Line
);
555 ShellStatus
= SHELL_INVALID_PARAMETER
;
557 if (*ArgSetWalker
== L
')') {
558 ASSERT(Info
->Step
== 1 || Info
->Step
== -1);
560 if (ArgSetWalker
[0] == L
'-') {
561 Info
->Step
= 0 - (INTN
)ReturnUintn(ArgSetWalker
+1);
563 Info
->Step
= (INTN
)ReturnUintn(ArgSetWalker
);
566 if (StrStr(ArgSetWalker
, L
" ") != NULL
) {
571 STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT
),
572 gShellLevel1HiiHandle
,
574 CurrentScriptFile
->CurrentCommand
->Line
);
575 ShellStatus
= SHELL_INVALID_PARAMETER
;
585 if (ShellStatus
== SHELL_SUCCESS
) {
586 if (InternalIsAliasOnList(Info
->ReplacementName
, &CurrentScriptFile
->SubstList
)) {
587 Info
->RemoveSubstAlias
= FALSE
;
589 Info
->RemoveSubstAlias
= TRUE
;
592 if (CurrentScriptFile
->CurrentCommand
!= NULL
) {
593 CurrentScriptFile
->CurrentCommand
->Data
= Info
;
601 STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT
),
602 gShellLevel1HiiHandle
,
604 CurrentScriptFile
!=NULL
605 && CurrentScriptFile
->CurrentCommand
!=NULL
606 ? CurrentScriptFile
->CurrentCommand
->Line
:0);
607 ShellStatus
= SHELL_INVALID_PARAMETER
;
611 // These need to be NULL since they are used to determine if this is the first pass later on...
613 ASSERT(ArgSetWalker
== NULL
);
614 ASSERT(ArgSet
== NULL
);
617 if (CurrentScriptFile
!= NULL
&& CurrentScriptFile
->CurrentCommand
!= NULL
) {
618 Info
= (SHELL_FOR_INFO
*)CurrentScriptFile
->CurrentCommand
->Data
;
619 if (CurrentScriptFile
->CurrentCommand
->Reset
) {
620 Info
->CurrentValue
= (CHAR16
*)Info
->Set
;
622 CurrentScriptFile
->CurrentCommand
->Reset
= FALSE
;
625 ShellStatus
= SHELL_UNSUPPORTED
;
628 if (ShellStatus
== SHELL_SUCCESS
) {
629 ASSERT(Info
!= NULL
);
630 if (Info
->Step
!= 0) {
632 // only advance if not the first pass
636 // sequence version of for loop...
638 Info
->Current
+= Info
->Step
;
641 TempString
= AllocateZeroPool(50*sizeof(CHAR16
));
642 UnicodeSPrint(TempString
, 50*sizeof(CHAR16
), L
"%d", Info
->Current
);
643 InternalUpdateAliasOnList(Info
->ReplacementName
, TempString
, &CurrentScriptFile
->SubstList
);
644 FreePool(TempString
);
646 if ((Info
->Step
> 0 && Info
->Current
> Info
->End
) || (Info
->Step
< 0 && Info
->Current
< Info
->End
)) {
647 CurrentScriptFile
->CurrentCommand
->Data
= NULL
;
649 // find the matching endfor (we're done with the loop)
651 if (!MoveToTag(GetNextNode
, L
"endfor", L
"for", NULL
, CurrentScriptFile
, TRUE
, FALSE
, FALSE
)) {
656 STRING_TOKEN (STR_SYNTAX_NO_MATCHING
),
657 gShellLevel1HiiHandle
,
660 CurrentScriptFile
!=NULL
661 && CurrentScriptFile
->CurrentCommand
!=NULL
662 ? CurrentScriptFile
->CurrentCommand
->Line
:0);
663 ShellStatus
= SHELL_DEVICE_ERROR
;
665 if (Info
->RemoveSubstAlias
) {
667 // remove item from list
669 InternalRemoveAliasFromList(Info
->ReplacementName
, &CurrentScriptFile
->SubstList
);
675 // Must be in 'in' version of for loop...
677 ASSERT(Info
->Set
!= NULL
);
678 if (Info
->CurrentValue
!= NULL
&& *Info
->CurrentValue
!= CHAR_NULL
) {
679 if (Info
->CurrentValue
[0] == L
' ') {
680 Info
->CurrentValue
++;
682 if (Info
->CurrentValue
[0] == L
'\"') {
683 Info
->CurrentValue
++;
686 // do the next one of the set
688 ASSERT(TempString
== NULL
);
689 TempString
= StrnCatGrow(&TempString
, NULL
, Info
->CurrentValue
, 0);
690 if (TempString
== NULL
) {
691 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
693 TempSpot
= StrStr(TempString
, L
"\" \"");
694 if (TempSpot
!= NULL
) {
695 *TempSpot
= CHAR_NULL
;
697 while (TempString
[StrLen(TempString
)-1] == L
'\"') {
698 TempString
[StrLen(TempString
)-1] = CHAR_NULL
;
700 InternalUpdateAliasOnList(Info
->ReplacementName
, TempString
, &CurrentScriptFile
->SubstList
);
701 Info
->CurrentValue
+= StrLen(TempString
);
703 if (Info
->CurrentValue
[0] == L
'\"') {
704 Info
->CurrentValue
++;
706 FreePool(TempString
);
709 CurrentScriptFile
->CurrentCommand
->Data
= NULL
;
711 // find the matching endfor (we're done with the loop)
713 if (!MoveToTag(GetNextNode
, L
"endfor", L
"for", NULL
, CurrentScriptFile
, TRUE
, FALSE
, FALSE
)) {
718 STRING_TOKEN (STR_SYNTAX_NO_MATCHING
),
719 gShellLevel1HiiHandle
,
722 CurrentScriptFile
!=NULL
723 && CurrentScriptFile
->CurrentCommand
!=NULL
724 ? CurrentScriptFile
->CurrentCommand
->Line
:0);
725 ShellStatus
= SHELL_DEVICE_ERROR
;
727 if (Info
->RemoveSubstAlias
) {
729 // remove item from list
731 InternalRemoveAliasFromList(Info
->ReplacementName
, &CurrentScriptFile
->SubstList
);
737 if (ArgSet
!= NULL
) {
740 return (ShellStatus
);