#!/usr/bin/sh
# Detects a shell.efi bootloader on a EFI System Partition

. /usr/share/os-prober/common.sh

found=

efi_shell=$(find "$1" -iname 'shell.efi' -type f 2>/dev/null | head -1)
if [ -n "${efi_shell}" ]; then
	# the path must be relative to the EFI directory we were handed, since
	# 05efi prefixes it with "<partition>@/<efi dir>/"
	path="${efi_shell#"$1"/}"
	long="EFI firmware management shell"
	short="EFI_SHELL"
	found=true
fi

if [ -n "$found" ]; then
	label="$(count_next_label "$short")"
	result "${path}:${long}:${label}"
fi

exit 0
