Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: export



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On November 26, 2014 8:07:19 AM EAT, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>On 11/25/2014 08:32 PM, Bart Schaefer wrote:
>> On Nov 25,  4:57pm, Ray Andrews wrote:
>> } Subject: export
>> }
>> } When I export a variable it is only available in subsequent shells
>in
>> } the same xterm. Can I make it export globally?
>>
>
>You guys don't understand what I'm asking.  I know I can't pass
>variables 'backwards' (except via a file), but when I export, the
>variable will be available  in *subsequent* shells but only in the
>same xterm:
>
>	pts/2 HP-y5--5-Debian1 root /aWorking/Zsh $ export trash=TRASH
>
>	pts/2 HP-y5--5-Debian1 root /aWorking/Zsh $ zsh
>
>	pts/2 HP-y5--5-Debian1 root /aWorking/Zsh $ echo $trash
>	TRASH
>
>... export does what it should do, but *only* in the same xterm.
>If I now go to another xterm, $trash is not set:
>
>	pts/9 HP-y5--5-Debian1 root /boot/Clone/y8--5-Debian2 $ zsh
>
>	pts/9 HP-y5--5-Debian1 root /boot/Clone/y8--5-Debian2 $ echo $trash

In another xterm there is different zsh process. Environment for the new shells is inherited from the parent. It absolutely irrelevant which existing process you may want to modify environment in. The only thing that was added is that with this requirements you may take this environment once at startup (e.g. in $HOME/.zshenv) and not in some hook like precmd.

And it does not do what it does "in xterm". It only does thing for the current shell process and next process run from the shell only inherits the environment. Given the existence of screen and dtach (not tmux: here environment is inherited from the server) you may migrate shells between terminal emulators. Or start screen in one and attach in its neighbour: after some scripting this may be a solution. Tmux may also be a solution: if you export in your shell and then repeat "export" using "tmux set-environment -g" then exported variable will appear in all new tmux instances.
-----BEGIN PGP SIGNATURE-----
Version: APG v1.1.1

iQJNBAEBCgA3BQJUdWoyMBwfMDI7PjIgHTg6PjswOSAQOzU6QTA9NEA+MjhHIDxr
cC1wYXZAeWFuZGV4LnJ1PgAKCRBu+P2/AXZZIns4EADOYIUvpa4jnzqL3EKkEw5A
nqOk2l8ytAgiK9Y4Nxd/9NTJMJ41H4sFJO/0bE3RARhx5eeVcItLgFnLaRKm5AyR
ghDeiRJgehcrph+gQFqKROWJ4jLFG62HuWDXlkqWuVcpLZHf9JE//nMQFl3RLjc1
gW4szARFQUhGb4E0bQhg7T+wZzA2KF1tb8Nhj1pt23/LvyZzot3Hnj5TQvvogZ2d
Ajajk42e/Z8rRvwuZDc8u1uiSwwhM9NoFXbaQEUDO+ddpS4CQW1cyxeYa9u7y2S5
jzV09STtQb4V6hBhPKS5JqZiCGYwjS4k/yGvWPnyck6WIw6UhPuPMhmHjw1AGYOt
tPrzMu3h6H2XAPVh6HvtPhkqvPTvUO9g3B6aJDYjXh1YvDMnPjOIgUL/naSyML5E
qCzoP9oOtaeqkyxkLidBKnrxW2/1/ExwjAg9gj7244zOxXRDd+L4o3S6bG+4Z1iR
w+T4fltR0v7e3Ad3lbM0nERl8UaWhbQMhvIL7d8WCA/dSbdxuee3dATYk+y/Ucaw
uLItZXiyPj2jBowoOuNONkjOqgqaUI18Uu7QTMaUBBs4fXiIPbJziqh5W8/P629A
CZwME1Cwq8tgPn1ggsnkG6o4X27u1w9WqBSmarAGh5tBb+CGXdGtl/D/DwerJDsb
omg7NC9P5XLcLXmSGL9uRw==
=+xrg
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author