Last active
January 28, 2018 04:50
-
-
Save jennings/7a4d720836dc8861c99145abd01d5364 to your computer and use it in GitHub Desktop.
Executes a command after adding a `.env` file to the environment. This is probably terribly unsafe.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# usage: dotenv irb | |
begin | |
File.foreach('.env') do |line| | |
line = line.strip | |
unless line.start_with?('#') | |
parts = line.split '=', 2 | |
if parts.length == 2 | |
ENV[parts[0]] = parts[1] | |
end | |
end | |
end | |
rescue Exception => err | |
STDERR.puts err | |
end | |
exec(*ARGF.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment