Hello,
I made some improvements in ShellPkg that I think would be nice for the
community.
=======================================================
ShellPkg: Improvements in space handling, "if" command also accepts
directory and user input reading.
1. Improvements in space handling at command lines to accept tab (\t)
as a space;
2. "If" command also accepts a directory when checking if a file
exists;
3. When waiting for user input, support some cases when a key event is
generated
but the device is not ready when the keystroke is read.
Just ignore the event and wait again for another key.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Leandro G. B. Becker <lbec...@positivo.com.br>
=======================================================
Best regards to all!
Leandro G. B. Becker
Positivo Informática S.A.
--- a/ShellPkg/Application/Shell/FileHandleWrappers.c Thu Jan 16 13:53:56 2014
+++ b/ShellPkg/Application/Shell/FileHandleWrappers.c Mon Jun 16 10:16:53 2014
@@ -414,8 +414,15 @@
//
// Read a key
//
- gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
+ // Patch for some BIOSes that generates and key event but then the device
is not ready yet
+ // Ignore it and wait again
+ do {
+ gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
+ }
+ while (Status == EFI_NOT_READY);
+
if (EFI_ERROR (Status)) {
break;
}
@@ -571,7 +578,7 @@
break;
default:
- if (Key.UnicodeChar >= ' ') {
+ if (Key.UnicodeChar >= ' ' && Key.UnicodeChar < 0x7F) {
//
// If we are at the buffer's end, drop the key
//
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c Thu Nov 21 13:17:29 2013
+++ a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c Mon Jan 27 17:25:10 2014
@@ -398,8 +398,23 @@
// is what remains a file in CWD???
//
OperationResult =
(BOOLEAN)(ShellFileExists(StatementWalker)==EFI_SUCCESS);
+ // Checks also if is a directory
+ if (!OperationResult) {
+ if (ShellIsDirectory(StatementWalker)==EFI_SUCCESS)
+ OperationResult = TRUE;
+ }
} else if (StatementWalker[0] == CHAR_NULL && StartParameterNumber+1 ==
EndParameterNumber) {
- OperationResult =
(BOOLEAN)(ShellFileExists(gEfiShellParametersProtocol->Argv[++StartParameterNumber])==EFI_SUCCESS);
+ CHAR16* path = gEfiShellParametersProtocol->Argv[++StartParameterNumber];
+ OperationResult = (BOOLEAN)(ShellFileExists(path)==EFI_SUCCESS);
+ // Checks also if is a directory
+ if (!OperationResult) {
+ if (ShellIsDirectory(path)==EFI_SUCCESS)
+ OperationResult = TRUE;
+ }
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN),
gShellLevel1HiiHandle, L"exist(s)");
Status = EFI_INVALID_PARAMETER;
@@ -524,6 +539,12 @@
BinOp = OperatorLessOrEqual;
} else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"==")) {
BinOp = OperatorEqual;
+ }
+ else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"!=")) {
+ BinOp = OperatorNotEqual;
} else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ugt")) {
BinOp = OperatorUnisgnedGreaterThan;
} else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ult")) {
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c Mon Jan 27
16:13:56 2014
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c Tue Jan 28
09:54:22 2014
@@ -49,7 +49,7 @@
//
// make sure we dont have any leading spaces
//
- while ((*Walker)[0] == L' ') {
+ while ((*Walker)[0] == L' ' || (*Walker)[0] == L'\t') {
(*Walker)++;
}
@@ -120,10 +120,10 @@
CopyMem(NextDelim, NextDelim+1, StrSize(NextDelim) -
sizeof(NextDelim[0]));
}
}
- while ((*TempParameter)[StrLen(*TempParameter)-1] == L' ') {
+ while ((*TempParameter)[StrLen(*TempParameter)-1] == L' ' ||
(*TempParameter)[StrLen(*TempParameter)-1] == L'\t') {
(*TempParameter)[StrLen(*TempParameter)-1] = CHAR_NULL;
}
- while ((*TempParameter)[0] == L' ') {
+ while ((*TempParameter)[0] == L' ' || (*TempParameter)[0] == L'\t') {
CopyMem(*TempParameter, (*TempParameter)+1, StrSize(*TempParameter) -
sizeof((*TempParameter)[0]));
}
}
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel