在没有先前值赋值的情况下声明和测试变量

问题描述 投票:1回答:1

给定一个标准的bash环境,通常会出现以下行为吗?

~ $ declare testa
~ $ declare -p testa
bash: declare: testa: not found

在撰写本文时,不同操作系统中不同bash的输出中的给定情况似乎存在差异(此处未显示)。

此外,是否有任何明确的bash API手册,参考或其他文档涵盖此案例?

bash shell ubuntu declare
1个回答
1
投票

这被认为是与之相关的

bash 4.4 relase,Entry“f。声明的`-p'选项和类似的builtins将显示命名变量的属性,即使这些变量没有被分配值(技术上未设置)。”

© www.soinside.com 2019 - 2024. All rights reserved.