bash - 在没有事先赋值的情况下声明和设置变量

标签 bash shell ubuntu declare

给定一个标准的 bash 环境,以下行为是否普遍预期?

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

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

此外,是否有任何明确的 bash API 手册、引用或其他文档涵盖这种情况?

最佳答案

这被认为与

the bash 4.4 relase, Entry "f. The `-p' option to declare and similar builtins will display attributes for named variables even when those variables have not been assigned values (which are technically unset)."

关于bash - 在没有事先赋值的情况下声明和设置变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49665313/

相关文章:

bash - 在 bash 脚本中模拟 ENTER 按键

string - 线路操作和排序

bash - Vim - 在搜索时捕获字符串并在替换时使用

c - 如何在 bash 脚本中运行一个 c 程序并给它 2 个参数?

ubuntu - 更改亮度ubuntu12.04LTS

linux - 在 RHEL6.7 上用 sed 替换 sed

regex - 复制与范围内的数字模式匹配的文件

string - 删除多余的字符串而不循环

xml - 如何在 XML 变量中连接用户名?

matlab - 运行可执行文件而不显示在 "top"