@MaxRAF

Как правильно перевести описание оператора case в bash?

Всем привет.

Делаю перевод статьи, но не могу правильно и понятно перевести.

Часть статьи (жирным выделил, что не могу перевести, чтобы предложение нормально выглядело):

The last of the important iteration loops is case. The case statement is used to
evaluate a number of expected values. The case statement in particular is important
in Linux startup scripts that on previous versions of RHEL were used to start ser-
vices. In a case statement, you define every specific argument that you expect, which
is followed by the command that needs to be executed if that argument was used.
In Listing 31.10 , you can see the blueprint of the case statement that was used on
RHEL 6 to start almost any service.

Вот собственно листинг:
case "$1" in
     start)
          start;;
     stop)
          rm -f $lockfile
          stop;;
     restart)
          restart;;
     reload)
          reload;;
     status)
          status
          ;;
     *)
          echo "Usage: $0 (start|stop|restart|reload|status)"
          ;;
esac


Далее пошел абзац. Тоже не могу полностью его перевести корректно.

The case statement has a few particularities. To start, the generic syntax is case
item-to-evaluate in . Then follows a list of all possible values that need to be evalu-
ated. Each item is closed with a ). Then follows a list of commands that need to be
executed if the specific argument was used. The list of commands is closed with a
double semicolon. This ;; can be used directly after the last command, and it can be
used on a separate line. Also notice that the *) refers to all other options not previ-
ously specified. It is a “catchall” statement. The case iteration loop is closed by an
esac statement.

Notice that the evaluations in case are performed in order. When the first match
is made, the case statement will not evaluate anything else. Within the evaluation,
wildcard-like patterns can be used. This shows in the *) evaluation, which matches
everything. But you could as well use evaluations like start|Start|START) to match
the use of a different case.

Помогите. Для сайта делаю, чтобы другим было полезно.
  • Вопрос задан
  • 63 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

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