]> git.madduck.net Git - code/myrepos.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

mr: Check if unsafe ENV variables are set
authorRichard Hartmann <richih@debian.org>
Fri, 21 Nov 2014 23:34:22 +0000 (00:34 +0100)
committerRichard Hartmann <richih@debian.org>
Fri, 21 Nov 2014 23:34:22 +0000 (00:34 +0100)
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

diff --git a/mr b/mr
index 7fa3180f56259753a4292b4d8846e60eeb901684..e0d27a125a003471e8e4ca09b8bbf992ef43559f 100755 (executable)
--- 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';