Skip to content

Instantly share code, notes, and snippets.

@monsieurp
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monsieurp/311d3d5579d7a5600b13 to your computer and use it in GitHub Desktop.
Save monsieurp/311d3d5579d7a5600b13 to your computer and use it in GitHub Desktop.
From mayhem to normality.
--- /usr/bin/echangelog 2014-11-02 17:34:41.730843075 +0100
+++ echangelog 2014-11-02 22:10:13.524146598 +0100
@@ -108,17 +108,14 @@
exit 0;
}
-sub getenv($) {
+sub getenv ($) {
my $key = shift;
+ my $env = $ENV{$key};
- # Ensure our variable exist
- if ( defined($ENV{$key}) ) {
- # Ensure we don't get empty variables
- if ( length($ENV{$key}) > 0 ) {
- return $ENV{$key};
- }
- }
- return;
+ # Ensure the variable has been set
+ # as an environment variable,
+ # checks for its lenghts and returns it
+ return $env if $env and (length($env) > 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment