From: Shumin Qiu Date: Mon, 9 Dec 2013 02:24:39 +0000 (+0000) Subject: Follow Shell specification to make sure the “command.man” file is always used no... X-Git-Tag: edk2-stable201903~12010 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=42f75495f3a89f30747406f7bf8fec9919da7b28;p=mirror_edk2.git Follow Shell specification to make sure the “command.man” file is always used no matter “command.efi -?” or “command -?” is typed. Signed-off-by: Shumin Qiu Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14947 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/ShellPkg/Application/Shell/ShellManParser.c b/ShellPkg/Application/Shell/ShellManParser.c index 8196a6ac9d..525c9343bd 100644 --- a/ShellPkg/Application/Shell/ShellManParser.c +++ b/ShellPkg/Application/Shell/ShellManParser.c @@ -492,19 +492,6 @@ ManFileFindTitleSection( StrCpy(TitleString, L".TH "); StrCat(TitleString, Command); - // - // If the "name" ends with .efi we can safely chop that off since "help foo.efi" and "help foo" - // should produce the same results. - // - if ((StrLen(Command)> 4) - && (TitleString[StrLen(TitleString)-1] == L'i' || TitleString[StrLen(TitleString)-1] == L'I') - && (TitleString[StrLen(TitleString)-2] == L'f' || TitleString[StrLen(TitleString)-2] == L'F') - && (TitleString[StrLen(TitleString)-3] == L'e' || TitleString[StrLen(TitleString)-2] == L'E') - && (TitleString[StrLen(TitleString)-4] == L'.') - ) { - TitleString[StrLen(TitleString)-4] = CHAR_NULL; - } - TitleLen = StrLen(TitleString); for (;!ShellFileHandleEof(Handle);Size = 1024) { Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, Ascii); diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 89132969b6..ea30aaefc3 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -2769,15 +2769,33 @@ EfiShellGetHelpText( ) { CONST CHAR16 *ManFileName; + CHAR16 *FixCommand; + EFI_STATUS Status; ASSERT(HelpText != NULL); + FixCommand = NULL; ManFileName = ShellCommandGetManFileNameHandler(Command); if (ManFileName != NULL) { return (ProcessManFile(ManFileName, Command, Sections, NULL, HelpText)); } else { - return (ProcessManFile(Command, Command, Sections, NULL, HelpText)); + if ((StrLen(Command)> 4) + && (Command[StrLen(Command)-1] == L'i' || Command[StrLen(Command)-1] == L'I') + && (Command[StrLen(Command)-2] == L'f' || Command[StrLen(Command)-2] == L'F') + && (Command[StrLen(Command)-3] == L'e' || Command[StrLen(Command)-3] == L'E') + && (Command[StrLen(Command)-4] == L'.') + ) { + FixCommand = AllocateZeroPool(StrSize(Command) - 4 * sizeof (CHAR16)); + ASSERT(FixCommand != NULL); + + StrnCpy(FixCommand, Command, StrLen(Command)-4); + Status = ProcessManFile(FixCommand, FixCommand, Sections, NULL, HelpText); + FreePool(FixCommand); + return Status; + } else { + return (ProcessManFile(Command, Command, Sections, NULL, HelpText)); + } } }