mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 07:34:06 +02:00
ShellPkg: Remove trailing \r\n when redirect to env variable (EX: use ">v")
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chris Phillips <chrisp@hp.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14891 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
c2efcf0afd
commit
416a423f08
@ -3,6 +3,7 @@
|
|||||||
StdIn, StdOut, StdErr, etc...).
|
StdIn, StdOut, StdErr, etc...).
|
||||||
|
|
||||||
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -950,8 +951,48 @@ FileInterfaceEnvClose(
|
|||||||
IN EFI_FILE_PROTOCOL *This
|
IN EFI_FILE_PROTOCOL *This
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
VOID* NewBuffer;
|
||||||
|
UINTN NewSize;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Most if not all UEFI commands will have an '\r\n' at the end of any output.
|
||||||
|
// Since the output was redirected to a variable, it does not make sense to
|
||||||
|
// keep this. So, before closing, strip the trailing '\r\n' from the variable
|
||||||
|
// if it exists.
|
||||||
|
//
|
||||||
|
NewBuffer = NULL;
|
||||||
|
NewSize = 0;
|
||||||
|
|
||||||
|
Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
|
||||||
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
|
NewBuffer = AllocateZeroPool(NewSize + sizeof(CHAR16));
|
||||||
|
if (NewBuffer == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!EFI_ERROR(Status)) {
|
||||||
|
|
||||||
|
if (StrSize(NewBuffer) > 6)
|
||||||
|
{
|
||||||
|
if ((((CHAR16*)NewBuffer)[(StrSize(NewBuffer)/2) - 2] == CHAR_LINEFEED)
|
||||||
|
&& (((CHAR16*)NewBuffer)[(StrSize(NewBuffer)/2) - 3] == CHAR_CARRIAGE_RETURN)) {
|
||||||
|
((CHAR16*)NewBuffer)[(StrSize(NewBuffer)/2) - 3] = CHAR_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsVolatileEnv(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name)) {
|
||||||
|
Status = SHELL_SET_ENVIRONMENT_VARIABLE_V(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, StrSize(NewBuffer), NewBuffer);
|
||||||
|
} else {
|
||||||
|
Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, StrSize(NewBuffer), NewBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SHELL_FREE_NON_NULL(NewBuffer);
|
||||||
FreePool((EFI_FILE_PROTOCOL_ENVIRONMENT*)This);
|
FreePool((EFI_FILE_PROTOCOL_ENVIRONMENT*)This);
|
||||||
return (EFI_SUCCESS);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user