From d977f4f0abb8e9c61e0fda75fd5684ad6e265c8e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 4 Dec 2011 21:50:07 +0000 Subject: [PATCH 1/1] Perform an "extract variable" refactoring to reduce duplication and the chance of future typos. (cherry picked from commit bb9a1f48de42059d0db23ece614de6fb29706d1a) --- mr | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); -- 2.39.5