b09cbbbf6a36bf8fc7f50e52ccf2bcb5be5c084e
commit b09cbbbf6a36bf8fc7f50e52ccf2bcb5be5c084e
Author: spesk1 <spesk@pm.me>
Date: Fri Jun 21 12:05:37 2019 -0400

Split Shellex.pm into it's own repo so I can use it elsewhere

diff --git a/lib/SimplyGit/Git.pm b/lib/SimplyGit/Git.pm
index ab8c64a..5896e06 100644
--- a/lib/SimplyGit/Git.pm
+++ b/lib/SimplyGit/Git.pm
@@ -2,18 +2,30 @@ package SimplyGit::Git;
use strict;
use warnings;
use Log::Log4perl qw(:easy);
-use lib ".";
-use SimplyGit::Shellex qw(shellex findBin knocker);
+use lib "/usr/local/lib/";
+use Shellex::Shellex qw(shellex findBin);
use Exporter qw(import);
our @EXPORT_OK = qw(
readConfig getStatus returnState addFiles
commitChanges pushChanges stashAndReset resetFromUpstream
updateGitIgnore appendRepoUserConfig parseSGConfig
- warnOnUser basicClone basicPull
+ warnOnUser basicClone basicPull knocker
);

# TODO: Add info/debug logging for all subroutines

+sub knocker($$$) {
+
+ my $target = shift;
+ my $portRef = shift;
+ my $logger = shift;
+ my $nmapCmd = findBin("nmap",$logger);
+ foreach my $port (@$portRef) {
+ shellex("$nmapCmd -Pn --host_timeout 201 --max-retries 0 -p $port $target > /dev/null",$logger);
+ }
+
+}
+
sub checkPath($$) {

my $path = shift;
diff --git a/lib/SimplyGit/Shellex.pm b/lib/SimplyGit/Shellex.pm
deleted file mode 100644
index fef7acc..0000000
--- a/lib/SimplyGit/Shellex.pm
+++ /dev/null
@@ -1,65 +0,0 @@
-package SimplyGit::Shellex;
-use strict;
-use warnings;
-use Log::Log4perl qw(:easy);
-use Exporter qw(import);
-our @EXPORT_OK = qw(shellex findBin knocker);
-
-sub knocker($$$) {
-
- my $target = shift;
- my $portRef = shift;
- my $logger = shift;
- my $nmapCmd = findBin("nmap",$logger);
- foreach my $port (@$portRef) {
- shellex("$nmapCmd -Pn --host_timeout 201 --max-retries 0 -p $port $target > /dev/null",$logger);
- }
-
-}
-
-sub shellex {
-
- my $cmd = shift;
- my $logger = shift;
- if ( defined $logger && $logger ne '' ) {
- $logger->info("Running: $cmd 2>&1");
- }
-
- my $output = `$cmd 2>&1`;
- chomp $output;
- my $rc = $?;
- if ( defined $logger && $logger ne '' ) {
- $logger->info("Returned: $rc");
- }
-
- if ( $rc != 0 ) {
- if ( defined $logger && $logger ne '' ) {
- $logger->error("$cmd returned non-zero: $rc");
- }
-
- print "$cmd returned non-zero: $rc\n";
- exit 1;
- }
-
- return $output;
-
-}
-
-sub findBin {
-
- my $cmd = shift;
- my $logger = shift;
- my $binPath = shellex("which $cmd",$logger);
- my $rc = $?;
- chomp $binPath;
- if ( $rc != 0 ) {
- if ( defined $logger && $logger ne '' ) {
- $logger->error("Couldn't find a path for $cmd, exiting...");
- }
- exit 1;
- } else {
- return $binPath;
- }
-
-}
-1;
diff --git a/sg b/sg
index 3b47d3f..9402da6 100755
--- a/sg
+++ b/sg
@@ -7,12 +7,12 @@ use Getopt::Long qw(GetOptions);
use Log::Log4perl qw(:easy);
# TODO: This needs to be scoped properly
use lib "/usr/local/lib";
-use SimplyGit::Shellex qw(shellex findBin knocker);
+use Shellex::Shellex qw(shellex findBin);
use SimplyGit::Git qw(
readConfig getStatus returnState addFiles
commitChanges pushChanges stashAndReset resetFromUpstream
updateGitIgnore appendRepoUserConfig parseSGConfig
- warnOnUser basicClone basicPull
+ warnOnUser basicClone basicPull knocker
);

sub initSG($) {