Установить переменную оболочки, затем вызвать подпроцесс не удалось

La forma en que hago esto es:

Obtenga el UUID de VboxAdditions

[fredmj@Lagrange ~]$ vboxmanage list dvds [...] UUID: 3cc8e4fb-e56e-blabla... State: created Type: readonly Location: /usr/share/virtualbox/VBoxGuestAdditions.iso Storage format: RAW Capacity: 55 MBytes Encryption: disabled

use vboxmanage storageattach con el UUID correcto

para tomar el UUID y ponerlo en el comando vboxmanage:

[fredmj@Lagrange ~]$ vboxmanage storageattach CENTOS7.GUESTADD --storagectl SATA --port 1 --type dvddrive --medium 3cc8e4fb-e56e-blabla..

Leyendo el manual de usuario Pensé que era posible usar algo como --medium additionspero no logré averiguar cómo

0
03.07.2019, 01:02
1 ответ

Если вам нужно, чтобы OPTERR был равен 0 во время вызова функции, установите его как локальную переменную, как указал Гордон Дэвиссон:

#!/bin/bash

myfunc() {
  local OPTERR=0
  printf "Inside myfunc, OPTERR=%d\n" "$OPTERR"
  while getopts ":a:" opt; do
    echo $opt is $OPTARG
  done
}

printf "Before calling myfunc, OPTERR=%d\n" "$OPTERR"
myfunc
printf "After calling myfunc, OPTERR=%d\n" "$OPTERR"

Результат:

Before calling myfunc, OPTERR=1
Inside myfunc, OPTERR=0
After calling myfunc, OPTERR=1
0
28.01.2020, 02:39

Теги

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