組み込みデバイスでスクリプトを実行するときに変数がバインドされていませんか?

組み込みデバイスでスクリプトを実行するときに変数がバインドされていませんか?

スクリプトデスクトップで実行すると正常に動作しますcurl -sL https://sentry.io/get-cli/ | bash

curl組み込みデバイスで上記と同じコマンドを呼び出すと、次の結果が表示されます。

bash: line 22: !DOWNLOAD_URL_LOOKUP: unbound variable

なぜこれは古い組み込みデバイスでのみ起こりますか?(Ubuntu 14.04、GNU bash、バージョン4.3.11(1)-リリース(arm-unknown-linux-gnueabihf))


関連スクリプト:

#!/bin/bash
set -eu

SENTRY_DOWNLOAD_Darwin_x86_64="https://github.com/getsentry/sentry-cli/releases/download/1.26.0/sentry-cli-Darwin-x86_64"
SENTRY_DOWNLOAD_Linux_i686="https://github.com/getsentry/sentry-cli/releases/download/1.26.0/sentry-cli-Linux-i686"
SENTRY_DOWNLOAD_Linux_x86_64="https://github.com/getsentry/sentry-cli/releases/download/1.26.0/sentry-cli-Linux-x86_64"
SENTRY_DOWNLOAD_Windows_i686="https://github.com/getsentry/sentry-cli/releases/download/1.26.0/sentry-cli-Windows-i686.exe"
SENTRY_DOWNLOAD_Windows_x86_64="https://github.com/getsentry/sentry-cli/releases/download/1.26.0/sentry-cli-Windows-x86_64.exe"
VERSION="1.26.0"
PLATFORM=`uname -s`
ARCH=`uname -m`

# If the install directory is not set, set it to a default
if [ -z ${INSTALL_DIR+x} ]; then
  INSTALL_DIR=/usr/local/bin
fi
if [ -z ${INSTALL_PATH+x} ]; then
  INSTALL_PATH="${INSTALL_DIR}/sentry-cli"
fi

DOWNLOAD_URL_LOOKUP="SENTRY_DOWNLOAD_${PLATFORM}_${ARCH}"
DOWNLOAD_URL="${!DOWNLOAD_URL_LOOKUP}"

echo "This script will automatically install sentry-cli ${VERSION} for you."
echo "Installation path: ${INSTALL_PATH}"
if [ "x$(id -u)" == "x0" ]; then
  echo "Warning: this script is currently running as root. This is dangerous. "
  echo "         Instead run it as normal user. We will sudo as needed."
fi

if [ -f "$INSTALL_PATH" ]; then
  echo "error: sentry-cli is already installed."
  exit 1
fi

if [ x$DOWNLOAD_URL == x ]; then
  echo "error: your platform and architecture (${PLATFORM}-${ARCH}) is unsupported."
  exit 1
fi

if ! hash curl 2> /dev/null; then
  echo "error: you do not have 'curl' installed which is required for this script."
  exit 1
fi

TEMP_FILE=`mktemp "${TMPDIR:-/tmp}/.sentrycli.XXXXXXXX"`

cleanup() {
  rm -f "$TEMP_FILE"
}

trap cleanup EXIT
curl -SL --progress-bar "$DOWNLOAD_URL" > "$TEMP_FILE"
chmod 0755 "$TEMP_FILE"
if ! mv "$TEMP_FILE" "$INSTALL_PATH" 2> /dev/null; then
  sudo -k mv "$TEMP_FILE" "$INSTALL_PATH"
fi

echo 'Done!'

ベストアンサー1

ここには多くの情報はありませんが、変数を取得しましたか?そのset +u場合は、ソースファイルの前に呼び出してからすぐに有効にして、ソースファイルの変数の厳密性を無効にしてみてください。set -u

おすすめ記事