Grub не обнаруживает диск Windows

Похоже, вы хотите выполнить $1и в зависимости от успеха или неудачи выполнить $2или $3. Вот один из способов сделать это:

successhandler() {
  echo GREAT SUCCESS
}

failurehandler() {
  echo sad failure
}

checkcondition() {
  if (( RANDOM < 15000 ))
  then
    true
  else
    false
  fi
}

myif() {
  # disable filename generation (in case globs are present)
  set -f
  if $1 > /dev/null 2>&1
  then
    $2
    true
  else
    $3
    false
  fi
}

Здесь я создал произвольные версии обработчиков успеха, обработчиков ошибок и контрольных условий, чтобы продемонстрировать поведение.

Вот несколько примеров запуска:

$ myif true successhandler failurehandler
GREAT SUCCESS
$ myif false successhandler failurehandler
sad failure
$ myif 'test -f /etc/hosts' successhandler failurehandler
GREAT SUCCESS
$ myif 'test -f /etc/hosts/not/there' successhandler failurehandler
sad failure
$ myif checkcondition successhandler failurehandler
GREAT SUCCESS
$ myif checkcondition successhandler failurehandler
sad failure
$ myif checkcondition successhandler failurehandler
GREAT SUCCESS
$ myif checkcondition successhandler failurehandler
sad failure
$ myif checkcondition successhandler failurehandler
sad failure

Внутри myif()я специально опускаю stdout и stderr в /dev/null; отрегулируйте это по своему усмотрению.

1
17.05.2020, 21:59
1 ответ

Таким образом, решение состояло в том, чтобы преобразовать мою установку Windows в UEFI (с помощью mbr2gpt в Windows ), после этого мне пришлось снова установить grub по умолчанию, и все работает нормально.

1
28.04.2021, 23:13

Теги

Похожие вопросы