Bashエラー
エラー解決
script.sh: line 57: FOO_56: unbound variable の原因と解決法
script.sh: line 57: FOO_56: unbound variable の原因と具体的な解決手順をまとめました。
エラーメッセージ(全文)
script.sh: line 57: FOO_56: unbound variable
このエラーとは
script.sh: line 57: FOO_56: unbound variable は Bash 開発でよく遭遇するエラーです。
想定環境: Windows / macOS / Linux
よく出る状況: シェルスクリプト / cron
よくある原因
- set -u
- クォート
- cron 環境
解決方法
方法1: shellcheck
shellcheck script.sh.
それでも直らないとき
バージョン情報(Bash のバージョン、OS、実行コマンド)を添えて、エラーメッセージ全文と直前に変更した点を確認してください。ログの数行上にも原因の手がかりが残っていることが多いです。
まとめ
「script.sh: line 57: FOO_56: unbound variable」は set -u が原因のことが多いです。上記の手順で切り分けてください。
次にやること
同じ Bash カテゴリの関連エラーもあわせて確認してください。
よくある質問
script.sh: line 57: FOO_56: unbound variable とは何ですか?
script.sh: line 57: FOO_56: unbound variable は Bash 実行時に表示されるエラーです。set -u
script.sh: line 57: FOO_56: unbound variable の原因は?
set -u。クォート。cron 環境。
script.sh: line 57: FOO_56: unbound variable の直し方は?
shellcheck:shellcheck script.sh.
Bash で script.sh が出るのはなぜ?
シェルスクリプト / cron
script.sh: line 57: FOO_56: unbound variable を防ぐには?
。
次に読むべき記事
- ./deploy-57.sh: line 59: syntax error near unexpected token `&&' の原因と解決法
- cron: (58 10 * * *) CMD (/usr/local/bin/job-58.sh) failed with exit code 58 の原因と解決法
- find: '/var/log/app-59': Permission denied の原因と解決法
- script.sh: line 49: FOO_48: unbound variable の原因と解決法
- script.sh: line 41: FOO_40: unbound variable の原因と解決法
同カテゴリ「Bashエラー」の記事
- bash: bash: ./script.sh: Permission denied の原因と解決法
- find: '/var/log/app-59': Permission denied の原因と解決法
- find: '/var/log/app-51': Permission denied の原因と解決法
- find: '/var/log/app-43': Permission denied の原因と解決法
- find: '/var/log/app-35': Permission denied の原因と解決法
- find: '/var/log/app-27': Permission denied の原因と解決法
人気記事
- TS2307: Cannot find module '@components/Widget601' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget591' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget581' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget571' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget561' or its corresponding type declarations の原因と解決法
- TS2307: Cannot find module '@components/Widget551' or its corresponding type declarations の原因と解決法
学習ルート
体系的に学びたい方はこちらから。
エラー・トラブル集で続きを探す →あわせて読みたい
- script.sh: line 49: FOO_48: unbound variable の原因と解決法同カテゴリの関連エラー
- script.sh: line 41: FOO_40: unbound variable の原因と解決法同カテゴリの関連エラー
- script.sh: line 33: FOO_32: unbound variable の原因と解決法同カテゴリの関連エラー
- script.sh: line 25: FOO_24: unbound variable の原因と解決法同カテゴリの関連エラー
- script.sh: line 17: FOO_16: unbound variable の原因と解決法同カテゴリの関連エラー