<commit_before>#! /usr/bin/perl -w

use strict;
( my $progname = $0 ) =~ s#^.*/##;

sub find_from_table($);
sub find_in_dir($$);
sub search_and_exit;
sub show_table($);

if (defined($ARGV[0])&&( "$ARGV[0]" eq "--help" )){
  print <<END;
This script find a script from two keywords.
Usage: $progname word1 word2
First we check user table and search in CSGSCRIPTDIR and than in CSGINVERSE
Then we check csg table and search in CSGINVERSE

Hacky usage: $progname --direct scriptname
then we try to find scriptname in global,pwd,CSGSCRIPTDIR,CSGINVERSE

USES: \$CSGINVERSE \$CSGSCRIPTDIR 
NEEDS:
END
  exit 0;
}

my $csg_table="csg_table";
my $user_table="csg_table";

(my $csgshare=$ENV{'CSGINVERSE'}) || die "CSGINVERSE not defined\n";
$csg_table="$csgshare/$csg_table";

my $csgscriptdir=$ENV{'CSGSCRIPTDIR'};
if ($csgscriptdir) {
  $user_table="$csgscriptdir/$user_table";
} else {
  $user_table=undef;
  $csgscriptdir=undef;
}

my $scriptname=undef;

if (defined($ARGV[0])&&("$ARGV[0]" eq "--status" )){
  print "csg table status\n";
  show_table($csg_table);
  print "Check sums\n";
  system('md5sum $CSGINVERSE/MD5SUM');
  system('cd $CSGINVERSE; md5sum -c $CSGINVERSE/MD5SUM || echo WARNING: You have modified csg scripts, better copy them and to user scripts dir');
  if (defined($user_table)&&( -r "$user_table")) {
    print "user table status\n";
    show_table($user_table);
  } else {
    print "No user table\n";
  }
  exit 0;
}

###################MAIN PROGRAMM#######################

( $#ARGV < 1 ) && die "$progname needs two arguments\n";

#--direct options
if ( "$ARGV[0]" eq "--direct" ) {
  search_and_exit($ARGV[1]," ",$ENV{'PWD'},$csgscriptdir,$csgshare);
  die "Could find script $ARGV[1]\n";
}
<commit_msg>*.pl: '-' will not be parsed as an option anymore<commit_after>#! /usr/bin/perl -w

use strict;
( my $progname = $0 ) =~ s#^.*/##;

sub find_from_table($);
sub find_in_dir($$);
sub search_and_exit;
sub show_table($);

if (defined($ARGV[0])&&( "$ARGV[0]" eq "--help" )){
  print <<END;
This script find a script from two keywords.
Usage: $progname word1 word2
First we check user table and search in CSGSCRIPTDIR and than in CSGINVERSE
Then we check csg table and search in CSGINVERSE

Hacky usage: $progname --direct scriptname
then we try to find scriptname in global,pwd,CSGSCRIPTDIR,CSGINVERSE

USES: \$CSGINVERSE \$CSGSCRIPTDIR 
NEEDS:
END
  exit 0;
}

my $csg_table="csg_table";
my $user_table="csg_table";

(my $csgshare=$ENV{'CSGINVERSE'}) || die "CSGINVERSE not defined\n";
$csg_table="$csgshare/$csg_table";

my $csgscriptdir=$ENV{'CSGSCRIPTDIR'};
if ($csgscriptdir) {
  $user_table="$csgscriptdir/$user_table";
} else {
  $user_table=undef;
  $csgscriptdir=undef;
}

my $scriptname=undef;

if (defined($ARGV[0])&&("$ARGV[0]" eq "--status" )){
  print "csg table status\n";
  show_table($csg_table);
  print "Check sums\n";
  system('md5sum $CSGINVERSE/MD5SUM');
  system('cd $CSGINVERSE; md5sum -c $CSGINVERSE/MD5SUM || echo WARNING: You have modified csg scripts, better copy them to your user scripts dir');
  if (defined($user_table)&&( -r "$user_table")) {
    print "user table status\n";
    show_table($user_table);
  } else {
    print "No user table\n";
  }
  exit 0;
}

###################MAIN PROGRAMM#######################

( $#ARGV < 1 ) && die "$progname needs two arguments\n";

#--direct options
if ( "$ARGV[0]" eq "--direct" ) {
  search_and_exit($ARGV[1]," ",$ENV{'PWD'},$csgscriptdir,$csgshare);
  die "Could find script $ARGV[1]\n";
}

{'fraction_non_alphanumeric': 0.1888412017167382, 'fraction_numerical': 0.009728183118741058, 'mean_word_length': 4.965870307167235, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5817430', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1352, 'n_words': 350}