这是专门关于bash
的- 在这个答案declare
中对一般情况进行了非常详尽的处理(其中提到“ // , ,的输出”,但没有提到的输出)。typeset
declare
export -p
ksh93
mksh
zsh
bash
给定一个本地/导出/数组/关联数组(但可能不是 nameref)变量, infoo
的输出是否保证可重用?官方文档没有提到类似的内容:declare -p foo
bash
bash
该
-p
选项将显示每个的属性和值name
。当-p
与参数一起使用时,除和name
之外的其他选项将被忽略。-f
-F
我浏览了一下CHANGES
,看到了关于函数的内容:
This document details the changes between this version, bash-2.05-beta1,
and the previous version, bash-2.05-alpha1.
...
b. When `set' is called without options, it prints function definitions in a
way that allows them to be reused as input. This affects `declare' and
`declare -p' as well.
对于其他几个命令,-p
旨在生成可重用的输出:
s. The `shopt' `-p' option now causes output to be displayed in a reusable
format.
...
u. `umask' now has a `-p' option to print output in a reusable format.
Bash-2.0 contained extensive changes and new features from bash-1.14.7.
Here's a short list:
...
most builtins use -p option to display output in a reusable form
(for consistency)
但我找不到任何关于declare -p
变量的信息。