Won't work. You can only set a shell variable applying to the current process on unix.
DOS etc. had a backdoor to allow a child process to set an environment variable in its parent command.com etc., so if you find somebody saying OF COURSE this works be cautious. Even in this case there were limits based on how much memory was allocated.
I've got round this in the past by having layered programs, i.e. the shell, then a custom program, then a second shell which inherits variables.
MarkMLl