output of `export -p' seems misleading

2012-11-09 Thread wuya
Hi all, 1. why `export -p' output something in the format `declare -x foo="bar"' 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. 3. As in bash 4.2, -g option is a

Re: output of `export -p' seems misleading

2012-11-09 Thread Chet Ramey
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 tha

Re: output of `export -p' seems misleading

2012-11-09 Thread Greg Wooledge
On Fri, Nov 09, 2012 at 11:07:28AM -0500, Chet Ramey wrote: > On 11/9/12 4:09 AM, wuya wrote: > >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 no

Re: output of `export -p' seems misleading

2012-11-09 Thread Greg Wooledge
On Fri, Nov 09, 2012 at 11:18:24AM -0500, Greg Wooledge wrote: > restore_environment() { > set -o posix > eval "$saved_output_of_export_dash_p" > set +o posix > } Err, what I meant was: save_environment() { set -o posix saved_env=$(export -p) set +o posix } restore_environment() {