tag:blogger.com,1999:blog-2425290326823263574.post9137833529282086484..comments2022-12-04T18:48:06.405-08:00Comments on Krazy Glew's Blog: calling a function to change the environmentAndy "Krazy" Glewhttp://www.blogger.com/profile/08442494949914217568noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-2425290326823263574.post-8549947568622442562011-11-13T14:24:59.065-08:002011-11-13T14:24:59.065-08:00"... stop it just before it exits..."
W..."... stop it just before it exits..."<br /><br />What if the environment setting tool is itself wrapperized? <br /><br />One would have to know whether to look at the environment of the child, or grandchild, or ...<br /><br />This is a hack. It may make things better, but not perfect.Andy "Krazy" Glewhttps://www.blogger.com/profile/08442494949914217568noreply@blogger.comtag:blogger.com,1999:blog-2425290326823263574.post-4665324224775014992011-11-13T14:15:52.913-08:002011-11-13T14:15:52.913-08:00The way this is usually done is to have the child ...The way this is usually done is to have the child output some commands the parent evals. For example try running ssh-agent. The usage is then eval `ssh-agent`.<br /><br />It autodetects the shell to generate the correct syntax (can be overridden).<br /><br />You can also make both senses work (as does ssh-agent). If you do "ssh-agent foo bar" then it executes "foo bar" with the appropriately configured environment. If given no args then it outputs the shell commands the parent evals.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2425290326823263574.post-91519813710722092802011-11-13T13:39:55.505-08:002011-11-13T13:39:55.505-08:00Linux /proc/PROCESSID/environ gives a way of getti...Linux /proc/PROCESSID/environ gives a way of getting at a child's environment.<br /><br />Now, how can I stop it just as it is about to exit?<br /><br />And how unportable this will be. Cygwin? Nah.Andy "Krazy" Glewhttps://www.blogger.com/profile/08442494949914217568noreply@blogger.com