How do I export an environment variable from within a Ruby script to the parent shell? For example, implementing a naïve implementation of the read
Bash builtin:
#!/usr/bin/ruby
varname = ARGV[0]
ENV[varname] = STDIN.gets # but have varname exported to the parent process
Simple answer: You can't.
Longer answer: You can't, unless the operating environment provides hooks to do so. Most do not. The best you can usually do is print out the assignments you want done and have the parent execute them.