Created
February 17, 2014 08:57
-
-
Save ytnobody/9047094 to your computer and use it in GitHub Desktop.
export environment variables as envdir format
This file contains hidden or 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 perl | |
use strict; | |
use warnings; | |
my $dir = $ARGV[0] || 'env'; | |
mkdir $dir unless -d $dir; | |
my @data = `env`; | |
chdir $dir; | |
for my $entry (@data) { | |
chomp $entry; | |
my ($name, $val) = split('=', $entry, 2); | |
open my $fh, '>', $name or die $!; | |
print $fh $val; | |
close $fh; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment