如何删除shellcheck在inting shell脚本时的警告 "SC2154"?
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
echo "proxy=$http_proxy" | sudo tee -a /etc/test.txt
警告是 "SC2154: http_proxy is referenced but not assigned."。
EDIT:我想用sudo把环境变量 "http_proxy "写到test.txt文件中。
作为抑制警告的方法,你可以明确地展开 http_proxy
如果是null或未设置,则为nothing。
echo "proxy=${http_proxy:-}"