Menu

Passing parameters to shell.efi no longer works.

lx07
2020-04-09
2020-07-02
  • lx07

    lx07 - 2020-04-09

    I have a 2015 MacBook Pro with a manual stanza to launch Mojave by passing the name of a shell script to shell.efi on the options line. In rEFInd version 11.4 this worked fine. In 11.5 and 12.0 shell.efi is still launched but it does not call the .nsh file.

    Pressing F2 twice shows the option line fs0:EFI\tools\launch_mojave.nsh correctly but it is ignored by the shell and I'm dropped into the prompt.

    I am using the edk version 1 shell from here https://github.com/tianocore/edk2/tree/UDK2018/EdkShellBinPkg/FullShell/X64 . Later versions of the shell don't work for me so I don't know if this issue is shell version specific.

    Reversion of commit 140ce6dcc2c17b46ed02762e53d5c71db772dffe ("Stop passing the filename to launched programs") allows the shell to process the passed script. The NEWS.txt part of the diff shows this change was done for unified kernel booting.

    diff --git a/NEWS.txt b/NEWS.txt
    index 612f369..76a2839 100644
    --- a/NEWS.txt
    +++ b/NEWS.txt
    @@ -1,19 +1,6 @@
     0.11.6 (?/??/2020):
     -------------------
    
    -- Previous versions of rEFInd have all passed the name of the program being
    -  launched as a parameter to that program, just as the EFI shell does. This
    -  is causing problems for a new unified kernel image format that combines a
    -  Linux kernel, initrd, EFI stub loader, and some other elements into a
    -  single file. Thus, I'm changing to NOT passing the follow-on program's
    -  filename as an option. (Gummiboot/systemd-boot and GRUB 2 both work this
    -  way, and unless you explicitly add the program filename to the options
    -  list, so does launching a file directly via an EFI boot manager entry
    -  created via efibootmgr.) Note that rEFInd continues adding a space to the
    -  end of options lists passed to the macOS boot loader, since it ignores the
    -  commands if this is not done. (No space is added to commands passed to
    -  other programs, though.)
    -
     - The handling of screen resets on return from a program has been adjusted
       to avoid problems with program error messages being erased by rEFInd's
       screen clearing. If a program returns an error code, its output should
    diff --git a/include/version.h b/include/version.h
    index 41ebeb2..c626689 100644
    --- a/include/version.h
    +++ b/include/version.h
    @@ -10,5 +10,5 @@
      *
      */
    
    -#define REFIND_VERSION L"0.11.5.3"
    +#define REFIND_VERSION L"0.11.5.2"
    
    diff --git a/refind/launch_efi.c b/refind/launch_efi.c
    index 609803f..3a8d218 100644
    --- a/refind/launch_efi.c
    +++ b/refind/launch_efi.c
    @@ -156,6 +156,7 @@ EFI_STATUS StartEFIImage(IN REFIT_VOLUME *Volume,
         EFI_LOADED_IMAGE        *ChildLoadedImage = NULL;
         CHAR16                  ErrorInfo[256];
         CHAR16                  *FullLoadOptions = NULL;
    +    CHAR16                  *Temp;
    
         // set load options
         if (LoadOptions != NULL) {
    @@ -175,6 +176,14 @@ EFI_STATUS StartEFIImage(IN REFIT_VOLUME *Volume,
         // protect for this condition; but sometimes Volume comes back NULL, so provide
         // an exception. (TODO: Handle this special condition better.)
         if (IsValidLoader(Volume->RootDir, Filename)) {
    +        if (Filename) {
    +            Temp = PoolPrint(L"\\%s %s", Filename, FullLoadOptions ? FullLoadOptions : L"");
    +            if (Temp != NULL) {
    +                MyFreePool(FullLoadOptions);
    +                FullLoadOptions = Temp;
    +            }
    +        } // if (Filename)
    +
             DevicePath = FileDevicePath(Volume->DeviceHandle, Filename);
             // NOTE: Below commented-out line could be more efficient if file were read ahead of
             // time and passed as a pre-loaded image to LoadImage(), but it doesn't work on my
    

    Manual stanza definition fwiw:

    menuentry "Mojave" {
        # Can't have 2 manual stanza for macOS based on volume name or partition UUID
        # Get loader GUID from macOS2 subvolume: diskutil info disk1s1|grep 'Volume UUID'
        # Get filesystem mounts from EFI shell : map -r > FS0:\map.txt
        # echo "fs6:\DD3856E8-5866-4F7E-8DDC-692FB7EB1C9F\System\Library\CoreServices\boot.efi" > /Volumes/ESP/EFI/tools/launch_Mojave.nsh
        # echo "fs8:\DD3856E8-5866-4F7E-8DDC-692FB7EB1C9F\boot.efi" > /Volumes/ESP/EFI/tools/launch_Mojave_recovery.nsh
        icon \EFI\refind\themes\colourful\myicons\os_mac_old.png
        loader \EFI\tools\shell.efi
        options "fs0:EFI\tools\launch_mojave.nsh"
        submenuentry "Verbose" {
            options "fs0:\EFI\tools\launch_mojave-v.nsh"
        }
        submenuentry "Single User" {
            options "fs0:\EFI\tools\launch_mojave-vs.nsh"
        }
        submenuentry "Safe Mode" {
            options "fs0:\EFI\tools\launch_mojave-vx.nsh"
        }
        submenuentry "Recovery" {
            options "fs0:\EFI\tools\launch_mojave_recovery.nsh"
        }
    }
    
     

    Last edit: lx07 2020-04-09
  • John McHugo

    John McHugo - 2020-07-02

    Hate to say it, but "me, too" on refind 0.12.0. Prevents a simple boot into Windows 10 on my old Macbook. Once dropped into the shell, typing the "nsh" script path to activate it completes the boot. Or revert to 0.11.4 as a workaround, as suggested.

     

Log in to post a comment.