On 11/9/12 4:09 AM, wuya wrote: > Hi all, > 1. why `export -p' output something in the format `declare -x foo="bar"'
Because the declare form is bash's `native' notation. If you're in Posix mode, the output is in the form of `export' commands. > 2. this format gives user an implication that by executing these `declare' > commands, all those variables got exported, but this is only partly true as > it fails in functions. That's not quite true. The documentation implies, though maybe not as clearly as possible, that each name argument to declare/export/readonly is treated as a variable name by default. The -f option is what you need to refer to functions. > 3. As in bash 4.2, -g option is added. why not change output format of > `export -p' to `declare -g foo="bar"'? Because they are not at all the same thing. -x refers to the environment. -g changes bash's internal variable scoping. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/