From: Adam Spiers Date: Sun, 4 Dec 2011 21:50:07 +0000 (+0000) Subject: Perform an "extract variable" refactoring to reduce duplication X-Git-Url: https://git.madduck.net/code/myrepos.git/commitdiff_plain/d977f4f0abb8e9c61e0fda75fd5684ad6e265c8e?ds=inline;pf=code Perform an "extract variable" refactoring to reduce duplication and the chance of future typos. (cherry picked from commit bb9a1f48de42059d0db23ece614de6fb29706d1a) --- diff --git a/mr b/mr index e89d01a..8883aab 100755 --- a/mr +++ b/mr @@ -546,6 +546,7 @@ my $jobs=1; my $trust_all=0; my $directory=getcwd(); +my $HOME_MR_CONFIG = "$ENV{HOME}/.mrconfig"; $ENV{MR_CONFIG}=find_mrconfig(); # globals :-( @@ -1102,14 +1103,14 @@ sub is_trusted_config { my $config=shift; # must be abs_pathed already # We always trust ~/.mrconfig. - return 1 if $config eq abs_path("$ENV{HOME}/.mrconfig"); + return 1 if $config eq abs_path($HOME_MR_CONFIG); return 1 if $trust_all; my $trustfile=$ENV{HOME}."/.mrtrust"; if (! %trusted) { - $trusted{"$ENV{HOME}/.mrconfig"}=1; + $trusted{$HOME_MR_CONFIG}=1; if (open (TRUST, "<", $trustfile)) { while () { chomp; @@ -1732,7 +1733,7 @@ sub find_mrconfig { } $dir=~s/\/[^\/]*$//; } - return "$ENV{HOME}/.mrconfig"; + return $HOME_MR_CONFIG; } sub getopts { @@ -1802,7 +1803,7 @@ sub main { init(); startingconfig(); - loadconfig("$ENV{HOME}/.mrconfig"); + loadconfig($HOME_MR_CONFIG); loadconfig($ENV{MR_CONFIG}); #use Data::Dumper; print Dumper(\%config);