From 9cd8963574cb722f2997c1f311fb941fcb230db2 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 22 Nov 2014 00:34:22 +0100 Subject: [PATCH 1/1] mr: Check if unsafe ENV variables are set If e.g. $GIT_DIR is set, it's near certain that the user is about to shoot their own foot so we abort. --- mr | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mr b/mr index 7fa3180..e0d27a1 100755 --- a/mr +++ b/mr @@ -1879,6 +1879,13 @@ sub getopts { } } +sub check { + my @env = qw(GIT_DIR VCSH_COMMAND); + foreach (@env) { + die ("mr: environment variable '$_' is set. You are about to shoot your own foot.\n") if ($ENV{$_}); + } +} + sub init { $SIG{INT}=sub { print STDERR "mr: interrupted\n"; @@ -1914,6 +1921,7 @@ sub exitstats { sub main { getopts(); + check(); init(); help(@ARGV) if $ARGV[0] eq 'help'; -- 2.39.5