[sf-lug] printenv "vs." set [was: Re: shell, man(1) [was: ...
Michael Paoli
Michael.Paoli at cal.berkeley.edu
Sun Aug 21 08:49:30 PDT 2016
> From: "Alex Kleider" <akleider at sonic.net>
> Subject: Re: shell, man(1) [was: path name expansion]
> Date: Sat, 20 Aug 2016 08:59:29 -0700
> On 2016-08-19 11:13, Michael Paoli wrote:
>> $ man bash
>> ...
>> set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...]
>> set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]
>> Without options, the name and value of each shell variable are
>> displayed in a format that can be reused as input for setting or
>> resetting the currently-set variables. Read-only variables can-
>> not be reset. In posix mode, only shell variables are listed.
>> The output is sorted according to the current locale. When
>> options are specified, they set or unset shell attributes. Any
>> arguments remaining after option processing are treated as val-
>> ues for the positional parameters and are assigned, in order, to
>> $1, $2, ... $n. Options, if specified, have the following
>> meanings:
>> ...
>> $ printenv | grep SHELL | grep -v '^XT'
>> SHELL=And why would you think this tells you the shell you're running?
>> $
>> What SHELL is set to in the environment, and the shell one is running,
>> are not necessarily the same ... hopefully obvious by my example
>> above.
>
> printenv and set do not appear to be doing the same thing.
> alex at X301n3:~/Test$ printenv | grep SHELL | grep -v '^XT'
> SHELL=/bin/bash
> alex at X301n3:~/Test$ set | grep '^BASH_VERSION='
> BASH_VERSION='4.3.11(1)-release'
> alex at X301n3:~/Test$ printenv | grep '^BASH_VERSION='
Yes, they're not doing the same thing.
RFTM. :-)
bash(1)
...
>> set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...]
>> set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]
>> Without options, the name and value of each shell variable
printenv(1)
...
Print the values of the specified environment VARIABLE(s)
...
More information about the sf-lug
mailing list