<commit_before>#!/bin/bash
#
# Shell-Script which creates a symbolic hash-link for each CA certificate
# and each CRL in the given directory.
# Copyright (C) 2003 <NAME> <<EMAIL>>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# $Id$
#

OPENSSL="openssl"

# function to create the hash link
function mk_link()
{
  nr=0
  while [ -e $hash$nr ]; do
    if [ $file -ef $hash$nr ] || [ -h $file ]; then
      break;
    fi
    nr=`expr $nr + 1`
  done
  if [ ! $file -ef $hash$nr ] && [ ! -h $file ]; then
    ln -s $file $hash$nr
  fi
}

# save the current directory
old_dir=$PWD
# change to the target directory
if [ $1 ]; then
  if [ -d $1 ]; then
    cd $1
  else
    echo "Error: $1 is not a valid directory!"
    exit -1
  fi
fi
# test the presence of openssl
if [ -z "`$OPENSSL version 2> /dev/null`" ]
then
	echo "$OPENSSL not found! install openssl first"
	exit -1
fi
# process all files
for file in `ls *`; do
  hash=`$OPENSSL x509 -inform pem -in $file -noout -hash 2> /dev/null`
  if [ ! -z $hash ]; then
    is_ca=`$OPENSSL x509 -inform pem -in $file -noout -text | grep 'CA:TRUE'`
    if [ ! -z $is_ca ]; then
      hash=$hash.
      mk_link
    fi
    continue
  fi
  hash=`$OPENSSL x509 -inform der -in $file -noout -hash 2> /dev/null`
  if [ ! -z $hash ]; then
    is_ca=`$OPENSSL x509 -inform der -in $file -noout -text | grep 'CA:TRUE'`
    if [ ! -z $is_ca ]; then
      hash=$hash.
      mk_link
    fi
    continue
  fi
  hash=`$OPENSSL crl -inform pem -in $file -noout -hash 2> /dev/null`
  if [ ! -z $hash ]; then
    hash=$hash.r
    mk_link
    continue
  fi
  hash=`$OPENSSL crl -inform der -in $file -noout -hash 2> /dev/null`
  if [ ! -z $hash ]; then
    hash=$hash.r
    mk_link
    continue
  fi

  # nothing can be done with the file
  echo "we got a problem with: $file"
done
# go back to the former directory
cd $old_dir

exit 0<commit_msg>do not save/restore the current directory since we do not need to<commit_after>#!/bin/bash
#
# Shell-Script which creates a symbolic hash-link for each CA certificate
# and each CRL in the given directory.
# Copyright (C) 2003 <NAME> <<EMAIL>>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# $Id$
#

OPENSSL="openssl"

# function to create the hash link
function mk_link()
{
  nr=0
  while [ -e $hash$nr ]; do
    if [ $file -ef $hash$nr ] || [ -h $file ]; then
      break;
    fi
    nr=`expr $nr + 1`
  done
  if [ ! $file -ef $hash$nr ] && [ ! -h $file ]; then
    ln -s $file $hash$nr
  fi
}

# change to the target directory
if [ $1 ]; then
  if [ -d $1 ]; then
    cd $1
  else
    echo "Error: $1 is not a valid directory!"
    exit -1
  fi
fi
# test the presence of openssl
if [ -z "`$OPENSSL version 2> /dev/null`" ]
then
	echo "$OPENSSL not found! install openssl first"
	exit -1
fi
# process all files
for file in `ls *`; do
  hash=`$OPENSSL x509 -inform pem -in $file -noout -hash 2> /dev/null`
  if [ ! -z $hash ]; then
    is_ca=`$OPENSSL x509 -inform pem -in $file -noout -text | grep 'CA:TRUE'`
    if [ ! -z $is_ca ]; then
      hash=$hash.
      mk_link
    fi
    continue
  fi
  hash=`$OPENSSL x509 -inform der -in $file -noout -hash 2> /dev/null`
  if [ ! -z $hash ]; then
    is_ca=`$OPENSSL x509 -inform der -in $file -noout -text | grep 'CA:TRUE'`
    if [ ! -z $is_ca ]; then
      hash=$hash.
      mk_link
    fi
    continue
  fi
  hash=`$OPENSSL crl -inform pem -in $file -noout -hash 2> /dev/null`
  if [ ! -z $hash ]; then
    hash=$hash.r
    mk_link
    continue
  fi
  hash=`$OPENSSL crl -inform der -in $file -noout -hash 2> /dev/null`
  if [ ! -z $hash ]; then
    hash=$hash.r
    mk_link
    continue
  fi

  # nothing can be done with the file
  echo "we got a problem with: $file"
done

exit 0
{'fraction_non_alphanumeric': 0.11977834612105712, 'fraction_numerical': 0.013213981244671782, 'mean_word_length': 2.683673469387755, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2192048', 'n_tokens_mistral': 1711, 'n_tokens_neox': 1624, 'n_words': 663}