<commit_before>#!/bin/bash

# Copyright (C) 2013 <NAME>
# Copyright (C) 2012 AntonioCS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -eo pipefail

# Defines

CONFIGFILE="$( cd "$( dirname "$0" )" && pwd )/config"

if [ -e "$CONFIGFILE" ]; then
    source "$CONFIGFILE"
else
    echo "Config file not found."
    exit 1
fi

if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
   echo "USERNAME or PASSWORD has not been set in the config file."
   exit 1
fi

USERAGENT="Bash No-IP Updater/1.0 $USERNAME"

if [ ! -d "$LOGDIR" ]; then
    if ! mkdir -p "$LOGDIR"; then
        echo "Log directory could not be created or accessed."
        exit 1
    fi
fi

LOGFILE=${LOGDIR%/}/noip.log
if [ ! -e "$LOGFILE" ]; then
    if ! touch "$LOGFILE"; then
        echo "Log files could not be created. Is the log directory writable?"
        exit 1
    fi
fi
if [ ! -w "$LOGFILE" ]; then
    echo "Log file not writable."
    exit 1
fi

# Functions

function cmd_exists() {
    command -v "$1" > /dev/null 2>&1
}

# Adapted from one of the more readable answers by Gilles at
# https://unix.stackexchange.com/questions/60653/urlencode-function/60698#60698
function urlencode() {
    local string="$1"
    while [ -n "$string" ]; do
        local tail="${string#?}"
        local head="${string%"$tail"}"
        case "$head" in
            [-._~0-9A-Za-z])
                printf "%c" "$head";;
            *)<commit_msg>Copy fatal errors to stderr<commit_after>#!/bin/bash

# Copyright (C) 2013 <NAME>
# Copyright (C) 2012 AntonioCS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -eo pipefail

# Defines

CONFIGFILE="$( cd "$( dirname "$0" )" && pwd )/config"

if [ -e "$CONFIGFILE" ]; then
    source "$CONFIGFILE"
else
    echo "Config file not found." >&2
    exit 1
fi

if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
   echo "USERNAME or PASSWORD has not been set in the config file." >&2
   exit 1
fi

USERAGENT="Bash No-IP Updater/1.0 $USERNAME"

if [ ! -d "$LOGDIR" ]; then
    if ! mkdir -p "$LOGDIR"; then
        echo "Log directory could not be created or accessed." >&2
        exit 1
    fi
fi

LOGFILE=${LOGDIR%/}/noip.log
if [ ! -e "$LOGFILE" ]; then
    if ! touch "$LOGFILE"; then
        echo "Log files could not be created. Is the log directory writable?" >&2
        exit 1
    fi
fi
if [ ! -w "$LOGFILE" ]; then
    echo "Log file not writable." >&2
    exit 1
fi

# Functions

function cmd_exists() {
    command -v "$1" > /dev/null 2>&1
}

# Adapted from one of the more readable answers by Gilles at
# https://unix.stackexchange.com/questions/60653/urlencode-function/60698#60698
function urlencode() {
    local string="$1"
    while [ -n "$string" ]; do
        local tail="${string#?}"
        local head="${string%"$tail"}"
        case "$head" in
            [-._~0-9A-Za-z])
                printf "%c" "$head";;
            *)
{'fraction_non_alphanumeric': 0.12804561949196475, 'fraction_numerical': 0.02255054432348367, 'mean_word_length': 2.828373015873016, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 2, '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': '176709', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1216, 'n_words': 479}