<commit_before>#!/bin/bash
#
# Commandline utility that pings a url until a 200 response is achieved ...
# or it gets tired and quits (where "gets tired" is defined as trying 20 times,
# pausing 4 seconds in between each try).
#
# Usage:
#
#   $ ./pinger [url]
#
# - If a 200 status is encountered, script exits 0 and prints a success message
# - If a 301 status is encountered, script exits 1 and prints a notice to supply
#   the new url
# - Otherwise the script sleeps for 4 seconds and retries
#
# exit status of 1 and message of "failed" is returned if script is not able to
# get a 200 response from the supplied URL after 20 tries.

set -e

function usage {
  echo "Usage: $0 [url]"
}

if [ $# != 1 ]; then
  echo "Error: must pass a url to ping."
  usage
  exit 1
elif [ $1 == '-h' ]; then
  usage
  exit 0
elif [ $1 == '-v' ]; then
  echo "version 1.0"
  exit 0
fi

for (( i=0; i < 20; i++ )); do
  http_header_response=$(curl -Is $1 | head -n1)
  if echo $http_header_response | grep -q "200 OK"; then
    echo "[$(date)] $1 responded with '200 OK' status after $((i + 1)) tries"
    exit 0
  elif echo $http_header_response | grep -q "301 Moved Permanently"; then
    echo "permanently moved - supply new url"
    exit 1
  else
    sleep 4
  fi
done

echo "failed"
exit 1
<commit_msg>Quote strings in conditions and make spacing of ; consistent<commit_after>#!/bin/bash
#
# Commandline utility that pings a url until a 200 response is achieved ...
# or it gets tired and quits (where "gets tired" is defined as trying 20 times,
# pausing 4 seconds in between each try).
#
# Usage:
#
#   $ ./pinger [url]
#
# - If a 200 status is encountered, script exits 0 and prints a success message
# - If a 301 status is encountered, script exits 1 and prints a notice to supply
#   the new url
# - Otherwise the script sleeps for 4 seconds and retries
#
# exit status of 1 and message of "failed" is returned if script is not able to
# get a 200 response from the supplied URL after 20 tries.

set -e

function usage {
  echo "Usage: $0 [url]"
}

if [ $# != 1 ] ; then
  echo "Error: must pass a url to ping."
  usage
  exit 1
elif [ "$1" == "-h" ] ; then
  usage
  exit 0
elif [ "$1" == "-v" ] ; then
  echo "version 1.0"
  exit 0
fi

for (( i=0; i < 20; i++ )) ; do
  http_header_response=$(curl -Is $1 | head -n1)
  if echo $http_header_response | grep -q "200 OK" ; then
    echo "[$(date)] $1 responded with '200 OK' status after $((i + 1)) tries"
    exit 0
  elif echo $http_header_response | grep -q "301 Moved Permanently" ; then
    echo "permanently moved - supply new url"
    exit 1
  else
    sleep 4
  fi
done

echo "failed"
exit 1

{'fraction_non_alphanumeric': 0.10691348696637704, 'fraction_numerical': 0.037778617302606725, 'mean_word_length': 3.012121212121212, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5337860', 'n_tokens_mistral': 961, 'n_tokens_neox': 858, 'n_words': 416}