Skip to main content
16 events
when toggle format what by license comment
Oct 11, 2017 at 15:52 vote accept rlf
Oct 11, 2017 at 15:51 history edited rlf CC BY-SA 3.0
fixed missing quote
Aug 31, 2017 at 16:01 answer added Stéphane Chazelas timeline score: 2
Jul 30, 2017 at 9:17 comment added rlf @KyleH Yes I have. The final column in the added table shows what effect export FOO has. In the case of zsh, there was no change. For bash it made the value of FOO visible both within the parent shell and from children.
Jul 29, 2017 at 21:41 comment added Kyle H Have you tried "export"ing your variable? When you run a command out spawns another shell so you have to export variables for subprocesses to be able to see them. Hopefully this helps. Didn't post as an answer because i tend to miss details in questions and don't want down votes.
Jul 29, 2017 at 19:07 history edited rlf CC BY-SA 3.0
Added results of more tests based on the comments.
Jul 27, 2017 at 23:48 comment added Wildcard @EliahKagan, interesting; you should post that as an answer. I also wonder if it makes a difference if you run export FOO in bash?
Jul 19, 2017 at 16:48 comment added Eliah Kagan I tested on Ubuntu 16.04 with zsh 5.1.1 and bash 4.3.48(1) and it seems setting an environment variable for zsh in GDB does not make it visible as a shell variable but does cause it to be passed on to child processes (as you have observed), while setting one for bash does make it visible as a shell variable but does not cause it to be passed on to child processes! It looks like zsh and bash use different strategies for managing variables, with zsh tracking non-environment variables and bash storing everything in its environment which it sanitizes when launching a (non-subshell) child.
Jul 12, 2017 at 6:09 comment added user1934428 That's what I thought. I guess the shell has somewhere a symbol table of variables, some of them are marked as "exported", which means that upon opening a subshell, they are placed into the environment of the child process. Initially (when the shell starts), the variables from the environment at that time are copied into the symbol table (of course also as "exported" variables). When you change the environment, the shell doesn't get noticed to update their symbol table - but child processes (like env) see the modified environment.
Jul 11, 2017 at 14:07 comment added rlf The correct value is printed from a new sub shell (tested for bash child also). Clearly the environment is persistent somehow as the child can inherit it but why doesn't the parent honour it?
Jul 11, 2017 at 4:45 comment added user1934428 What happens, if you do a zsh -c 'echo $FOO' (use single quotes!) instead? Can you see it then?
Jul 10, 2017 at 19:03 history tweeted twitter.com/StackUnix/status/884488241633574912
Jul 9, 2017 at 23:06 history edited rlf CC BY-SA 3.0
Fixed broken title
Jul 9, 2017 at 23:05 history undeleted rlf
Jul 9, 2017 at 13:46 history deleted rlf via Vote
Jul 9, 2017 at 13:46 history asked rlf CC BY-SA 3.0